Example usage for java.awt.geom Point2D getY

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

Introduction

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

Prototype

public abstract double getY();

Source Link

Document

Returns the Y coordinate of this Point2D in double precision.

Usage

From source file:de.fhg.igd.mapviewer.BasicMapKit.java

private Rectangle2D generateBoundingRect(double minX, double minY, double maxX, double maxY, int epsg, int zoom)
        throws IllegalGeoPositionException {
    java.awt.geom.Point2D p1 = getMainMap().getTileFactory().getTileProvider().getConverter()
            .geoToPixel(new GeoPosition(minX, minY, epsg), zoom);
    java.awt.geom.Point2D p2 = getMainMap().getTileFactory().getTileProvider().getConverter()
            .geoToPixel(new GeoPosition(maxX, maxY, epsg), zoom);

    return new Rectangle2D.Double((p1.getX() < p2.getX()) ? (p1.getX()) : (p2.getX()),
            (p1.getY() < p2.getY()) ? (p1.getY()) : (p2.getY()), Math.abs(p2.getX() - p1.getX()),
            Math.abs(p2.getY() - p1.getY()));
}

From source file:org.jcurl.core.swing.RockEditDisplay.java

protected void paintSpeed(final Graphics2D g2, final int idx) {
    if (idx < 0)
        return;/*from   w  w  w.  j  a  va2s  . c  o m*/
    final Point2D cwc = getPos().getRock(idx);
    final Point2D cdc = wc2dc(cwc, null);
    // prepare a direction beam (line) 5 Meters long from cwc
    final Point2D dir_dc;
    final Point2D normwc;
    final double vwc_abs;
    {
        Point2D norm = speed.getRock(idx);
        vwc_abs = MathVec.abs2D(norm);
        if (vwc_abs == 0.0)
            normwc = new Point2D.Double(0, -1);
        else
            normwc = MathVec.mult(1.0 / vwc_abs, norm, null);
        norm = MathVec.mult(5, normwc, null);
        MathVec.add(cwc, norm, norm);
        wc2dc(norm, norm);
        dir_dc = norm;
    }
    // prepare a perpendicular line for the "strength"
    final Point2D abs1_dc;
    final Point2D abs2_dc;
    final Point2D spotWc;
    {
        final double len = 0.5;
        spotWc = getSpeedSpotWC(idx, null);
        // get a perpendicular
        abs2_dc = new Point2D.Double(-normwc.getY(), normwc.getX());
        MathVec.mult(len, abs2_dc, abs2_dc);
        abs1_dc = MathVec.add(spotWc, abs2_dc, null);
        MathVec.mult(-1, abs2_dc, abs2_dc);
        MathVec.add(spotWc, abs2_dc, abs2_dc);
        wc2dc(abs1_dc, abs1_dc);
        wc2dc(abs2_dc, abs2_dc);
    }

    lineDC(g2, cdc, dir_dc);
    lineDC(g2, abs1_dc, abs2_dc);
    // circle at the hot "spot" for changing speed
    circleDC(g2, wc2dc(spotWc, null), hotRadiusDC);
}

From source file:org.jfree.experimental.chart.plot.dial.DialValueIndicator.java

/**
 * Draws the background to the specified graphics device.  If the dial
 * frame specifies a window, the clipping region will already have been 
 * set to this window before this method is called.
 *
 * @param g2  the graphics device (<code>null</code> not permitted).
 * @param plot  the plot (ignored here).
 * @param frame  the dial frame (ignored here).
 * @param view  the view rectangle (<code>null</code> not permitted). 
 *///from  w  w w. j a v  a2s  . c om
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, Rectangle2D view) {

    // work out the anchor point
    Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, this.radius);
    Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN);
    Point2D pt = arc.getStartPoint();

    // calculate the bounds of the template value
    FontMetrics fm = g2.getFontMetrics(this.font);
    String s = this.formatter.format(this.templateValue);
    Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm);

    // align this rectangle to the frameAnchor
    Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(tb.getWidth(), tb.getHeight()), pt.getX(),
            pt.getY(), this.frameAnchor);

    // add the insets
    Rectangle2D fb = this.insets.createOutsetRectangle(bounds);

    // draw the background
    g2.setPaint(this.backgroundPaint);
    g2.fill(fb);

    // draw the border
    g2.setStroke(this.outlineStroke);
    g2.setPaint(this.outlinePaint);
    g2.draw(fb);

    // now find the text anchor point
    double value = plot.getValue(this.datasetIndex);
    String valueStr = this.formatter.format(value);
    Point2D pt2 = RectangleAnchor.coordinates(bounds, this.valueAnchor);
    g2.setPaint(this.paint);
    g2.setFont(this.font);
    TextUtilities.drawAlignedString(valueStr, g2, (float) pt2.getX(), (float) pt2.getY(), this.textAnchor);

}

