Search in sources :

Example 1 with EdgeLabel

use of y.view.EdgeLabel 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 EdgeLabel

use of y.view.EdgeLabel in project binnavi by google.

the class CEdgeLabelHoverState method mousePressed.

@Override
public IMouseStateChange mousePressed(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()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitNodeLabels()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitEdges()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitEdgeLabels()) {
        final EdgeLabel label = hitInfo.getHitEdgeLabel();
        if (label == m_label) {
            // }
            return new CStateChange(this, true);
        } else {
            throw new IllegalStateException();
        }
    } else if (hitInfo.hasHitBends()) {
        throw new IllegalStateException();
    } else if (hitInfo.hasHitPorts()) {
        return new CStateChange(this, true);
    } else {
        m_factory.createEdgeLabelExitState(m_label, event);
        return new CStateChange(this, true);
    }
}
Also used : HitInfo(y.view.HitInfo) EdgeLabel(y.view.EdgeLabel) CStateChange(com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)

Example 3 with EdgeLabel

use of y.view.EdgeLabel in project binnavi by google.

the class CBendClickedLeftState 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()) {
        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);
        final Edge e = hitInfo.getHitEdge();
        return new CStateChange(m_factory.createEdgeEnterState(e, event), true);
    } else if (hitInfo.hasHitEdgeLabels()) {
        m_factory.createBendExitState(m_bend, event);
        final EdgeLabel l = hitInfo.getHitEdgeLabel();
        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 {
        m_factory.createBendExitState(m_bend, event);
        return new CStateChange(this, 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 4 with EdgeLabel

use of y.view.EdgeLabel in project binnavi by google.

the class ZoomFunctions method zoomToEdgeLabel.

public static <EdgeType extends ZyGraphEdge<?, ?, ?>> void zoomToEdgeLabel(final AbstractZyGraph<?, EdgeType> graph, final EdgeType edge) {
    final EdgeLabel label = edge.getRealizer().getLabel();
    final YRectangle labelBounds = label.getBox();
    final Rectangle viewBounds = graph.getView().getBounds();
    final double widthZoom = viewBounds.getWidth() / labelBounds.getWidth();
    final double heightZoom = viewBounds.getHeight() / labelBounds.getHeight();
    final double oldZoom = graph.getView().getZoom();
    graph.getView().setZoom(0.8 * Math.min(widthZoom, heightZoom));
    ZoomHelpers.keepZoomValid(graph.getView());
    final double newZoom = graph.getView().getZoom();
    graph.getView().setZoom(oldZoom);
    final Point2D newCenter = new Point2D.Double(labelBounds.getX() + (0.5 * labelBounds.getWidth()), labelBounds.getY() + (0.5 * labelBounds.getHeight()));
    graph.getView().focusView(newZoom, newCenter, true);
    graph.updateViews();
}
Also used : Point2D(java.awt.geom.Point2D) YRectangle(y.geom.YRectangle) EdgeLabel(y.view.EdgeLabel) Rectangle(java.awt.Rectangle) YRectangle(y.geom.YRectangle)

Example 5 with EdgeLabel

use of y.view.EdgeLabel in project binnavi by google.

the class CDefaultEdgeLabelEnterAction method execute.

@Override
public void execute(final CEdgeLabelEnterState<NodeType, EdgeType> state, final MouseEvent event) {
    highlightEdge(state.getLabel());
    final AbstractZyGraph<NodeType, EdgeType> graph = state.getGraph();
    final EdgeLabel label = state.getLabel();
    for (final IZyEditModeListener<NodeType, EdgeType> listener : state.getStateFactory().getListeners()) {
        try {
            listener.edgeLabelEntered(label, event);
        } catch (final Exception exception) {
        // TODO: (timkornau): implement logging here.
        }
    }
    graph.updateViews();
}
Also used : EdgeLabel(y.view.EdgeLabel)

Aggregations

EdgeLabel (y.view.EdgeLabel)5 CStateChange (com.google.security.zynamics.zylib.gui.zygraph.editmode.CStateChange)3 HitInfo (y.view.HitInfo)3 ZyGraphEdge (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.edges.ZyGraphEdge)2 Edge (y.base.Edge)2 Rectangle (java.awt.Rectangle)1 Point2D (java.awt.geom.Point2D)1 YRectangle (y.geom.YRectangle)1