Author: kono
Date: 2010-10-26 16:57:01 -0700 (Tue, 26 Oct 2010)
New Revision: 22498

Added:
   
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/PaintVisualProperty.java
Removed:
   
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/ColorVisualProperty.java
Modified:
   
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/DiscreteMappingTest.java
   
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DVisualLexicon.java
   
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/TwoDVisualLexicon.java
   
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/VisualPropertyTest.java
Log:
Color VP had been changed to Paint VP.

Modified: 
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/DiscreteMappingTest.java
===================================================================
--- 
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/DiscreteMappingTest.java
  2010-10-26 23:43:06 UTC (rev 22497)
+++ 
core3/default-mappingcalculators/trunk/src/test/java/org/cytoscape/vizmap/DiscreteMappingTest.java
  2010-10-26 23:57:01 UTC (rev 22498)
@@ -3,6 +3,7 @@
 import static org.junit.Assert.*;
 
 import java.awt.Color;
+import java.awt.Paint;
 
 import org.cytoscape.view.presentation.property.TwoDVisualLexicon;
 import org.cytoscape.view.vizmap.mappings.DiscreteMapping;
@@ -25,7 +26,7 @@
                final String attrName = "sample attr 1";
                final Class<String> type = String.class;
                
-               final DiscreteMapping<String, Color> mapping = new 
DiscreteMapping<String, Color>(attrName, type, TwoDVisualLexicon.NODE_COLOR);
+               final DiscreteMapping<String, Paint> mapping = new 
DiscreteMapping<String, Paint>(attrName, type, TwoDVisualLexicon.NODE_COLOR);
                
                assertEquals(attrName, mapping.getMappingAttributeName());
                assertEquals(type, mapping.getMappingAttributeType());

Modified: 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DVisualLexicon.java
===================================================================
--- 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DVisualLexicon.java
        2010-10-26 23:43:06 UTC (rev 22497)
+++ 
core3/ding-presentation-impl/trunk/src/main/java/org/cytoscape/ding/impl/DVisualLexicon.java
        2010-10-26 23:57:01 UTC (rev 22498)
@@ -37,6 +37,7 @@
 import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Font;
+import java.awt.Paint;
 import java.awt.Stroke;
 
 import org.cytoscape.ding.ArrowShape;
@@ -44,7 +45,7 @@
 import org.cytoscape.view.model.NullDataType;
 import org.cytoscape.view.model.VisualProperty;
 import org.cytoscape.view.presentation.property.BooleanVisualProperty;
-import org.cytoscape.view.presentation.property.ColorVisualProperty;
+import org.cytoscape.view.presentation.property.PaintVisualProperty;
 import org.cytoscape.view.presentation.property.DoubleVisualProperty;
 import org.cytoscape.view.presentation.property.NullVisualProperty;
 import org.cytoscape.view.presentation.property.StringVisualProperty;
@@ -69,10 +70,10 @@
        public static final VisualProperty<NodeShape> NODE_SHAPE = new 
NodeShapeTwoDVisualProperty(
                        NodeShape.ROUND_RECT, "NODE_SHAPE", "Node Shape");
 