From source file:at.gv.egiz.pdfas.lib.impl.stamping.pdfbox.PDFAsVisualSignatureBuilder.java

public void createSignatureRectangle(PDSignatureField signatureField, PDFAsVisualSignatureDesigner properties,
        float degrees) throws IOException {

    PDRectangle rect = new PDRectangle();

    Point2D upSrc = new Point2D.Float();
    upSrc.setLocation(properties.getxAxis() + properties.getWidth(),
            properties.getPageHeight() - properties.getyAxis());

    Point2D llSrc = new Point2D.Float();
    llSrc.setLocation(properties.getxAxis(),
            properties.getPageHeight() - properties.getyAxis() - properties.getHeight());

    rect.setUpperRightX((float) upSrc.getX());
    rect.setUpperRightY((float) upSrc.getY());
    rect.setLowerLeftY((float) llSrc.getY());
    rect.setLowerLeftX((float) llSrc.getX());
    logger.debug("orig rectangle of signature has been created: {}", rect.toString());

    AffineTransform transform = new AffineTransform();
    transform.setToIdentity();/*from www .  j a v a2 s. c  o m*/
    if (degrees % 360 != 0) {
        transform.setToRotation(Math.toRadians(degrees), llSrc.getX(), llSrc.getY());
    }

    Point2D upDst = new Point2D.Float();
    transform.transform(upSrc, upDst);

    Point2D llDst = new Point2D.Float();
    transform.transform(llSrc, llDst);

    float xPos = properties.getxAxis();
    float yPos = properties.getPageHeight() - properties.getyAxis();
    logger.debug("POS {} x {}", xPos, yPos);
    logger.debug("SIZE {} x {}", properties.getWidth(), properties.getHeight());
    // translate according to page! rotation
    int pageRotation = properties.getPageRotation();
    AffineTransform translate = new AffineTransform();
    switch (pageRotation) {
    case 90:
        translate.setToTranslation(
                properties.getPageHeight() - (properties.getPageHeight() - properties.getyAxis())
                        - properties.getxAxis() + properties.getHeight(),
                properties.getxAxis() + properties.getHeight()
                        - (properties.getPageHeight() - properties.getyAxis()));
        break;
    case 180:
        // translate.setToTranslation(properties.getPageWidth() -
        // properties.getxAxis() - properties.getxAxis(),
        // properties.getPageHeight() - properties.getyAxis() +
        // properties.getHeight());
        translate.setToTranslation(properties.getPageWidth() - 2 * xPos,
                properties.getPageHeight() - 2 * (yPos - properties.getHeight()));
        break;
    case 270:
        translate.setToTranslation(-properties.getHeight() + yPos - xPos,
                properties.getPageWidth() - (yPos - properties.getHeight()) - xPos);
        break;
    }

    translate.transform(upDst, upDst);
    translate.transform(llDst, llDst);

    rect.setUpperRightX((float) upDst.getX());
    rect.setUpperRightY((float) upDst.getY());
    rect.setLowerLeftY((float) llDst.getY());
    rect.setLowerLeftX((float) llDst.getX());
    logger.debug("rectangle of signature has been created: {}", rect.toString());
    signatureField.getWidget().setRectangle(rect);
    getStructure().setSignatureRectangle(rect);
    logger.debug("rectangle of signature has been created");
}

