use of y.view.Bend in project binnavi by google.
the class CDefaultNodeDraggedLeftAction method execute.
@Override
public void execute(final CNodeDraggedLeftState<NodeType, EdgeType> state, final MouseEvent event) {
CMouseCursorHelper.setHandCursor(state.getGraph());
moveToFront((ZyGraphLayeredRenderer<?>) state.getGraph().getView().getGraph2DRenderer(), state.getNode());
// 1. The dragged node is always moved
// 2. The selected nodes are only moved if the dragged node is selected too
final AbstractZyGraph<NodeType, EdgeType> graph = state.getGraph();
final Set<Bend> movedBends = new HashSet<Bend>();
final NodeType draggedNode = graph.getNode(state.getNode());
final ZyLabelContent labelContent = draggedNode.getRealizer().getNodeContent();
if (graph.getEditMode().getLabelEventHandler().isActiveLabel(labelContent)) {
CEditNodeHelper.setCaretEnd(graph, state.getNode(), event);
CEditNodeHelper.select(graph, state.getNode(), event);
} else if (draggedNode.isSelected()) {
for (final NodeType n : graph.getSelectedNodes()) {
CNodeMover.moveNode(graph, n, state.getDistanceX(), state.getDistanceY(), movedBends);
}
} else {
CNodeMover.moveNode(graph, draggedNode, state.getDistanceX(), state.getDistanceY(), movedBends);
}
graph.updateViews();
}
use of y.view.Bend in project binnavi by google.
the class ZyEdgeRealizer method removeBend.
@Override
public Bend removeBend(final Bend bend) {
final int index = bendPos(bend);
final Bend rbend = super.removeBend(bend);
for (final IZyEdgeRealizerListener<EdgeType> listener : m_listeners) {
try {
listener.removedBend(this, index);
} catch (final Exception exception) {
exception.printStackTrace();
}
}
return rbend;
}
use of y.view.Bend in project binnavi by google.
the class ZyEdgeRealizer method appendBend.
@Override
public Bend appendBend(final double x, final double y) {
final Bend bend = super.appendBend(x, y);
bend.setSelected(isSelected());
return bend;
}
use of y.view.Bend 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.view.Bend 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);
}
}
}
Aggregations