use of y.geom.YPoint 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.geom.YPoint in project binnavi by google.
the class YHelpers method openFolder.
/**
* Opens a folder node.
*
* @param graph The graph the folder node belongs to.
* @param folderNode The folder node to be opened.
*/
public static void openFolder(final Graph2D graph, final Node folderNode) {
Preconditions.checkNotNull(graph, "Error: Graph argument can not be null");
Preconditions.checkNotNull(folderNode, "Error: Folder node argument can not be null");
final HierarchyManager hierarchy = graph.getHierarchyManager();
final double w = graph.getWidth(folderNode);
final double h = graph.getHeight(folderNode);
final NodeList folderNodes = new NodeList();
folderNodes.add(folderNode);
graph.firePreEvent();
for (final NodeCursor nc = folderNodes.nodes(); nc.ok(); nc.next()) {
// get original location of folder node
final Graph2D innerGraph = (Graph2D) hierarchy.getInnerGraph(nc.node());
final YPoint folderP = graph.getLocation(nc.node());
final NodeList innerNodes = new NodeList(innerGraph.nodes());
hierarchy.openFolder(nc.node());
// get new location of group node
final Rectangle2D.Double gBox = graph.getRealizer(nc.node()).getBoundingBox();
// move grouped nodes to former location of folder node
LayoutTool.moveSubgraph(graph, innerNodes.nodes(), folderP.x - gBox.x, folderP.y - gBox.y);
}
graph.firePostEvent();
graph.unselectAll();
for (final NodeCursor nc = folderNodes.nodes(); nc.ok(); nc.next()) {
graph.setSelected(nc.node(), true);
}
// to the node
if ((w != graph.getWidth(folderNode)) || (h != graph.getHeight(folderNode))) {
for (final EdgeCursor ec = folderNode.outEdges(); ec.ok(); ec.next()) {
graph.setSourcePointRel(ec.edge(), YPoint.ORIGIN);
}
for (final EdgeCursor ec = folderNode.inEdges(); ec.ok(); ec.next()) {
graph.setTargetPointRel(ec.edge(), YPoint.ORIGIN);
}
}
graph.updateViews();
}
use of y.geom.YPoint in project binnavi by google.
the class ZyGraphEdge method getPaths.
public ArrayList<Pair<Double, Double>> getPaths() {
final int points = getRealizer(m_edge).pointCount();
final ArrayList<Pair<Double, Double>> pointsList = new ArrayList<>();
for (int i = 0; i < points; i++) {
final YPoint point = getRealizer(m_edge).getPoint(i);
pointsList.add(new Pair<Double, Double>(point.x, point.y));
}
return pointsList;
}
Aggregations