Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/netKnow/Class/routing/DraggableNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ private void initialize() {
rightPane = (AnchorPane) getParent();
});

System.out.println("initialize");
mDragLink = new NodeLink();
mDragLink.setVisible(false);
}
Expand Down
24 changes: 20 additions & 4 deletions src/netKnow/Class/routing/NodeLink.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,6 @@ public void bindEnds (DraggableNode source, DraggableNode target) {
}

public void setStartAndEnd(String start, String end){
System.out.println("\n\tMyID: " + this.getId());
System.out.println("\tStart: " + start);
System.out.println("\tEnd: " + end);
startIDNode = start;
endIDNode = end;
}
Expand All @@ -109,9 +106,28 @@ public void relocateLabelCoords(AnchorPane right_pane){
FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
double textLength = fontLoader.computeStringWidth(infoLabel.getText(), infoLabel.getFont());
double cordX = (source.getLayoutX() + target.getLayoutX() - textLength/2) / 2 ;
double cordY = (source.getLayoutY() + source.getWidth()/2 + target.getLayoutY() + target.getWidth()/2 ) / 2 + 20;
double cordY = (source.getLayoutY() + source.getWidth()/2 + target.getLayoutY() + target.getWidth()/2 ) / 2;
infoLabel.setLayoutX(cordX);
infoLabel.setLayoutY(cordY);
infoLabel.setRotate(getRotateValue(source, target));
}
}

private double getRotateValue(DraggableNode source, DraggableNode target){
double x1 = source.getLayoutX();
double y1 = source.getLayoutY();
double x2 = target.getLayoutX();
double y2 = target.getLayoutY();

double a = Math.abs(x1-x2);
double c = Math.sqrt(Math.pow((x2-x1), 2) + Math.pow((y2-y1),2));
double degree = Math.toDegrees(Math.asin(a/c));

if((x1 < x2 && y1 > y2) || (x1 > x2 && y1 < y2)){ // source lub target lewy gorny rog
degree = -(90 - degree);
}else if((x1 < x2 && y1 < y2) || (x1 > x2 && y1 > y2)){ // source lub target prawy gorny rog
degree = 90 - degree;
}
return degree;
}
}
1 change: 0 additions & 1 deletion src/netKnow/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public void start(Stage primaryStage) throws Exception{

public static void main(String[] args) {
launch(args);

}

}
1 change: 0 additions & 1 deletion src/netKnow/controller/RoutingController.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ private void buildDragHandlers() {
};

root_pane.setOnDragDone(event -> {
System.out.println("drag done hehe");
right_pane.removeEventHandler(DragEvent.DRAG_OVER, mIconDragOverRightPane);
right_pane.removeEventHandler(DragEvent.DRAG_DROPPED, mIconDragDropped);
base_pane.removeEventHandler(DragEvent.DRAG_OVER, mIconDragOverRoot);
Expand Down