Package java.awt.geom

Examples of java.awt.geom.Line2D$Double


  /**
   * @see Graphics#drawPolyline(int[], int[], int)
   */
  public void drawPolyline(final int[] x, final int[] y, final int nPoints)
  {
    final Line2D line = new Line2D.Double(x[0], y[0], x[0], y[0]);
    for (int i = 1; i < nPoints; i++)
    {
      line.setLine(line.getX2(), line.getY2(), x[i], y[i]);
      draw(line);
    }
  }
View Full Code Here


    for (int i = getLowest(); i <= highest; i++)
    {
      for (int j = 0; j < 10; j++)
      {
        final double xx = valueToJava2D(i + j / 10.0, area);
        final Line2D mark = new Line2D.Double(xx, area.getCenterY() - 2.0, xx,
            area.getCenterY() + 2.0);
        g2.draw(mark);
      }
    }
    final double xx = valueToJava2D(highest, area);
    final Line2D mark = new Line2D.Double(xx, area.getCenterY() - 2.0, xx,
        area.getCenterY() + 2.0);
    g2.draw(mark);
  }
View Full Code Here

                        default: {
                            break;
                        }
                    }

                    Line2D line = new Line2D.Float(x, offset, x + lineWidth, offset);
                    graphics.draw(line);
                }

                y += textBounds.getHeight();
            }
View Full Code Here

     * Runs the test using the specified harness.
     *
     * @param harness  the test harness (<code>null</code> not permitted).
     */
    public void test(TestHarness harness) {
        Line2D line1 = new Line2D.Double(1.0, 2.0, 3.0, 4.0);
        Line2D line2 = null;
        line2 = (Line2D) line1.clone();
        harness.check(line1.getX1() == line2.getX1());
        harness.check(line1.getX2() == line2.getX2());
        harness.check(line1.getY1() == line2.getY1());
        harness.check(line1.getY2() == line2.getY2());
        harness.check(line1.getClass() == line2.getClass());
        harness.check(line1 != line2);
    }
View Full Code Here

