use of y.view.EdgeRealizer in project binnavi by google.
the class ZyNodeRealizer method scalePortCoordinates.
protected void scalePortCoordinates(final Node node, final double wOld, final double wNew, final double hOld, final double hNew) {
final Graph2D graph = (Graph2D) node.getGraph();
final double wScaling = wOld > 0 ? wNew / wOld : 1.0d;
final double hScaling = hOld > 0 ? hNew / hOld : 1.0d;
for (Edge e = node.firstOutEdge(); e != null; e = e.nextOutEdge()) {
final EdgeRealizer er = graph.getRealizer(e);
final Port port = er.getSourcePort();
final double px = port.getOffsetX() * wScaling;
final double py = port.getOffsetY() * hScaling;
port.setOffsets(px, py);
graph.setSourcePointRel(e, new YPoint(px, py));
}
for (Edge e = node.firstInEdge(); e != null; e = e.nextInEdge()) {
final EdgeRealizer er = graph.getRealizer(e);
final Port port = er.getTargetPort();
final double px = port.getOffsetX() * wScaling;
final double py = port.getOffsetY() * hScaling;
port.setOffsets(px, py);
graph.setTargetPointRel(e, new YPoint(px, py));
}
}
use of y.view.EdgeRealizer in project binnavi by google.
the class CEdgeClickHandler method zoomEdgeNode.
/**
* Zooms to the source or target of an edge depending on what is farther away from the visible
* part of the graph.
*
* @param graph The graph the edge belongs to.
* @param edge The edge that provides the potential zoom targets.
*/
private static void zoomEdgeNode(final AbstractZyGraph<?, ?> graph, final Edge edge, final double mouseX, final double mouseY) {
assert edge != null;
final AbstractZyGraphSettings settings = graph.getSettings();
final boolean animate = settings.getLayoutSettings().getAnimateLayout();
final EdgeRealizer realizer = graph.getGraph().getRealizer(edge);
final NodeRealizer sourceRealizer = graph.getGraph().getRealizer(edge.source());
final NodeRealizer targetRealizer = graph.getGraph().getRealizer(edge.target());
final double srcPortX = realizer.getSourcePort().getX(sourceRealizer);
final double srcPortY = realizer.getSourcePort().getY(sourceRealizer);
final double tarPortX = realizer.getSourcePort().getX(targetRealizer);
final double tarPortY = realizer.getSourcePort().getY(targetRealizer);
final double srcLengthA = Math.abs(srcPortX - mouseX);
final double srcHeightB = Math.abs(srcPortY - mouseY);
final double tarLengthA = Math.abs(tarPortX - mouseX);
final double tarHeightB = Math.abs(tarPortY - mouseY);
final double srcLengthC = Math.sqrt(Math.pow(srcLengthA, 2) + Math.pow(srcHeightB, 2));
final double tarLengthC = Math.sqrt(Math.pow(tarLengthA, 2) + Math.pow(tarHeightB, 2));
if (srcLengthC > tarLengthC) {
final Point2D.Double center = new Point2D.Double(sourceRealizer.getCenterX(), sourceRealizer.getCenterY());
graph.getView().focusView(graph.getView().getZoom(), center, animate);
} else {
final Point2D.Double center = new Point2D.Double(targetRealizer.getCenterX(), targetRealizer.getCenterY());
graph.getView().focusView(graph.getView().getZoom(), center, animate);
}
}
use of y.view.EdgeRealizer in project binnavi by google.
the class CEdgeHighlighter method highlightEdgesOfNode.
/**
* Highlights all edges of a node.
*
* @param node The node whose edges are highlighted.
* @param highlight True to add highlighting to the edges. False to remove it.
*/
public static void highlightEdgesOfNode(final Node node, final boolean highlight) {
final EdgeCursor edges = node.edges();
int edgeCount = node.degree();
for (Edge edge = edges.edge(); edgeCount > 0; edgeCount--) {
final EdgeRealizer edgeRealizer = ((Graph2D) node.getGraph()).getRealizer(edge);
highlightEdge(edgeRealizer, highlight);
edges.cyclicNext();
edge = edges.edge();
}
}
Aggregations