From source file:edu.snu.leader.discrete.simulator.Agent.java

/**
 * Initializes Agent/*from  w ww  . jav  a2  s .co m*/
 * 
 * @param simState The simulation state
 */
public void initialize(SimulationState simState, Point2D initialLocation) {
    _simState = simState;

    _initialLocation = new Vector2D(initialLocation.getX(), initialLocation.getY());

    String nearestNeighborCount = _simState.getProperties().getProperty("nearest-neighbor-count");
    Validate.notEmpty(nearestNeighborCount, "Nearest neighbor count may not be empty");
    _nearestNeighborCount = Integer.parseInt(nearestNeighborCount);

    String maxLocationRadius = _simState.getProperties().getProperty("max-location-radius");
    Validate.notEmpty(maxLocationRadius, "Max location raidus may not be empty");
    _maxLocationRadius = Double.parseDouble(maxLocationRadius);

    String canMultipleInitiate = _simState.getProperties().getProperty("can-multiple-initiate");
    Validate.notEmpty(canMultipleInitiate, "Can multiple initiate may not be empty");
    _canMultipleInitiate = Boolean.parseBoolean(canMultipleInitiate);

    String cancellationThreshold = _simState.getProperties().getProperty("cancellation-threshold");
    Validate.notEmpty(cancellationThreshold, "Use cancellation threshold may not be empty");
    _cancellationThreshold = Double.parseDouble(cancellationThreshold);

    String lambda = _simState.getProperties().getProperty("lambda");
    Validate.notEmpty(lambda, "Lambda may not be empty");
    _lambda = Float.parseFloat(lambda);

    String preCalcProbs = _simState.getProperties().getProperty("pre-calculate-probabilities");
    Validate.notEmpty(preCalcProbs, "pre-calculate-probabilities may not be empty");
    _preCalcProbs = Boolean.parseBoolean(preCalcProbs);

    _communicationType = _simState.getCommunicationType();

    _positionHistory = new Reporter(_id.toString() + ".dat", "", false);

    reset();

    _personalityTrait.initialize(this);
}

From source file:org.apache.pdfbox.rendering.PageDrawer.java

@Override
public void appendRectangle(Point2D p0, Point2D p1, Point2D p2, Point2D p3) {
    // to ensure that the path is created in the right direction, we have to create
    // it by combining single lines instead of creating a simple rectangle
    linePath.moveTo((float) p0.getX(), (float) p0.getY());
    linePath.lineTo((float) p1.getX(), (float) p1.getY());
    linePath.lineTo((float) p2.getX(), (float) p2.getY());
    linePath.lineTo((float) p3.getX(), (float) p3.getY());

    // close the subpath instead of adding the last line so that a possible set line
    // cap style isn't taken into account at the "beginning" of the rectangle
    linePath.closePath();//  ww  w  .ja  v a 2  s. c o  m
}

From source file:org.squidy.designer.model.PipeShape.java

