Revision: 3491
Author: [email protected]
Date: Tue May  4 14:26:07 2010
Log: The "bounds" property for PlayPenComponents is no longer persisted. We do not need to know the size of each component, only the location. Zoom level is independent of each client. A "location" property is now being persisted instead.

In order to draw the components correctly, it requires knowledge of the table and key names, as well as a reference to the PlayPen to calculate the preferred size of the components. The code has modified to revalidate the components when the "location" property is set or when the PlayPen is initially set in the PlayPenContentPane.
http://code.google.com/p/power-architect/source/detail?r=3491

Modified:
 /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java
 /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java

=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java Fri Apr 23 14:24:33 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenComponent.java Tue May 4 14:26:07 2010
@@ -252,7 +252,7 @@
         setBounds(new Rectangle(x, y, width, height));
     }

-    @Mutator
+    @Transient @Mutator
     public void setBounds(Rectangle r) {
         Rectangle oldBounds = getBounds();
         repaint();
@@ -271,7 +271,7 @@
     /**
      * Returns a copy of this component's bounding rectangle.
      */
-    @Accessor
+    @Transient @Accessor
     public Rectangle getBounds() {
         return getBounds(null);
     }
@@ -341,7 +341,7 @@
      * create a new point for you.
      * @return p if p was not null; a new point otherwise.
      */
-    @Transient @Accessor
+    @Accessor
     public Point getLocation(Point p) {
         if (p == null) p = new Point();
         p.x = bounds.x;
@@ -354,9 +354,28 @@
* component to a negative co-ordinate, it will automatically be normalized (along
      * with everything else in the playpen) to non-negative coordinates.
      */
-    @Transient @Mutator
+    @Mutator
     public void setLocation(Point point) {
-        setBounds(point.x,point.y, getWidth(), getHeight());
+        Point oldLocation = bounds.getLocation();
+
+        int width = getWidth();
+        int height = getHeight();
+
+        if (getPlayPen() != null) {
+            PlayPenComponentUI ui = getUI();
+
+            if (ui != null) {
+                ui.revalidate();
+                Dimension ps = ui.getPreferredSize();
+                if (ps != null) {
+                    width = ps.width;
+                    height = ps.height;
+                }
+            }
+        }
+
+        setBounds(point.x,point.y, width, height);
+        firePropertyChange("location", oldLocation, point);
     }

     /**
@@ -366,7 +385,7 @@
      */
     @Transient @Mutator
     public void setLocation(int x, int y) {
-        setBounds(x, y, getWidth(), getHeight());
+        setLocation(new Point(x, y));
     }

     @NonBound
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java Fri Apr 30 15:31:53 2010 +++ /trunk/src/main/java/ca/sqlpower/architect/swingui/PlayPenContentPane.java Tue May 4 14:26:07 2010
@@ -149,6 +149,10 @@
         if (owner != null) {
owner.addPropertyChangeListener("zoom", new ZoomFixer()); //$NON-NLS-1$
             firePropertyChange("playPen", null, owner);
+
+            for (PlayPenComponent ppc : getChildren()) {
+                ppc.revalidate();
+            }
         }
     }

Reply via email to