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:FindHullWindowLogic.java

static public void fullfilTableWithConvexHull(JTable jTableDest, ArrayList<Point2D> convexHull) {
    DefaultTableModel jTableDestModel = (DefaultTableModel) jTableDest.getModel();
    jTableDestModel.setRowCount(0);//from  www  .j  ava2  s .  com

    int i = 1;
    for (Point2D onePoint : convexHull) {
        if (i != 1 && areTheSamePoints(onePoint, convexHull.get(0)))
            break;
        jTableDestModel.addRow(new Object[] { i + ".", onePoint.getX(), onePoint.getY() });
        i++;
    }

}

From source file:MainWindowLogic.java

static void readPointsFile(File fil_hndl, JTable tabela) throws IOException, InvalidFormatInFileException {
    ReadPointsFromFile pointsReader = new ReadPointsFromFile(fil_hndl.getPath());
    System.out.println("cieka wcztytywanego pliku: " + fil_hndl.getPath());
    Point2D[] readed = pointsReader.readPoints();

    DefaultTableModel defaultModelTabeli = (DefaultTableModel) tabela.getModel();

    for (Point2D point : readed) {
        defaultModelTabeli.addRow(//from   ww w.j a  v  a2 s.c  om
                new Object[] { defaultModelTabeli.getRowCount() + 1 + ".", point.getX(), point.getY(), false });
    }

}

From source file:GraphicsUtil.java

public static void drawCentered(Graphics g, BufferedImage img, Point2D location, double newWidth,
        double newHeight, ImageObserver observer) {
    Graphics2D g2 = (Graphics2D) g;
    g2.drawImage(img, // what to draw
            (int) (location.getX() - (newWidth / 2)), // dest left
            (int) (location.getY() - (newHeight / 2)), // dest top
            (int) (location.getX() + (newWidth / 2)), // dest right
            (int) (location.getY() + (newHeight / 2)), // dest bottom
            0, // src left
            0, // src top
            img.getWidth(), // src right
            img.getHeight(), // src bottom
            observer // to notify of image updates
    );/*from  www .  ja va 2s.  c  o  m*/
}

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

protected static void circleDC(final Graphics2D g, final Point2D center, final int radius) {
    final int cx = (int) center.getX();
    final int cy = (int) center.getY();
    g.drawArc(cx - radius, cy - radius, 2 * radius, 2 * radius, 0, 360);
}

From source file:PaintUtils.java

private static double calcAngle(Point2D p1, Point2D p2) {
    double x_off = p2.getX() - p1.getX();
    double y_off = p2.getY() - p1.getY();
    double angle = Math.atan(y_off / x_off);
    if (x_off < 0) {
        angle = angle + Math.PI;//  w  w w  . jav  a  2  s  . c om
    }

    if (angle < 0) {
        angle += 2 * Math.PI;
    }
    if (angle > 2 * Math.PI) {
        angle -= 2 * Math.PI;
    }
    return angle;
}

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

/**
 * @param g/*from   w w  w  . j  ava  2 s .co m*/
 * @param abs1_dc
 * @param abs2_dc
 */
protected static void lineDC(final Graphics2D g, final Point2D abs1_dc, final Point2D abs2_dc) {
    // perpendicular line for the "strength"
    g.drawLine((int) abs1_dc.getX(), (int) abs1_dc.getY(), (int) abs2_dc.getX(), (int) abs2_dc.getY());
}

From source file:jcurl.sim.core.SlideCurves.java

/**
 * Transform the trajectory from speed-coordinates (the y-axis points along
 * the direction of motion) to world coordinates and seed the
 * {@link Polynome}s <code>p[0]</code> and <code>p[1]</code>.
 * //from  ww  w  .  java2  s. c o  m
 * @param x0
 *            initial location x(t0)
 * @param e
 *            unit vector of speed
 * @param xt
 *            trajectory x(t) in "speed-coordinates"
 * @param p
 *            array of {@link Polynome}s of which <code>p[0]</code> and
 *            <code>p[1]</code> get filled.
 */
protected static void transformRc2Wc(final Point2D x0, final Point2D e, final double[] xt, final Polynome[] p) {
    // x(t) = x0 + e * x(t)
    double[] tmp = MathVec.mult(e.getX(), xt, null);
    tmp[0] += x0.getX();
    p[0] = new Polynome(tmp);
    tmp = MathVec.mult(e.getY(), xt, null);
    tmp[0] += x0.getY();
    p[1] = new Polynome(tmp);
}

From source file:net.panthema.BispanningGame.GraphString.java

public static String write_graph(MyGraph g, Transformer<Integer, Point2D> gl) {
    ByteArrayOutputStream ba = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(ba);

    // print the vertex list

    pw.print('V');
    pw.print(g.getVertexCount());/* w  w w.  ja va 2 s.c o m*/
    pw.print(':');

    Collection<Integer> vcoll = g.getVertices();
    ArrayList<Integer> vlist = new ArrayList<Integer>(vcoll);
    Collections.sort(vlist, new Comparator<Integer>() {
        public int compare(Integer arg0, Integer arg1) {
            return arg0 - arg1;
        }
    });

    for (Integer v : vlist) {
        pw.print('i');
        pw.print(v);

        Point2D pos = gl.transform(v);
        pw.print('x');
        pw.print((int) pos.getX());
        pw.print('y');
        pw.print((int) pos.getY());

        pw.print('/');
    }
    pw.print(';');

    // print the edge list

    pw.print('E');
    pw.print(g.getEdgeCount());
    pw.print(':');

    Collection<MyEdge> ecoll = g.getEdges();
    ArrayList<MyEdge> elist = new ArrayList<MyEdge>(ecoll);
    Collections.sort(elist, new Comparator<MyEdge>() {
        public int compare(MyEdge arg0, MyEdge arg1) {
            return arg0.id - arg1.id;
        }
    });

    for (MyEdge e : elist) {
        Integer e_x = g.getEndpoints(e).getFirst();
        Integer e_y = g.getEndpoints(e).getSecond();

        pw.print('i');
        pw.print(e.id);

        pw.print('t');
        pw.print(e_x);
        pw.print('h');
        pw.print(e_y);

        pw.print('c');
        pw.print(e.color);

        pw.print('/');
    }
    pw.print(';');

    pw.flush();

    return ba.toString();
}

From source file:inflor.core.utils.ChartUtils.java

public static Point2D getPlotCoordinates(MouseEvent e, FCSChartPanel panel) {
    Point2D p = panel.translateScreenToJava2D(e.getPoint());
    Rectangle2D plotArea = panel.getScreenDataArea();
    XYPlot plot = panel.getChart().getXYPlot();
    double x = plot.getDomainAxis().java2DToValue(p.getX(), plotArea, plot.getDomainAxisEdge());
    double y = plot.getRangeAxis().java2DToValue(p.getY(), plotArea, plot.getRangeAxisEdge());
    return new Point2D.Double(x, y);
}

From source file:Main.java

/**
 * Serialises a <code>Point2D</code> object.
 *
 * @param p  the point object (<code>null</code> permitted).
 * @param stream  the output stream (<code>null</code> not permitted).
 *
 * @throws IOException if there is an I/O error.
 *//* w  ww  . ja  v  a  2s  .  c o  m*/
public static void writePoint2D(final Point2D p, final ObjectOutputStream stream) throws IOException {

    if (stream == null) {
        throw new IllegalArgumentException("Null 'stream' argument.");
    }
    if (p != null) {
        stream.writeBoolean(false);
        stream.writeDouble(p.getX());
        stream.writeDouble(p.getY());
    } else {
        stream.writeBoolean(true);
    }
}