From tchemit@users.labs.libre-entreprise.org Mon Mar  9 01:35:44 2009
From: tchemit@users.labs.libre-entreprise.org
To: buix-commits@list.nuiton.org
Subject: [Buix-commits] r1259 - in jaxx/trunk/jaxx-runtime-swing: .
	src/main/java/jaxx/runtime/swing
Date: Mon, 09 Mar 2009 01:35:43 +0100
Message-ID: <20090309003543.DFCC1461BF3@labs.libre-entreprise.org>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="===============8812256059794018926=="

--===============8812256059794018926==
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable

Author: tchemit
Date: 2009-03-09 00:35:43 +0000 (Mon, 09 Mar 2009)
New Revision: 1259

Modified:
   jaxx/trunk/jaxx-runtime-swing/changelog.txt
   jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLay=
erUI.java
Log:
in BlockingLayerUI, add a new state 'block' to enable/disable blocking mode w=
ith a blockingColor

Modified: jaxx/trunk/jaxx-runtime-swing/changelog.txt
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jaxx/trunk/jaxx-runtime-swing/changelog.txt	2009-03-04 23:12:53 UTC (rev =
1258)
+++ jaxx/trunk/jaxx-runtime-swing/changelog.txt	2009-03-09 00:35:43 UTC (rev =
1259)
@@ -1,4 +1,5 @@
 1.3 ?? 200903??
+ * 20090309 [chemit] - in BlockingLayerUI, add a new state 'block' to enable=
/disable blocking mode with a blockingColor
  * 20090303 [chemit] - in BlockingLayerUI, add a new state 'useIcon' to enab=
le/disable use of the action icon
                      - add a simple WizardModel
  * 20090301 [chemit] - add usefull methods in JAXXButtonGroup

Modified: jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/Bloc=
kingLayerUI.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLa=
yerUI.java	2009-03-04 23:12:53 UTC (rev 1258)
+++ jaxx/trunk/jaxx-runtime-swing/src/main/java/jaxx/runtime/swing/BlockingLa=
yerUI.java	2009-03-09 00:35:43 UTC (rev 1259)
@@ -1,8 +1,12 @@
 package jaxx.runtime.swing;
=20
+import java.awt.AlphaComposite;
+import java.awt.Color;
 import java.awt.Component;
 import java.awt.Graphics2D;
+import java.awt.Insets;
 import java.awt.Point;
+import java.awt.Rectangle;
 import java.awt.RenderingHints;
 import java.awt.event.ActionEvent;
 import java.awt.event.KeyEvent;
@@ -34,6 +38,7 @@
     public static final String CAN_CLICK_PROPERTY =3D "canClick";
     public static final String ACCEPT_ICON_PROPERTY =3D "acceptIcon";
     public static final String BLOCK_ICON_PROPERTY =3D "blockIcon";
+    public static final String BLOCK_PROPERTY =3D "block";
     private static final long serialVersionUID =3D 1L;
     /**
      * Action to be treated when click on icon
@@ -48,6 +53,10 @@
      */
     protected BufferedImage acceptIcon;
     /**
+     * Optinal color to put fill background when blocking
+     */
+    protected Color blockingColor;
+    /**
      * Internal state to known when we can accept click
      */
     protected boolean canClick;
@@ -60,6 +69,10 @@
      * By default, this is active.
      */
     protected boolean useIcon =3D true;
+    /**
+     * Internal state when should block event and paint layer
+     */
+    protected boolean block;
=20
     public void setAcceptAction(Action acceptAction) {
         this.acceptAction =3D acceptAction;
@@ -86,6 +99,28 @@
         }
     }
=20
+    public void setBlock(boolean block) {
+        boolean oldvalue =3D this.block;
+        this.block =3D block;
+        firePropertyChange(BLOCK_PROPERTY, oldvalue, block);
+        if (oldvalue !=3D block) {
+            setDirty(true);
+        }
+    }
+
+    @Override
+    public void setDirty(boolean isDirty) {
+        super.setDirty(isDirty);
+    }
+
+    public void setBlockIcon(BufferedImage blockIcon) {
+        this.blockIcon =3D blockIcon;
+    }
+
+    public void setBlockingColor(Color blockingColor) {
+        this.blockingColor =3D blockingColor;
+    }
+
     public BufferedImage getBlockIcon() {
         return blockIcon;
     }
@@ -99,7 +134,11 @@
     }
=20
     public void setUseIcon(boolean useIcon) {
+        boolean oldvalue =3D this.useIcon;
         this.useIcon =3D useIcon;
+        if (oldvalue !=3D useIcon) {
+            setDirty(true);
+        }
     }
=20
     @Override
@@ -109,13 +148,17 @@
         clone.acceptIcon =3D acceptIcon;
         clone.blockIcon =3D blockIcon;
         clone.useIcon =3D useIcon;
+        clone.block =3D block;
+        clone.blockingColor =3D blockingColor;
         clone.setCanClick(false);
         return clone;
     }
=20
     @Override
     protected void processKeyEvent(KeyEvent e, JXLayer<JComponent> l) {
-        e.consume();
+        if (useIcon || block) {
+            e.consume();
+        }
     }
=20
     @Override
@@ -123,7 +166,9 @@
         if (useIcon) {
             updateCanClickState(l, e);
         }
-        e.consume();
+        if (useIcon || block) {
+            e.consume();
+        }
     }
=20
     @Override
@@ -143,12 +188,32 @@
                     break;
             }
         }
-        e.consume();
+        if (useIcon || block) {
+            e.consume();
+        }
+
     }
=20
     @Override
     protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) {
         super.paintLayer(g2, l);
+        if (block && blockingColor !=3D null) {
+            // to be in sync with the view if the layer has a border
+            /*Insets layerInsets =3D l.getInsets();
+            g2.translate(layerInsets.left, layerInsets.top);
+
+            JComponent view =3D l.getView();
+            // To prevent painting on view's border
+            Insets insets =3D view.getInsets();
+            g2.clip(new Rectangle(insets.left, insets.top,
+            view.getWidth() - insets.left - insets.right,
+            view.getHeight() - insets.top - insets.bottom));
+             */
+
+            g2.setColor(blockingColor);
+            g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OV=
ER, .1f));
+            g2.fillRect(0, 0, l.getWidth(), l.getHeight());
+        }
         if (useIcon && getCurrentIcon() !=3D null) {
             g2.drawImage(getCurrentIcon(), l.getWidth() - getCurrentIcon().g=
etWidth() - 1, 0, null);
         }


--===============8812256059794018926==--


