Skip to content

Commit

Permalink
Merge pull request #213 from ProgrammingLife2016/gui/selection-manage…
Browse files Browse the repository at this point in the history
…r-changes

Gui/selection manager changes
  • Loading branch information
Pathemeous authored Jun 10, 2016
2 parents a911ec4 + c52e35d commit 516c766
Show file tree
Hide file tree
Showing 19 changed files with 357 additions and 391 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public class RootLayoutController implements

@FXML
private AnchorPane rootPane;
@FXML
private SelectionPaneController selectionPaneController;
// @FXML
// private SelectionPaneController selectionPaneController;
@FXML
private SplitPane mainPane;
@FXML
Expand All @@ -81,6 +81,9 @@ public class RootLayoutController implements
@FXML
private GraphPaneController graphPaneController;

@FXML
private SelectionPaneController selectionPaneController;

/**
* Initializes the controller class.
*
Expand All @@ -97,7 +100,7 @@ public void initialize(URL location, ResourceBundle resources) {
rootPane.sceneProperty().addListener(new ChangeListener<Scene>() {
@Override
public void changed(ObservableValue<? extends Scene> observable, Scene oldValue,
Scene newValue) {
Scene newValue) {
if (newValue != null) {
initializeSearchPaneController();
// fire this only once when scene is set.
Expand Down Expand Up @@ -154,29 +157,20 @@ public Region getPane() {
return rootPane;
}

/**
* Draw two subgraphs.
*
* @param topGenomes the genomes of the top graph.
* @param bottomGenomes the genomes of the bottom graph.
*/
public void drawGraph(ArrayList<Integer> topGenomes, ArrayList<Integer> bottomGenomes) {
graphPaneController.compareTwoGraphs(topGenomes, bottomGenomes);
}

