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/07/13 17:19:14 UTC
svn commit: r793608 - in
/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk: Component.java
effects/Decorator.java
Author: gbrown
Date: Mon Jul 13 15:19:14 2009
New Revision: 793608
URL: http://svn.apache.org/viewvc?rev=793608&view=rev
Log:
Eliminate Component dependency on weak hash map; improve Decorator Javadoc.
Modified:
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java?rev=793608&r1=793607&r2=793608&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/Component.java Mon Jul 13 15:19:14 2009
@@ -628,7 +628,7 @@
private static int nextHandle = 0;
// Map of all components by handle
- private static HashMap<Integer, Component> components = new HashMap<Integer, Component>(true);
+ private static HashMap<Integer, Component> components = new HashMap<Integer, Component>();
private static ComponentDictionary componentDictionary = new ComponentDictionary();
// Class event listeners
@@ -639,16 +639,6 @@
*/
public Component() {
handle = nextHandle++;
- components.put(handle, this);
- }
-
- @Override
- protected void finalize() throws Throwable {
- try {
- components.remove(handle);
- } finally {
- super.finalize();
- }
}
/**
@@ -761,6 +751,12 @@
clearFocus();
}
+ if (parent == null) {
+ components.remove(handle);
+ } else {
+ components.put(handle, this);
+ }
+
Container previousParent = this.parent;
this.parent = parent;
Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java?rev=793608&r1=793607&r2=793608&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/Decorator.java Mon Jul 13 15:19:14 2009
@@ -26,6 +26,26 @@
/**
* Interface defining a component "decorator". Decorators allow a caller to
* attach additional visual effects to a component.
+ * <p>
+ * Decorators use a chained prepare/update model to modify the graphics in
+ * which a component is painted. The <tt>prepare()</tt> method of each decorator
+ * in a component's decorator sequence is called in reverse order before the
+ * component's <tt>paint()</tt> method is called. <tt>prepare()</tt> returns
+ * an instance of <tt>Graphics2D</tt> that is passed to prior decorators,
+ * and ultimately to the component itself. This allows decorators to modify the
+ * graphics context before it reaches the component. After the component has
+ * been painted, each decorator's <tt>update()</tt> method is then called in
+ * order to allow the decorator to further modify the resulting output.
+ * <p>
+ * Decorators are not restricted to painting within the component's bounds.
+ * However, they are clipped to the bounds of the component's parent. They are
+ * not clipped to their own bounds because, due to the chained painting model,
+ * it is not safe assume that a clip applied to a given decorator during the
+ * prepare phase will be valid for subsequent updates, or even for painting the
+ * component itself; though a component paints into a copy of the final prepared
+ * graphics, it must still be clipped to the intersection of its own bounds and
+ * the current clip (not the intersections of all preceding decorator prepare()
+ * calls).
*
* @author gbrown
*/