Author: mes
Date: 2009-12-10 16:08:28 -0800 (Thu, 10 Dec 2009)
New Revision: 18724

Added:
   cytoscape/trunk/src/cytoscape/visual/strokes/BackwardSlashStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/ForwardSlashStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/VerticalSlashStroke.java
Modified:
   cytoscape/trunk/src/cytoscape/visual/LineStyle.java
   cytoscape/trunk/src/cytoscape/visual/strokes/ContiguousArrowStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/DashDotStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/DotStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/EqualDashStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/LongDashStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/ParallelStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/PipeStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/SeparateArrowStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/ShapeStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/SineWaveStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/SolidStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/WidthStroke.java
   cytoscape/trunk/src/cytoscape/visual/strokes/ZigzagStroke.java
Log:
tweak to the WidthStroke API so that it uses LineStyles instead of the regex 
string

Modified: cytoscape/trunk/src/cytoscape/visual/LineStyle.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/LineStyle.java 2009-12-10 23:32:19 UTC 
(rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/LineStyle.java 2009-12-11 00:08:28 UTC 
(rev 18724)
@@ -54,19 +54,20 @@
  * @author kono
  */
 public enum LineStyle {
-       SOLID("line", new SolidStroke(1.0f,"line")),
-       LONG_DASH( "dash", new LongDashStroke(1.0f,"dash")),
-       EQUAL( "equal", new EqualDashStroke(1.0f,"equal")),
-       UNEVEN( "uneven", new DashDotStroke(1.0f,"uneven")),
-       DOT("dot", new DotStroke(1.0f,"dot")),
-       ZIGZAG("zigzag", new ZigzagStroke(1.0f,"zigzag")),
-       SINEWAVE("sinewave", new SineWaveStroke(1.0f,"sinewave")),
-       VERTICAL_SLASH("vertical_slash",new 
PipeStroke(1.0f,PipeStroke.Type.VERTICAL,"vertical_slash")),
-       FORWARD_SLASH("forward_slash",new 
PipeStroke(1.0f,PipeStroke.Type.FORWARD,"forward_slash")),
-       BACKWARD_SLASH("backward_slash",new 
PipeStroke(1.0f,PipeStroke.Type.BACKWARD,"backward_slash")),
-       PARALLEL_LINES("parallel_lines", new 
ParallelStroke(1.0f,"parallel_lines")),
-       CONTIGUOUS_ARROW("contiguous_arrow", new 
ContiguousArrowStroke(1.0f,"contiguous_arrow")),
-       SEPARATE_ARROW("separate_arrow", new 
SeparateArrowStroke(1.0f,"separate_arrow")),
+       // note that "line" and "dash" regexs are legacy, so don't change them!
+       SOLID("line", new SolidStroke(1.0f)),
+       LONG_DASH( "dash", new LongDashStroke(1.0f)),
+       EQUAL_DASH( "equal_dash", new EqualDashStroke(1.0f)),
+       DASH_DOT( "dash_dot", new DashDotStroke(1.0f)),
+       DOT("dot_dot", new DotStroke(1.0f)),
+       ZIGZAG("zigzag", new ZigzagStroke(1.0f)),
+       SINEWAVE("sinewave", new SineWaveStroke(1.0f)),
+       VERTICAL_SLASH("vertical_slash",new 
VerticalSlashStroke(1.0f,PipeStroke.Type.VERTICAL)),
+       FORWARD_SLASH("forward_slash",new 
ForwardSlashStroke(1.0f,PipeStroke.Type.FORWARD)),
+       BACKWARD_SLASH("backward_slash",new 
BackwardSlashStroke(1.0f,PipeStroke.Type.BACKWARD)),
+       PARALLEL_LINES("parallel_lines", new ParallelStroke(1.0f)),
+       CONTIGUOUS_ARROW("contiguous_arrow", new ContiguousArrowStroke(1.0f)),
+       SEPARATE_ARROW("separate_arrow", new SeparateArrowStroke(1.0f)),
        ;
 
        private String regex;
@@ -81,6 +82,12 @@
                return regex;
        }
 
+       /**
+        * Attempts to parse a LineStyle object from a string.  If the string 
does
+        * not match any LineStyle.toString() value exactly, then it attempts a 
regular
+        * expression match on regex pattern defined in this Enum. The regex 
support
+        * exists primarily to support legacy file formats.  
+        */
        public static LineStyle parse(String val) {
                // First check the style names.
                for ( LineStyle ls : values() ) {
@@ -102,24 +109,6 @@
                return SOLID;
        }
 
-       private static Pattern numPattern = Pattern.compile("(\\d+)");
-
-       /** 
-        * This method attempts to extract a width from a string that has
-        * a number in it like "dashed1" or "line2". This exists to support
-        * old-style line type definitions.
-        * @return The parsed value or if something doesn't match, 1.0
-        */
-       public static float parseWidth(String s) {
-               Matcher m = numPattern.matcher(s);
-               if ( m.matches() ) {
-                       try {
-                               return (new Float(m.group(1))).floatValue();
-                       } catch (Exception e) { }
-               }
-               return 1.0f;
-       }
-
        /**
         * Will attempt to find the LineStyle based on the type of stroke.
         * If it doesn't match a known stroke, it will return SOLID.
@@ -127,16 +116,22 @@
         */
        public static LineStyle extractLineStyle(Stroke s) {
                if ( s instanceof WidthStroke ) {
-                       return LineStyle.parse( ((WidthStroke)s).getName() );   
+                       return ((WidthStroke)s).getLineStyle(); 
                } 
 
                return SOLID;
        }
 
+       /**
+        * Creates a new stroke of this LineStyle with the specified width.
+        */
        public Stroke getStroke(float width) {
                return stroke.newInstanceForWidth( width );
        }
-       
+
+       /**
+        * Returns a map of Icons that can be used for user interfaces.
+        */
     public static Map<Object,Icon> getIconSet() {
         Map<Object,Icon> icons = new HashMap<Object,Icon>();
 

Added: cytoscape/trunk/src/cytoscape/visual/strokes/BackwardSlashStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/BackwardSlashStroke.java       
                        (rev 0)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/BackwardSlashStroke.java       
2009-12-11 00:08:28 UTC (rev 18724)
@@ -0,0 +1,13 @@
+
+
+package cytoscape.visual.strokes;
+
+import static cytoscape.visual.LineStyle.BACKWARD_SLASH;
+
+public class BackwardSlashStroke extends PipeStroke {
+
+       public BackwardSlashStroke(float width, Type offsetType) {
+               super(width,offsetType,BACKWARD_SLASH);
+       }
+}
+

Modified: 
cytoscape/trunk/src/cytoscape/visual/strokes/ContiguousArrowStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/ContiguousArrowStroke.java     
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/ContiguousArrowStroke.java     
2009-12-11 00:08:28 UTC (rev 18724)
@@ -4,19 +4,19 @@
 
 import java.awt.Shape;
 import java.awt.geom.GeneralPath;
+import static cytoscape.visual.LineStyle.CONTIGUOUS_ARROW;
 
 public class ContiguousArrowStroke extends ShapeStroke {
 
-
-       public ContiguousArrowStroke(float width, String name) {
-               super( new Shape[] { getArrowStroke(width) }, 3f*width, name, 
width );
+       public ContiguousArrowStroke(float width) {
+               super( new Shape[] { getArrowStroke(width) }, 3f*width, 
CONTIGUOUS_ARROW, width );
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new ContiguousArrowStroke(w,name);
+               return new ContiguousArrowStroke(w);
        }
 
-       static Shape getArrowStroke(final float width) {
+       private static Shape getArrowStroke(final float width) {
                GeneralPath shape = new GeneralPath();
 
                // change these to change the arrow proportions 

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/DashDotStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/DashDotStroke.java     
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/DashDotStroke.java     
2009-12-11 00:08:28 UTC (rev 18724)
@@ -6,29 +6,29 @@
 import java.awt.BasicStroke;
 import java.awt.Stroke;
 import java.awt.Shape;
+import cytoscape.visual.LineStyle;
+import static cytoscape.visual.LineStyle.DASH_DOT;
 
 public class DashDotStroke extends BasicStroke implements WidthStroke {
 
-       String name;
-       float width;
+       private float width;
 
-       public DashDotStroke(float width, String name) {
+       public DashDotStroke(float width) {
                super(width, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 
                      10.0f, new float[]{width * 4f,width*2f,width,width*2f}, 
0.0f);
 
-               this.name = name;
                this.width = width;
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new DashDotStroke(w,name);
+               return new DashDotStroke(w);
        }
 
-       public String getName() {
-               return name;
+       public LineStyle getLineStyle() {
+               return DASH_DOT;
        }
 
-       public String toString() { return name + " " + Float.toString(width); }
+       public String toString() { return DASH_DOT + " " + 
Float.toString(width); }
 }
 
 

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/DotStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/DotStroke.java 2009-12-10 
23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/DotStroke.java 2009-12-11 
00:08:28 UTC (rev 18724)
@@ -3,17 +3,17 @@
 
 import java.awt.Shape;
 import java.awt.geom.Ellipse2D;
+import static cytoscape.visual.LineStyle.DOT;
 
 public class DotStroke extends ShapeStroke {
 
-       public DotStroke(float width, String name) {
-               super( new Shape[] { new Ellipse2D.Float(0, 0, width, width) }, 
width * 2f, name, width );
-               this.name = name;
+       public DotStroke(float width) {
+               super( new Shape[] { new Ellipse2D.Float(0, 0, width, width) }, 
width * 2f, DOT, width );
                this.width = width;
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new DotStroke(w,name);
+               return new DotStroke(w);
        }
 }
 

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/EqualDashStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/EqualDashStroke.java   
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/EqualDashStroke.java   
2009-12-11 00:08:28 UTC (rev 18724)
@@ -5,29 +5,29 @@
 import java.awt.BasicStroke;
 import java.awt.Stroke;
 import java.awt.Shape;
+import cytoscape.visual.LineStyle;
+import static cytoscape.visual.LineStyle.EQUAL_DASH;
 
 public class EqualDashStroke extends BasicStroke implements WidthStroke {
 
-       String name;
-       float width;
+       private float width;
 
-       public EqualDashStroke(float width, String name) {
+       public EqualDashStroke(float width) {
                super(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 
                      10.0f, new float[]{width * 2f,width * 2f}, 0.0f);
 
-               this.name = name;
                this.width = width;
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new EqualDashStroke(w,name);
+               return new EqualDashStroke(w);
        }
 
-       public String getName() {
-               return name;
+       public LineStyle getLineStyle() {
+               return EQUAL_DASH;
        }
 
-       public String toString() { return name + " " + Float.toString(width); }
+       public String toString() { return EQUAL_DASH.toString() + " " + 
Float.toString(width); }
 }
 
 

Added: cytoscape/trunk/src/cytoscape/visual/strokes/ForwardSlashStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/ForwardSlashStroke.java        
                        (rev 0)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/ForwardSlashStroke.java        
2009-12-11 00:08:28 UTC (rev 18724)
@@ -0,0 +1,13 @@
+
+
+package cytoscape.visual.strokes;
+
+import static cytoscape.visual.LineStyle.FORWARD_SLASH;
+
+public class ForwardSlashStroke extends PipeStroke {
+
+       public ForwardSlashStroke(float width, Type offsetType) {
+               super(width,offsetType,FORWARD_SLASH);
+       }
+}
+

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/LongDashStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/LongDashStroke.java    
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/LongDashStroke.java    
2009-12-11 00:08:28 UTC (rev 18724)
@@ -5,28 +5,28 @@
 import java.awt.BasicStroke;
 import java.awt.Stroke;
 import java.awt.Shape;
+import cytoscape.visual.LineStyle;
+import static cytoscape.visual.LineStyle.LONG_DASH;
 
 public class LongDashStroke extends BasicStroke implements WidthStroke {
 
-       String name;
        float width;
 
-       public LongDashStroke(float width, String name) {
+       public LongDashStroke(float width) {
                super(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 
                      10.0f, new float[]{width * 4f, width * 2f}, 0.0f);
-               this.name = name;
                this.width = width;
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new LongDashStroke(w,name);
+               return new LongDashStroke(w);
        }
 
-       public String getName() {
-               return name;
+       public LineStyle getLineStyle() {
+               return LONG_DASH;
        }
 
-       public String toString() { return name + " " + Float.toString(width); }
+       public String toString() { return LONG_DASH.toString() + " " + 
Float.toString(width); }
 }
 
 

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/ParallelStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/ParallelStroke.java    
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/ParallelStroke.java    
2009-12-11 00:08:28 UTC (rev 18724)
@@ -4,20 +4,20 @@
 
 import java.awt.Shape;
 import java.awt.geom.GeneralPath;
+import static cytoscape.visual.LineStyle.PARALLEL_LINES;
 
 public class ParallelStroke extends ShapeStroke {
 
-       public ParallelStroke(float width, String name) {
-               super( new Shape[] { getParallelStroke(width) }, 1f, name, 
width );
-               this.name = name;
+       public ParallelStroke(float width) {
+               super( new Shape[] { getParallelStroke(width) }, 1f, 
PARALLEL_LINES, width );
                this.width = width;
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new ParallelStroke(w,name);
+               return new ParallelStroke(w);
        }
 
-       static Shape getParallelStroke(final float width) {
+       private static Shape getParallelStroke(final float width) {
                GeneralPath shape = new GeneralPath();
 
                shape.moveTo(0f,-0.5f*width);

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/PipeStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/PipeStroke.java        
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/PipeStroke.java        
2009-12-11 00:08:28 UTC (rev 18724)
@@ -4,6 +4,7 @@
 
 import java.awt.Shape;
 import java.awt.geom.GeneralPath;
+import cytoscape.visual.LineStyle;
 
 public class PipeStroke extends ShapeStroke {
 
@@ -25,16 +26,17 @@
 
        private Type offsetType;
 
-       public PipeStroke(float width, Type offsetType, String name) {
-               super( new Shape[] { getShape(width, offsetType) },  width, 
name, width );
+       PipeStroke(float width, Type offsetType, LineStyle lineStyle) {
+               super( new Shape[] { getShape(width, offsetType) },  width, 
lineStyle, width );
                this.offsetType = offsetType;
+               this.lineStyle = lineStyle;
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new PipeStroke(w,offsetType,name);
+               return new PipeStroke(w,offsetType,lineStyle);
        }
 
-       static Shape getShape(final float input, final Type offsetType) {
+       private static Shape getShape(final float input, final Type offsetType) 
{
                GeneralPath shape = new GeneralPath();
                float height = input;
                float width = input/5f;

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/SeparateArrowStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/SeparateArrowStroke.java       
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/SeparateArrowStroke.java       
2009-12-11 00:08:28 UTC (rev 18724)
@@ -4,19 +4,19 @@
 
 import java.awt.Shape;
 import java.awt.geom.GeneralPath;
+import static cytoscape.visual.LineStyle.SEPARATE_ARROW;
 
 public class SeparateArrowStroke extends ShapeStroke {
 
-
-       public SeparateArrowStroke(float width, String name) {
-               super( new Shape[] { getArrowStroke(width) }, 5f*width, name, 
width );
+       public SeparateArrowStroke(float width) {
+               super( new Shape[] { getArrowStroke(width) }, 5f*width, 
SEPARATE_ARROW, width );
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new SeparateArrowStroke(w,name);
+               return new SeparateArrowStroke(w);
        }
 
-       static Shape getArrowStroke(final float width) {
+       private static Shape getArrowStroke(final float width) {
                GeneralPath shape = new GeneralPath();
 
                // change these to change the arrow proportions 

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/ShapeStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/ShapeStroke.java       
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/ShapeStroke.java       
2009-12-11 00:08:28 UTC (rev 18724)
@@ -18,6 +18,7 @@
 
 import java.awt.*;
 import java.awt.geom.*;
+import cytoscape.visual.LineStyle;
 
 public abstract class ShapeStroke implements WidthStroke {
        private Shape shapes[];
@@ -26,13 +27,13 @@
        private AffineTransform transform = new AffineTransform();
        private static final float FLATNESS = 0.1f;
 
-       protected String name;
+       protected LineStyle lineStyle;
        protected float width;
 
-       public ShapeStroke( Shape shapes[], float advance, String name, float 
width ) {
+       public ShapeStroke( Shape shapes[], float advance, LineStyle lineStyle, 
float width ) {
                this.advance = advance;
                this.shapes = new Shape[shapes.length];
-               this.name = name;
+               this.lineStyle = lineStyle;
                this.width = width;
 
                for ( int i = 0; i < this.shapes.length; i++ ) {
@@ -108,12 +109,12 @@
        }
 
 
-       public String getName() {
-               return name;
+       public LineStyle getLineStyle() {
+               return lineStyle;
        }
 
        public String toString() { 
-               return name + " " + Float.toString(width); 
+               return lineStyle.toString() + " " + Float.toString(width); 
        }
        
        abstract public WidthStroke newInstanceForWidth(float w);

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/SineWaveStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/SineWaveStroke.java    
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/SineWaveStroke.java    
2009-12-11 00:08:28 UTC (rev 18724)
@@ -4,21 +4,22 @@
 
 import java.awt.Shape;
 import java.awt.geom.GeneralPath;
+import static cytoscape.visual.LineStyle.SINEWAVE;
 
 public class SineWaveStroke extends ShapeStroke {
 
        // TODO consider making the wavelength and amplitude Cytoscape 
properties.
 
-       public SineWaveStroke(float width, String name) {
+       public SineWaveStroke(float width) {
                // second arg here is the advance - advance must equal 
wavelength below
-               super( new Shape[] { getSineWave(width) }, 10f, name, width );
+               super( new Shape[] { getSineWave(width) }, 10f, SINEWAVE, width 
);
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new SineWaveStroke(w,name);
+               return new SineWaveStroke(w);
        }
 
-       static Shape getSineWave(final float width) {
+       private static Shape getSineWave(final float width) {
                GeneralPath shape = new GeneralPath();
 
                // wavelength must equal advance specified in constructor or 

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/SolidStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/SolidStroke.java       
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/SolidStroke.java       
2009-12-11 00:08:28 UTC (rev 18724)
@@ -4,27 +4,27 @@
 import java.awt.BasicStroke;
 import java.awt.Stroke;
 import java.awt.Shape;
+import cytoscape.visual.LineStyle;
+import static cytoscape.visual.LineStyle.SOLID;
 
 public class SolidStroke extends BasicStroke implements WidthStroke {
 
-       String name;
-       float width;
+       private float width;
 
-       public SolidStroke(float width, String name) {
+       public SolidStroke(float width) {
                super(width,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND);
-               this.name = name;
                this.width = width;
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new SolidStroke(w,name);
+               return new SolidStroke(w);
        }
 
-       public String getName() {
-               return name;
+       public LineStyle getLineStyle() {
+               return SOLID;
        }
 
-       public String toString() { return name + " " + Float.toString(width); }
+       public String toString() { return SOLID.toString() + " " + 
Float.toString(width); }
 }
 
 

Added: cytoscape/trunk/src/cytoscape/visual/strokes/VerticalSlashStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/VerticalSlashStroke.java       
                        (rev 0)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/VerticalSlashStroke.java       
2009-12-11 00:08:28 UTC (rev 18724)
@@ -0,0 +1,13 @@
+
+
+package cytoscape.visual.strokes;
+
+import static cytoscape.visual.LineStyle.VERTICAL_SLASH;
+
+public class VerticalSlashStroke extends PipeStroke {
+
+       public VerticalSlashStroke(float width, Type offsetType) {
+               super(width,offsetType,VERTICAL_SLASH);
+       }
+}
+

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/WidthStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/WidthStroke.java       
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/WidthStroke.java       
2009-12-11 00:08:28 UTC (rev 18724)
@@ -2,8 +2,22 @@
 package cytoscape.visual.strokes;
 
 import java.awt.Stroke;
+import cytoscape.visual.LineStyle;
 
+/**
+ * A simple extension of Stroke that allows Stroke objects to be
+ * coupled with LineStyle enum values and allows the width of the
+ * stroke to be adjusted.
+ */
 public interface WidthStroke extends Stroke {
+       
+       /**
+        * @return A new instance of this WidthStroke with the specified width.
+        */
        WidthStroke newInstanceForWidth(float width);
-       String getName();
+
+       /**
+        * @return the LineStyle associated with this particular WidthStroke.
+        */
+       LineStyle getLineStyle();
 }

Modified: cytoscape/trunk/src/cytoscape/visual/strokes/ZigzagStroke.java
===================================================================
--- cytoscape/trunk/src/cytoscape/visual/strokes/ZigzagStroke.java      
2009-12-10 23:32:19 UTC (rev 18723)
+++ cytoscape/trunk/src/cytoscape/visual/strokes/ZigzagStroke.java      
2009-12-11 00:08:28 UTC (rev 18724)
@@ -18,19 +18,20 @@
 
 import java.awt.*;
 import java.awt.geom.*;
+import cytoscape.visual.LineStyle;
+import static cytoscape.visual.LineStyle.ZIGZAG;
 
 public class ZigzagStroke implements WidthStroke {
+
        private float amplitude = 10.0f;
        private float wavelength = 10.0f;
     private Stroke stroke;
        private static final float FLATNESS = 1;
-       private String name;
        private float width;
 
        // TODO we can do fancier stuff if we pass in Stroke, amplitude and 
wavelength
        // as params
-       public ZigzagStroke( float width, String name ) {
-               this.name = name;
+       public ZigzagStroke( float width ) {
                this.width = width;
         this.stroke = new BasicStroke(width);
        }
@@ -101,16 +102,16 @@
                return stroke.createStrokedShape( result );
        }
 
-       public String getName() {
-               return getName();
+       public LineStyle getLineStyle() {
+               return ZIGZAG;
        }
 
        public WidthStroke newInstanceForWidth(float w) {
-               return new ZigzagStroke(w,name);
+               return new ZigzagStroke(w);
        }
 
        public String toString() {
-               return name + " " + Float.toString(width);
+               return ZIGZAG.toString() + " " + Float.toString(width);
        }
 
 }

--

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