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);
}
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);
}
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;
}
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;
}
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);
}
}
Aggregations