Revision: 938
Author: allain.lalonde
Date: Wed Jan 20 10:51:17 2010
Log: 2.0-spike extras now uses Generics.
http://code.google.com/p/piccolo2d/source/detail?r=938

Modified:
/piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/PFrame.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/activities/PPositionPathActivity.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PNavigationEventHandler.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PNotification.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PNotificationCenter.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PSelectionEventHandler.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/handles/PBoundsHandle.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/nodes/PStyledText.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PComboBox.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PSwing.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PSwingRepaintManager.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/swing/PDefaultScrollDirector.java /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/swing/SwingLayoutNode.java /piccolo2d.java/branches/2.0-spike/extras/src/test/java/org/piccolo2d/extras/pswing/PComboBoxTest.java /piccolo2d.java/branches/2.0-spike/extras/src/test/java/org/piccolo2d/extras/util/ShadowUtilsTest.java

=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/PFrame.java Tue Jan 19 12:49:37 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/PFrame.java Wed Jan 20 10:51:17 2010
@@ -244,7 +244,7 @@
      * @return best display mode the given device supports
      */
     protected DisplayMode getBestDisplayMode(final GraphicsDevice device) {
-        final Iterator itr = getPreferredDisplayModes(device).iterator();
+ final Iterator<DisplayMode> itr = getPreferredDisplayModes(device).iterator();
         while (itr.hasNext()) {
             final DisplayMode each = (DisplayMode) itr.next();
             final DisplayMode[] modes = device.getDisplayModes();
@@ -266,8 +266,8 @@
      * @param device the device being inspected
      * @return preferred display mode
      */
- protected Collection getPreferredDisplayModes(final GraphicsDevice device) {
-        final ArrayList result = new ArrayList();
+ protected Collection<DisplayMode> getPreferredDisplayModes(final GraphicsDevice device) {
+        final ArrayList<DisplayMode> result = new ArrayList<DisplayMode>();

         result.add(device.getDisplayMode());
         /*
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/activities/PPositionPathActivity.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/activities/PPositionPathActivity.java Wed Jan 20 10:51:17 2010
@@ -169,7 +169,7 @@
      */
     public void setPositions(final GeneralPath path) {
         final PathIterator pi = path.getPathIterator(null, 1);
-        final ArrayList points = new ArrayList();
+        final ArrayList<Point2D> points = new ArrayList<Point2D>();
         final float[] point = new float[6];
         float distanceSum = 0;
         float lastMoveToX = 0;
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PNavigationEventHandler.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PNavigationEventHandler.java Wed Jan 20 10:51:17 2010
@@ -60,7 +60,7 @@
  * @author Jesse Grosjean
  */
 public class PNavigationEventHandler extends PBasicInputEventHandler {
-    /** Minum size under which two scales are considered the same. */
+    /** Minimum size under which two scales are considered the same. */
     private static final double SCALING_THRESHOLD = 0.0001;
/** Amount of time it takes to animation view from one location to another. */
     private static final int NAVIGATION_DURATION = 500;
@@ -77,7 +77,7 @@
     /** The OUT direction on the scene. */
     public static final int OUT = 5;

- private static Hashtable NODE_TO_GLOBAL_NODE_CENTER_MAPPING = new Hashtable(); + private static Hashtable<PNode, Point2D> NODE_TO_GLOBAL_NODE_CENTER_MAPPING = new Hashtable<PNode, Point2D>();

     private PNode focusNode;
     private PTransformActivity navigationActivity;
@@ -263,12 +263,12 @@
final Point2D highlightCenter = focusNode.getGlobalFullBounds().getCenter2D();
         NODE_TO_GLOBAL_NODE_CENTER_MAPPING.put(focusNode, highlightCenter);

-        final List l = getNeighbors();
+        final List<PNode> l = getNeighbors();
         sortNodesByDistanceFromPoint(l, highlightCenter);

-        final Iterator i = l.iterator();
+        final Iterator<PNode> i = l.iterator();
         while (i.hasNext()) {
-            final PNode each = (PNode) i.next();
+            final PNode each = i.next();
             if (nodeIsNeighborInDirection(each, direction)) {
                 return each;
             }
@@ -283,18 +283,18 @@
      *
      * @return list of nodes that are 1 hop away from the current focusNode
      */
-    public List getNeighbors() {
-        final ArrayList result = new ArrayList();
+    public List<PNode> getNeighbors() {
+        final ArrayList<PNode> result = new ArrayList<PNode>();
         if (focusNode == null || focusNode.getParent() == null) {
             return result;
         }

         final PNode focusParent = focusNode.getParent();
-
-        final Iterator i = focusParent.getChildrenIterator();
+
+        final Iterator<PNode> i = focusParent.getChildrenIterator();

         while (i.hasNext()) {
-            final PNode each = (PNode) i.next();
+            final PNode each = i.next();
             if (each != focusNode && each.getPickable()) {
                 result.add(each);
             }
@@ -363,13 +363,9 @@
      * @param nodes list of nodes to be sorted
      * @param point point from which distance is being computed
      */
- public void sortNodesByDistanceFromPoint(final List nodes, final Point2D point) {
-        Collections.sort(nodes, new Comparator() {
-            public int compare(final Object o1, final Object o2) {
-                return compare((PNode) o1, (PNode) o2);
-            }
-
-            private int compare(final PNode each1, final PNode each2) {
+ public void sortNodesByDistanceFromPoint(final List<PNode> nodes, final Point2D point) {
+        Collections.sort(nodes, new Comparator<PNode>() {
+            public int compare(final PNode each1, final PNode each2) {
final Point2D center1 = each1.getGlobalFullBounds().getCenter2D(); final Point2D center2 = each2.getGlobalFullBounds().getCenter2D();

=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PNotification.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PNotification.java Wed Jan 20 10:51:17 2010
@@ -59,7 +59,7 @@
     /** The Object associated with this notification. */
     protected Object source;
     /** A free form map of properties to attach to this notification. */
-    protected Map properties;
+    protected Map<Object, Object> properties;

     /**
      * Creates a notification.
@@ -68,7 +68,7 @@
      * @param source object associated with this notification
* @param properties free form map of information about the notification
      */
- public PNotification(final String name, final Object source, final Map properties) { + public PNotification(final String name, final Object source, final Map<Object, Object> properties) {
         this.name = name;
         this.source = source;
         this.properties = properties;
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PNotificationCenter.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PNotificationCenter.java Wed Jan 20 10:51:17 2010
@@ -69,10 +69,10 @@
     protected  static volatile PNotificationCenter DEFAULT_CENTER;

     /** A map of listeners keyed by NotificationKey objects. */
-    protected HashMap listenersMap;
+ protected HashMap<NotificationKey, List<NotificationTarget>> listenersMap;

/** A queue of NotificationKeys that are available to be garbage collected. */
-    protected ReferenceQueue keyQueue;
+    protected ReferenceQueue<NotificationKey> keyQueue;

     /**
      * Singleton accessor for the PNotificationCenter.
@@ -87,8 +87,8 @@
     }

     private PNotificationCenter() {
-        listenersMap = new HashMap();
-        keyQueue = new ReferenceQueue();
+ listenersMap = new HashMap<NotificationKey, List<NotificationTarget>>();
+        keyQueue = new ReferenceQueue<NotificationKey>();
     }

     /**
@@ -122,9 +122,9 @@
final NotificationKey key = new NotificationKey(name, sanitizedObject); final NotificationTarget notificationTarget = new NotificationTarget(listener, method);

-        List list = (List) listenersMap.get(key);
+        List<NotificationTarget> list = listenersMap.get(key);
         if (list == null) {
-            list = new ArrayList();
+            list = new ArrayList<NotificationTarget>();
listenersMap.put(new NotificationKey(name, sanitizedObject, keyQueue), list);
         }

@@ -138,7 +138,7 @@
private Method extractCallbackMethod(final Object listener, final String methodName) {
         Method method = null;
         try {
-            Class[] classes = new Class[1];
+            Class<?>[] classes = new Class<?>[1];
             classes[0] = PNotification.class;
             method = listener.getClass().getMethod(methodName, classes);
         }
@@ -183,7 +183,7 @@
     public void removeListener(final Object listener) {
         processKeyQueue();

- final Iterator i = new LinkedList(listenersMap.keySet()).iterator(); + final Iterator<NotificationKey> i = new LinkedList<NotificationKey>(listenersMap.keySet()).iterator();
         while (i.hasNext()) {
             removeListener(listener, i.next());
         }
@@ -209,10 +209,9 @@
public void removeListener(final Object listener, final String notificationName, final Object object) {
         processKeyQueue();

-        final List keys = matchingKeys(notificationName, object);
-        final Iterator it = keys.iterator();
-        while (it.hasNext()) {
-            removeListener(listener, it.next());
+ final List<NotificationKey> keys = matchingKeys(notificationName, object);
+        for (NotificationKey key : keys) {
+            removeListener(listener, key);
         }
     }

@@ -253,7 +252,7 @@
      *            listeners
      */
     public void postNotification(final PNotification notification) {
-        final List mergedListeners = new LinkedList();
+ final List<NotificationTarget> mergedListeners = new LinkedList<NotificationTarget>();

         final Object name = notification.getName();
         final Object object = notification.getObject();
@@ -283,17 +282,17 @@
      * @param object source of the notification
      * @param listeners list to append listeners to
      */
- private void fillWithMatchingListeners(final Object notificationName, final Object object, final List listeners) { + private void fillWithMatchingListeners(final Object notificationName, final Object object, final List<NotificationTarget> listeners) { final Object key = new NotificationKey(nullify(notificationName), nullify(object));
-        final List globalListeners = (List) listenersMap.get(key);
+ final List<NotificationTarget> globalListeners = listenersMap.get(key);
         if (globalListeners != null) {
             listeners.addAll(globalListeners);
         }
     }

- private void dispatchNotifications(final PNotification notification, final List listeners) { + private void dispatchNotifications(final PNotification notification, final List<NotificationTarget> listeners) {
         NotificationTarget listener;
-        final Iterator listenerIterator = listeners.iterator();
+ final Iterator<NotificationTarget> listenerIterator = listeners.iterator();

         while (listenerIterator.hasNext()) {
             listener = (NotificationTarget) listenerIterator.next();
@@ -328,11 +327,11 @@
      *
      * @return list of matching keys
      */
-    protected List matchingKeys(final String name, final Object object) {
-        final List result = new LinkedList();
+ protected List<NotificationKey> matchingKeys(final String name, final Object object) { + final List<NotificationKey> result = new LinkedList<NotificationKey>();

final NotificationKey searchKey = new NotificationKey(name, object);
-        final Iterator it = listenersMap.keySet().iterator();
+ final Iterator<NotificationKey> it = listenersMap.keySet().iterator();
         while (it.hasNext()) {
             final NotificationKey key = (NotificationKey) it.next();
             if (searchKey.equals(key)) {
@@ -356,14 +355,14 @@
             return;
         }

-        final List list = (List) listenersMap.get(key);
+        final List<NotificationTarget> list = listenersMap.get(key);
         if (list == null) {
             return;
         }

-        final Iterator it = list.iterator();
+        final Iterator<NotificationTarget> it = list.iterator();
         while (it.hasNext()) {
-            final Object observer = ((NotificationTarget) it.next()).get();
+            final Object observer = it.next().get();
             if (observer == null || listener == observer) {
                 it.remove();
             }
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PSelectionEventHandler.java Tue Jan 19 13:09:08 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/event/PSelectionEventHandler.java Wed Jan 20 10:51:17 2010
@@ -53,7 +53,6 @@
 import org.piccolo2d.util.PDimension;
 import org.piccolo2d.util.PNodeFilter;

-
 /**
  * <code>PSelectionEventHandler</code> provides standard interaction for
  * selection. Clicking selects the object under the cursor. Shift-clicking
@@ -76,9 +75,9 @@
     private static final int NUM_STROKES = 10;

     /** The current selection. */
-    private HashMap selection = null;
+    private HashMap<PNode, Boolean> selection = null;
     /** List of nodes whose children can be selected. */
-    private List selectableParents = null;
+    private List<PNode> selectableParents = null;

     private PPath marquee = null;
     /** Node that marquee is added to as a child. */
@@ -90,11 +89,11 @@
     private Stroke[] strokes = null;

     /** Used within drag handler temporarily. */
-    private HashMap allItems = null;
+    private HashMap<PNode, Boolean> allItems = null;

     /** Used within drag handler temporarily. */
-    private ArrayList unselectList = null;
-    private HashMap marqueeMap = null;
+    private ArrayList<PNode> unselectList = null;
+    private HashMap<PNode, Boolean> marqueeMap = null;

     /** Node pressed on (or null if none). */
     private PNode pressNode = null;
@@ -118,7 +117,7 @@
      */
public PSelectionEventHandler(final PNode marqueeParent, final PNode selectableParent) {
         this.marqueeParent = marqueeParent;
-        selectableParents = new ArrayList();
+        selectableParents = new ArrayList<PNode>();
         selectableParents.add(selectableParent);
         init();
     }
@@ -131,7 +130,7 @@
* @param selectableParents A list of nodes whose children will be selected
      *            by this event handler.
      */
- public PSelectionEventHandler(final PNode marqueeParent, final List selectableParents) { + public PSelectionEventHandler(final PNode marqueeParent, final List<PNode> selectableParents) {
         this.marqueeParent = marqueeParent;
         this.selectableParents = selectableParents;
         init();
@@ -150,10 +149,10 @@
strokes[i] = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 1, dash, i);
         }

-        selection = new HashMap();
-        allItems = new HashMap();
-        unselectList = new ArrayList();
-        marqueeMap = new HashMap();
+        selection = new HashMap<PNode, Boolean>();
+        allItems = new HashMap<PNode, Boolean>();
+        unselectList = new ArrayList<PNode>();
+        marqueeMap = new HashMap<PNode, Boolean>();
     }

     /**
@@ -161,11 +160,9 @@
      *
      * @param items collection of items to be selected
      */
-    public void select(final Collection items) {
+    public void select(final Collection<PNode> items) {
         boolean changes = false;
-        final Iterator itemIt = items.iterator();
-        while (itemIt.hasNext()) {
-            final PNode node = (PNode) itemIt.next();
+        for (PNode node : items) {
             changes |= internalSelect(node);
         }
         if (changes) {
@@ -178,7 +175,7 @@
      *
      * @param items map where keys are to be selected
      */
-    public void select(final Map items) {
+    public void select(final Map<PNode, Boolean> items) {
         select(items.keySet());
     }

@@ -230,11 +227,9 @@
      *
      * @param items items to remove form the selection
      */
-    public void unselect(final Collection items) {
+    public void unselect(final Collection<PNode> items) {
         boolean changes = false;
-        final Iterator itemIt = items.iterator();
-        while (itemIt.hasNext()) {
-            final PNode node = (PNode) itemIt.next();
+        for (PNode node : items) {
             changes |= internalUnselect(node);
         }
         if (changes) {
@@ -285,7 +280,7 @@
     public void unselectAll() {
         // Because unselect() removes from selection, we need to
// take a copy of it first so it isn't changed while we're iterating
-        final ArrayList sel = new ArrayList(selection.keySet());
+ final ArrayList<PNode> sel = new ArrayList<PNode>(selection.keySet());
         unselect(sel);
     }

@@ -304,8 +299,8 @@
      *
      * @return copy of selection
      */
-    public Collection getSelection() {
-        return new ArrayList(selection.keySet());
+    public Collection<PNode> getSelection() {
+        return new ArrayList<PNode>(selection.keySet());
     }

     /**
@@ -314,7 +309,7 @@
      *
      * @return direct reference to selection
      */
-    public Collection getSelectionReference() {
+    public Collection<PNode> getSelectionReference() {
         return Collections.unmodifiableCollection(selection.keySet());
     }

@@ -328,16 +323,13 @@
     protected boolean isSelectable(final PNode node) {
         boolean selectable = false;

-        final Iterator parentsIt = selectableParents.iterator();
-        while (parentsIt.hasNext()) {
-            final PNode parent = (PNode) parentsIt.next();
+        for (PNode parent : selectableParents) {
             if (parent.getChildrenReference().contains(node)) {
                 selectable = true;
                 break;
             }
             else if (parent instanceof PCamera) {
- for (int i = 0; i < ((PCamera) parent).getLayerCount(); i++) {
-                    final PLayer layer = ((PCamera) parent).getLayer(i);
+ for (PLayer layer : ((PCamera) parent).getLayersReference()) {
                     if (layer.getChildrenReference().contains(node)) {
                         selectable = true;
                         break;
@@ -385,7 +377,7 @@
      *
      * @param c nodes to become selectable parents.
      */
-    public void setSelectableParents(final Collection c) {
+    public void setSelectableParents(final Collection<PNode> c) {
         selectableParents.clear();
         selectableParents.addAll(c);
     }
@@ -395,8 +387,8 @@
      *
      * @return selectable parents
      */
-    public Collection getSelectableParents() {
-        return new ArrayList(selectableParents);
+    public Collection<PNode> getSelectableParents() {
+        return new ArrayList<PNode>(selectableParents);
     }

     // //////////////////////////////////////////////////////
@@ -606,24 +598,20 @@

         allItems.clear();
         final PNodeFilter filter = createNodeFilter(b);
-        final Iterator parentsIt = selectableParents.iterator();
-        while (parentsIt.hasNext()) {
-            final PNode parent = (PNode) parentsIt.next();
-
-            Collection items;
+        for (PNode parent : selectableParents) {
+            Collection<PNode> items;
             if (parent instanceof PCamera) {
-                items = new ArrayList();
- for (int i = 0; i < ((PCamera) parent).getLayerCount(); i++) { - ((PCamera) parent).getLayer(i).getAllNodes(filter, items);
+                items = new ArrayList<PNode>();
+ for (PLayer layer : ((PCamera)parent).getLayersReference()) {
+                    layer.getAllNodes(filter, items);
                 }
             }
             else {
                 items = parent.getAllNodes(filter, null);
             }

-            final Iterator itemsIt = items.iterator();
-            while (itemsIt.hasNext()) {
-                allItems.put(itemsIt.next(), Boolean.TRUE);
+            for (PNode item : items) {
+                allItems.put(item, Boolean.TRUE);
             }
         }
     }
@@ -637,9 +625,7 @@
         unselectList.clear();
         // Make just the items in the list selected
         // Do this efficiently by first unselecting things not in the list
-        Iterator selectionEn = selection.keySet().iterator();
-        while (selectionEn.hasNext()) {
-            final PNode node = (PNode) selectionEn.next();
+        for (PNode node : selection.keySet()) {
             if (!allItems.containsKey(node)) {
                 unselectList.add(node);
             }
@@ -647,7 +633,7 @@
         unselect(unselectList);

         // Then select the rest
-        selectionEn = allItems.keySet().iterator();
+        Iterator<PNode> selectionEn = allItems.keySet().iterator();
         while (selectionEn.hasNext()) {
             final PNode node = (PNode) selectionEn.next();
if (!selection.containsKey(node) && !marqueeMap.containsKey(node) && isSelectable(node)) {
@@ -668,9 +654,8 @@
      */
     protected void computeOptionMarqueeSelection(final PInputEvent pie) {
         unselectList.clear();
-        Iterator selectionEn = selection.keySet().iterator();
-        while (selectionEn.hasNext()) {
-            final PNode node = (PNode) selectionEn.next();
+
+        for (PNode node : selection.keySet()) {
if (!allItems.containsKey(node) && marqueeMap.containsKey(node)) {
                 marqueeMap.remove(node);
                 unselectList.add(node);
@@ -679,7 +664,7 @@
         unselect(unselectList);

         // Then select the rest
-        selectionEn = allItems.keySet().iterator();
+        Iterator<PNode> selectionEn = allItems.keySet().iterator();
         while (selectionEn.hasNext()) {
             final PNode node = (PNode) selectionEn.next();
if (!selection.containsKey(node) && !marqueeMap.containsKey(node) && isSelectable(node)) {
@@ -728,10 +713,8 @@
         e.getTopCamera().localToView(d);

         final PDimension gDist = new PDimension();
-        final Iterator selectionEn = getSelection().iterator();
-        while (selectionEn.hasNext()) {
-            final PNode node = (PNode) selectionEn.next();
-
+
+        for (PNode node : getSelection()) {
             gDist.setSize(d);
             node.getParent().globalToLocal(gDist);
             node.offset(gDist.getWidth(), gDist.getHeight());
@@ -785,9 +768,7 @@
      */
     public void keyPressed(final PInputEvent e) {
         if (e.getKeyCode() == KeyEvent.VK_DELETE && deleteKeyActive) {
-            final Iterator selectionEn = selection.keySet().iterator();
-            while (selectionEn.hasNext()) {
-                final PNode node = (PNode) selectionEn.next();
+            for (PNode node : selection.keySet()) {
                 node.removeFromParent();
             }
             selection.clear();
@@ -871,8 +852,7 @@
          */
         public boolean isCameraLayer(final PNode node) {
             if (node instanceof PLayer) {
- for (final Iterator i = selectableParents.iterator(); i.hasNext();) {
-                    final PNode parent = (PNode) i.next();
+                for (PNode parent : selectableParents) {
if (parent instanceof PCamera && ((PCamera) parent).indexOfLayer((PLayer) node) != -1) {
                         return true;
                     }
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/handles/PBoundsHandle.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/handles/PBoundsHandle.java Wed Jan 20 10:51:17 2010
@@ -31,7 +31,6 @@
 import java.awt.Cursor;
 import java.awt.geom.Point2D;
 import java.util.ArrayList;
-import java.util.Iterator;

 import javax.swing.SwingConstants;

@@ -104,13 +103,11 @@
      * @param node node having its handles removed from
      */
     public static void removeBoundsHandlesFrom(final PNode node) {
-        final ArrayList handles = new ArrayList();
-
-        final Iterator i = node.getChildrenIterator();
-        while (i.hasNext()) {
-            final PNode each = (PNode) i.next();
+ final ArrayList<PBoundsHandle> handles = new ArrayList<PBoundsHandle>();
+
+        for (PNode each : node.getChildrenReference()) {
             if (each instanceof PBoundsHandle) {
-                handles.add(each);
+                handles.add((PBoundsHandle)each);
             }
         }
         node.removeChildren(handles);
@@ -259,11 +256,9 @@
      * @param flipY whether to allow flipping along the y direction
      */
public void flipSiblingBoundsHandles(final boolean flipX, final boolean flipY) {
-        final Iterator i = getParent().getChildrenIterator();
-        while (i.hasNext()) {
-            final Object each = i.next();
-            if (each instanceof PBoundsHandle) {
-                ((PBoundsHandle) each).flipHandleIfNeeded(flipX, flipY);
+        for (PNode child : getParent().getChildrenReference()) {
+            if (child instanceof PBoundsHandle) {
+                ((PBoundsHandle) child).flipHandleIfNeeded(flipX, flipY);
             }
         }
     }
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/nodes/PStyledText.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/nodes/PStyledText.java Wed Jan 20 10:51:17 2010
@@ -78,7 +78,7 @@
     protected Document document;

     /** String contents of the document. */
-    protected transient ArrayList stringContents;
+    protected transient ArrayList<AttributedString> stringContents;

     /** Tracks the information about line metrics within the document. */
     protected transient LineInfo[] lines;
@@ -174,7 +174,7 @@
      */
     public void syncWithDocument() {
         // First get the actual text and stick it in an Attributed String
-        stringContents = new ArrayList();
+        stringContents = new ArrayList<AttributedString>();

         String documentString;
         try {
@@ -188,7 +188,7 @@
         }

         // The paragraph start and end indices
-        final ArrayList pEnds = extractParagraphRanges(documentString);
+ final ArrayList<RunInfo> pEnds = extractParagraphRanges(documentString);

         // The default style context - which will be reused
final StyleContext styleContext = StyleContext.getDefaultStyleContext();
@@ -198,11 +198,11 @@

         AttributedString attributedString;

-        final Iterator contentIterator = stringContents.iterator();
-        final Iterator paragraphIterator = pEnds.iterator();
+ final Iterator<AttributedString> contentIterator = stringContents.iterator();
+        final Iterator<RunInfo> paragraphIterator = pEnds.iterator();
         while (contentIterator.hasNext() && paragraphIterator.hasNext()) {
-            paragraphRange = (RunInfo) paragraphIterator.next();
-            attributedString = (AttributedString) contentIterator.next();
+            paragraphRange = paragraphIterator.next();
+            attributedString = contentIterator.next();
             pos = paragraphRange.startIndex;

             // The current element will be used as a temp variable while
@@ -356,9 +356,9 @@
         return font;
     }

-    private ArrayList extractParagraphRanges(final String documentString) {
+ private ArrayList<RunInfo> extractParagraphRanges(final String documentString) {
         // The paragraph start and end indices
-        final ArrayList paragraphRanges = new ArrayList();
+ final ArrayList<RunInfo> paragraphRanges = new ArrayList<RunInfo>();

         // The current position in the specified range
         int pos = 0;
@@ -427,19 +427,19 @@
             return;
         }

-        final ArrayList linesList = new ArrayList();
+        final ArrayList<LineInfo> linesList = new ArrayList<LineInfo>();

         double textWidth = 0;
         double textHeight = 0;

-        final Iterator contentIterator = stringContents.iterator();
+ final Iterator<AttributedString> contentIterator = stringContents.iterator();

         while (contentIterator.hasNext()) {
final AttributedString ats = (AttributedString) contentIterator.next();
             final AttributedCharacterIterator itr = ats.getIterator();

             LineBreakMeasurer measurer;
-            ArrayList breakList = null;
+            ArrayList<Integer> breakList = null;

             measurer = new LineBreakMeasurer(itr, SWING_FRC);
             breakList = extractLineBreaks(itr, measurer);
@@ -541,9 +541,8 @@

     // Because swing doesn't use fractional font metrics by default, we use
     // LineBreakMeasurer to find out where Swing is going to break them
- private ArrayList extractLineBreaks(final AttributedCharacterIterator itr, final LineBreakMeasurer measurer) {
-        ArrayList breakList;
-        breakList = new ArrayList();
+ private ArrayList<Integer> extractLineBreaks(final AttributedCharacterIterator itr, final LineBreakMeasurer measurer) {
+        ArrayList<Integer> breakList = new ArrayList<Integer>();
         while (measurer.getPosition() < itr.getEndIndex()) {
             if (constrainWidthToTextWidth) {
                 measurer.nextLayout(Float.MAX_VALUE);
@@ -742,7 +741,7 @@
      */
     protected static class LineInfo {
         /** Segments which make up this line's formatting segments. */
-        public List segments;
+        public List<SegmentInfo> segments;

         /** Maximum of the line segments' ascents. */
         public double maxAscent;
@@ -757,7 +756,7 @@
          * Creates a LineInfo that contains no segments.
          */
         public LineInfo() {
-            segments = new ArrayList();
+            segments = new ArrayList<SegmentInfo>();
         }
     }

=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PComboBox.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PComboBox.java Wed Jan 20 10:51:17 2010
@@ -104,7 +104,7 @@
      *
      * @param items The items to populate the PComboBox list
      */
-    public PComboBox(final Vector items) {
+    public PComboBox(final Vector<?> items) {
         super(items);
         init();
     }
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PSwing.java Tue Jan 19 12:49:37 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PSwing.java Wed Jan 20 10:51:17 2010
@@ -239,7 +239,7 @@
* Used to keep track of which nodes we've attached listeners to since no
      * built in support in PNode.
      */
-    private final ArrayList listeningTo = new ArrayList();
+    private final ArrayList<PNode> listeningTo = new ArrayList<PNode>();

     /** The parent listener for camera/canvas changes. */
private final PropertyChangeListener parentListener = new PropertyChangeListener() {
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PSwingRepaintManager.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/pswing/PSwingRepaintManager.java Wed Jan 20 10:51:17 2010
@@ -76,7 +76,7 @@

     // The components that are currently painting
     // This needs to be a vector for thread safety
-    private final Vector paintingComponents = new Vector();
+ private final Vector<JComponent> paintingComponents = new Vector<JComponent>();

     /**
* Locks repaint for a particular (Swing) component displayed by PCanvas.
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/swing/PDefaultScrollDirector.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/swing/PDefaultScrollDirector.java Wed Jan 20 10:51:17 2010
@@ -34,8 +34,6 @@
 import java.awt.geom.Rectangle2D;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
-import java.util.Iterator;
-import java.util.List;

 import javax.swing.ScrollPaneConstants;

@@ -47,7 +45,6 @@
 import org.piccolo2d.util.PAffineTransform;
 import org.piccolo2d.util.PBounds;

-
 /**
  * The default scroll director implementation. This default implementation
  * follows the widely accepted model of scrolling - namely the scrollbars
@@ -139,9 +136,8 @@
         if (camera != null) {
             // First we compute the union of all the layers
             final PBounds layerBounds = new PBounds();
-            final List layers = camera.getLayersReference();
-            for (final Iterator i = layers.iterator(); i.hasNext();) {
-                final PLayer layer = (PLayer) i.next();
+
+            for (PLayer layer : camera.getLayersReference()) {
                 layerBounds.add(layer.getFullBoundsReference());
             }

@@ -169,9 +165,8 @@
         if (camera != null) {
             // First we compute the union of all the layers
             final PBounds bounds = new PBounds();
-            final List layers = camera.getLayersReference();
-            for (final Iterator i = layers.iterator(); i.hasNext();) {
-                final PLayer layer = (PLayer) i.next();
+
+            for (PLayer layer : camera.getLayersReference()) {
                 bounds.add(layer.getFullBoundsReference());
             }

@@ -205,9 +200,8 @@

         // Get the union of all the layers' bounds
         final PBounds layerBounds = new PBounds();
-        final List layers = camera.getLayersReference();
-        for (final Iterator i = layers.iterator(); i.hasNext();) {
-            final PLayer layer = (PLayer) i.next();
+
+        for (PLayer layer : camera.getLayersReference()) {
             layerBounds.add(layer.getFullBoundsReference());
         }

@@ -258,7 +252,8 @@
     }

     private boolean isBoundsChangedEvent(final PropertyChangeEvent pce) {
- return PNode.PROPERTY_BOUNDS.equals(pce.getPropertyName()) || PNode.PROPERTY_FULL_BOUNDS.equals(pce.getPropertyName());
+        return PNode.PROPERTY_BOUNDS.equals(pce.getPropertyName())
+ || PNode.PROPERTY_FULL_BOUNDS.equals(pce.getPropertyName());
     }

     /**
@@ -277,9 +272,7 @@

             // Get the union of all the layers' bounds
             final PBounds layerBounds = new PBounds();
-            final List layers = camera.getLayersReference();
-            for (final Iterator i = layers.iterator(); i.hasNext();) {
-                final PLayer layer = (PLayer) i.next();
+            for (PLayer layer : camera.getLayersReference()) {
                 layerBounds.add(layer.getFullBoundsReference());
             }

=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/swing/SwingLayoutNode.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/main/java/org/piccolo2d/extras/swing/SwingLayoutNode.java Wed Jan 20 10:51:17 2010
@@ -254,16 +254,14 @@
      *            the child
      * @param anchor specifies the location from which layout takes place
      */
- public void addChildren(final Collection nodes, final Object constraints, final Anchor anchor) {
-        final Iterator i = nodes.iterator();
-        while (i.hasNext()) {
-            final PNode each = (PNode) i.next();
-            addChild(each, constraints, anchor);
+ public void addChildren(final Collection<PNode> nodes, final Object constraints, final Anchor anchor) {
+        for (PNode node : nodes) {
+            addChild(node, constraints, anchor);
         }
     }

     /** {...@inheritdoc} */
-    public void addChildren(final Collection nodes) {
+    public void addChildren(final Collection<PNode> nodes) {
         addChildren(nodes, null, defaultAnchor);
     }

@@ -274,7 +272,7 @@
* @param constraints constraints the layout manager uses when laying out
      *            the child
      */
- public void addChildren(final Collection nodes, final Object constraints) { + public void addChildren(final Collection<PNode> nodes, final Object constraints) {
         addChildren(nodes, constraints, defaultAnchor);
     }

@@ -284,7 +282,7 @@
      * @param nodes nodes to add to the end of the list
      * @param anchor specifies the location from which layout takes place
      */
-    public void addChildren(final Collection nodes, final Anchor anchor) {
+ public void addChildren(final Collection<PNode> nodes, final Anchor anchor) {
         addChildren(nodes, null, anchor);
     }

@@ -318,9 +316,9 @@
      * less efficient) manner.
      */
     public void removeAllChildren() {
-        final Iterator i = getChildrenIterator();
+        final Iterator<PNode> i = getChildrenIterator();
         while (i.hasNext()) {
-            removeChild((PNode) i.next());
+            removeChild(i.next());
         }
     }

=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/test/java/org/piccolo2d/extras/pswing/PComboBoxTest.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/test/java/org/piccolo2d/extras/pswing/PComboBoxTest.java Wed Jan 20 10:51:17 2010
@@ -48,7 +48,7 @@
     }

     public void testConstructsWithVector() {
-        final Vector items = new Vector();
+        final Vector<String> items = new Vector<String>();
         items.add("A");
         items.add("B");
         final PComboBox combo = new PComboBox(items);
=======================================
--- /piccolo2d.java/branches/2.0-spike/extras/src/test/java/org/piccolo2d/extras/util/ShadowUtilsTest.java Tue Jan 19 12:39:24 2010 +++ /piccolo2d.java/branches/2.0-spike/extras/src/test/java/org/piccolo2d/extras/util/ShadowUtilsTest.java Wed Jan 20 10:51:17 2010
@@ -33,10 +33,6 @@
 import java.awt.Paint;
 import java.awt.image.BufferedImage;

-import org.piccolo2d.extras.nodes.PShadow;
-import org.piccolo2d.extras.util.ShadowUtils;
-
-
 import junit.framework.TestCase;

 /**
-- 
Piccolo2D Developers Group: http://groups.google.com/group/piccolo2d-dev?hl=en

Reply via email to