Example usage for java.awt.geom Point2D getX

List of usage examples for java.awt.geom Point2D getX

Introduction

In this page you can find the example usage for java.awt.geom Point2D getX.

Prototype

public abstract double getX();

Source Link

Document

Returns the X coordinate of this Point2D in double precision.

Usage

From source file:mulavito.gui.components.LayerViewer.java

/**
 * @return the extent of the graph according to its vertices' location
 *//*from  ww  w.j a va  2  s  .co m*/
public void updateGraphBoundsCache() {
    double minX = Double.MAX_VALUE;
    double minY = Double.MAX_VALUE;
    double maxX = -Double.MAX_VALUE;
    double maxY = -Double.MAX_VALUE;

    for (V v : getGraphLayout().getGraph().getVertices()) {
        Point2D p = getGraphLayout().transform(v);

        minX = Math.min(minX, p.getX());
        minY = Math.min(minY, p.getY());

        maxX = Math.max(maxX, p.getX());
        maxY = Math.max(maxY, p.getY());
    }

    // no point
    if (minX > maxX || minY > maxY)
        minX = maxX = minY = maxY = 0;

    if (graphBoundsCache == null)
        graphBoundsCache = new Rectangle2D.Double();

    graphBoundsCache.setRect(minX, minY, maxX - minX, maxY - minY);

    double excess = Math.max(Math.max(graphBoundsCache.width * 0.1, graphBoundsCache.height * 0.1), 10);

    // include the given excess
    graphBoundsCache.setRect(graphBoundsCache.x - excess, graphBoundsCache.y - excess,
            graphBoundsCache.width + 2 * excess, graphBoundsCache.height + 2 * excess);
}

From source file:pt.lsts.neptus.plugins.wg.WgCtdLayer.java

private boolean isVisibleInRender(Point2D sPos, StateRenderer2D renderer) {
    Dimension rendDim = renderer.getSize();
    if (sPos.getX() < 0 && sPos.getY() < 0)
        return false;
    else if (sPos.getX() > rendDim.getWidth() && sPos.getY() > rendDim.getHeight())
        return false;

    return true;/*w  w w  . j  a va  2  s.c  om*/
}

From source file:be.ugent.maf.cellmissy.gui.view.renderer.jfreechart.ExtendedBoxAndWhiskerRenderer.java

/**
 * Creates a dot to represent an outlier.
 *
 * @param point the location./*from   w w  w . ja  v  a2 s  .  c o  m*/
 * @param oRadius the outlier radius.
 *
 */
private Shape createEllipse(Point2D point, double oRadius) {
    return new Ellipse2D.Double(point.getX(), point.getY(), oRadius * 2.0, oRadius * 2.0);
}

From source file:views.network.MyRadialTreeLayout.java

private Point2D getMaxXY() {
    double maxx = 0;
    double maxy = 0;
    for (Point2D p : locations.values()) {
        maxx = Math.max(maxx, p.getX());
        maxy = Math.max(maxy, p.getY());
    }//from  w w  w. j  a v a  2s  .  co m
    return new Point2D.Double(maxx, maxy);
}

From source file:inflor.core.gates.ui.PolygonGateAnnotation.java

@Override
public XYGateAnnotation updateVertex(Point2D v, double dx, double dy, double xHandleSize, double yHandleSize) {
    double[] x = getDomainPoints();
    double[] y = getRangePoints();
    double xMin = v.getX() - xHandleSize;
    double xMax = v.getX() + xHandleSize;
    double yMin = v.getY() - yHandleSize;
    double yMax = v.getY() + yHandleSize;
    for (int i = 0; i < x.length; i++) {
        if (xMin <= x[i] && x[i] <= xMax && yMin <= y[i] && y[i] <= yMax) {
            x[i] = x[i] + dx;//www.ja  va2  s  .c o m
            y[i] = y[i] + dy;
        }
    }

    double[] newPoints = new double[polygonPoints.length];
    for (int i = 0; i < newPoints.length; i += 2) {
        newPoints[i] = x[i / 2];
        newPoints[i + 1] = y[i / 2];
    }

    return new PolygonGateAnnotation(subsetName, domainAxisName, rangeAxisName, newPoints,
            LookAndFeel.SELECTED_STROKE, LookAndFeel.SELECTED_GATE_COLOR);
}

From source file:org.owasp.benchmark.score.report.ScatterTools.java

private void makeDataLabels(OverallResults or, XYPlot xyplot) {
    HashMap<Point2D, String> map = makePointList(or);
    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);
            // set color of average to black and everything else to blue
            if (averageLabel == label.toCharArray()[0]) {
                annotation.setPaint(Color.magenta);
            } else {
                annotation.setPaint(Color.blue);
            }//from   w ww.j  av a2 s  .c  om
            annotation.setFont(theme.getRegularFont());
            xyplot.addAnnotation(annotation);
        }
    }
}

From source file:at.knowcenter.wag.egov.egiz.pdf.operator.path.construction.CurveTo.java

