Search in sources :

Example 1 with Graph2DView

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

the class ZyGraphDragAndDropSupport method getDragOverState.

/**
   * Determine the drag over state for the given location, i.e. the object under the cursor.
   *
   * @param graph The zygraph for which to determine the drag over state.
   * @param location The location where to query the drag over state.
   * @return The drag over state for the zygraph at the given location.
   */
public static DragOverState getDragOverState(final ZyGraph graph, final Point location) {
    final Graph2DView view = graph.getView();
    final double worldX = view.toWorldCoordX((int) location.getX());
    final double worldY = view.toWorldCoordY((int) location.getY());
    final HitInfoFactory factory = view.getHitInfoFactory();
    final HitInfo hit = factory.createHitInfo(worldX, worldY, Graph2DTraversal.NODES, true);
    if (hit.hasHitNodes()) {
        final NaviNode naviNode = graph.getMappings().getNode(hit.getHitNode());
        if (naviNode != null) {
            return new DragOverState(naviNode, ZyNodeContentHelpers.getObjectWrapper(naviNode, worldX, worldY));
        }
    }
    return new DragOverState(null, null);
}
Also used : Graph2DView(y.view.Graph2DView) HitInfo(y.view.HitInfo) HitInfoFactory(y.view.HitInfoFactory)

Example 2 with Graph2DView

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

the class GraphExporters method exportPartAsJPEG.

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

Example 3 with Graph2DView

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

the class GraphExporters method exportAllAsPNG.

// Warning on raw types on the following methods are suppressed. We need to use the raw type to
// allow these methods to be called without introducing dependencies on yFiles.
@SuppressWarnings("unchecked")
public static boolean exportAllAsPNG(final AbstractZyGraph zygraph, final String filename) throws IOException {
    Graph2DView view = zygraph.getView();
    final ImageOutputHandler png = createPNGOutputHandler();
    exportGraphToImageFileFormat(view.getGraph2D(), png, filename, png.createDefaultGraph2DView(view.getGraph2D()));
    return true;
}
Also used : Graph2DView(y.view.Graph2DView) ImageOutputHandler(y.io.ImageOutputHandler)

Example 4 with Graph2DView

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

the class GraphExporters method exportAllAsSVG.

@SuppressWarnings("unchecked")
public static boolean exportAllAsSVG(final AbstractZyGraph zygraph, final String filename) throws IOException {
    Graph2DView view = zygraph.getView();
    final SVGIOHandler svg = new SVGIOHandler();
    exportGraphToImageFileFormat(view.getGraph2D(), svg, filename, svg.createDefaultGraph2DView(view.getGraph2D()));
    return true;
}
Also used : Graph2DView(y.view.Graph2DView) SVGIOHandler(yext.svg.io.SVGIOHandler)

Example 5 with Graph2DView

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

the class GraphExporters method exportGraphToImageFileFormat.

private static void exportGraphToImageFileFormat(final Graph2D graph, final IOHandler ioh, final String outFile, final Graph2DView exportView) throws IOException {
    final Graph2DView originalView = replaceCurrentWithExportView(graph, exportView);
    configureExportView((Graph2DView) graph.getCurrentView());
    try {
        writeGraphToFile(graph, ioh, outFile);
    } catch (final IOException e) {
        throw e;
    } finally {
        restoreOriginalView(graph, originalView);
    }
}
Also used : Graph2DView(y.view.Graph2DView) IOException(java.io.IOException)

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