-       public static final VisualProperty<Color> NODE_SELECTED_PAINT = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> NODE_SELECTED_PAINT = new 
PaintVisualProperty(
                        Color.YELLOW, "NODE_SELECTED_PAINT", "Node Selected 
Paint");
 
-       public static final VisualProperty<Color> NODE_BORDER_PAINT = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> NODE_BORDER_PAINT = new 
PaintVisualProperty(
                        Color.BLACK, "NODE_BORDER_PAINT", "Node Border Paint");
 
        public static final VisualProperty<Double> NODE_BORDER_WIDTH = new 
DoubleVisualProperty(
@@ -110,21 +111,21 @@
        public static final VisualProperty<Integer> NODE_TRANSPARENCY = new 
IntegerTwoDVisualProperty(
                        200, "NODE_TRANSPARENCY", "Node Transparency");
 
-       public static final VisualProperty<Color> EDGE_SELECTED_PAINT = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> EDGE_SELECTED_PAINT = new 
PaintVisualProperty(
                        Color.RED, "EDGE_SELECTED_PAINT", "Edge Selected 
Paint");
        
        public static final VisualProperty<? extends Stroke> EDGE_STROKE = new 
StrokeTwoDVisualProperty(
                        new BasicStroke(), "EDGE_STROKE", "Edge Stroke");
 
-       public static final VisualProperty<Color> 
EDGE_SOURCE_ARROW_SELECTED_PAINT = new ColorVisualProperty(
+       public static final VisualProperty<Paint> 
EDGE_SOURCE_ARROW_SELECTED_PAINT = new PaintVisualProperty(
                        Color.YELLOW, "EDGE_SOURCE_ARROW_SELECTED_PAINT", "Edge 
Source Arrow Selected Paint");
-       public static final VisualProperty<Color> 
EDGE_TARGET_ARROW_SELECTED_PAINT = new ColorVisualProperty(
+       public static final VisualProperty<Paint> 
EDGE_TARGET_ARROW_SELECTED_PAINT = new PaintVisualProperty(
                        Color.YELLOW, "EDGE_TARGET_ARROW_SELECTED_PAINT",
                        "Edge Target Arrow Selected Paint");
-       public static final VisualProperty<Color> 
EDGE_SOURCE_ARROW_UNSELECTED_PAINT = new ColorVisualProperty(
+       public static final VisualProperty<Paint> 
EDGE_SOURCE_ARROW_UNSELECTED_PAINT = new PaintVisualProperty(
                        Color.BLACK, "EDGE_SOURCE_ARROW_UNSELECTED_PAINT",
                        "Edge Source Arrow Unselected Paint");
-       public static final VisualProperty<Color> 
EDGE_TARGET_ARROW_UNSELECTED_PAINT = new ColorVisualProperty(
+       public static final VisualProperty<Paint> 
EDGE_TARGET_ARROW_UNSELECTED_PAINT = new PaintVisualProperty(
                        Color.BLACK, "EDGE_TARGET_ARROW_UNSELECTED_PAINT",
                        "Edge Target Arrow Unselected Paint");
 

Deleted: 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/ColorVisualProperty.java
===================================================================
--- 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/ColorVisualProperty.java
        2010-10-26 23:43:06 UTC (rev 22497)
+++ 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/ColorVisualProperty.java
        2010-10-26 23:57:01 UTC (rev 22498)
@@ -1,88 +0,0 @@
-
-/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications.  In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage.  See
- the GNU Lesser General Public License for more details.
-
- 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 org.cytoscape.view.presentation.property; 
-
-import java.awt.Color;
-import java.awt.Paint;
-import java.util.StringTokenizer;
-
-import org.cytoscape.view.model.AbstractVisualProperty;
-
-public class ColorVisualProperty extends AbstractVisualProperty<Color> { 
-
-       public ColorVisualProperty(final Color def, final String id, final 
String name) {
-               super(def, Color.class, id, name);
-       }
-       
-       public String toSerializableString(final Color color) {
-               final Integer red = Integer.valueOf(color.getRed());
-               final Integer green = Integer.valueOf(color.getGreen());
-               final Integer blue = Integer.valueOf(color.getBlue());
-
-               return red.toString() + "," + green.toString() + "," + 
blue.toString();
-       }
-
-       public Color parseSerializableString(final String text) {
-               // Start by seeing if this is a hex representation
-               if (text.startsWith("#")) {
-                       try {
-                               return Color.decode(text);
-                       } catch (NumberFormatException e) {
-                               throw new IllegalArgumentException("invalid hex 
RGB format");   
-                       }
-               }
-
-               // ok, this must be 3 comma separated integers instead
-               StringTokenizer strtok = new StringTokenizer(text, ",");
-
-               if (strtok.countTokens() != 3) 
-                       throw new IllegalArgumentException("not all RGB 
integers specified");   
-
-               String red = strtok.nextToken().trim();
-               String green = strtok.nextToken().trim();
-               String blue = strtok.nextToken().trim();
-
-               try {
-                       int r = Integer.parseInt(red);
-                       int g = Integer.parseInt(green);
-                       int b = Integer.parseInt(blue);
-
-                       return new Color(r, g, b);
-               } catch (NumberFormatException e) {
-                       throw new IllegalArgumentException("invalid RGB 
format");       
-               }
-       }
-}

Copied: 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/PaintVisualProperty.java
 (from rev 22416, 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/ColorVisualProperty.java)
===================================================================
--- 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/PaintVisualProperty.java
                                (rev 0)
+++ 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/PaintVisualProperty.java
        2010-10-26 23:57:01 UTC (rev 22498)
@@ -0,0 +1,95 @@
+
+/*
+ Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ 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 org.cytoscape.view.presentation.property; 
+
+import java.awt.Color;
+import java.awt.Paint;
+import java.util.StringTokenizer;
+
+import org.cytoscape.view.model.AbstractVisualProperty;
+
+public class PaintVisualProperty extends AbstractVisualProperty<Paint> { 
+
+       public PaintVisualProperty(final Paint def, final String id, final 
String name) {
+               super(def, Paint.class, id, name);
+       }
+       
+       
+       @Override public String toSerializableString(final Paint paint) {
+               if(paint instanceof Color == false)
+                       throw new UnsupportedOperationException("Currently, 
this implementation supports only Color object.");
+               
+               final Color color = (Color) paint;
+               
+               final Integer red = Integer.valueOf(color.getRed());
+               final Integer green = Integer.valueOf(color.getGreen());
+               final Integer blue = Integer.valueOf(color.getBlue());
+
+               return red.toString() + "," + green.toString() + "," + 
blue.toString();
+       }
+
+       
+       @Override public Paint parseSerializableString(final String text) {
+               // Start by seeing if this is a hex representation
+               if (text.startsWith("#")) {
+                       try {
+                               return Color.decode(text);
+                       } catch (NumberFormatException e) {
+                               throw new IllegalArgumentException("invalid hex 
RGB format");   
+                       }
+               }
+
+               // ok, this must be 3 comma separated integers instead
+               StringTokenizer strtok = new StringTokenizer(text, ",");
+
+               if (strtok.countTokens() != 3) 
+                       throw new IllegalArgumentException("not all RGB 
integers specified");   
+
+               String red = strtok.nextToken().trim();
+               String green = strtok.nextToken().trim();
+               String blue = strtok.nextToken().trim();
+
+               try {
+                       int r = Integer.parseInt(red);
+                       int g = Integer.parseInt(green);
+                       int b = Integer.parseInt(blue);
+
+                       return new Color(r, g, b);
+               } catch (NumberFormatException e) {
+                       throw new IllegalArgumentException("invalid RGB 
format");       
+               }
+       }
+}

Modified: 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/TwoDVisualLexicon.java
===================================================================
--- 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/TwoDVisualLexicon.java
  2010-10-26 23:43:06 UTC (rev 22497)
+++ 
core3/presentation-api/trunk/src/main/java/org/cytoscape/view/presentation/property/TwoDVisualLexicon.java
  2010-10-26 23:57:01 UTC (rev 22498)
@@ -35,6 +35,7 @@
 package org.cytoscape.view.presentation.property;
 
 import java.awt.Color;
+import java.awt.Paint;
 
 import org.cytoscape.view.model.NullDataType;
 import org.cytoscape.view.model.VisualProperty;
@@ -62,13 +63,13 @@
        public static final VisualProperty<Visualizable> EDGE = new 
DefaultVisualizableVisualProperty(
                        "EDGE", "Edge Visual Property");
 
-       public static final VisualProperty<Color> NODE_PAINT = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> NODE_PAINT = new 
PaintVisualProperty(
                        Color.gray, "NODE_PAINT", "Node Paint");
-       public static final VisualProperty<Color> NODE_COLOR = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> NODE_COLOR = new 
PaintVisualProperty(
                        Color.RED, "NODE_COLOR", "Node Color");
-       public static final VisualProperty<Color> NODE_SELECTED_COLOR = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> NODE_SELECTED_COLOR = new 
PaintVisualProperty(
                        Color.YELLOW, "NODE_SELECTED_COLOR", "Node Selected 
Color");
-       public static final VisualProperty<Color> NODE_LABEL_COLOR = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> NODE_LABEL_COLOR = new 
PaintVisualProperty(
                        Color.BLACK, "NODE_LABEL_COLOR", "Node Label Color");
 
        public static final VisualProperty<String> NODE_TEXT = new 
StringVisualProperty(
@@ -96,11 +97,11 @@
        public static final VisualProperty<Boolean> NODE_SELECTED = new 
BooleanVisualProperty(
                        false, "NODE_SELECTED", "Node Selected");
 
-       public static final VisualProperty<Color> EDGE_PAINT = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> EDGE_PAINT = new 
PaintVisualProperty(
                        Color.gray, "EDGE_PAINT", "Edge Paint");
-       public static final VisualProperty<Color> EDGE_COLOR = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> EDGE_COLOR = new 
PaintVisualProperty(
                        Color.gray, "EDGE_COLOR", "Edge Color");
-       public static final VisualProperty<Color> EDGE_LABEL_COLOR = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> EDGE_LABEL_COLOR = new 
PaintVisualProperty(
                        Color.BLACK, "EDGE_LABEL_COLOR", "Edge Label Color");
 
        public static final VisualProperty<String> EDGE_TEXT = new 
StringVisualProperty(
@@ -137,9 +138,9 @@
        public static final VisualProperty<String> NETWORK_TITLE = new 
StringVisualProperty(
                        "", "NETWORK_TITLE", "Network Title");
 
-       public static final VisualProperty<Color> NETWORK_PAINT = new 
ColorVisualProperty(
+       public static final VisualProperty<Paint> NETWORK_PAINT = new 
PaintVisualProperty(
                        Color.WHITE, "NETWORK_PAINT", "Network Paint");
-       public static final VisualProperty<Color> NETWORK_BACKGROUND_COLOR = 
new ColorVisualProperty(
+       public static final VisualProperty<Paint> NETWORK_BACKGROUND_COLOR = 
new PaintVisualProperty(
                        Color.WHITE, "NETWORK_BACKGROUND_COLOR", "Network 
Background Color");
 
        /**

Modified: 
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/VisualPropertyTest.java
===================================================================
--- 
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/VisualPropertyTest.java
  2010-10-26 23:43:06 UTC (rev 22497)
+++ 
core3/presentation-api/trunk/src/test/java/org/cytoscape/view/presentation/VisualPropertyTest.java
  2010-10-26 23:57:01 UTC (rev 22498)
@@ -12,7 +12,7 @@
 import org.cytoscape.view.presentation.internal.property.NullDataTypeImpl;
 import org.cytoscape.view.presentation.internal.property.VisualizableImpl;
 import org.cytoscape.view.presentation.property.NullVisualProperty;
-import org.cytoscape.view.presentation.property.ColorVisualProperty;
+import org.cytoscape.view.presentation.property.PaintVisualProperty;
 import org.cytoscape.view.presentation.property.TwoDVisualLexicon;
 import org.junit.After;
 import org.junit.Before;
@@ -30,8 +30,8 @@
        
        @Test
        public void testVisualProperties() {
-               final VisualProperty<Color> colorProp = 
TwoDVisualLexicon.NODE_COLOR;
-               assertEquals(Color.class, colorProp.getType());
+               final VisualProperty<Paint> colorProp = 
TwoDVisualLexicon.NODE_COLOR;
+               assertEquals(Paint.class, colorProp.getType());
                
                final VisualProperty<Boolean> booleanProp = 
TwoDVisualLexicon.NODE_VISIBLE;
                assertEquals(Boolean.class, booleanProp.getType());
@@ -45,8 +45,8 @@
                assertEquals("20.0", 
doubleProp.toSerializableString(Double.valueOf(20)));
                assertEquals(Double.valueOf(100.12), 
doubleProp.parseSerializableString("100.12"));
                
-               final VisualProperty<Color> paintProp = 
TwoDVisualLexicon.NODE_COLOR;
-               assertEquals(Color.class, paintProp.getType());
+               final VisualProperty<Paint> paintProp = 
TwoDVisualLexicon.NODE_COLOR;
+               assertEquals(Paint.class, paintProp.getType());
                
                final Color testColor = new Color(10, 20, 30); 
                assertEquals("10,20,30", 
paintProp.toSerializableString(testColor));
@@ -54,19 +54,19 @@
                assertEquals(testColor, 
paintProp.parseSerializableString("10,20,30"));
                
                try {
-                       final Color result = 
paintProp.parseSerializableString("#2JK20A141E");
+                       final Paint result = 
paintProp.parseSerializableString("#2JK20A141E");
                }catch(Exception e) {
                        assertTrue(e instanceof IllegalArgumentException);
                }
                
                try {
-                       final Color result = 
paintProp.parseSerializableString("10, 20");
+                       final Paint result = 
paintProp.parseSerializableString("10, 20");
                }catch(Exception e) {
                        assertTrue(e instanceof IllegalArgumentException);
                }
                
                try {
-                       final Color result = 
paintProp.parseSerializableString("10, 20, IJK");
+                       final Paint result = 
paintProp.parseSerializableString("10, 20, IJK");
                }catch(Exception e) {
                        assertTrue(e instanceof IllegalArgumentException);
                }

-- 
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