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
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,7 @@ private void drawAnnotationBox(GraphNode node, IViewGraphNode viewNode,
}
drawnChildNodes.add(viewAnnotation);
viewAnnotation.addLabel(drawnChildNodes);
viewAnnotation.addArrow(drawnChildNodes);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.shape.Rectangle;
import nl.tudelft.pl2016gr2.gui.view.selection.AnnotationDescription;
import nl.tudelft.pl2016gr2.gui.view.selection.ISelectable;
Expand All @@ -11,6 +13,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Objects;

/**
* This is an annotation indicator object which can be added to a IViewGraphNode to indicate that it
Expand All @@ -22,7 +25,13 @@ public class ViewAnnotation extends Rectangle implements ISelectable {

private static final double MINIMUM_LABEL_WIDTH = 10.0;
private static final double MINIMUM_LABEL_HEIGHT = 12.0;
private static final double MINIMUM_ARROW_WIDTH = 25.0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimum arrow with is alrgeer than minimum label width? Sure this is desired? (weird overlapping with many small nodes)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the annotation is smaller than MINIMUM_LABEL_WIDTH the label (text) isn't drawn. If the annotation is smaller than MINIMUM_ARROW_WIDTH the arrow won't be drawn.

private static final Image RIGHT_ARROW = new Image(
ViewAnnotation.class.getClassLoader().getResourceAsStream("images/arrow-right.png"));
private static final Image LEFT_ARROW = new Image(
ViewAnnotation.class.getClassLoader().getResourceAsStream("images/arrow-left.png"));
private final Annotation annotation;
private boolean oddOffset = false;

/**
* Construct a view annotation which can be drawn in the UI.
Expand Down Expand Up @@ -61,10 +70,36 @@ public void addLabel(ArrayList<Node> nodes) {
label.setLayoutX(getLayoutX());
}

/**
* Add an arrow to indicate the annotation direction.
*
* @param nodes the list of nodes to which to add the arrow.
*/
public void addArrow(ArrayList<Node> nodes) {
if (getWidth() < MINIMUM_ARROW_WIDTH || getHeight() < MINIMUM_LABEL_HEIGHT) {
return;
}
ImageView arrow;
if (Objects.equals(annotation.strand, "-")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be done with inheritance (ReverseViewAnnotation extends ViewAnnotation), Leaving this for now since we want a release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be sure, you do know this is the same as annotation.strand.equals("-"), but with a null check right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did not explicitly realise, but my point was that deciding to draw either forward or backward arrows should be done with different annotation(view) classes. the null-check is good for safety right now but in general shouldn't be necessary

arrow = new ImageView(LEFT_ARROW);
} else {
arrow = new ImageView(RIGHT_ARROW);
}
nodes.add(arrow);
arrow.setMouseTransparent(true);
if (oddOffset || getLayoutY() - LEFT_ARROW.getHeight() < 0) {
arrow.setLayoutY(getLayoutY() + getHeight());
} else {
arrow.setLayoutY(getLayoutY() - LEFT_ARROW.getHeight());
}
arrow.setLayoutX(getLayoutX() + (getWidth() - LEFT_ARROW.getWidth()) / 2.0);
}

/**
* Sets a vertical offset to this label so if doesn't overlap with a different label.
*/
public void setOddOffset() {
oddOffset = true;
setLayoutY(getLayoutY() + getHeight());
}

Expand Down
Binary file added PL2/PL2-gui/src/main/resources/images/arrow-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.