@Override
public void process(PDFOperator operator, List<COSBase> operands) throws IOException {
    try {// w  w  w  . jav a 2s.  c o  m
        PDFPage pdfPage = (PDFPage) context;

        COSNumber x1 = (COSNumber) operands.get(0);
        COSNumber y1 = (COSNumber) operands.get(1);
        COSNumber x2 = (COSNumber) operands.get(2);
        COSNumber y2 = (COSNumber) operands.get(3);
        COSNumber x3 = (COSNumber) operands.get(4);
        COSNumber y3 = (COSNumber) operands.get(5);

        Point2D p1 = transform(x1.doubleValue(), y1.doubleValue());
        Point2D p2 = transform(x2.doubleValue(), y2.doubleValue());
        Point2D p3 = transform(x3.doubleValue(), y3.doubleValue());

        pdfPage.getCurrentPath().curveTo((float) p1.getX(), (float) p1.getY(), (float) p2.getX(),
                (float) p2.getY(), (float) p3.getX(), (float) p3.getY());

        if (log.isTraceEnabled()) {
            log.trace("Appending cubic Bezier curve with x1:" + p1.getX() + ",y1:" + p1.getY() + ", x2:"
                    + p2.getX() + ",y2:" + p2.getY() + ", x3:" + p3.getX() + ",y3:" + p3.getY());
        }
    } catch (Exception e) {
        log.warn("Error processing operator 'c'.", e);
    }
}

From source file:views.network.MyRadialTreeLayout.java

public Point2D transform(V v) {
    PolarPoint pp = polarLocations.get(v);
    double centerX = getSize().getWidth() / 2;
    double centerY = getSize().getHeight() / 2;
    Point2D cartesian = PolarPoint.polarToCartesian(pp);
    cartesian.setLocation(cartesian.getX() + centerX, cartesian.getY() + centerY);
    return cartesian;
}

From source file:at.knowcenter.wag.egov.egiz.pdf.operator.path.construction.CurveToReplicateInitialPoint.java

@Override
public void process(PDFOperator operator, List<COSBase> operands) throws IOException {
    try {//from   w w w  .  ja  v  a 2 s.c o m
        PDFPage pdfPage = (PDFPage) context;

        COSNumber x2 = (COSNumber) operands.get(0);
        COSNumber y2 = (COSNumber) operands.get(1);
        COSNumber x3 = (COSNumber) operands.get(2);
        COSNumber y3 = (COSNumber) operands.get(3);

        Point2D currentPoint = pdfPage.getCurrentPath().getCurrentPoint();
        Point2D p2 = transform(x2.doubleValue(), y2.doubleValue());
        Point2D p3 = transform(x3.doubleValue(), y3.doubleValue());

        pdfPage.getCurrentPath().curveTo((float) currentPoint.getX(), (float) currentPoint.getY(),
                (float) p2.getX(), (float) p2.getY(), (float) p3.getX(), (float) p3.getY());

        if (log.isTraceEnabled()) {
            log.trace("Appending cubic Bezier curve with x2:" + p2.getX() + ",y2:" + p2.getY() + ", x3:"
                    + p3.getX() + ",y3:" + p3.getY() + ", using current point x:" + currentPoint.getX() + ",y:"
                    + currentPoint.getY());
        }
    } catch (Exception e) {
        log.warn("Error processing operator 'v'.", e);
    }
}

From source file:gui.ReEditingPopupGraphMousePlugin.java

@SuppressWarnings({ "unchecked", "serial" })
protected void handlePopup(MouseEvent e) {
    final VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource();
    final Layout<V, E> layout = vv.getGraphLayout();
    final Graph<V, E> graph = layout.getGraph();
    final Point2D p = e.getPoint();
    final Point2D ivp = p;
    GraphElementAccessor<V, E> pickSupport = vv.getPickSupport();

    if (pickSupport != null) {
        final V vertex = pickSupport.getVertex(layout, ivp.getX(), ivp.getY());
        final E edge = pickSupport.getEdge(layout, ivp.getX(), ivp.getY());
        final PickedState<V> pickedVertexState = vv.getPickedVertexState();
        final PickedState<E> pickedEdgeState = vv.getPickedEdgeState();

        if (vertex != null) {
            Set<V> picked = pickedVertexState.getPicked();
            if (picked.size() > 0) {
                if (graph instanceof UndirectedGraph == false) {
                    JMenu directedMenu = new JMenu("Create Directed Edge");
                    popup.add(directedMenu);
                    for (final V other : picked) {
                        directedMenu.add(new AbstractAction("[" + other + "," + vertex + "]") {
                            public void actionPerformed(ActionEvent e) {
                                graph.addEdge(edgeFactory.create(), other, vertex, EdgeType.DIRECTED);
                                vv.repaint();
                            }/*w  w w.  j av a 2 s  .  c o m*/
                        });
                    }
                }
                if (graph instanceof DirectedGraph == false) {
                    JMenu undirectedMenu = new JMenu("Create Undirected Edge");
                    popup.add(undirectedMenu);
                    for (final V other : picked) {
                        undirectedMenu.add(new AbstractAction("[" + other + "," + vertex + "]") {
                            public void actionPerformed(ActionEvent e) {
                                graph.addEdge(edgeFactory.create(), other, vertex);
                                vv.repaint();
                            }
                        });
                    }
                }
            }
            popup.add(new AbstractAction("Delete TETRA Vertex") {
                public void actionPerformed(ActionEvent e) {
                    pickedVertexState.pick(vertex, false);
                    graph.removeVertex(vertex);
                    vv.repaint();
                }
            });
        } else if (edge != null) {
            popup.add(new AbstractAction("Delete Edge") {
                public void actionPerformed(ActionEvent e) {
                    pickedEdgeState.pick(edge, false);
                    graph.removeEdge(edge);
                    vv.repaint();
                }
            });
        } else {
            popup.add(new AbstractAction("Create TETRA Vertex") {
                public void actionPerformed(ActionEvent e) {
                    V newVertex = vertexFactory.create();
                    graph.addVertex(newVertex);
                    layout.setLocation(newVertex,
                            vv.getRenderContext().getMultiLayerTransformer().inverseTransform(p));
                    vv.repaint();
                }
            });
        }
        if (popup.getComponentCount() > 0) {
            popup.show(vv, e.getX(), e.getY());
        }
    }
}