Author: kono
Date: 2012-01-12 12:54:55 -0800 (Thu, 12 Jan 2012)
New Revision: 27999

Modified:
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/EdgeBendIcon.java
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/StrokeIcon.java
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/VisualPropertyIconFactory.java
Log:
fixes #569 Missing icon renderers had been implemented.

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/EdgeBendIcon.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/EdgeBendIcon.java
   2012-01-12 20:21:55 UTC (rev 27998)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/EdgeBendIcon.java
   2012-01-12 20:54:55 UTC (rev 27999)
@@ -1,5 +1,65 @@
 package org.cytoscape.ding.icon;
 
-public class EdgeBendIcon {
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.RenderingHints;
+import java.awt.Stroke;
+import java.awt.geom.CubicCurve2D;
+import java.awt.geom.Line2D;
 
+import org.cytoscape.ding.Bend;
+
+public class EdgeBendIcon extends VisualPropertyIcon<Bend> {
+
+       private static final long serialVersionUID = 3321774231185088226L;
+
+       private static final Stroke EDGE_STROKE = new BasicStroke(2.0f, 
BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
+       private static final int FONT_SIZE = 32;
+       private static final Font FONT = new Font("SansSerif", Font.BOLD, 
FONT_SIZE);
+       private static final Color NUMBER_COLOR = new Color(100, 100, 100, 90);
+
+       public EdgeBendIcon(Bend value, int width, int height, final String 
name) {
+               super(value, width, height, name);
+       }
+
+       @Override
+       public void paintIcon(Component c, Graphics g, int x, int y) {
+               final Graphics2D g2d = (Graphics2D) g;
+               g2d.setColor(color);
+               g2d.setStroke(EDGE_STROKE);
+               final int yPosition = (height + 20) / 2;
+
+               // Turn AA on
+               g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
RenderingHints.VALUE_ANTIALIAS_ON);
+
+               final Integer handles = value.getAllHandles().size();
+               if (handles == 0) {
+                       // No Handles: Just draw straight line
+                       g2d.draw(new Line2D.Double(leftPad, yPosition, width * 
1.5, yPosition));
+               } else {
+                       final double newWidth = width * 1.5;
+                       final CubicCurve2D curvedLine = new 
CubicCurve2D.Double(leftPad, yPosition,
+                                       newWidth/2, yPosition + height,
+                                       newWidth*3/4, yPosition - height,
+                                       newWidth, yPosition);
+                       g2d.draw(curvedLine);
+
+                       final Font original = g2d.getFont();
+
+                       if (value != null) {
+                               g2d.setColor(NUMBER_COLOR);
+                               g2d.setFont(FONT);
+                               final int cHeight = c.getHeight();
+                               g2d.drawString(handles.toString(), 
x+leftPad+15, y + (cHeight / 2) - 5);
+                       }
+
+                       // Set to original
+                       g2d.setFont(original);
+               }
+       }
+
 }

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/StrokeIcon.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/StrokeIcon.java
     2012-01-12 20:21:55 UTC (rev 27998)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/StrokeIcon.java
     2012-01-12 20:54:55 UTC (rev 27999)
@@ -34,9 +34,7 @@
 */
 package org.cytoscape.ding.icon;
 
-import java.awt.Color;
 import java.awt.Component;
-import java.awt.Font;
 import java.awt.Graphics;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
@@ -48,23 +46,15 @@
  *
  */
 public class StrokeIcon extends VisualPropertyIcon<Stroke> {
+       
        private final static long serialVersionUID = 1202339875918391L;
-
-       private Graphics2D g2d;
-
-       // If not null, this message will be shown over the icon.
-       private String superimposedText = null;
-       private Font textFont = null;
-       private Color textColor = null;
-
+       
        /**
-        * Creates a new LineTypeIcon object.
-        *
-        * @param stroke DOCUMENT ME!
-        * @param width DOCUMENT ME!
-        * @param height DOCUMENT ME!
-        * @param name DOCUMENT ME!
-        * @param color DOCUMENT ME!
+        * 
+        * @param stroke
+        * @param width
+        * @param height
+        * @param name
         */
        public StrokeIcon(final Stroke stroke, int width, int height, String 
name) {
                super(stroke, width, height, name);
@@ -72,63 +62,13 @@
 
        
        @Override public void paintIcon(Component c, Graphics g, int x, int y) {
-               g2d = (Graphics2D) g;
+               final Graphics2D g2d = (Graphics2D) g;
                g2d.setColor(color);
                // AA on
                g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
RenderingHints.VALUE_ANTIALIAS_ON);
 
-               //g2d.translate(leftPad, bottomPad);
                g2d.setStroke(value);
                final int yPosition = (height + 20) / 2;
                g2d.draw(new Line2D.Double(leftPad, yPosition, width*1.5, 
yPosition));
-
-//             /*
-//              * Superimpose text if text object is not empty.
-//              */
-//             if (superimposedText != null) {
-//
-//                     if (textColor == null) {
-//                             g2d.setColor(Color.DARK_GRAY);
-//                     } else
-//                             g2d.setColor(textColor);
-//
-//                     if (textFont == null) {
-//                             g2d.setFont(new Font("SansSerif", Font.BOLD, 
24));
-//                     } else {
-//                             g2d.setFont(textFont);
-//                     }
-//
-//                     g2d.drawString(superimposedText, 20, (height + 40) / 2);
-//             }
-//
-//             //g2d.translate(-leftPad, -bottomPad);
-//             g2d.setFont(new Font("SansSerif", Font.BOLD, 14));
        }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param text DOCUMENT ME!
-        */
-       public void setText(final String text) {
-               this.superimposedText = text;
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param font DOCUMENT ME!
-        */
-       public void setTextFont(final Font font) {
-               this.textFont = font;
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param color DOCUMENT ME!
-        */
-       public void setTextColor(final Color color) {
-               this.textColor = color;
-       }
 }

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/VisualPropertyIconFactory.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/VisualPropertyIconFactory.java
      2012-01-12 20:21:55 UTC (rev 27998)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/icon/VisualPropertyIconFactory.java
      2012-01-12 20:54:55 UTC (rev 27999)
@@ -6,6 +6,7 @@
 
 import javax.swing.Icon;
 
+import org.cytoscape.ding.Bend;
 import org.cytoscape.ding.DArrowShape;
 import org.cytoscape.ding.DNodeShape;
 import org.cytoscape.ding.ObjectPosition;
@@ -60,6 +61,8 @@
                                icon = new TextIcon(value, w, h, ""); // No 
arrow
                        else
                                icon = new ArrowIcon(dShape.getShape(), w, h, 
dShape.getDisplayName());
+               } else if(value instanceof Bend) {
+                       icon = new EdgeBendIcon((Bend) value, w, h, 
value.toString());
                } else {
                        // If not found, use return value of toString() as icon.
                        icon = new TextIcon(value, w, h, value.toString());

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