/**
* Initialize the selection manager (which manages showing the description of selected objects).
*/
private void initializeSelectionManager() {
selectionManager = new SelectionManager(this, selectionPaneController);
selectionManager = new SelectionManager();
treePaneController.setup(selectionManager, graphPaneController);
graphPaneController.setup(selectionManager);
selectionPaneController.setup(selectionManager);
mainPane.setOnMouseClicked((MouseEvent event) -> {
if (!event.isConsumed()) {
selectionManager.deselect();
event.consume();
}
});
treePaneController.setup(selectionManager, graphPaneController);
graphPaneController.setup(selectionManager);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,5 +259,4 @@ public void setData(Collection<MetaData> metaDatas) {
masterData.clear();
masterData.addAll(metaDatas);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,13 @@ public void initialize(URL location, ResourceBundle resources) {

initializeScrollbar();
initializeScrollEvent();
initializeOnMouseEventHandler();
}

/**
* Initialize the mouse handlers.
*/
private void initializeOnMouseEventHandler() {
mainPane.setOnMouseClicked(event -> {
if (contextMenu != null) {
contextMenu.hide();
Expand Down Expand Up @@ -708,7 +715,14 @@ private void drawNode(Pane pane, GraphNode node, HashSet<GraphNode> drawnGraphNo
height = width;
}
IViewGraphNode viewNode = ViewNodeBuilder.buildNode(node,
width, height, nestedDepth, selectionManager);
width, height, nestedDepth);

viewNode.get().setOnMouseClicked(mouseEvent -> {
selectionManager.select(viewNode);
mouseEvent.consume();
});
// select when previously selected node is equal to this new one
selectionManager.checkSelected(viewNode);
pane.getChildren().add(viewNode.get());
viewNode.centerXProperty().set(zoomFactor.get()
* (node.getLevel() - startLevel - node.size() / 2.0));
Expand Down Expand Up @@ -926,6 +940,9 @@ private void deleteBottomGraph() {
*/
public void setup(SelectionManager selectionManager) {
this.selectionManager = selectionManager;
selectionManager.addListener((observable, oldValue, newValue) -> {
graphUpdater.update();
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Ellipse;
import nl.tudelft.pl2016gr2.gui.view.selection.GraphBubbleDescription;
import nl.tudelft.pl2016gr2.gui.view.selection.ISelectable;
import nl.tudelft.pl2016gr2.gui.view.selection.ISelectionInfo;
import nl.tudelft.pl2016gr2.gui.view.selection.SelectionManager;
import nl.tudelft.pl2016gr2.model.graph.nodes.GraphNode;

/**
* An ellipse representation of a node, which can be drawn in the user interface.
Expand All @@ -13,19 +15,19 @@
*/
public class ViewGraphNodeEllipse extends Ellipse implements IViewGraphNode {

private final ISelectionInfo selectionInfo;
private final GraphNode dataNode;

/**
* Construct a node circle.
*
* @param width the width of the ellipse.
* @param height the height of the ellipse.
* @param selectionInfo the select info for this node.
* @param dataNode the data node.
*/
public ViewGraphNodeEllipse(double width, double height, ISelectionInfo selectionInfo) {
public ViewGraphNodeEllipse(double width, double height, GraphNode dataNode) {
super(width * GraphPaneController.NODE_MARGIN / 2.0, height / 2.0);
setStrokeWidth(height / 20.0d);
this.selectionInfo = selectionInfo;
this.dataNode = dataNode;
}

@Override
Expand Down Expand Up @@ -54,7 +56,16 @@ public void deselect() {
}

@Override
public ISelectionInfo getSelectionInfo(SelectionManager selectionManager) {
return selectionInfo;
public ISelectionInfo getSelectionInfo() {
return new GraphBubbleDescription(dataNode.toString());
}

@Override
public boolean isEqualSelection(ISelectable other) {
if (other instanceof ViewGraphNodeEllipse) {
ViewGraphNodeEllipse that = (ViewGraphNodeEllipse) other;
return this.dataNode.getId() == that.dataNode.getId();
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import javafx.scene.Node;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import nl.tudelft.pl2016gr2.gui.view.selection.GraphBubbleDescription;
import nl.tudelft.pl2016gr2.gui.view.selection.ISelectable;
import nl.tudelft.pl2016gr2.gui.view.selection.ISelectionInfo;
import nl.tudelft.pl2016gr2.gui.view.selection.SelectionManager;
import nl.tudelft.pl2016gr2.model.graph.nodes.GraphNode;

/**
* A square representation of a node, which can be drawn in the user interface.
Expand All @@ -17,23 +19,22 @@ public class ViewGraphNodeRectangle extends Rectangle implements IViewGraphNode

private final DoubleProperty centerXProperty = new SimpleDoubleProperty();
private final DoubleProperty centerYProperty = new SimpleDoubleProperty();
private final ISelectionInfo selectionInfo;
private final GraphNode dataNode;

/**
* Constructor.
*
* @param width the width of the rectangle.
* @param width the width of the rectangle.
* @param height the height of the rectangle.
* @param selectionInfo the select info for this node.
* @param dataNode the data object.
*/
public ViewGraphNodeRectangle(double width, double height,
ISelectionInfo selectionInfo) {
GraphNode dataNode) {
super(width/* * GraphPaneController.NODE_MARGIN*/, height);
layoutXProperty().bind(centerXProperty.add(-width / 2.0));
layoutYProperty().bind(centerYProperty.add(-height / 2.0));
setFill(Color.ALICEBLUE);
setStrokeWidth(height / 20.0d);
this.selectionInfo = selectionInfo;
this.dataNode = dataNode;
}

@Override
Expand Down Expand Up @@ -62,7 +63,16 @@ public void deselect() {
}

@Override
public ISelectionInfo getSelectionInfo(SelectionManager selectionManager) {
return selectionInfo;
public ISelectionInfo getSelectionInfo() {
return new GraphBubbleDescription(dataNode.toString());
}

@Override
public boolean isEqualSelection(ISelectable other) {
if (other instanceof ViewGraphNodeRectangle) {
ViewGraphNodeRectangle that = (ViewGraphNodeRectangle) other;
return this.dataNode.getId() == that.dataNode.getId();
}
return false;
}
}
Loading

0 comments on commit 516c766

Please sign in to comment.