Search in sources :

Example 11 with CStateChange

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

the class CEdgeLabelHoverState method mouseMoved.

@Override
public IMouseStateChange mouseMoved(final MouseEvent event, final AbstractZyGraph<?, ?> g) {
    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 {
        // We are in the node hover state but now there are no more hit nodes.
        // That means we just left the node and we have to undo all GUI changes
        // we made when entering the node.
        m_factory.createEdgeLabelExitState(m_label, event);
        return new CStateChange(m_factory.createDefaultState(), true);
    }
}
Also used : HitInfo(y.view.HitInfo) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)

Example 12 with CStateChange

use of com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange 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 13 with CStateChange

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

the class CDefaultState method mouseMoved.

@Override
public IMouseStateChange mouseMoved(final MouseEvent event, final AbstractZyGraph<?, ?> g) {
    final double x = g.getEditMode().translateX(event.getX());
    final double y = g.getEditMode().translateY(event.getY());
    final HitInfo hitInfo = g.getGraph().getHitInfo(x, y);
    if (hitInfo.hasHitNodes()) {
        return CHitNodesTransformer.enterNode(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitEdges()) {
        return CHitEdgesTransformer.enterEdge(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitEdgeLabels()) {
        return CHitEdgeLabelsTransformer.enterEdgeLabel(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitBends()) {
        return CHitBendsTransformer.enterBend(m_factory, event, hitInfo);
    } else if (hitInfo.hasHitPorts()) {
        return new CStateChange(this, true);
    } else {
        return new CStateChange(this, 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