private PBounds computeBounds() {

    // TODO: [RR] Hack!!! Do not compute bounds if ports are invisible.
    // if (source.getOutputPort().getScale() < 1.0 ||
    // target.getOutputPort().getScale() < 1.0) {
    // return getBoundsReference();
    // }/*w w  w  .j  a va  2  s  . co  m*/

    PortShape sourcePortShape;
    PortShape targetPortShape;
    if (!source.getParent().equals(target.getParent())) {
        if (source instanceof PipelineShape && !(target instanceof PipelineShape)) {
            // ConnectorShape<?, ?> tmp = source;
            // source = target;
            // target = tmp;

            sourcePortShape = source.getInputPort();
            targetPortShape = target.getInputPort();
        } else if (!(source instanceof PipelineShape) && target instanceof PipelineShape) {
            sourcePortShape = source.getOutputPort();
            targetPortShape = target.getOutputPort();
        } else {
            // TODO [RR]: This may cause unexpected painting of shapes -> The visual shape drawing does not match the processing hierarchy.
            sourcePortShape = source.getInputPort();
            targetPortShape = target.getInputPort();
        }
    } else {
        sourcePortShape = source.getOutputPort();
        targetPortShape = target.getInputPort();
    }

    // System.out.println("GFB: " + source.getGlobalFullBounds());
    // System.out.println("FBR: " + source.getFullBoundsReference());
    // System.out.println("BR : " + source.getBoundsReference());
    // System.out.println("Off: " + source.getOffset());

    Point2D p1 = globalToLocal(
            sourcePortShape.getParent().localToGlobal(sourcePortShape.getFullBoundsReference().getCenter2D()));
    Point2D p2 = globalToLocal(
            targetPortShape.getParent().localToGlobal(targetPortShape.getFullBoundsReference().getCenter2D()));

    double x1 = p1.getX();
    double x2 = p2.getX();
    double y1 = p1.getY();
    double y2 = p2.getY();

    // Rectangle2D bounds1 =
    // globalToLocal(sourcePortShape.getGlobalFullBounds());
    // Rectangle2D bounds2 =
    // globalToLocal(targetPortShape.getGlobalFullBounds());
    //      
    // double x1 = bounds1.getMinX();
    // double x2 = bounds2.getMinX();
    // double y1 = bounds1.getMinY();
    // double y2 = bounds2.getMinY();

    double x = Math.min(x1, x2);
    double y = Math.min(y1, y2);
    double width = Math.max(Math.abs(x1 - x2), 1);
    double height = Math.max(Math.abs(y1 - y2), 1);

    // Rectangle2D b = localToParent(new PBounds(x, y, width, height));
    //       shape.setCurve(x1, y1, x1 + (width / 2), y1, x2 - (width / 2), y2,
    //       x2, y2);

    shape.setLine(x1, y1 - LINE_WIDTH / 2.0 - 10, x2, y2 - LINE_WIDTH / 2.0 - 10);

    return new PBounds(shape.getBounds());
}

From source file:Hexagon.java

public void align(Rectangle2D bounds, Direction direction) {
    // these are defined here INSTEAD of in the switch, or it won't compile
    Point2D newTopRight, newTopLeft, newBottomRight, newBottomLeft;
    Point2D oldTopRight, oldTopLeft, oldBottomRight, oldBottomLeft;

    switch (direction) {
    case NorthEast:
        newTopRight = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());
        oldTopRight = boundingCorners.get(BoundingCorner.TopRight);
        translate(newTopRight.getX() - oldTopRight.getX(), // deltaX
                newTopRight.getY() - oldTopRight.getY() // deltaY
        );/*from   w  w  w .  j a  v  a 2s.c o m*/
        break;
    case East:
        newTopRight = new Point2D.Double(bounds.getMaxX(), bounds.getMinY());
        oldTopRight = boundingCorners.get(BoundingCorner.TopRight);
        translate(newTopRight.getX() - oldTopRight.getX(), // deltaX
                0 // deltaY
        );
        break;
    case SouthEast:
        newBottomRight = new Point2D.Double(bounds.getMaxX(), bounds.getMaxY());
        oldBottomRight = boundingCorners.get(BoundingCorner.BottomRight);
        translate(newBottomRight.getX() - oldBottomRight.getX(), // deltaX
                newBottomRight.getY() - oldBottomRight.getY() // deltaY
        );
        break;
    case SouthWest:
        newBottomLeft = new Point2D.Double(bounds.getMinX(), bounds.getMaxY());
        oldBottomLeft = boundingCorners.get(BoundingCorner.BottomLeft);
        translate(newBottomLeft.getX() - oldBottomLeft.getX(), // deltaX
                newBottomLeft.getY() - oldBottomLeft.getY() // deltaY
        );
        break;
    case West:
        newTopLeft = new Point2D.Double(bounds.getMinX(), bounds.getMinY());
        oldTopLeft = boundingCorners.get(BoundingCorner.TopLeft);
        translate(newTopLeft.getX() - oldTopLeft.getX(), // deltaX
                0 // deltaY
        );
        break;
    case NorthWest:
        newTopLeft = new Point2D.Double(bounds.getMinX(), bounds.getMinY());
        oldTopLeft = boundingCorners.get(BoundingCorner.TopLeft);
        translate(newTopLeft.getX() - oldTopLeft.getX(), // deltaX
                newTopLeft.getY() - oldTopLeft.getY() // deltaY
        );
        break;
    }
}