public class getPathIterator
  implements Testlet
{
  public void test(TestHarness harness)
  {
    Line2D line1 = new Line2D.Double(1.0, 2.0, 3.0, 4.0);
    PathIterator iterator = line1.getPathIterator(null);
    double[] c = new double[6];
   
    harness.check(!iterator.isDone());                                  
    harness.check(iterator.currentSegment(c), PathIterator.SEG_MOVETO)
    harness.check(c[0], 1.0);                                      
View Full Code Here

public class ptLineDist
  implements Testlet
{
  public void test(TestHarness harness)
  {
    Line2D line1 = new Line2D.Double(0.0, 0.0, 1.0, 0.0);
    harness.check(0.0, line1.ptLineDist(-50.0, 0.0));
    harness.check(0.0, line1.ptLineDist(0.0, 0.0));
    harness.check(0.0, line1.ptLineDist(1.0, 0.0));
    harness.check(0.0, line1.ptLineDist(50.0, 0.0));
    harness.check(1.0, line1.ptLineDist(-50.0, 1.0));
    harness.check(1.0, line1.ptLineDist(0.0, 1.0));
    harness.check(1.0, line1.ptLineDist(1.0, 1.0));
    harness.check(1.0, line1.ptLineDist(50.0, 1.0));
    harness.check(1.0, line1.ptLineDist(-50.0, -1.0));
    harness.check(1.0, line1.ptLineDist(0.0, -1.0));
    harness.check(1.0, line1.ptLineDist(1.0, -1.0));
    harness.check(1.0, line1.ptLineDist(50.0, -1.0));
 
    harness.check(0.0, line1.ptLineDist(new Point2D.Double(-50.0, 0.0)));
    harness.check(0.0, line1.ptLineDist(new Point2D.Double(0.0, 0.0)));
    harness.check(0.0, line1.ptLineDist(new Point2D.Double(1.0, 0.0)));
    harness.check(0.0, line1.ptLineDist(new Point2D.Double(50.0, 0.0)));
    harness.check(1.0, line1.ptLineDist(new Point2D.Double(-50.0, 1.0)));
    harness.check(1.0, line1.ptLineDist(new Point2D.Double(0.0, 1.0)));
    harness.check(1.0, line1.ptLineDist(new Point2D.Double(1.0, 1.0)));
    harness.check(1.0, line1.ptLineDist(new Point2D.Double(50.0, 1.0)));
    harness.check(1.0, line1.ptLineDist(new Point2D.Double(-50.0, -1.0)));
    harness.check(1.0, line1.ptLineDist(new Point2D.Double(0.0, -1.0)));
    harness.check(1.0, line1.ptLineDist(new Point2D.Double(1.0, -1.0)));
    harness.check(1.0, line1.ptLineDist(new Point2D.Double(50.0, -1.0)));
   
    boolean pass = false;
    try {
      line1.ptLineDist(null);
    }
    catch (NullPointerException e) {
      pass = true;
    }
    harness.check(pass)
View Full Code Here

public class ptSegDist
  implements Testlet
{
  public void test(TestHarness harness)
  {
    Line2D line1 = new Line2D.Double(0.0, 0.0, 1.0, 0.0);
    harness.check(50.0, line1.ptSegDist(-50.0, 0.0));
    harness.check(0.0, line1.ptSegDist(0.0, 0.0));
    harness.check(0.0, line1.ptSegDist(1.0, 0.0));
    harness.check(49.0, line1.ptSegDist(50.0, 0.0));
    harness.check(Math.sqrt(2501.0), line1.ptSegDist(-50.0, 1.0));
    harness.check(1.0, line1.ptSegDist(0.0, 1.0));
    harness.check(1.0, line1.ptSegDist(1.0, 1.0));
    harness.check(Math.sqrt(49.0*49.0+1.0), line1.ptSegDist(50.0, 1.0));
    harness.check(Math.sqrt(2501.0), line1.ptSegDist(-50.0, -1.0));
    harness.check(1.0, line1.ptSegDist(0.0, -1.0));
    harness.check(1.0, line1.ptSegDist(1.0, -1.0));
    harness.check(Math.sqrt(49.0*49.0+1.0), line1.ptSegDist(50.0, -1.0));

    harness.check(50.0, line1.ptSegDist(new Point2D.Double(-50.0, 0.0)));
    harness.check(0.0, line1.ptSegDist(new Point2D.Double(0.0, 0.0)));
    harness.check(0.0, line1.ptSegDist(new Point2D.Double(1.0, 0.0)));
    harness.check(49.0, line1.ptSegDist(new Point2D.Double(50.0, 0.0)));
    harness.check(Math.sqrt(2501.0), line1.ptSegDist(new Point2D.Double(-50.0, 1.0)));
    harness.check(1.0, line1.ptSegDist(new Point2D.Double(0.0, 1.0)));
    harness.check(1.0, line1.ptSegDist(new Point2D.Double(1.0, 1.0)));
    harness.check(Math.sqrt(49.0*49.0+1.0), line1.ptSegDist(new Point2D.Double(50.0, 1.0)));
    harness.check(Math.sqrt(2501.0), line1.ptSegDist(new Point2D.Double(-50.0, -1.0)));
    harness.check(1.0, line1.ptSegDist(new Point2D.Double(0.0, -1.0)));
    harness.check(1.0, line1.ptSegDist(new Point2D.Double(1.0, -1.0)));
    harness.check(Math.sqrt(49.0*49.0+1.0), line1.ptSegDist(new Point2D.Double(50.0, -1.0)));
 
    boolean pass = false;
    try {
      line1.ptSegDist(null);
    }
    catch (NullPointerException e) {
      pass = true;
    }
    harness.check(pass)
View Full Code Here

   * Runs the test using the specified harness.
   *
   * @param harness  the test harness (<code>null</code> not permitted).
   */
  public void test(TestHarness harness) {
      Line2D line1 = new Line2D.Double(1.0, 2.0, 3.0, 4.0);
      harness.check(line1.contains(1.0, 2.0) == false);
      harness.check(line1.contains(3.0, 4.0) == false);
      harness.check(line1.contains(new Point2D.Double(1.0, 2.0)) == false);
      harness.check(line1.contains(new Point2D.Double(3.0, 4.0)) == false);
      harness.check(line1.contains((Point2D) null) == false);
      harness.check(line1.contains(new Rectangle2D.Double(1.0, 2.0, 0.0, 0.0)) == false);
      harness.check(line1.contains((Rectangle2D) null) == false);
  }
View Full Code Here

public class getP2
  implements Testlet
{
  public void test(TestHarness harness)
  {
    Line2D line1 = new Line2D.Double(1.0, 2.0, 3.0, 4.0);
    Point2D pt2 = line1.getP2();
    harness.check(pt2.getX() == 3.0);
    harness.check(pt2.getY() == 4.0);
  }
View Full Code Here

public class intersects
  implements Testlet
{
  public void test(TestHarness harness)
  {
    Line2D line1 = new Line2D.Double(0.0, 0.0, 1.0, 0.0);
    harness.check(line1.intersects(0.0, -1.0, 1.0, 1.0));
    harness.check(line1.intersects(0.0, 0.0, 1.0, 1.0));
    harness.check(!line1.intersects(0.0, 1.0, 1.0, 1.0));

    harness.check(line1.intersects(new Rectangle2D.Double(0.0, -1.0, 1.0, 1.0)));
    harness.check(line1.intersects(new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0)));
    harness.check(!line1.intersects(new Rectangle2D.Double(0.0, 1.0, 1.0, 1.0)));

    Line2D line2 = new Line2D.Double(0.0, 0.0, 0.0, 1.0);
    harness.check(line2.intersects(-1.0, 0.0, 1.0, 1.0));
    harness.check(line2.intersects(0.0, 0.0, 1.0, 1.0));
    harness.check(!line2.intersects(1.0, 0.0, 1.0, 1.0));
   
    harness.check(line2.intersects(new Rectangle2D.Double(-1.0, 0.0, 1.0, 1.0)));
    harness.check(line2.intersects(new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0)));
    harness.check(!line2.intersects(new Rectangle2D.Double(1.0, 0.0, 1.0, 1.0)));

    Line2D line3 = new Line2D.Double(0.0, 1.0, 1.0, 1.0);
    harness.check(!line3.intersects(0.0, -1.0, 1.0, 1.0));
    harness.check(line3.intersects(0.0, 0.0, 1.0, 1.0));
    harness.check(line3.intersects(0.0, 1.0, 1.0, 1.0));
    harness.check(!line3.intersects(new Rectangle2D.Double(0.0, -1.0, 1.0, 1.0)));
    harness.check(line3.intersects(new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0)));
    harness.check(line3.intersects(new Rectangle2D.Double(0.0, 1.0, 1.0, 1.0)));
   
    Line2D line4 = new Line2D.Double(1.0, 0.0, 1.0, 1.0);
    harness.check(!line4.intersects(-1.0, 0.0, 1.0, 1.0));
    harness.check(line4.intersects(0.0, 0.0, 1.0, 1.0));
    harness.check(line4.intersects(1.0, 0.0, 1.0, 1.0));
    harness.check(!line4.intersects(new Rectangle2D.Double(-1.0, 0.0, 1.0, 1.0)));
    harness.check(line4.intersects(new Rectangle2D.Double(0.0, 0.0, 1.0, 1.0)));
    harness.check(line4.intersects(new Rectangle2D.Double(1.0, 0.0, 1.0, 1.0)));

    boolean pass = false;
    try {
        line4.intersects(null);
    }
    catch (NullPointerException e) {
        pass = true;
    }
    harness.check(pass)
View Full Code Here

TOP

Related Classes of java.awt.geom.Line2D$Double

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.