Search in sources :

Example 1 with CStateChange

use of com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange in project binnavi by google.

the class CBendEnterState method mouseMoved.

@Override
public IMouseStateChange mouseMoved(final MouseEvent event, final AbstractZyGraph<?, ?> graph) {
    final double x = m_graph.getEditMode().translateX(event.getX());
    final double y = m_graph.getEditMode().translateY(event.getY());
    final HitInfo hitInfo = m_graph.getGraph().getHitInfo(x, y);
    if (hitInfo.hasHitNodes()) {
        m_factory.createBendExitState(m_bend, event);
        return CHitNodesTransformer.enterNode(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitNodeLabels()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitEdges()) {
        final Edge e = hitInfo.getHitEdge();
        m_factory.createBendExitState(m_bend, event);
        return new CStateChange(m_factory.createEdgeEnterState(e, event), true);
    } else if (hitInfo.hasHitEdgeLabels()) {
        final EdgeLabel l = hitInfo.getHitEdgeLabel();
        m_factory.createBendExitState(m_bend, event);
        return new CStateChange(m_factory.createEdgeLabelEnterState(l, event), true);
    } else if (hitInfo.hasHitBends()) {
        return CHitBendsTransformer.changeBend(m_factory, event, hitInfo, m_bend);
    } else if (hitInfo.hasHitPorts()) {
        return new CStateChange(this, true);
    } else {
        return new CStateChange(m_factory.createBendExitState(m_bend, event), true);
    }
}
Also used : HitInfo(y.view.HitInfo) EdgeLabel(y.view.EdgeLabel) ZyGraphEdge(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.edges.ZyGraphEdge) Edge(y.base.Edge) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)

Example 2 with CStateChange

use of com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange in project binnavi by google.

the class CBendHoverState method mouseMoved.

@Override
public IMouseStateChange mouseMoved(final MouseEvent event, final AbstractZyGraph<?, ?> graph) {
    final double x = m_graph.getEditMode().translateX(event.getX());
    final double y = m_graph.getEditMode().translateY(event.getY());
    final HitInfo hitInfo = m_graph.getGraph().getHitInfo(x, y);
    if (hitInfo.hasHitNodes()) {
        m_factory.createBendExitState(m_bend, event);
        return CHitNodesTransformer.enterNode(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitNodeLabels()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitEdges()) {
        m_factory.createBendExitState(m_bend, event);
        return CHitEdgesTransformer.enterEdge(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitEdgeLabels()) {
        m_factory.createBendExitState(m_bend, event);
        return CHitEdgeLabelsTransformer.enterEdgeLabel(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitBends()) {
        return CHitBendsTransformer.changeBend(m_factory, event, hitInfo, m_bend);
    } else if (hitInfo.hasHitPorts()) {
        return new CStateChange(this, true);
    } else {
        return new CStateChange(m_factory.createDefaultState(), true);
    }
}
Also used : HitInfo(y.view.HitInfo) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)

Example 3 with CStateChange

use of com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange in project binnavi by google.

the class CNodeEditState method mouseReleased.

@Override
public IMouseStateChange mouseReleased(final MouseEvent event, final AbstractZyGraph<?, ?> graph) {
    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()) {
            if (n == m_node) {
                if (!m_isDragging) {
                    // Change caret
                    CEditNodeHelper.setCaretEnd(graph, n, event);
                } else {
                    m_isDragging = false;
                }
                return new CStateChange(this, false);
            } else {
                m_factory.createNodeEditExitState(m_node, event);
                return new CStateChange(m_factory.createNodePressedLeftState(n, event), true);
            }
        } else if (SwingUtilities.isRightMouseButton(event)) {
            if (n == m_node) {
                return new CStateChange(this, false);
            } else {
                m_factory.createNodeEditExitState(m_node, event);
                return new CStateChange(m_factory.createNodePressedRightState(n, event), true);
            }
        } else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) {
            if (n == m_node) {
                if (!m_isDragging) {
                    // Change caret
                    CEditNodeHelper.setCaretEnd(graph, n, event);
                } else {
                    m_isDragging = false;
                }
                return new CStateChange(this, false);
            } else {
                m_factory.createNodeEditExitState(m_node, event);
                return new CStateChange(m_factory.createNodePressedMiddleState(n, event), true);
            }
        } else {
            return new CStateChange(this, false);
        }
    } else if (hitInfo.hasHitNodeLabels()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitEdges()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdge(), event), true);
    } else if (hitInfo.hasHitEdgeLabels()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdgeLabel().getEdge(), event), true);
    } else if (hitInfo.hasHitBends()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createBendPressedLeftState(hitInfo.getHitBend(), event), true);
    } else if (hitInfo.hasHitPorts()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createDefaultState(), true);
    } else {
        // User left-pressed the background.
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createBackgroundPressedLeftState(event), true);
    }
}
Also used : HitInfo(y.view.HitInfo) ZyGraphNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode) Node(y.base.Node) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)

