Author: mes
Date: 2009-12-15 16:21:23 -0800 (Tue, 15 Dec 2009)
New Revision: 18774

Added:
   cytoscape/trunk/src/cytoscape/visual/strokes/ZeroStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/package.html
Modified:
   cytoscape/trunk/src/cytoscape/visual/LineStyle.java
   cytoscape/trunk/src/cytoscape/visual/properties/NodeLineStyleProp.java
Log:
fixed a few bugs related to the new line styles and node borders

Modified: cytoscape/trunk/src/cytoscape/visual/LineStyle.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/LineStyle.java 2009-12-15 23:51:19 UTC 
(rev 18773)
+++ cytoscape/trunk/src/cytoscape/visual/LineStyle.java 2009-12-16 00:21:23 UTC 
(rev 18774)
@@ -126,7 +126,10 @@
         * Creates a new stroke of this LineStyle with the specified width.
         */
        public Stroke getStroke(float width) {
-               return stroke.newInstanceForWidth( width );
+               if ( width <= 0 )
+                       return new ZeroStroke(stroke);
+               else
+                       return stroke.newInstanceForWidth( width );
        }
 
        /**

Modified: cytoscape/trunk/src/cytoscape/visual/properties/NodeLineStyleProp.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/properties/NodeLineStyleProp.java      
2009-12-15 23:51:19 UTC (rev 18773)
+++ cytoscape/trunk/src/cytoscape/visual/properties/NodeLineStyleProp.java      
2009-12-16 00:21:23 UTC (rev 18774)
@@ -44,7 +44,7 @@
 
 import giny.view.NodeView;
 
-import java.awt.BasicStroke;
+import java.awt.Stroke;
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Font;
@@ -79,12 +79,9 @@
                        public void paintIcon(Component c, Graphics g, int x, 
int y) {
                                super.setColor(new Color(10, 10, 10, 0));
                                super.paintIcon(c, g, x, y);
-
-                               final BasicStroke stroke = (BasicStroke) 
((LineStyle) value)
-                                                                               
                    .getStroke(((Number) VisualPropertyType.NODE_LINE_WIDTH
-                                                                               
                                .getDefault(Cytoscape.getVisualMappingManager()
-                                                                               
                                                     .getVisualStyle()))
-                                                                               
                               .floatValue());
+                               
+                               final float width = ((Number) 
VisualPropertyType.NODE_LINE_WIDTH.getDefault(Cytoscape.getVisualMappingManager().getVisualStyle())).floatValue();
+                               final Stroke stroke = ((LineStyle) 
value).getStroke(width);
                                g2d.setStroke(stroke);
                                g2d.setColor(Color.DARK_GRAY);
                                g2d.translate(15, 4);

Added: cytoscape/trunk/src/cytoscape/visual/strokes/ZeroStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/ZeroStroke.java                
                (rev 0)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/ZeroStroke.java        
2009-12-16 00:21:23 UTC (rev 18774)
@@ -0,0 +1,42 @@
+
+package cytoscape.visual.strokes;
+
+import java.awt.BasicStroke;
+import java.awt.Stroke;
+import java.awt.Shape;
+import cytoscape.visual.LineStyle;
+
+/**
+ * Rather than handle strokes of width 0 for all implementations of 
WidthStroke,
+ * use this wrapper class that, when the width is less than or equal to 0 a
+ * BasicStroke is returned, whereas when the width is greater than 0, return 
the
+ * specified actual WidthStroke.
+ */
+public class ZeroStroke extends BasicStroke implements WidthStroke {
+
+       final WidthStroke actualStroke;
+
+       /**
+        * @param actualStroke The actual WidthStroke that this ZeroStroke 
represents. This
+        * object will be used whenever the width for a new instance is greater 
than 0.
+        */
+       public ZeroStroke(WidthStroke actualStroke) {
+               super(0);
+               this.actualStroke = actualStroke;
+       }
+
+       public WidthStroke newInstanceForWidth(float w) {
+               if ( w <= 0 )
+                       return new ZeroStroke(actualStroke);
+               else
+                       return actualStroke.newInstanceForWidth(w);
+       }
+
+       public LineStyle getLineStyle() {
+               return actualStroke.getLineStyle();
+       }
+
+       public String toString() { return getLineStyle().toString() + " 0"; }
+}
+
+

Added: cytoscape/trunk/src/cytoscape/visual/strokes/package.html
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/package.html                   
        (rev 0)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/package.html   2009-12-16 
00:21:23 UTC (rev 18774)
@@ -0,0 +1,7 @@
+<html>
+<body>
+The WidthStroke objects in this package should NOT be used directly by anyone 
other
+than the LineStyle enum!!!!  Seriously, DON'T USE THESE CLASSES!!!
+</body>
+</html>
+

--

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