Search in sources :

Example 6 with Graph2DView

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

the class CRegisterHotKeys method register.

public static <NodeType extends ZyGraphNode<?>> void register(final AbstractZyGraph<NodeType, ?> graph) {
    final Graph2DView view = graph.getView();
    final Graph2DViewActions actions = new Graph2DViewActions(view);
    final ActionMap amap = actions.createActionMap();
    final InputMap imap = actions.createDefaultInputMap(amap);
    view.setActionMap(amap);
    view.setInputMap(JComponent.WHEN_FOCUSED, imap);
    view.getCanvasComponent().setActionMap(amap);
    view.getCanvasComponent().setInputMap(JComponent.WHEN_FOCUSED, imap);
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), "DOWN");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), "UP");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), "LEFT");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), "RIGHT");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0), "+");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0), "-");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, 0), "m");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_S, 0), "s");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LESS, 0), "<");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, KeyEvent.CTRL_DOWN_MASK), "SELECT_VISIBLE_NODES");
    imap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK), "COPY_CONTENT_FROM_SELECTED_NODES");
    amap.remove(Graph2DViewActions.DELETE_SELECTION);
    amap.remove(Graph2DViewActions.EDIT_LABEL);
    registerActions(graph);
}
Also used : Graph2DView(y.view.Graph2DView) ActionMap(javax.swing.ActionMap) InputMap(javax.swing.InputMap) Graph2DViewActions(y.view.Graph2DViewActions)

Example 7 with Graph2DView

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

the class GraphExporters method exportPartAsGIF.

@SuppressWarnings("unchecked")
public static void exportPartAsGIF(final AbstractZyGraph zygraph, final String filename) throws IOException {
    Graph2DView view = zygraph.getView();
    final y.io.GIFIOHandler jpg = new y.io.GIFIOHandler();
    jpg.setAntialiasingEnabled(true);
    exportGraphPartToImageFileFormat(view.getGraph2D(), jpg, filename);
}
Also used : Graph2DView(y.view.Graph2DView)

Example 8 with Graph2DView

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

the class GraphExporters method exportPartAsPNG.

@SuppressWarnings("unchecked")
public static void exportPartAsPNG(final AbstractZyGraph zygraph, final String filename) throws IOException {
    Graph2DView view = zygraph.getView();
    final ImageOutputHandler png = createPNGOutputHandler();
    png.setAntialiasingEnabled(true);
    exportGraphPartToImageFileFormat(view.getGraph2D(), png, filename);
}
Also used : Graph2DView(y.view.Graph2DView) ImageOutputHandler(y.io.ImageOutputHandler)

Example 9 with Graph2DView

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

the class GraphExporters method replaceCurrentWithExportView.

private static Graph2DView replaceCurrentWithExportView(final Graph2D graph, final Graph2DView exportView) {
    // Save the currently active view.
    final Graph2DView originalView = (Graph2DView) graph.getCurrentView();
    // Use the Graph2DRenderer instance of the currently active view. (Optional.)
    exportView.setGraph2DRenderer(originalView.getGraph2DRenderer());
    // Replace the currently active view containing the graph with the "export"
    // view.
    graph.setCurrentView(exportView);
    return originalView;
}
Also used : Graph2DView(y.view.Graph2DView)

Example 10 with Graph2DView

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

the class GraphExporters method exportPartAsSVG.

@SuppressWarnings("unchecked")
public static void exportPartAsSVG(final AbstractZyGraph zygraph, final String filename) throws IOException {
    Graph2DView view = zygraph.getView();
    final SVGIOHandler svg = new SVGIOHandler();
    exportGraphPartToImageFileFormat(view.getGraph2D(), svg, filename);
}
Also used : Graph2DView(y.view.Graph2DView) SVGIOHandler(yext.svg.io.SVGIOHandler)

Aggregations

Graph2DView (y.view.Graph2DView)11 ImageOutputHandler (y.io.ImageOutputHandler)2 SVGIOHandler (yext.svg.io.SVGIOHandler)2 ZyGraph2DView (com.google.security.zynamics.zylib.yfileswrap.gui.zygraph.ZyGraph2DView)1 IOException (java.io.IOException)1 ActionMap (javax.swing.ActionMap)1 InputMap (javax.swing.InputMap)1 DefaultBackgroundRenderer (y.view.DefaultBackgroundRenderer)1 Graph2D (y.view.Graph2D)1 Graph2DViewActions (y.view.Graph2DViewActions)1 HitInfo (y.view.HitInfo)1 HitInfoFactory (y.view.HitInfoFactory)1