+ return deepPathCopy(path);
+ }
+
+ public void setPath(Point... path)
+ {
+ this.path = deepPathCopy(path);
+ recalculateEffectivePath();
+ callPathChangedListeners();
+ callRedrawListeners();
+ }
+
+ public Point getPathPoint(int index)
+ {
+ return pointCopy(path[index]);
+ }
+
+ public void setPathPoint(Point p, int index)
+ {
+ path[index] = pointCopy(p);
+ recalculateEffectivePath();
+ callPathChangedListeners();
+ callRedrawListeners();
+ }
+
+ public void insertPathPoint(Point p, int index)
+ {
+ if (path == null)
+ path = new Point[] { pointCopy(p) };
+ else
+ {
+ Point[] oldPath = path;
+ path = new Point[oldPath.length + 1];
+ System.arraycopy(oldPath, 0, path, 0, index);
+ if (index < oldPath.length)
+ System.arraycopy(oldPath, index, path, index + 1, oldPath.length - index);
+ path[index] = pointCopy(p);
+ }
+ }
+
+ public void removePathPoint(int index)
+ {
+ if (path.length == 0)
+ path = null;
+ else
+ {
+ Point[] oldPath = path;
+ path = new Point[oldPath.length - 1];
+ System.arraycopy(oldPath, 0, path, 0, index);
+ if (index < oldPath.length - 1)
+ System.arraycopy(oldPath, index + 1, path, index, oldPath.length - index - 1);
+ }
+ }
+
+ public double[] getEffectivePath()
+ {
+ return Arrays.copyOf(effectivePath, effectivePath.length);
+ }
+
+ private static Point[] deepPathCopy(Point[] path)
+ {
+ if (path == null)
+ return null;
+ Point[] copy = new Point[path.length];
+ for (int i = 0; i < path.length; i++)
+ copy[i] = pointCopy(path[i]);
+ return copy;
+ }
+
+ private static Point pointCopy(Point p)
+ {
+ return new Point(p.x, p.y);