Examples of PathIterator


Examples of java.awt.geom.PathIterator

        if (validArea.isEmpty()) {
            return 0;
        }

        PathIterator pi = validArea.getPathIterator(new AffineTransform());

        Vector points = new Vector();

        //System.out.println("iteracao: " + cor);
        while (!pi.isDone()) {

            double[] point = new double[6];

            int mode = pi.currentSegment(point);

            if (mode == PathIterator.SEG_MOVETO) {

                //System.out.println("MOVE_TO");

                if (points.size() != 0) {
                    // FINALIZAR ESSA SHAPE E ADICIONAR A AREA A A
                    //   System.out.println("WEIRD MOVE_TO");
                    a += calculaArea(points);
                }

                double[] p = new double[2];
                p[0] = point[0];
                p[1] = point[1];
                // System.out.println("Comecando em " + p[0] + "," + p[1]);
                points.addElement(p);

            } else if (mode == PathIterator.SEG_LINETO) {

                double[] p = new double[2];
                p[0] = point[0];
                p[1] = point[1];
                //  System.out.println("passando em " + p[0] + "," + p[1]);
                points.addElement(p);

            } else if (mode == PathIterator.SEG_CLOSE) {

                // System.out.println("fechando com " + points.size() + "
                // pontos");
                a += calculaArea(points);

            } else {

                throw new SecurityException();

            }

            pi.next();

        }

        return (Math.abs(a));
View Full Code Here

Examples of java.awt.geom.PathIterator

      if (otherData != null)
    out.writeObject(otherData);
      return;
  }

  PathIterator pathIterator
      = ((Shape)theObject).getPathIterator(null);

  // obtain and write the winding rule
  int rule = pathIterator.getWindingRule();
  out.writeInt(rule);

  float[] coordinates = new float[6];

  // iteratively write isDone, segment type and segment coordinates
  boolean isDone = pathIterator.isDone();
  while (!isDone){
      int segmentType = pathIterator.currentSegment(coordinates);
      out.writeBoolean(isDone);
      out.writeInt(segmentType);
      for (int i = 0; i < 6; i++)
    out.writeFloat(coordinates[i]) ;
      pathIterator.next();
      isDone = pathIterator.isDone();
  }
  out.writeBoolean(isDone);
    }
View Full Code Here

Examples of java.awt.geom.PathIterator

   * @param geomFact the GeometryFactory to use
   * @return a Geometry representing the shape
   */
  public static Geometry read(Shape shp, double flatness, GeometryFactory geomFact)
  {
    PathIterator pathIt = shp.getPathIterator(INVERT_Y, flatness);
    return ShapeReader.read(pathIt, geomFact);
  }
View Full Code Here

