diff --git a/src/main/java/jarhead/DrawPanel.java b/src/main/java/jarhead/DrawPanel.java index 22976f5..57e2a1b 100644 --- a/src/main/java/jarhead/DrawPanel.java +++ b/src/main/java/jarhead/DrawPanel.java @@ -25,7 +25,7 @@ public class DrawPanel extends JPanel { - boolean debug = false; + boolean debug = true; private LinkedList managers; private ProgramProperties robot; @@ -131,7 +131,6 @@ private void renderSplines(Graphics g, TrajectorySequence trajectory, Color colo } private void renderRobotPath(Graphics2D g, TrajectorySequence trajectory, Color color, float transparency) { - //TODO: make this faster :( if (this.getWidth() != this.getHeight()) System.out.println("w != h"); BufferedImage image; if (this.getWidth() > 0) @@ -500,6 +499,7 @@ private void mPressed(MouseEvent e) { if (midDist < (clickSize * main.scale) && midDist < closest) { closest = midDist; index = counter; + tangentialHeading = pose.getHeading(); mid = true; } @@ -536,6 +536,7 @@ private void mPressed(MouseEvent e) { main.currentN = getCurrentManager().size(); //TODO: make it face towards the tangential heading mouse.splineHeading = mouse.headingTo(getCurrentManager().get(index)); + mouse.robotHeading = mouse.splineHeading; getCurrentManager().add(index,mouse); } else { //editing existing node @@ -584,7 +585,6 @@ private void mReleased(MouseEvent e){ private void mDragged(MouseEvent e) { Node mouse = new Node(e.getPoint()); - System.out.println(mouse.toString()); if (SwingUtilities.isRightMouseButton(e)) return; if(edit){ int index = getCurrentManager().editIndex; diff --git a/src/main/java/jarhead/ExportPanel.java b/src/main/java/jarhead/ExportPanel.java index 7088966..e229348 100644 --- a/src/main/java/jarhead/ExportPanel.java +++ b/src/main/java/jarhead/ExportPanel.java @@ -18,7 +18,7 @@ public class ExportPanel extends JPanel { this.setBackground(Color.darkGray.darker()); this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - this.setMinimumSize(new Dimension(200,0)); + this.setMinimumSize(new Dimension(200,10)); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); this.add(scroll); diff --git a/src/main/java/jarhead/Import.java b/src/main/java/jarhead/Import.java index 882357f..54af7a4 100644 --- a/src/main/java/jarhead/Import.java +++ b/src/main/java/jarhead/Import.java @@ -68,11 +68,9 @@ public LinkedList read(File file){ for (int i = 0; i < managers.size(); i++) { NodeManager manager = managers.get(i); - System.out.println(allText.substring(starts.get(i), ends.get(i))); + //matches all the data within the trajectory builder Matcher data = dataPattern.matcher(allText.substring(starts.get(i), ends.get(i))); - while(data.find()){ - boolean discard = false; Node node = new Node(); String type = data.group(1); try{ @@ -96,13 +94,12 @@ public LinkedList read(File file){ nlist.add(0.0); } } - System.out.println(nlist.toString()); try{ node.x = (nlist.get(0)+72.0)*main.scale; node.y = (72.0 - nlist.get(1))*main.scale; - System.out.println(node.toString()); switch (node.getType()){ case splineTo: + case splineToConstantHeading: node.splineHeading = nlist.get(2)-90.0; node.robotHeading = node.splineHeading; break; @@ -111,31 +108,15 @@ public LinkedList read(File file){ node.splineHeading = nlist.get(3)-90.0; node.robotHeading = nlist.get(2)-90.0; break; - case splineToConstantHeading: - node.splineHeading = nlist.get(2)-90.0; - node.robotHeading = node.splineHeading; - break; case lineTo: + case lineToConstantHeading: break; case lineToSplineHeading: - node.robotHeading = nlist.get(2)-90.0; - break; case lineToLinearHeading: node.robotHeading = nlist.get(2)-90.0; break; - case lineToConstantHeading: - break; - case displacementMarker: - break; default: - //TODO: fix importing - Matcher displace = markerPattern.matcher(allText.substring(data.start(), data.end())); - while(displace.find()){ - System.out.println(displace.group(0)); - System.out.println(displace.group(2)); - manager.get(manager.size()-1).code = displace.group(2); - discard = true; - } + } } catch (Exception e) { @@ -145,9 +126,26 @@ public LinkedList read(File file){ node.robotHeading = 90; node.robotHeading = 90; } - if(!discard) - manager.add(node); - + manager.add(node); + +// case displacementMarker: +// //TODO: fix importing +// Matcher displace = markerPattern.matcher(allText.substring(starts.get(i), ends.get(i))); +// while(displace.find()){ +// System.out.println(displace.group(0)); +// System.out.println(displace.group(2)); +// manager.get(manager.size()-1).code = displace.group(2); +// discard = true; +// } +// break; + } + Matcher markers = markerPattern.matcher(allText.substring(starts.get(i), ends.get(i))); + while(markers.find()){ +// System.out.println(markers.group(0)); + System.out.println(markers.group(1)); + System.out.println(markers.group(2)); + manager.get(manager.size()-1).setType(Node.Type.displacementMarker); + manager.get(manager.size()-1).code = markers.group(2).trim(); } } return managers;