List of usage examples for java.awt.geom Point2D getY
public abstract double getY();
From source file:edu.uci.ics.jung.algorithms.layout.FRLayout2.java
protected synchronized void calcPositions(V v) { Point2D fvd = this.frVertexData.get(v); if (fvd == null) return;//from ww w. j a va 2 s .co m Point2D xyd = transform(v); double deltaLength = Math.max(EPSILON, Math.sqrt(fvd.getX() * fvd.getX() + fvd.getY() * fvd.getY())); double newXDisp = fvd.getX() / deltaLength * Math.min(deltaLength, temperature); assert Double.isNaN(newXDisp) == false : "Unexpected mathematical result in FRLayout:calcPositions [xdisp]"; double newYDisp = fvd.getY() / deltaLength * Math.min(deltaLength, temperature); double newX = xyd.getX() + Math.max(-5, Math.min(5, newXDisp)); double newY = xyd.getY() + Math.max(-5, Math.min(5, newYDisp)); newX = Math.max(innerBounds.getMinX(), Math.min(newX, innerBounds.getMaxX())); newY = Math.max(innerBounds.getMinY(), Math.min(newY, innerBounds.getMaxY())); xyd.setLocation(newX, newY); }
From source file:inflor.core.gates.ui.PolygonGateAdapter.java
private void updateTemporaryAnnotation() { Point2D previousVertex = null; if (segments != null) { segments.stream().forEach(panel::removeTemporaryAnnotation); }// ww w.j av a 2 s . co m segments = new ArrayList<>(); for (Point2D v : vertices) { if (previousVertex == null) { previousVertex = v; } else { segments.add( new XYLineAnnotation(previousVertex.getX(), previousVertex.getY(), v.getX(), v.getY())); previousVertex = v; } } segments.stream().forEach(panel::addTemporaryAnnotation); }
From source file:edu.uci.ics.jung.algorithms.layout.FRLayout.java
protected void calcAttraction(E e) { Pair<V> endpoints = getGraph().getEndpoints(e); V v1 = endpoints.getFirst();/*from ww w . j a v a 2 s .c om*/ V v2 = endpoints.getSecond(); boolean v1_locked = isLocked(v1); boolean v2_locked = isLocked(v2); if (v1_locked && v2_locked) { // both locked, do nothing return; } Point2D p1 = transform(v1); Point2D p2 = transform(v2); if (p1 == null || p2 == null) return; double xDelta = p1.getX() - p2.getX(); double yDelta = p1.getY() - p2.getY(); double deltaLength = Math.max(EPSILON, Math.sqrt((xDelta * xDelta) + (yDelta * yDelta))); double force = (deltaLength * deltaLength) / attraction_constant; if (Double.isNaN(force)) { throw new IllegalArgumentException("Unexpected mathematical result in FRLayout:calcPositions [force]"); } double dx = (xDelta / deltaLength) * force; double dy = (yDelta / deltaLength) * force; if (v1_locked == false) { FRVertexData fvd1 = getFRData(v1); fvd1.offset(-dx, -dy); } if (v2_locked == false) { FRVertexData fvd2 = getFRData(v2); fvd2.offset(dx, dy); } }
From source file:net.sf.maltcms.chromaui.charts.events.XYAnnotationAdder.java
/** * * @param name/* w ww. j a v a2 s. c om*/ * @param visible * @param min * @param max * @param cp */ public XYAnnotationAdder(String name, boolean visible, Point2D min, Point2D max, ChartPanel cp) { this.qt = new QuadTree<>(min.getX(), min.getY(), max.getX() - min.getX(), max.getY() - min.getY(), 3); this.cp = cp; this.name = name; this.visible = visible; }
From source file:net.sf.maltcms.chromaui.charts.events.XYPeakAnnotationOverlay.java
/** * * @param name//from www . j ava2 s .com * @param visible * @param min * @param max * @param cp */ public XYPeakAnnotationOverlay(String name, boolean visible, Point2D min, Point2D max, ChartPanel cp) { this.qt = new QuadTree<>(min.getX(), min.getY(), max.getX() - min.getX(), max.getY() - min.getY(), 3); this.cp = cp; this.name = name; this.visible = visible; }
From source file:grafix.telas.MolduraAreaDados.java
private Point2D converterPontoNaMolduraParaPlot_EixoLinear(final Point2D pontoMoldura) { XYPlot plot = getPlot();/*from w ww . j a v a2 s. c om*/ ValueAxis vAxis = plot.getRangeAxis(); ValueAxis dAxis = plot.getDomainAxis(); double fracaoX = pontoMoldura.getX() / this.getWidth(); double fracaoY = 1 - (pontoMoldura.getY() / this.getHeight()); double dX = dAxis.getUpperBound() - dAxis.getLowerBound(); double dY = vAxis.getUpperBound() - vAxis.getLowerBound(); return new Point2D.Double(dAxis.getLowerBound() + dX * fracaoX, vAxis.getLowerBound() + dY * fracaoY); }
From source file:grafix.telas.MolduraAreaDados.java
private Point2D converterPontoNaMolduraParaPlot_EixoLog(final Point2D pontoMoldura) { XYPlot plot = getPlot();//from w ww. j av a 2 s. c om ValueAxis vAxis = plot.getRangeAxis(); ValueAxis dAxis = plot.getDomainAxis(); double fracaoX = pontoMoldura.getX() / this.getWidth(); double fracaoYlog = 1 - (pontoMoldura.getY() / this.getHeight()); double dX = dAxis.getUpperBound() - dAxis.getLowerBound(); double dYlog = Math.log10(vAxis.getUpperBound()) - Math.log10(vAxis.getLowerBound()); double ylog = Math.log10(vAxis.getLowerBound()) + fracaoYlog * dYlog; return new Point2D.Double(dAxis.getLowerBound() + dX * fracaoX, Math.pow(10, ylog)); }
From source file:org.owasp.benchmark.score.report.ScatterHome.java
private void makeDataLabels(Set<Report> toolResults, XYPlot xyplot) { HashMap<Point2D, String> map = makePointList(toolResults); for (Entry<Point2D, String> e : map.entrySet()) { if (e.getValue() != null) { Point2D p = e.getKey(); String label = sort(e.getValue()); XYTextAnnotation annotation = new XYTextAnnotation(label, p.getX(), p.getY()); annotation.setTextAnchor(p.getX() < 3 ? TextAnchor.TOP_LEFT : TextAnchor.TOP_CENTER); annotation.setBackgroundPaint(Color.white); if (label.toCharArray()[0] == averageLabel) { annotation.setPaint(Color.magenta); } else { annotation.setPaint(Color.blue); }// w ww . j ava2s. co m annotation.setFont(theme.getRegularFont()); xyplot.addAnnotation(annotation); } } }
From source file:edu.uci.ics.jung.algorithms.layout.FRLayout2.java
protected void calcAttraction(E e) { Pair<V> endpoints = getGraph().getEndpoints(e); V v1 = endpoints.getFirst();// w ww . j a v a 2 s . c o m V v2 = endpoints.getSecond(); boolean v1_locked = isLocked(v1); boolean v2_locked = isLocked(v2); if (v1_locked && v2_locked) { // both locked, do nothing return; } Point2D p1 = transform(v1); Point2D p2 = transform(v2); if (p1 == null || p2 == null) return; double xDelta = p1.getX() - p2.getX(); double yDelta = p1.getY() - p2.getY(); double deltaLength = Math.max(EPSILON, p1.distance(p2)); double force = deltaLength / attraction_constant; assert Double.isNaN(force) == false : "Unexpected mathematical result in FRLayout:calcPositions [force]"; double dx = xDelta * force; double dy = yDelta * force; Point2D fvd1 = frVertexData.get(v1); Point2D fvd2 = frVertexData.get(v2); if (v2_locked) { // double the offset for v1, as v2 will not be moving in // the opposite direction fvd1.setLocation(fvd1.getX() - 2 * dx, fvd1.getY() - 2 * dy); } else { fvd1.setLocation(fvd1.getX() - dx, fvd1.getY() - dy); } if (v1_locked) { // double the offset for v2, as v1 will not be moving in // the opposite direction fvd2.setLocation(fvd2.getX() + 2 * dx, fvd2.getY() + 2 * dy); } else { fvd2.setLocation(fvd2.getX() + dx, fvd2.getY() + dy); } }
From source file:edu.uci.ics.jung.algorithms.layout.ISOMLayout.java
private synchronized void adjust() { //Generate random position in graph space Point2D tempXYD = new Point2D.Double(); // creates a new XY data location tempXYD.setLocation(10 + Math.random() * getSize().getWidth(), 10 + Math.random() * getSize().getHeight()); //Get closest vertex to random position V winner = elementAccessor.getVertex(this, tempXYD.getX(), tempXYD.getY()); while (true) { try {// w w w . j a v a 2 s.co m for (V v : getGraph().getVertices()) { ISOMVertexData ivd = getISOMVertexData(v); ivd.distance = 0; ivd.visited = false; } break; } catch (ConcurrentModificationException cme) { } } adjustVertex(winner, tempXYD); }