Package co.ideago.AdvancedPoint

Examples of co.ideago.AdvancedPoint.Point2D


import co.ideago.AdvancedPoint.TooFewPointsException;

public class Test {
  public static void main(String[] args) {
    // Are two points equal?
    Point2D p1 = new Point2D(2.0, 2.0);
    Point2D p2 = new Point2D(2.0, 2.0);
   
    System.out.println(p1 + " is equal to " + p2 + "? " + p1.equals(p2));
   
    // Create an ArrayList of awt Points
    ArrayList<java.awt.Point> awtPoints = new ArrayList<java.awt.Point>();
    awtPoints.add(new java.awt.Point(4,4));
    awtPoints.add(new java.awt.Point(2,4));
    awtPoints.add(new java.awt.Point(3,5));
    awtPoints.add(new java.awt.Point(5,6));
    awtPoints.add(new java.awt.Point(5,5));
    awtPoints.add(new java.awt.Point(4,5));
   
    ArrayList<Point2D> points = null;
    try {
      points = PointUtil.pointConverter(awtPoints);
     
      for (Point2D p : points) {
        System.out.println(p.getX() + " " + p.getY());
      }
    } catch (InstantiationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
   
    System.out.println("----------- Testing Convex Hull ----------");
   
    List<Point2D> convexHull = null;
    try {
      convexHull = ConvexHull.giftWrap2D(points);
      for (Point2D p : convexHull) {
        System.out.println(p.getX() + " " + p.getY());
      }
     
    } catch (TooFewPointsException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
   
   
    System.out.println("--------- Test Outliers --------");
    List<Point2D> outliers = new ArrayList<Point2D>();
    outliers.add(new Point2D(-1.0, 1.0));
    outliers.add(new Point2D(10.0, 1.0));
    outliers.add(new Point2D(9.0, 4.0));
    outliers.add(new Point2D(4.0, 5.0));
   
    List<Point2D> result = ConvexHull.outliers(outliers, convexHull);
    for (Point2D p : result) {
      System.out.println(p);
    }
View Full Code Here

TOP

Related Classes of co.ideago.AdvancedPoint.Point2D

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.