From source file:net.sf.mzmine.modules.visualization.metamsecorrelate.visual.pseudospectra.PseudoSpectraRenderer.java

@Override
protected void drawItemLabel(Graphics2D g2, XYDataset dataset, int series, int item, XYPlot plot,
        XYItemLabelGenerator generator, Rectangle2D bar, boolean negative) {
    //super.drawItemLabel(g2, dataset, series, item, plot, generator, bar, negative);  

    if (generator != null) {
        String label = generator.generateLabel(dataset, series, item);

        if (label != null) {
            Font labelFont = getItemLabelFont(series, item);
            Paint paint = getItemLabelPaint(series, item);
            g2.setFont(labelFont);/*w w  w.j  av  a  2 s  . co  m*/
            g2.setPaint(paint);

            // get the label position..
            ItemLabelPosition position;
            if (!negative) {
                position = getPositiveItemLabelPosition(series, item);
            } else {
                position = getNegativeItemLabelPosition(series, item);
            }

            // work out the label anchor point...
            Point2D anchorPoint = calculateLabelAnchorPoint(position.getItemLabelAnchor(), bar,
                    plot.getOrientation());

            // split by \n
            String symbol = "\n";
            String[] splitted = label.split(symbol);

            if (splitted.length > 1) {
                FontRenderContext frc = g2.getFontRenderContext();
                GlyphVector gv = g2.getFont().createGlyphVector(frc, "Fg,");
                int height = 4 + (int) gv.getPixelBounds(null, 0, 0).getHeight();
                // draw more than one row
                for (int i = 0; i < splitted.length; i++) {
                    int offset = -height * (splitted.length - i - 1);
                    TextUtilities.drawRotatedString(splitted[i], g2, (float) anchorPoint.getX(),
                            (float) anchorPoint.getY() + offset, position.getTextAnchor(), position.getAngle(),
                            position.getRotationAnchor());
                }
            } else {
                // one row 
                TextUtilities.drawRotatedString(label, g2, (float) anchorPoint.getX(),
                        (float) anchorPoint.getY(), position.getTextAnchor(), position.getAngle(),
                        position.getRotationAnchor());
            }
        }
    }

}

From source file:org.yccheok.jstock.gui.charting.ChartLayerUI.java

@Override
protected void paintLayer(Graphics2D g2, JXLayer<? extends V> layer) {
    super.paintLayer(g2, layer);

    if (this.mainTraceInfo.getPoint() == null) {
        return;/*from w  w w .  j  a va  2  s . c o m*/
    }

    final Object oldValueAntiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
    final Color oldColor = g2.getColor();

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setColor(COLOR_BLUE);
    final int BALL_RADIUS = 8;
    g2.fillOval((int) (this.mainTraceInfo.getPoint().getX() - (BALL_RADIUS >> 1) + 0.5),
            (int) (this.mainTraceInfo.getPoint().getY() - (BALL_RADIUS >> 1) + 0.5), BALL_RADIUS, BALL_RADIUS);

    for (TraceInfo indicatorTraceInfo : this.indicatorTraceInfos) {
        final Point2D point = indicatorTraceInfo.getPoint();
        if (null == point) {
            continue;
        }
        g2.fillOval((int) (point.getX() - (BALL_RADIUS >> 1) + 0.5),
                (int) (point.getY() - (BALL_RADIUS >> 1) + 0.5), BALL_RADIUS, BALL_RADIUS);
    }

    g2.setColor(oldColor);

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, oldValueAntiAlias);
    this.drawInformationBox(g2, layer);
}