Author: kono
Date: 2009-12-03 14:31:28 -0800 (Thu, 03 Dec 2009)
New Revision: 18647

Modified:
   cytoscape/trunk/src/cytoscape/visual/ui/PopupLabelPositionChooser.java
   cytoscape/trunk/src/cytoscape/visual/ui/ValueDisplayer.java
   
cytoscape/trunk/src/cytoscape/visual/ui/editors/discrete/CyLabelPositionPropertyEditor.java
Log:
Label position default value bug fixed.

Modified: cytoscape/trunk/src/cytoscape/visual/ui/PopupLabelPositionChooser.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/ui/PopupLabelPositionChooser.java      
2009-12-03 21:58:26 UTC (rev 18646)
+++ cytoscape/trunk/src/cytoscape/visual/ui/PopupLabelPositionChooser.java      
2009-12-03 22:31:28 UTC (rev 18647)
@@ -36,20 +36,13 @@
  */
 package cytoscape.visual.ui;
 
-import cytoscape.visual.LabelPosition;
-import cytoscape.Cytoscape;
-import cytoscape.visual.parsers.ObjectToString;
-import cytoscape.visual.VisualPropertyType;
-
+import giny.model.GraphObject;
 import giny.view.Label;
-import giny.model.GraphObject;
 
-
 import java.awt.Dialog;
 import java.awt.Frame;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
@@ -58,38 +51,53 @@
 import javax.swing.JDialog;
 import javax.swing.JPanel;
 
+import cytoscape.Cytoscape;
+import cytoscape.visual.LabelPosition;
+import cytoscape.visual.VisualPropertyType;
+import cytoscape.visual.parsers.ObjectToString;
 
 /**
  *
  */
-public class PopupLabelPositionChooser extends JDialog implements 
PropertyChangeListener {
+public class PopupLabelPositionChooser extends JDialog implements
+               PropertyChangeListener {
        protected LabelPosition lp;
        protected LabelPosition newlp;
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param f DOCUMENT ME!
-        * @param pos DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param f
+        *            DOCUMENT ME!
+        * @param pos
+        *            DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public static LabelPosition showDialog(Dialog f, LabelPosition pos) {
-               PopupLabelPositionChooser placer = new 
PopupLabelPositionChooser(f, true, pos);
+               PopupLabelPositionChooser placer = new 
PopupLabelPositionChooser(f,
+                               true, pos);
 
                return placer.getLabelPosition();
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param f DOCUMENT ME!
-        * @param pos DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param f
+        *            DOCUMENT ME!
+        * @param pos
+        *            DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public static LabelPosition showDialog(Frame f, LabelPosition pos) {
-               PopupLabelPositionChooser placer = new 
PopupLabelPositionChooser(f, true, pos);
+               final LabelPosition position = (LabelPosition) Cytoscape
+                               .getVisualMappingManager().getVisualStyle()
+                               
.getNodeAppearanceCalculator().getDefaultAppearance().get(
+                                               
VisualPropertyType.NODE_LABEL_POSITION);
+               PopupLabelPositionChooser placer = new 
PopupLabelPositionChooser(f,
+                               true, position);
 
                return placer.getLabelPosition();
        }
@@ -106,7 +114,8 @@
 
        private void init(LabelPosition pos) {
                if (pos == null)
-                       lp = new LabelPosition(Label.NONE, Label.NONE, 
Label.JUSTIFY_CENTER, 0.0, 0.0);
+                       lp = new LabelPosition(Label.NONE, Label.NONE,
+                                       Label.JUSTIFY_CENTER, 0.0, 0.0);
                else
                        lp = pos;
 
@@ -116,11 +125,13 @@
 
                JPanel placer = new JPanel();
                placer.setLayout(new BoxLayout(placer, BoxLayout.Y_AXIS));
-               placer.setOpaque(true); //content panes must be opaque
+               placer.setOpaque(true); // content panes must be opaque
 
-               //Set up and connect the gui components.
-               LabelPlacerGraphic graphic = new LabelPlacerGraphic(new 
LabelPosition(lp));
-               LabelPlacerControl control = new LabelPlacerControl(new 
LabelPosition(lp));
+               // Set up and connect the gui components.
+               LabelPlacerGraphic graphic = new LabelPlacerGraphic(new 
LabelPosition(
+                               lp));
+               LabelPlacerControl control = new LabelPlacerControl(new 
LabelPosition(
+                               lp));
 
                control.addPropertyChangeListener(graphic);
                control.addPropertyChangeListener(this);
@@ -134,19 +145,19 @@
                JPanel buttonPanel = new JPanel();
                final JButton ok = new JButton("OK");
                ok.addActionListener(new ActionListener() {
-                               public void actionPerformed(ActionEvent e) {
-                                       lp = newlp;
-                                       dispose();
-                               }
-                       });
+                       public void actionPerformed(ActionEvent e) {
+                               lp = newlp;
+                               dispose();
+                       }
+               });
                ok.addActionListener(control);
 
                final JButton cancel = new JButton("Cancel");
                cancel.addActionListener(new ActionListener() {
-                               public void actionPerformed(ActionEvent e) {
-                                       dispose();
-                               }
-                       });
+                       public void actionPerformed(ActionEvent e) {
+                               dispose();
+                       }
+               });
 
                buttonPanel.add(ok);
                buttonPanel.add(cancel);
@@ -172,11 +183,14 @@
 
                        // horrible, horrible hack
                        GraphObject go = BypassHack.getCurrentObject();
