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:grafix.telas.MolduraAreaDados.java

private Point2D converterPontoNaMolduraParaPlot_EixoLinear(final Point2D pontoMoldura) {
    XYPlot plot = getPlot();/*from ww w. j av a  2  s  .  c o  m*/
    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  ww w. j  a  v a 2s . co m
    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.ScatterScores.java

private void makeDataLabels(List<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);
            annotation.setPaint(Color.blue);
            annotation.setFont(theme.getRegularFont());
            xyplot.addAnnotation(annotation);
        }/* w ww. j  a va 2  s  . co m*/
    }
}

From source file:com.projity.pm.graphic.network.NetworkRenderer.java

protected void translateShape(GraphicNode node, double dx, double dy) {
    Point2D v = scaleVector_1(new Point2D.Double(dx, dy));
    translateNonScaledShape(node, v.getX(), v.getY());
}

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 w w  w  .  j  ava  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:org.apache.fop.render.java2d.Java2DPainter.java

/** {@inheritDoc} */
public void drawText(int x, int y, int letterSpacing, int wordSpacing, int[] dx, String text)
        throws IFException {
    g2dState.updateColor(state.getTextColor());
    FontTriplet triplet = new FontTriplet(state.getFontFamily(), state.getFontStyle(), state.getFontWeight());
    //TODO Ignored: state.getFontVariant()
    //TODO Opportunity for font caching if font state is more heavily used
    Font font = getFontInfo().getFontInstance(triplet, state.getFontSize());
    //String fontName = font.getFontName();
    //float fontSize = state.getFontSize() / 1000f;
    g2dState.updateFont(font.getFontName(), state.getFontSize() * 1000);

    Graphics2D g2d = this.g2dState.getGraph();
    GlyphVector gv = g2d.getFont().createGlyphVector(g2d.getFontRenderContext(), text);
    Point2D cursor = new Point2D.Float(0, 0);

    int l = text.length();
    int dxl = (dx != null ? dx.length : 0);

    if (dx != null && dxl > 0 && dx[0] != 0) {
        cursor.setLocation(cursor.getX() - (dx[0] / 10f), cursor.getY());
        gv.setGlyphPosition(0, cursor);/*from  w w  w .ja va2  s . c  om*/
    }
    for (int i = 0; i < l; i++) {
        char orgChar = text.charAt(i);
        float glyphAdjust = 0;
        int cw = font.getCharWidth(orgChar);

        if ((wordSpacing != 0) && CharUtilities.isAdjustableSpace(orgChar)) {
            glyphAdjust += wordSpacing;
        }
        glyphAdjust += letterSpacing;
        if (dx != null && i < dxl - 1) {
            glyphAdjust += dx[i + 1];
        }

        cursor.setLocation(cursor.getX() + cw + glyphAdjust, cursor.getY());
        gv.setGlyphPosition(i + 1, cursor);
    }
    g2d.drawGlyphVector(gv, x, y);
}

From source file:net.bioclipse.model.ScatterPlotMouseHandler.java

private Number getDomainX(ChartPanel chartPanel, XYPlot plot, Point2D mousePoint) {
    ChartRenderingInfo info = chartPanel.getChartRenderingInfo();
    Rectangle2D dataArea = info.getPlotInfo().getDataArea();
    Number x = plot.getDomainAxis().java2DToValue(mousePoint.getX(), dataArea, plot.getDomainAxisEdge());

    return x;/*  w  w w.  ja  v a  2  s  .  c o m*/
}

From source file:net.sf.maltcms.chromaui.charts.events.XYPeakAnnotationOverlay.java

/**
 *
 * @param p//from w w w  .  j  a va 2  s .c  om
 */
public void addAnnotation(final Point2D p) {
    addXYPeakAnnotation(p.getX(), p.getY(), null, true);
}

From source file:gov.nih.nci.caintegrator.application.geneexpression.BoxAndWhiskerCoinPlotRenderer.java

private void drawEllipse(Point2D point, double oRadius, Graphics2D g2) {
    Ellipse2D dot = new Ellipse2D.Double(point.getX() + oRadius / 2, point.getY(), oRadius, oRadius);
    g2.draw(dot);//from  ww  w . j  a  v  a  2 s .  c o  m
}

From source file:com.mycompany.complexity.tool.mvn.TreeLayout.java

public void moveNodes(int x, int y) {
    Point2D p;
    for (V value : locations.keySet()) {
        p = locations.get(value);/*from   w w w.ja v  a  2  s .  c o  m*/
        p.setLocation(p.getX() + x, p.getY() + y);
        locations.get(value).setLocation(p);
    }
}