AreaROI(List<? extends Vertices> vertices, int c, int z, int t) { super(c, z, t); this.vertices = new ArrayList<>(); for (Vertices v : vertices) this.vertices.add(new DefaultMutableVertices(v)); }
@Override public Vertices duplicate() { return new DefaultMutableVertices((DefaultVertices)vertices.duplicate()); }
public static DefaultMutableVertices createMutableVertices() { return new DefaultMutableVertices(createVertices(DefaultVertices.DEFAULT_CAPACITY)); }
AreaROI(float[][] x, float[][] y, int c, int z, int t) { super(c, z, t); this.vertices = new ArrayList<>(); if (x.length != y.length) throw new IllegalArgumentException("Lengths of x and y are different!"); for (int i = 0; i < x.length; i++) { float[] x2 = x[i]; float[] y2 = y[i]; if (x.length != y.length) throw new IllegalArgumentException("Lengths of x and y are different!"); this.vertices.add(new DefaultMutableVertices(new DefaultVertices(x2, y2, false))); } }
public static DefaultMutableVertices createMutableVertices(final int capacity) { return new DefaultMutableVertices(new DefaultVertices(capacity)); }
public static MutableVertices createMutableVertices(final float[] x, final float[] y, final boolean copyArrays) { return new DefaultMutableVertices(new DefaultVertices(x, y, copyArrays)); }
public static List<Vertices> getVertices(final Shape shape) { Path2D path = shape instanceof Path2D ? (Path2D)shape : new Path2D.Float(shape); PathIterator iter = path.getPathIterator(null, 0.5); List<Vertices> verticesList = new ArrayList<>(); MutableVertices vertices = null; double[] seg = new double[6]; while (!iter.isDone()) { switch(iter.currentSegment(seg)) { case PathIterator.SEG_MOVETO: vertices = new DefaultMutableVertices(new DefaultVertices()); // Fall through case PathIterator.SEG_LINETO: vertices.add(seg[0], seg[1]); break; case PathIterator.SEG_CLOSE: // // Add first point again vertices.close(); verticesList.add(vertices.getVertices()); break; default: throw new RuntimeException("Invalid polygon " + path + " - only line connections are allowed"); }; iter.next(); } return verticesList; }