List of usage examples for java.awt.geom Point2D getY
public abstract double getY();
From source file:org.opennms.features.vaadin.topology.jung.RadialTreeLayoutAlgorithm.java
public void updateLayout(GraphContainer graph) { Graph g = new Graph(graph); int szl = g.getSemanticZoomLevel(); DirectedSparseGraph<Vertex, Edge> jungGraph = new DirectedSparseGraph<Vertex, Edge>(); List<Vertex> vertices = g.getVertices(szl); for (Vertex v : vertices) { jungGraph.addVertex(v);//from w w w . j a v a 2s . c o m } List<Edge> edges = g.getEdges(szl); for (Edge e : edges) { jungGraph.addEdge(e, e.getSource(), e.getTarget()); } DelegateForest<Vertex, Edge> forest = new DelegateForest<Vertex, Edge>(jungGraph); TreeLayout<Vertex, Edge> layout = new TreeLayout<Vertex, Edge>(forest); layout.setInitializer(new Transformer<Vertex, Point2D>() { public Point2D transform(Vertex v) { return new Point(v.getX(), v.getY()); } }); layout.setSize(new Dimension(750, 750)); for (Vertex v : vertices) { Point2D point = layout.transform(v); v.setX((int) point.getX()); v.setY((int) point.getY()); } }
From source file:org.opennms.features.vaadin.topology.jung.TreeLayoutAlgorithm.java
public void updateLayout(GraphContainer graph) { Graph g = new Graph(graph); int szl = g.getSemanticZoomLevel(); DirectedSparseGraph<Vertex, Edge> jungGraph = new DirectedSparseGraph<Vertex, Edge>(); List<Vertex> vertices = g.getVertices(szl); for (Vertex v : vertices) { jungGraph.addVertex(v);/*w ww . ja v a2 s . c o m*/ } List<Edge> edges = g.getEdges(szl); for (Edge e : edges) { jungGraph.addEdge(e, e.getSource(), e.getTarget()); } DelegateForest<Vertex, Edge> forest = new DelegateForest<Vertex, Edge>(jungGraph); RadialTreeLayout<Vertex, Edge> layout = new RadialTreeLayout<Vertex, Edge>(forest); layout.setInitializer(new Transformer<Vertex, Point2D>() { public Point2D transform(Vertex v) { return new Point(v.getX(), v.getY()); } }); layout.setSize(new Dimension(750, 750)); for (Vertex v : vertices) { Point2D point = layout.transform(v); v.setX((int) point.getX()); v.setY((int) point.getY()); } }
From source file:org.photovault.image.ChannelMapOperationFactory.java
/** Creates a new ChannelMapOperationFactory that initially creates objetcs that are equal to an existing ChannelMapOperation. @param o The operation used as template. If <code>null</code> the result is similar as if constructed with the no-argument constructor. *///from w ww .j a va 2 s .com public ChannelMapOperationFactory(ChannelMapOperation o) { if (o == null) { return; } Iterator iter = o.channelPoints.entrySet().iterator(); while (iter.hasNext()) { Map.Entry e = (Map.Entry) iter.next(); String name = (String) e.getKey(); Point2D[] points = (Point2D[]) e.getValue(); ColorCurve c = new ColorCurve(); for (int n = 0; n < points.length; n++) { Point2D p = points[n]; c.addPoint(p.getX(), p.getY()); } channelCurves.put(name, c); } }
From source file:org.pathvisio.pathlayout.layouts.Balloon.java
/** * create a new Balloon layout.//ww w . java2 s .c o m * @param swingEngine The PathVisio swing engine * @param selection Boolean whether to use currently selected nodes or complete pathway */ public Balloon(SwingEngine swingEngine, boolean selection) { super(swingEngine, selection); createDSMultigraph(); Forest<String, String> forest = new DelegateForest<String, String>(); List<PathwayElement> elements = pwy.getDataObjects(); for (PathwayElement element : elements) { if (element.getObjectType().equals(ObjectType.LINE)) { if (!forest.containsVertex(element.getStartGraphRef())) { forest.addVertex(element.getStartGraphRef()); } if (!forest.containsEdge(element.getEndGraphRef())) { forest.addVertex(element.getEndGraphRef()); } forest.addEdge(element.getGraphId(), element.getStartGraphRef(), element.getEndGraphRef()); } } BalloonLayout.DEFAULT_DISTX = 200; BalloonLayout.DEFAULT_DISTY = 200; l = new BalloonLayout<String, String>(forest); setDimension((Layout<String, String>) l); for (PathwayElement element : elements) { if (element.getObjectType().equals(ObjectType.DATANODE)) { Point2D p = new Point2D.Double(element.getMCenterX(), element.getMCenterY()); l.setLocation(element.getGraphId(), p); } } l.initialize(); for (String v : l.getGraph().getVertices()) { Point2D center = l.transform(v); double x = center.getX(); double y = center.getY(); PathwayElement e = pwy.getElementById(v); x = x + e.getMWidth() / 2 * 5; y = y + e.getMHeight() / 2 * 5; e.setMCenterX(x); e.setMCenterY(y); } //re-draw the lines drawLines(); }
From source file:chiliad.parser.pdf.extractor.vectorgraphics.operator.MoveTo.java
/** * process : m : Begin new subpath./*ww w . j a v a 2s . c o m*/ * * @param operator The operator that is being executed. * @param arguments List * @throws IOException If there is an error processing the operator. */ @Override public void process(PDFOperator operator, List<COSBase> arguments) throws IOException { try { VectorGraphicsExtractor extractor = (VectorGraphicsExtractor) context; COSNumber x = (COSNumber) arguments.get(0); COSNumber y = (COSNumber) arguments.get(1); Point2D pos = extractor.transformedPoint(x.doubleValue(), y.doubleValue()); extractor.getLinePath().moveTo((float) pos.getX(), (float) pos.getY()); } catch (Exception exception) { log.warn(exception, exception); } }
From source file:at.knowcenter.wag.egov.egiz.pdf.operator.path.construction.LineTo.java
@Override public void process(PDFOperator operator, List<COSBase> operands) throws IOException { try {//from w w w. j av a2s.co m PDFPage pdfPage = (PDFPage) context; COSNumber x = (COSNumber) operands.get(0); COSNumber y = (COSNumber) operands.get(1); Point2D p = transform(x.doubleValue(), y.doubleValue()); pdfPage.getCurrentPath().lineTo((float) p.getX(), (float) p.getY()); if (log.isTraceEnabled()) { log.trace("Adding line to x:" + p.getX() + ",y:" + p.getY()); } } catch (Exception e) { log.warn("Error processing operator 'l'.", e); } }
From source file:at.knowcenter.wag.egov.egiz.pdf.operator.path.construction.MoveTo.java
@Override public void process(PDFOperator operator, List<COSBase> operands) throws IOException { try {/* w ww .j a v a 2s .co m*/ PDFPage pdfPage = (PDFPage) context; COSNumber x = (COSNumber) operands.get(0); COSNumber y = (COSNumber) operands.get(1); Point2D p = transform(x.doubleValue(), y.doubleValue()); pdfPage.getCurrentPath().moveTo((float) p.getX(), (float) p.getY()); if (log.isTraceEnabled()) { log.trace("Moving current path to x:" + p.getX() + ",y:" + p.getY()); } } catch (Exception e) { log.warn("Error processing operator 'm'.", e); } }
From source file:lu.lippmann.cdb.graph.GraphUtil.java
/** * //w w w . j a v a 2 s . co m * @param layout * @param picked */ public static Layout<CNode, CEdge> reorganize(Layout<CNode, CEdge> layout, Set<CNode> picked) { Layout<CNode, CEdge> subLayout = null; //create map that copy the transformer of existing layout final HashMap<CNode, CPoint> mapTransform1 = new LinkedHashMap<CNode, CPoint>(); for (CNode v : layout.getGraph().getVertices()) { final Point2D tmp = layout.transform(v); mapTransform1.put(v, new CPoint(tmp.getX(), tmp.getY())); } // final Graph<CNode, CEdge> graph = layout.getGraph(); final AggregateLayout<CNode, CEdge> clusteringLayout = new AggregateLayout<CNode, CEdge>(layout); // put the picked vertices into a new sublayout //final Set<CNode> picked = vv.getPickedVertexState().getPicked(); if (picked != null && picked.size() >= 1) { final Point2D initCenter = GraphUtil.getCenter(picked, layout); final Graph<CNode, CEdge> subGraph = new DirectedSparseGraph<CNode, CEdge>(); try { for (CNode vertex : picked) { subGraph.addVertex(vertex); final Collection<CEdge> incidentEdges = graph.getIncidentEdges(vertex); if (incidentEdges != null) { for (final CEdge edge : incidentEdges) { final Pair<CNode> endpoints = graph.getEndpoints(edge); if (picked.containsAll(endpoints)) { subGraph.addEdge(edge, endpoints.getFirst(), endpoints.getSecond()); } } } } subLayout = buildMinimumSpanningForestLayout(subGraph); subLayout.setInitializer(layout); if (!(subLayout instanceof TreeLayout)) { subLayout.setSize(clusteringLayout.getSize()); } final Point2D subGraphCenter = GraphUtil.getCenter(picked, subLayout); final Point2D subLayoutCenter = new Point2D.Double(subLayout.getSize().getWidth() / 2, subLayout.getSize().getHeight() / 2); //System.out.println("Initial init center : " + initCenter); initCenter.setLocation(initCenter.getX() + (subLayoutCenter.getX() - subGraphCenter.getX()), initCenter.getY() + (subLayoutCenter.getY() - subGraphCenter.getY())); //System.out.println("Corrected init center : " + initCenter); clusteringLayout.put(subLayout, initCenter); //create map that copy the transformer of new layout final HashMap<CNode, CPoint> mapTransform2 = new LinkedHashMap<CNode, CPoint>(); for (CNode v : layout.getGraph().getVertices()) { final Point2D tmp = clusteringLayout.transform(v); mapTransform2.put(v, new CPoint(tmp.getX(), tmp.getY())); } // /** save the new layout and historize it !! */ ((GraphWithOperations) layout.getGraph()).changeLayout(mapTransform1, mapTransform2); } catch (Exception e) { e.printStackTrace(); } } return subLayout; }
From source file:at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.LineTo.java
@Override public void process(Operator operator, List<COSBase> operands) throws IOException { try {/*from w w w.j a va2s . c o m*/ PDFPage pdfPage = (PDFPage) context; COSNumber x = (COSNumber) operands.get(0); COSNumber y = (COSNumber) operands.get(1); Point2D p = transform(x.doubleValue(), y.doubleValue()); pdfPage.getCurrentPath().lineTo((float) p.getX(), (float) p.getY()); if (log.isTraceEnabled()) { log.trace("Adding line to x:" + p.getX() + ",y:" + p.getY()); } } catch (Exception e) { log.warn("Error processing operator 'l'.", e); } }
From source file:at.knowcenter.wag.egov.egiz.pdfbox2.pdf.operator.path.construction.MoveTo.java
public void process(Operator operator, List<COSBase> operands) throws IOException { try {//from ww w .j a v a 2 s .com PDFPage pdfPage = (PDFPage) context; COSNumber x = (COSNumber) operands.get(0); COSNumber y = (COSNumber) operands.get(1); Point2D p = transform(x.doubleValue(), y.doubleValue()); pdfPage.getCurrentPath().moveTo((float) p.getX(), (float) p.getY()); if (log.isTraceEnabled()) { log.trace("Moving current path to x:" + p.getX() + ",y:" + p.getY()); } } catch (Exception e) { log.warn("Error processing operator 'm'.", e); } }