Skip to content

Commit

Permalink
added displacement marker stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarhead committed Jan 26, 2023
1 parent 74406ca commit 68bd39e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
6 changes: 3 additions & 3 deletions src/main/java/jarhead/DrawPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public class DrawPanel extends JPanel {

boolean debug = false;
boolean debug = true;

private LinkedList<NodeManager> managers;
private ProgramProperties robot;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/jarhead/ExportPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
50 changes: 24 additions & 26 deletions src/main/java/jarhead/Import.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ public LinkedList<NodeManager> 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{
Expand All @@ -96,13 +94,12 @@ public LinkedList<NodeManager> 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;
Expand All @@ -111,31 +108,15 @@ public LinkedList<NodeManager> 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) {
Expand All @@ -145,9 +126,26 @@ public LinkedList<NodeManager> 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;
Expand Down

0 comments on commit 68bd39e

Please sign in to comment.