use of y.base.Edge in project binnavi by google.
the class CSelectionMode method selectionBoxAction.
@Override
protected void selectionBoxAction(final Rectangle rect, final boolean shiftMode) {
m_graph.getGraph().firePreEvent();
final NodeList selectedNodes = new NodeList();
for (final NodeCursor node = m_graph.getGraph().nodes(); node.ok(); node.next()) {
final NodeType zyNode = m_graph.getNode(node.node());
if ((zyNode == null) || (zyNode instanceof ZyProximityNode<?>)) {
continue;
}
if (belongsToSelection(node.node(), rect)) {
selectedNodes.add(node.node());
}
}
if (((getLastDragEvent().getModifiersEx() & InputEvent.CTRL_DOWN_MASK) == 0) && ((getLastDragEvent().getModifiersEx() & InputEvent.SHIFT_DOWN_MASK) == 0)) {
m_graph.getGraph().unselectAll();
}
for (final Object nodeObject : selectedNodes) {
final Node node = (Node) nodeObject;
m_graph.getGraph().setSelected(node, true);
}
for (final EdgeCursor ec = m_graph.getGraph().selectedEdges(); ec.ok(); ec.next()) {
final Edge e = ec.edge();
final Node src = e.source();
final Node dst = e.target();
if (!m_graph.getGraph().getRealizer(src).isSelected() && !m_graph.getGraph().getRealizer(dst).isSelected()) {
m_graph.getGraph().getRealizer(e).setSelected(false);
}
}
m_graph.getGraph().firePostEvent();
m_graph.getGraph().updateViews();
}
use of y.base.Edge in project binnavi by google.
the class CMousePressedHandler method handleMousePressed.
public static IMouseStateChange handleMousePressed(final CStateFactory<?, ?> factory, final IMouseState defaultState, final AbstractZyGraph<?, ?> graph, final MouseEvent event) {
final double x = graph.getEditMode().translateX(event.getX());
final double y = graph.getEditMode().translateY(event.getY());
final HitInfo hitInfo = graph.getGraph().getHitInfo(x, y);
if (hitInfo.hasHitNodes()) {
final Node n = hitInfo.getHitNode();
if (SwingUtilities.isLeftMouseButton(event) && !event.isAltDown()) {
return new CStateChange(factory.createNodePressedLeftState(n, event), true);
} else if (SwingUtilities.isRightMouseButton(event)) {
return new CStateChange(factory.createNodePressedRightState(n, event), true);
} else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) {
return new CStateChange(factory.createNodePressedMiddleState(n, event), false);
} else {
return new CStateChange(defaultState, true);
}
} else if (hitInfo.hasHitNodeLabels()) {
throw new IllegalStateException("yFiles Labels are not in use...");
} else if (hitInfo.hasHitEdges()) {
final Edge edge = hitInfo.getHitEdge();
if (SwingUtilities.isLeftMouseButton(event)) {
return new CStateChange(factory.createEdgePressedLeftState(edge, event), true);
} else if (SwingUtilities.isRightMouseButton(event)) {
return new CStateChange(factory.createEdgePressedRightState(edge, event), true);
} else {
return new CStateChange(defaultState, true);
}
} else if (hitInfo.hasHitEdgeLabels()) {
// {
return new CStateChange(defaultState, true);
// }
} else if (hitInfo.hasHitBends()) {
final Bend bend = hitInfo.getHitBend();
if (SwingUtilities.isLeftMouseButton(event)) {
return new CStateChange(factory.createBendPressedLeftState(bend, event), true);
} else {
return new CStateChange(defaultState, true);
}
} else if (hitInfo.hasHitPorts()) {
return new CStateChange(factory.createDefaultState(), true);
} else {
if (SwingUtilities.isLeftMouseButton(event)) {
return new CStateChange(factory.createBackgroundPressedLeftState(event), true);
} else if (SwingUtilities.isRightMouseButton(event)) {
return new CStateChange(factory.createBackgroundPressedRightState(event), true);
}
return new CStateChange(factory.createDefaultState(), true);
}
}
use of y.base.Edge in project binnavi by google.
the class CNodeMover method moveNode.
public static void moveNode(final AbstractZyGraph<?, ?> graph, final ZyGraphNode<?> node, final double xdist, final double ydist, final Set<Bend> movedBends) {
graph.getGraph().getRealizer(node.getNode()).moveBy(xdist, ydist);
for (final EdgeCursor cursor = node.getNode().edges(); cursor.ok(); cursor.next()) {
final Edge edge = cursor.edge();
for (final BendCursor bendCursor = graph.getGraph().getRealizer(edge).bends(); bendCursor.ok(); bendCursor.next()) {
final Bend bend = bendCursor.bend();
if (movedBends.contains(bend)) {
continue;
}
bend.moveBy(xdist, ydist);
movedBends.add(bend);
}
}
}
use of y.base.Edge in project binnavi by google.
the class CEdgeHighlighter method highlightEdgesOfNode.
/**
* Highlights all edges of a node.
*
* @param node The node whose edges are highlighted.
* @param highlight True to add highlighting to the edges. False to remove it.
*/
public static void highlightEdgesOfNode(final Node node, final boolean highlight) {
final EdgeCursor edges = node.edges();
int edgeCount = node.degree();
for (Edge edge = edges.edge(); edgeCount > 0; edgeCount--) {
final EdgeRealizer edgeRealizer = ((Graph2D) node.getGraph()).getRealizer(edge);
highlightEdge(edgeRealizer, highlight);
edges.cyclicNext();
edge = edges.edge();
}
}
use of y.base.Edge in project binnavi by google.
the class ZyGraphBuilder method convertEdges.
/**
* Converts the edges of a view into Graph2D edges.
*
* @param edges The edges to convert.
* @param graph2D The graph where the edges are inserted.
* @param rawNodeToNodeMap Keeps track of view node => graph node mappings.
* @param adjustColors
*/
private void convertEdges(final Collection<INaviEdge> edges, final Graph2D graph2D, final Map<INaviViewNode, Node> rawNodeToNodeMap, final boolean adjustColors) {
for (final INaviEdge edge : edges) {
// Get the nodes connected by the edge
final NaviNode sourceNode = m_ynodeToNodeMap.get(rawNodeToNodeMap.get(edge.getSource()));
final NaviNode targetNode = m_ynodeToNodeMap.get(rawNodeToNodeMap.get(edge.getTarget()));
final Pair<Edge, NaviEdge> result = ZyEdgeBuilder.convertEdge(edge, sourceNode, targetNode, graph2D, adjustColors);
m_yedgeToEdgeMap.put(result.first(), result.second());
}
}
Aggregations