Examples of PathIterator


Examples of java.awt.geom.PathIterator

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

    model.setPosition(-10, 20);
    model.setWidth(width);
    model.setThickness(thickness);
    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() {
    ISquaredShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();
    double width = 100;

    model.setPosition(-10, 20);
    model.setWidth(width);
    model.setThickness(thickness);
    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() {
    ISquaredShape model = getShape();
    Path2D path;
    PathIterator pi;
    double[] coords = new double[6];
    final double thickness = 3.;
    List<Double> xs = new ArrayList<>();
    List<Double> ys = new ArrayList<>();
    double width = 100;

    model.setPosition(-10, 20);
    model.setWidth(width);
    model.setThickness(thickness);
    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 testUpdateDblePathInside() {
    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.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() {
    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.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


  @SuppressWarnings("nls")
  @Override
  public void parse() throws ParseException {
    final PathIterator pi     = shape.getPathIterator(null);
    final double[] coords       = new double[6];
    final SVGPathSegList list   = new SVGPathSegList();
    element           = new SVGPathElement(document);

    while(!pi.isDone()) {
      switch(pi.currentSegment(coords)) {
        case PathIterator.SEG_CLOSE  : list.add(new SVGPathSegClosePath()); break;
        case PathIterator.SEG_LINETO: list.add(new SVGPathSegLineto(coords[0], coords[1], false)); break;
        case PathIterator.SEG_MOVETO: list.add(new SVGPathSegMoveto(coords[0], coords[1], false)); break;
        case PathIterator.SEG_CUBICTO: list.add(new SVGPathSegCurvetoCubic(coords[4], coords[5], coords[0], coords[1], coords[2], coords[3], false)); break;
        case PathIterator.SEG_QUADTO: list.add(new SVGPathSegCurvetoQuadratic(coords[2], coords[3], coords[0], coords[1], false)); break;
        default: throw new ParseException("Invalid Path2D element:" + pi.currentSegment(coords), -1);
      }
      pi.next();
    }

    element.setAttribute(SVGAttributes.SVG_D, list.toString());
    list.clear(); // Freeing the memory.
  }
View Full Code Here

Examples of java.awt.geom.PathIterator

                stream.writeDouble(arc.getAngleExtent());
                stream.writeInt(arc.getArcType());
            }
            else if (shape instanceof GeneralPath) {
                stream.writeObject(GeneralPath.class);
                final PathIterator pi = shape.getPathIterator(null);
                final float[] args = new float[6];
                stream.writeBoolean(pi.isDone());
                while (!pi.isDone()) {
                    final int type = pi.currentSegment(args);
                    stream.writeInt(type);
                    // TODO: could write this to only stream the values
                    // required for the segment type
                    for (int i = 0; i < 6; i++) {
                        stream.writeFloat(args[i]);
                    }
                    stream.writeInt(pi.getWindingRule());
                    pi.next();
                    stream.writeBoolean(pi.isDone());
                }
            }
            else {
                stream.writeObject(shape.getClass());
                stream.writeObject(shape);
View Full Code Here

Examples of java.awt.geom.PathIterator

     *
     * @param a An Area.
     */
    public ROIShape(Area a) {
        AffineTransform at = new AffineTransform(); // Identity
        PathIterator pi = a.getPathIterator(at);
        GeneralPath gp = new GeneralPath(pi.getWindingRule());
        gp.append(pi, false);

        theShape = gp;
    }
View Full Code Here

Examples of java.awt.geom.PathIterator

            if (!clip.getBounds().contains(bounds)) {
                return;
            }
        }

        PathIterator it = shape.getPathIterator(transform);
        double[] prev = null;
        double[] coords = new double[6];
        double[] first = new double[6];
        if(!it.isDone()) it.currentSegment(first); //first point
        while(!it.isDone()){
            int type = it.currentSegment(coords);
            if (prev != null ){
                Line line = new Line(group);
                if (stroke instanceof BasicStroke){
                    BasicStroke bs = (BasicStroke)stroke;
                    line.setLineWidth(bs.getLineWidth());
                    float[] dash = bs.getDashArray();
                    if (dash != null) line.setLineDashing(Line.PEN_DASH);
                }
                if(getColor() != null) line.setLineColor(getColor());
                if (type == PathIterator.SEG_LINETO) {
                    line.setAnchor(new java.awt.Rectangle((int)prev[0](int)prev[1], (int)(coords[0] - prev[0]), (int)(coords[1] - prev[1])));
                } else if (type == PathIterator.SEG_CLOSE){
                    line.setAnchor(new java.awt.Rectangle((int)coords[0](int)coords[1], (int)(first[0] - coords[0]), (int)(first[1] - coords[1])));
                }
                group.addShape(line);
            }
            prev = new double[]{coords[0],  coords[1]};
            it.next();
        }

    }
View Full Code Here

Examples of java.awt.geom.PathIterator

            if (bounds.height == 0) bounds.height = 1;
             if (!clip.getBounds().contains(bounds)) {
                return;
            }
        }
        PathIterator it = shape.getPathIterator(transform);
        ArrayList pnt = new ArrayList();
        double[] coords = new double[6];
        while(!it.isDone()){
            int type = it.currentSegment(coords);
            if (type != PathIterator.SEG_CLOSE) {
                pnt.add(new Point((int)coords[0], (int)coords[1]));
            }
            it.next();
        }
        int[] xPoints= new int[pnt.size()];
        int[] yPoints= new int[pnt.size()];
        for (int i = 0; i < pnt.size(); i++) {
            Point p = (Point)pnt.get(i);
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.