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:de.hstsoft.sdeep.NoteManager.java

public Note getNoteAt(Point2D mapPosition, int size) {
    int x = (int) mapPosition.getX() - size / 2;
    int y = (int) mapPosition.getY() - size / 2;
    Rectangle rectangle = new Rectangle(x, y, size, size);

    for (Note n : notes) {
        if (rectangle.contains(n.getPosition())) {
            return n;
        }/*from  w w  w.  jav a 2s.co  m*/
    }
    return null;
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    String s = "www.java2s.com www.java2s.com";
    Font font = new Font("Serif", Font.PLAIN, 24);
    FontRenderContext frc = g2.getFontRenderContext();
    g2.translate(40, 80);//from  ww  w.j a v a 2 s . c om

    GlyphVector gv = font.createGlyphVector(frc, s);
    int length = gv.getNumGlyphs();
    for (int i = 0; i < length; i++) {
        Point2D p = gv.getGlyphPosition(i);
        double theta = (double) i / (double) (length - 1) * Math.PI / 4;
        AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
        at.rotate(theta);
        Shape glyph = gv.getGlyphOutline(i);
        Shape transformedGlyph = at.createTransformedShape(glyph);
        g2.fill(transformedGlyph);
    }
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    String s = "www.java2s.com www.java2s.com";
    Font font = new Font("Serif", Font.PLAIN, 24);
    FontRenderContext frc = g2.getFontRenderContext();
    g2.translate(40, 80);/*w w w  .ja  v a  2s.c o  m*/

    GlyphVector gv = font.createGlyphVector(frc, s);
    System.out.println(gv.getFont());

    int length = gv.getNumGlyphs();
    for (int i = 0; i < length; i++) {
        Point2D p = gv.getGlyphPosition(i);
        double theta = (double) i / (double) (length - 1) * Math.PI / 4;
        AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
        at.rotate(theta);
        Shape glyph = gv.getGlyphOutline(i);
        Shape transformedGlyph = at.createTransformedShape(glyph);
        g2.fill(transformedGlyph);
    }
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    String s = "www.java2s.com www.java2s.com";
    Font font = new Font("Serif", Font.PLAIN, 24);
    FontRenderContext frc = g2.getFontRenderContext();
    g2.translate(40, 80);/*w  w  w .  ja  v a 2 s. com*/

    GlyphVector gv = font.createGlyphVector(frc, s);
    System.out.println(gv.getOutline());

    int length = gv.getNumGlyphs();
    for (int i = 0; i < length; i++) {
        Point2D p = gv.getGlyphPosition(i);
        double theta = (double) i / (double) (length - 1) * Math.PI / 4;
        AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
        at.rotate(theta);
        Shape glyph = gv.getGlyphOutline(i);
        Shape transformedGlyph = at.createTransformedShape(glyph);
        g2.fill(transformedGlyph);
    }
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    String s = "www.java2s.com www.java2s.com";
    Font font = new Font("Serif", Font.PLAIN, 24);
    FontRenderContext frc = g2.getFontRenderContext();
    g2.translate(40, 80);//from w w  w  .  j a v a 2s. c om

    GlyphVector gv = font.createGlyphVector(frc, s);
    System.out.println(gv.getVisualBounds());

    int length = gv.getNumGlyphs();
    for (int i = 0; i < length; i++) {
        Point2D p = gv.getGlyphPosition(i);
        double theta = (double) i / (double) (length - 1) * Math.PI / 4;
        AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
        at.rotate(theta);
        Shape glyph = gv.getGlyphOutline(i);
        Shape transformedGlyph = at.createTransformedShape(glyph);
        g2.fill(transformedGlyph);
    }
}

From source file:Main.java

public void paint(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    String s = "www.java2s.com www.java2s.com";
    Font font = new Font("Serif", Font.PLAIN, 24);
    FontRenderContext frc = g2.getFontRenderContext();
    g2.translate(40, 80);/*from  w  ww  . j a v a2 s .  c om*/

    GlyphVector gv = font.createGlyphVector(frc, s);
    System.out.println(gv.getLogicalBounds());

    int length = gv.getNumGlyphs();
    for (int i = 0; i < length; i++) {
        Point2D p = gv.getGlyphPosition(i);
        double theta = (double) i / (double) (length - 1) * Math.PI / 4;
        AffineTransform at = AffineTransform.getTranslateInstance(p.getX(), p.getY());
        at.rotate(theta);
        Shape glyph = gv.getGlyphOutline(i);
        Shape transformedGlyph = at.createTransformedShape(glyph);
        g2.fill(transformedGlyph);
    }
}

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 w  w.  j  av a 2  s. co  m
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:chiliad.parser.pdf.extractor.vectorgraphics.operator.MoveTo.java

/**
 * process : m : Begin new subpath./*from  w w  w . j a v a  2 s  .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:joshua.ui.tree_visualizer.DerivationTreeTransformer.java

public void setAnchorPoint(DerivationViewer.AnchorType type, Point2D viewerAnchor) {
    Point2D oldAnchor = getAnchorPosition(type);
    double x = viewerAnchor.getX() - oldAnchor.getX();
    double y = viewerAnchor.getY() - oldAnchor.getY();
    anchorPoint = new Point2D.Double(x, y);
}

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

@Override
public boolean containsPoint(Point2D p) {
    if (x0 <= p.getX() && p.getX() <= x1 && y0 <= p.getY() && p.getY() <= y1) {
        return true;
    } else {// w ww  .  ja v  a2 s.  c om
        return false;
    }
}