You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/05/01 02:09:20 UTC

svn commit: r770491 - in /incubator/pivot/trunk/wtk: src/pivot/wtk/media/drawing/Path.java test/pivot/wtk/media/drawing/test/sample.wtkd

Author: gbrown
Date: Fri May  1 00:09:20 2009
New Revision: 770491

URL: http://svn.apache.org/viewvc?rev=770491&view=rev
Log:
Move operation sequence back into Path class.

Modified:
    incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java
    incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd

Modified: incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java?rev=770491&r1=770490&r2=770491&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java (original)
+++ incubator/pivot/trunk/wtk/src/pivot/wtk/media/drawing/Path.java Fri May  1 00:09:20 2009
@@ -32,7 +32,8 @@
  *
  * @author tvolkert
  */
-public class Path extends Shape {
+public class Path extends Shape
+    implements Sequence<Path.Operation> {
     /**
      * Abstract base class for path operations. See the specific subclasses for
      * details.
@@ -454,106 +455,6 @@
     }
 
     /**
-     * Operation sequence implementation.
-     *
-     * @author tvolkert
-     */
-    public final class OperationSequence implements Sequence<Operation> {
-        /**
-         * {@inheritDoc}
-         */
-        public int add(Operation operation) {
-            int i = getLength();
-            insert(operation, i);
-
-            return i;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public void insert(Operation operation, int index) {
-            if (operation == null) {
-                throw new IllegalArgumentException("operation is null.");
-            }
-
-            if (index < 0 || index > getLength()) {
-                throw new IndexOutOfBoundsException();
-            }
-
-            if (operation.getPath() != null) {
-                throw new IllegalArgumentException("operation is already in use by another path.");
-            }
-
-            operations.insert(operation, index);
-            operation.setPath(Path.this);
-
-            invalidate();
-
-            pathListeners.operationInserted(Path.this, index);
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public Operation update(int index, Operation operation) {
-            throw new UnsupportedOperationException();
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public int remove(Operation operation) {
-            int index = indexOf(operation);
-            if (index != -1) {
-                remove(index, 1);
-            }
-
-            return index;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public Sequence<Operation> remove(int index, int count) {
-            Sequence<Operation> removed = operations.remove(index, count);
-
-            if (count > 0) {
-                for (int i = 0, n = removed.getLength(); i < n; i++) {
-                    removed.get(i).setPath(null);
-                }
-
-                invalidate();
-
-                pathListeners.operationsRemoved(Path.this, index, removed);
-            }
-
-            return removed;
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public Operation get(int index) {
-            return operations.get(index);
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public int indexOf(Operation operation) {
-            return operations.indexOf(operation);
-        }
-
-        /**
-         * {@inheritDoc}
-         */
-        public int getLength() {
-            return operations.getLength();
-        }
-    }
-
-    /**
      * The winding rule specifies how the interior of a path is determined.
      *
      * @author tvolkert
@@ -626,9 +527,7 @@
     }
 
     private WindingRule windingRule = WindingRule.NON_ZERO;
-
     private ArrayList<Operation> operations = new ArrayList<Operation>();
-    private OperationSequence operationSequence = new OperationSequence();
 
     private GeneralPath generalPath = new GeneralPath();
 
@@ -664,13 +563,96 @@
     }
 
     /**
-     * Returns the path operation sequence.
-     *
-     * @return
-     * The path operation sequence.
+     * {@inheritDoc}
+     */
+    public int add(Operation operation) {
+        int i = getLength();
+        insert(operation, i);
+
+        return i;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public void insert(Operation operation, int index) {
+        if (operation == null) {
+            throw new IllegalArgumentException("operation is null.");
+        }
+
+        if (index < 0 || index > getLength()) {
+            throw new IndexOutOfBoundsException();
+        }
+
+        if (operation.getPath() != null) {
+            throw new IllegalArgumentException("operation is already in use by another path.");
+        }
+
+        operations.insert(operation, index);
+        operation.setPath(Path.this);
+
+        invalidate();
+
+        pathListeners.operationInserted(Path.this, index);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Operation update(int index, Operation operation) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int remove(Operation operation) {
+        int index = indexOf(operation);
+        if (index != -1) {
+            remove(index, 1);
+        }
+
+        return index;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Sequence<Operation> remove(int index, int count) {
+        Sequence<Operation> removed = operations.remove(index, count);
+
+        if (count > 0) {
+            for (int i = 0, n = removed.getLength(); i < n; i++) {
+                removed.get(i).setPath(null);
+            }
+
+            invalidate();
+
+            pathListeners.operationsRemoved(Path.this, index, removed);
+        }
+
+        return removed;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public Operation get(int index) {
+        return operations.get(index);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int indexOf(Operation operation) {
+        return operations.indexOf(operation);
+    }
+
+    /**
+     * {@inheritDoc}
      */
-    public OperationSequence getOperations() {
-        return operationSequence;
+    public int getLength() {
+        return operations.getLength();
     }
 
     /**

Modified: incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd?rev=770491&r1=770490&r2=770491&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd (original)
+++ incubator/pivot/trunk/wtk/test/pivot/wtk/media/drawing/test/sample.wtkd Fri May  1 00:09:20 2009
@@ -32,15 +32,13 @@
             <Line x1="140" y1="86" x2="200" y2="86"
                 stroke="#cc00cc" strokeThickness="10"/>
             <Path x="132" y="83" stroke="#0088ff" strokeThickness="2">
-                <operations>
-                    <Path.MoveTo x="20" y="70"/>
-                    <Path.LineTo x="30" y="20"/>
-                    <Path.QuadTo x1="40" y1="10" x2="50" y2="20"/>
-                    <Path.LineTo x="60" y="70"/>
-                    <Path.QuadTo x1="70" y1="80" x2="60" y2="80"/>
-                    <Path.LineTo x="20" y="80"/>
-                    <Path.QuadTo x1="10" y1="80" x2="20" y2="70"/>
-                </operations>
+                <Path.MoveTo x="20" y="70"/>
+                <Path.LineTo x="30" y="20"/>
+                <Path.QuadTo x1="40" y1="10" x2="50" y2="20"/>
+                <Path.LineTo x="60" y="70"/>
+                <Path.QuadTo x1="70" y1="80" x2="60" y2="80"/>
+                <Path.LineTo x="20" y="80"/>
+                <Path.QuadTo x1="10" y1="80" x2="20" y2="70"/>
             </Path>
             <Ellipse x="60" y="180"
                 width="220" height="60" fill="#000000"