Example 4 with CStateChange

use of com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange in project binnavi by google.

the class CNodeEditState method mousePressed.

@Override
public IMouseStateChange mousePressed(final MouseEvent event, final AbstractZyGraph<?, ?> graph) {
    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()) {
            if (n == m_node) {
                if (!m_isDragging) {
                    // Change caret
                    CEditNodeHelper.setCaretStart(graph, n, event);
                } else {
                    m_isDragging = false;
                }
                return new CStateChange(this, false);
            } else {
                m_factory.createNodeEditExitState(m_node, event);
                return new CStateChange(m_factory.createNodePressedLeftState(n, event), true);
            }
        } else if (SwingUtilities.isRightMouseButton(event)) {
            if (n == m_node) {
                return new CStateChange(this, false);
            } else {
                m_factory.createNodeEditExitState(m_node, event);
                return new CStateChange(m_factory.createNodePressedRightState(n, event), true);
            }
        } else if (SwingUtilities.isMiddleMouseButton(event) || (event.isAltDown() && SwingUtilities.isLeftMouseButton(event))) {
            if (n == m_node) {
                if (!m_isDragging) {
                    // Change caret
                    CEditNodeHelper.setCaretStart(graph, n, event);
                } else {
                    m_isDragging = false;
                }
                return new CStateChange(this, false);
            } else {
                m_factory.createNodeEditExitState(m_node, event);
                return new CStateChange(m_factory.createNodePressedMiddleState(n, event), true);
            }
        } else {
            return new CStateChange(this, false);
        }
    } else if (hitInfo.hasHitNodeLabels()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitEdges()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdge(), event), true);
    } else if (hitInfo.hasHitEdgeLabels()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createEdgePressedLeftState(hitInfo.getHitEdgeLabel().getEdge(), event), true);
    } else if (hitInfo.hasHitBends()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createBendPressedLeftState(hitInfo.getHitBend(), event), true);
    } else if (hitInfo.hasHitPorts()) {
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createDefaultState(), true);
    } else {
        // User left-pressed the background.
        m_factory.createNodeEditExitState(m_node, event);
        return new CStateChange(m_factory.createBackgroundPressedLeftState(event), true);
    }
}
Also used : HitInfo(y.view.HitInfo) ZyGraphNode(com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode) Node(y.base.Node) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)

Example 5 with CStateChange

use of com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange in project binnavi by google.

the class CEdgeLabelEnterState method mouseMoved.

@Override
public IMouseStateChange mouseMoved(final MouseEvent event, final AbstractZyGraph<?, ?> graph) {
    final double x = m_graph.getEditMode().translateX(event.getX());
    final double y = m_graph.getEditMode().translateY(event.getY());
    final HitInfo hitInfo = m_graph.getGraph().getHitInfo(x, y);
    if (hitInfo.hasHitNodes()) {
        m_factory.createEdgeLabelExitState(m_label, event);
        return CHitNodesTransformer.enterNode(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitNodeLabels()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitEdges()) {
        m_factory.createEdgeLabelExitState(m_label, event);
        return CHitEdgesTransformer.enterEdge(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitEdgeLabels()) {
        return CHitEdgeLabelsTransformer.changeEdgeLabel(m_factory, event, hitInfo, m_label);
    } else if (hitInfo.hasHitBends()) {
        m_factory.createEdgeLabelExitState(m_label, event);
        return CHitBendsTransformer.enterBend(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitPorts()) {
        return new CStateChange(this, true);
    } else {
        return new CStateChange(m_factory.createEdgeLabelExitState(m_label, event), true);
    }
}
Also used : HitInfo(y.view.HitInfo) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)

Aggregations

CStateChange (com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)13 HitInfo (y.view.HitInfo)13 Edge (y.base.Edge)3 Node (y.base.Node)3 EdgeLabel (y.view.EdgeLabel)3 ZyGraphEdge (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.edges.ZyGraphEdge)2 ZyGraphNode (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.nodes.ZyGraphNode)2 Bend (y.view.Bend)1