Examples of java.awt.geom.PathIterator

  @Override@Test
  public void testUpdateDblePathInside() {
    IRectangularShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    final double height = 10.;
    final double dble = 1.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();

    model.setPosition(-10, 20);
    model.setWidth(100);
    model.setThickness(thickness);
    model.setDbleBordSep(dble);
    model.setHeight(height);
    model.setBordersPosition(BorderPos.INTO);
    model.setHasDbleBord(true);
    view.update();
    path = view.getPath();

    pi = path.getPathIterator(null);
    assertEquals(PathIterator.SEG_MOVETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_CLOSE, pi.currentSegment(coords));

    double xMin = Double.MAX_VALUE, yMin = Double.MAX_VALUE;
    double xMax = Double.MIN_VALUE, yMax = Double.MIN_VALUE;
    int i=0, size = xs.size();
    double val;
View Full Code Here

Examples of java.awt.geom.PathIterator

  @Override@Test
  public void testUpdateDblePathMiddle() {
    IRectangularShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    final double height = 10.;
    final double dble = 1.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();

    model.setPosition(-10, 20);
    model.setWidth(100);
    model.setThickness(thickness);
    model.setDbleBordSep(dble);
    model.setHeight(height);
    model.setBordersPosition(BorderPos.MID);
    model.setHasDbleBord(true);
    view.update();
    path = view.getPath();

    pi = path.getPathIterator(null);
    assertEquals(PathIterator.SEG_MOVETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_CLOSE, pi.currentSegment(coords));

    double xMin = Double.MAX_VALUE, yMin = Double.MAX_VALUE;
    double xMax = Double.MIN_VALUE, yMax = Double.MIN_VALUE;
    int i=0, size = xs.size();
    double val;
View Full Code Here

Examples of java.awt.geom.PathIterator

  @Override@Test
  public void testUpdateDblePathOutside() {
    IRectangularShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    final double height = 10.;
    final double dble = 1.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();

    model.setPosition(-10, 20);
    model.setWidth(100);
    model.setThickness(thickness);
    model.setDbleBordSep(dble);
    model.setHeight(height);
    model.setBordersPosition(BorderPos.OUT);
    model.setHasDbleBord(true);
    view.update();
    path = view.getPath();

    pi = path.getPathIterator(null);
    assertEquals(PathIterator.SEG_MOVETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_CLOSE, pi.currentSegment(coords));

    double xMin = Double.MAX_VALUE, yMin = Double.MAX_VALUE;
    double xMax = Double.MIN_VALUE, yMax = Double.MIN_VALUE;
    int i=0, size = xs.size();
    double val;
View Full Code Here

Examples of java.awt.geom.PathIterator

  @Override@Test
  public void testUpdateGeneralPathInside() {
    IRectangularShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    final double height = 5.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();

    model.setPosition(-10, 20);
    model.setWidth(100);
    model.setThickness(thickness);
    model.setHeight(height);
    model.setBordersPosition(BorderPos.INTO);
    view.update();
    path = view.getPath();

    pi = path.getPathIterator(null);
    assertEquals(PathIterator.SEG_MOVETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_CLOSE, pi.currentSegment(coords));

    double xMin = Double.MAX_VALUE, yMin = Double.MAX_VALUE;
    double xMax = Double.MIN_VALUE, yMax = Double.MIN_VALUE;
    int i=0, size = xs.size();
    double val;
View Full Code Here

Examples of java.awt.geom.PathIterator

  @Override@Test
  public void testUpdateGeneralPathMiddle() {
    IRectangularShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    final double height = 5.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();

    model.setPosition(-10, 20);
    model.setWidth(100);
    model.setThickness(thickness);
    model.setHeight(height);
    model.setBordersPosition(BorderPos.MID);
    view.update();
    path = view.getPath();

    pi = path.getPathIterator(null);
    assertEquals(PathIterator.SEG_MOVETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_CLOSE, pi.currentSegment(coords));

    double xMin = Double.MAX_VALUE, yMin = Double.MAX_VALUE;
    double xMax = Double.MIN_VALUE, yMax = Double.MIN_VALUE;
    int i=0, size = xs.size();
    double val;
View Full Code Here

Examples of java.awt.geom.PathIterator

  @Override@Test
  public void testUpdateGeneralPathOutside() {
    IRectangularShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    final double height = 5.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();

    model.setPosition(-10, 20);
    model.setWidth(100);
    model.setThickness(thickness);
    model.setHeight(height);
    model.setBordersPosition(BorderPos.OUT);
    view.update();
    path = view.getPath();

    pi = path.getPathIterator(null);
    assertEquals(PathIterator.SEG_MOVETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_CLOSE, pi.currentSegment(coords));

    double xMin = Double.MAX_VALUE, yMin = Double.MAX_VALUE;
    double xMax = Double.MIN_VALUE, yMax = Double.MIN_VALUE;
    int i=0, size = xs.size();
    double val;
View Full Code Here

Examples of java.awt.geom.PathIterator

  @Override@Test
  public void testUpdateDblePathOutside() {
    ISquaredShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    final double dble = 1.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();
    double width = 100;

    model.setPosition(-10, 20);
    model.setWidth(width);
    model.setThickness(thickness);
    model.setDbleBordSep(dble);
    model.setBordersPosition(BorderPos.OUT);
    model.setHasDbleBord(true);
    view.update();
    path = view.getPath();

    pi = path.getPathIterator(null);
    assertEquals(PathIterator.SEG_MOVETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_LINETO, pi.currentSegment(coords));
    xs.add(coords[0]);
    ys.add(coords[1]);
    pi.next();
    assertEquals(PathIterator.SEG_CLOSE, pi.currentSegment(coords));

    double xMin = Double.MAX_VALUE, yMin = Double.MAX_VALUE;
    double xMax = Double.MIN_VALUE, yMax = Double.MIN_VALUE;
    int i=0, size = xs.size();
    double val;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.