Search in sources :

Example 1 with Bend

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();
}
Also used : ZyLabelContent(com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent) Bend(y.view.Bend) HashSet(java.util.HashSet)

Example 2 with Bend

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;
}
Also used : Bend(y.view.Bend) YPoint(y.geom.YPoint)

Example 3 with Bend

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;
}
Also used : Bend(y.view.Bend)

Example 4 with 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);
    }
}
Also used : HitInfo(y.view.HitInfo) Bend(y.view.Bend) Node(y.base.Node) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange) Edge(y.base.Edge)

Example 5 with Bend

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);
        }
    }
}
Also used : EdgeCursor(y.base.EdgeCursor) BendCursor(y.view.BendCursor) Bend(y.view.Bend) Edge(y.base.Edge)

Aggregations

Bend (y.view.Bend)5 Edge (y.base.Edge)2 CStateChange (com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)1 ZyLabelContent (com.google.security.zynamics.zylib.gui.zygraph.realizers.ZyLabelContent)1 HashSet (java.util.HashSet)1 EdgeCursor (y.base.EdgeCursor)1 Node (y.base.Node)1 YPoint (y.geom.YPoint)1 BendCursor (y.view.BendCursor)1 HitInfo (y.view.HitInfo)1