-                       if ( go != null ) {
+                       if (go != null) {
                                String val = 
ObjectToString.getStringValue(newlp);
-                               
Cytoscape.getNodeAttributes().setAttribute(go.getIdentifier(), 
-                                                  
VisualPropertyType.NODE_LABEL_POSITION.getBypassAttrName(), val);
-                               
Cytoscape.getVisualMappingManager().getNetworkView().redrawGraph(false, true);
+                               Cytoscape.getNodeAttributes().setAttribute(
+                                               go.getIdentifier(),
+                                               
VisualPropertyType.NODE_LABEL_POSITION
+                                                               
.getBypassAttrName(), val);
+                               
Cytoscape.getVisualMappingManager().getNetworkView()
+                                               .redrawGraph(false, true);
                        }
                }
        }

Modified: cytoscape/trunk/src/cytoscape/visual/ui/ValueDisplayer.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/ui/ValueDisplayer.java 2009-12-03 
21:58:26 UTC (rev 18646)
+++ cytoscape/trunk/src/cytoscape/visual/ui/ValueDisplayer.java 2009-12-03 
22:31:28 UTC (rev 18647)
@@ -36,12 +36,14 @@
  */
 package cytoscape.visual.ui;
 
+import cytoscape.Cytoscape;
 import cytoscape.util.CyColorChooser;
 
 import cytoscape.visual.Arrow;
 import cytoscape.visual.LabelPosition;
 import cytoscape.visual.LineType;
 import cytoscape.visual.NodeShape;
+import cytoscape.visual.VisualPropertyType;
 import cytoscape.logger.CyLogger;
 
 import java.awt.Color;

Modified: 
cytoscape/trunk/src/cytoscape/visual/ui/editors/discrete/CyLabelPositionPropertyEditor.java
===================================================================
--- 
cytoscape/trunk/src/cytoscape/visual/ui/editors/discrete/CyLabelPositionPropertyEditor.java
 2009-12-03 21:58:26 UTC (rev 18646)
+++ 
cytoscape/trunk/src/cytoscape/visual/ui/editors/discrete/CyLabelPositionPropertyEditor.java
 2009-12-03 22:31:28 UTC (rev 18647)
@@ -31,29 +31,27 @@
  You should have received a copy of the GNU Lesser General Public License
  along with this library; if not, write to the Free Software Foundation,
  Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
-*/
+ */
 package cytoscape.visual.ui.editors.discrete;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.JButton;
+import javax.swing.JPanel;
+
 import com.l2fprod.common.swing.ComponentFactory;
 import com.l2fprod.common.swing.PercentLayout;
 
 import cytoscape.Cytoscape;
-
 import cytoscape.visual.LabelPosition;
-
 import cytoscape.visual.ui.PopupLabelPositionChooser;
 
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-
-import javax.swing.JButton;
-import javax.swing.JPanel;
-
-
 /**
  *
  */
-public class CyLabelPositionPropertyEditor extends 
com.l2fprod.common.beans.editor.AbstractPropertyEditor {
+public class CyLabelPositionPropertyEditor extends
+               com.l2fprod.common.beans.editor.AbstractPropertyEditor {
        private LabelPositionCellRenderer label;
        private JButton button;
        private LabelPosition position;
@@ -65,38 +63,41 @@
                editor = new JPanel(new PercentLayout(PercentLayout.HORIZONTAL, 
0));
                ((JPanel) editor).add("*", label = new 
LabelPositionCellRenderer());
                label.setOpaque(false);
-               ((JPanel) editor).add(button = 
ComponentFactory.Helper.getFactory().createMiniButton());
+               ((JPanel) editor).add(button = 
ComponentFactory.Helper.getFactory()
+                               .createMiniButton());
                button.addActionListener(new ActionListener() {
-                               public void actionPerformed(ActionEvent e) {
-                                       editLabelPosition();
-                               }
-                       });
-               ((JPanel) editor).add(button = 
ComponentFactory.Helper.getFactory().createMiniButton());
+                       public void actionPerformed(ActionEvent e) {
+                               editLabelPosition();
+                       }
+               });
+               ((JPanel) editor).add(button = 
ComponentFactory.Helper.getFactory()
+                               .createMiniButton());
                button.setText("X");
                button.addActionListener(new ActionListener() {
-                               public void actionPerformed(ActionEvent e) {
-                                       LabelPosition old = position;
-                                       label.setValue(null);
-                                       position = null;
-                                       firePropertyChange(old, null);
-                               }
-                       });
+                       public void actionPerformed(ActionEvent e) {
+                               LabelPosition old = position;
+                               label.setValue(null);
+                               position = null;
+                               firePropertyChange(old, null);
+                       }
+               });
                ((JPanel) editor).setOpaque(false);
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @return DOCUMENT ME!
         */
        public Object getValue() {
                return position;
        }
 
        /**
-        *  DOCUMENT ME!
-        *
-        * @param value DOCUMENT ME!
+        * DOCUMENT ME!
+        * 
+        * @param value
+        *            DOCUMENT ME!
         */
        public void setValue(Object value) {
                position = (LabelPosition) value;
@@ -104,8 +105,8 @@
        }
 
        protected void editLabelPosition() {
-               final LabelPosition newVal = 
PopupLabelPositionChooser.showDialog(Cytoscape.getDesktop(),
-                                                                               
  position);
+               final LabelPosition newVal = 
PopupLabelPositionChooser.showDialog(
+                               Cytoscape.getDesktop(), position);
 
                if (newVal != null) {
                        final LabelPosition old = position;

--

You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.


Reply via email to