Author: kono
Date: 2011-10-12 14:17:32 -0700 (Wed, 12 Oct 2011)
New Revision: 27145

Modified:
   
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
   
core3/api/trunk/presentation-api/src/test/java/org/cytoscape/view/presentation/RichVisualLexiconTest.java
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/EdgeView.java
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeDetails.java
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeView.java
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/EdgeViewDefaultSupport.java
Log:
fixes #386 Edge transparency had been implemented.

Modified: 
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
===================================================================
--- 
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
      2011-10-12 20:03:43 UTC (rev 27144)
+++ 
core3/api/trunk/presentation-api/src/main/java/org/cytoscape/view/presentation/property/RichVisualLexicon.java
      2011-10-12 21:17:32 UTC (rev 27145)
@@ -85,19 +85,22 @@
        
        public static final VisualProperty<Paint> EDGE_SELECTED_PAINT = new 
PaintVisualProperty(
                        Color.RED, MinimalVisualLexicon.PAINT_RANGE, 
"EDGE_SELECTED_PAINT",
-                       "Edge Selected Paint", CyEdge.class);
+                       "Edge Color (Selected)", CyEdge.class);
        public static final VisualProperty<Paint> EDGE_UNSELECTED_PAINT = new 
PaintVisualProperty(
                        Color.DARK_GRAY, MinimalVisualLexicon.PAINT_RANGE,
-                       "EDGE_UNSELECTED_PAINT", "Edge Unselected Paint", 
CyEdge.class);
+                       "EDGE_UNSELECTED_PAINT", "Edge Color (Unselected)", 
CyEdge.class);
        public static final VisualProperty<Paint> EDGE_STROKE_SELECTED_PAINT = 
new PaintVisualProperty(
                        Color.RED, MinimalVisualLexicon.PAINT_RANGE,
-                       "EDGE_STROKE_SELECTED_PAINT", "Edge Stroke Selected 
Paint",
+                       "EDGE_STROKE_SELECTED_PAINT", "Edge Stroke Color 
(Selected)",
                        CyEdge.class);
        public static final VisualProperty<Paint> EDGE_STROKE_UNSELECTED_PAINT 
= new PaintVisualProperty(
                        Color.DARK_GRAY, MinimalVisualLexicon.PAINT_RANGE,
-                       "EDGE_STROKE_UNSELECTED_PAINT", "Edge Stroke Unselected 
Paint",
+                       "EDGE_STROKE_UNSELECTED_PAINT", "Edge Stroke Color 
(Unselected)",
                        CyEdge.class);
        
+       public static final VisualProperty<Integer> EDGE_TRANSPARENCY = new 
IntegerVisualProperty(200,
+                       new ContinuousRange<Integer>(Integer.class, 0, 255, 
true, true), "EDGE_TRANSPARENCY", "Edge Transparency", CyEdge.class);
+       
 
        /**
         * Construct a {@linkplain org.cytoscape.view.model.VisualLexicon} for 
3D rendering engine.
@@ -139,6 +142,8 @@
                addVisualProperty(EDGE_STROKE_SELECTED_PAINT, 
EDGE_SELECTED_PAINT);
                addVisualProperty(EDGE_STROKE_UNSELECTED_PAINT, 
EDGE_UNSELECTED_PAINT);
                
+               addVisualProperty(EDGE_TRANSPARENCY, EDGE);
+               
                createLookupMap();
        }
        
@@ -175,6 +180,8 @@
                addIdentifierMapping(CyEdge.class, "edgeToolTip", EDGE_TOOLTIP);
                addIdentifierMapping(CyEdge.class, "edgeFont", 
EDGE_LABEL_FONT_FACE);
                addIdentifierMapping(CyEdge.class, "edgeFontSize", 
EDGE_LABEL_FONT_SIZE);
+               
+               addIdentifierMapping(CyEdge.class, "edgeTransparency", 
EDGE_TRANSPARENCY);
 
                // TODO add more!
        }

Modified: 
core3/api/trunk/presentation-api/src/test/java/org/cytoscape/view/presentation/RichVisualLexiconTest.java
===================================================================
--- 
core3/api/trunk/presentation-api/src/test/java/org/cytoscape/view/presentation/RichVisualLexiconTest.java
   2011-10-12 20:03:43 UTC (rev 27144)
+++ 
core3/api/trunk/presentation-api/src/test/java/org/cytoscape/view/presentation/RichVisualLexiconTest.java
   2011-10-12 21:17:32 UTC (rev 27145)
@@ -31,7 +31,7 @@
 
        @Test
        public void test2DLexicon() throws Exception {
-               assertEquals(50, richLex.getAllVisualProperties().size());
+               assertEquals(51, richLex.getAllVisualProperties().size());
        }
 
        @Test

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/EdgeView.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/EdgeView.java
    2011-10-12 20:03:43 UTC (rev 27144)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/EdgeView.java
    2011-10-12 21:17:32 UTC (rev 27145)
@@ -265,4 +265,8 @@
        public double getLabelOffsetX();
        public double getLabelOffsetY();
        public int getEdgeLabelAnchor();
+
+       
+       int getTransparency();
+       void setTransparency(final int transparency);
 }

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeDetails.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeDetails.java
   2011-10-12 20:03:43 UTC (rev 27144)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeDetails.java
   2011-10-12 21:17:32 UTC (rev 27145)
@@ -109,6 +109,7 @@
                m_labelWidths = new HashMap<Integer, Double>();
                
                m_segmentPaints = new HashMap<Integer, Paint>();
+               
                m_selectedPaints = new HashMap<Integer, Paint>();
                
                m_colorsLowDetail = new IntObjHash();
@@ -446,8 +447,8 @@
                        isCleared = false;
                }
        }
-
        
+       
        /**
         * {@inheritDoc}
         */

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeView.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeView.java
      2011-10-12 20:03:43 UTC (rev 27144)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeView.java
      2011-10-12 21:17:32 UTC (rev 27145)
@@ -66,10 +66,13 @@
        static final Paint DEFAULT_LABEL_PAINT = Color.black;
        
        DGraphView m_view;
+       
        final int m_inx; // Positive.
        boolean m_selected;
        
        Paint m_unselectedPaint;
+       
+       private Integer transparency;
 
        Paint m_sourceUnselectedPaint;
        Paint m_sourceSelectedPaint;
@@ -223,14 +226,13 @@
                                throw new NullPointerException("paint is null");
 
                        m_unselectedPaint = paint;
+                       m_unselectedPaint = new Color(((Color) 
m_unselectedPaint).getRed(),
+                                       ((Color) m_unselectedPaint).getGreen(), 
((Color) m_unselectedPaint).getBlue(), transparency);
 
                        if (!isSelected()) {
-                               m_view.m_edgeDetails.overrideSegmentPaint(m_inx,
-                                               m_unselectedPaint);
-
+                               
m_view.m_edgeDetails.overrideSegmentPaint(m_inx, m_unselectedPaint);
                                if (m_unselectedPaint instanceof Color)
-                                       
m_view.m_edgeDetails.overrideColorLowDetail(m_inx,
-                                                       (Color) 
m_unselectedPaint);
+                                       
m_view.m_edgeDetails.overrideColorLowDetail(m_inx, (Color) m_unselectedPaint);
 
                                m_view.m_contentChanged = true;
                        }
@@ -1367,7 +1369,42 @@
                        return m_view.m_edgeDetails.labelWidth(m_inx);
                }
        }
+       
+       
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public int getTransparency() {
+               return transparency;
+       }
+       
+       /**
+        * {@inheritDoc}
+        */
+       @Override
+       public void setTransparency(int trans) {
+               synchronized (m_view.m_lock) {
+                       if (trans < 0 || trans > 255)
+                               throw new 
IllegalArgumentException("Transparency is out of range.");
+                       
+                       transparency = trans;
 
+                       if (m_unselectedPaint instanceof Color) {
+
+                               m_unselectedPaint = new Color(((Color) 
m_unselectedPaint).getRed(),
+                                               ((Color) 
m_unselectedPaint).getGreen(), ((Color) m_unselectedPaint).getBlue(), trans);
+
+                               
m_view.m_edgeDetails.overrideSegmentPaint(m_inx, m_unselectedPaint);
+                               
m_view.m_edgeDetails.overrideColorLowDetail(m_inx, (Color) m_unselectedPaint);
+                       }
+                       m_view.m_contentChanged = true;
+               }
+
+       }
+
+       
+
        @Override
        public <T, V extends T> void setVisualProperty(VisualProperty<? extends 
T> vpOriginal, V value) {
                
@@ -1432,12 +1469,11 @@
                                
setStroke(DLineType.getDLineType(lineType).getStroke(newWidth));
                        }                       
                } else if (vp == DVisualLexicon.EDGE_LINE_TYPE) {
-//                     if(lineType == value)
-//                             return;
-                       
                        lineType = (LineType) value;
                        final Stroke newStroke = 
DLineType.getDLineType(lineType).getStroke(getStrokeWidth());
                        setStroke(newStroke);
+               } else if (vp == DVisualLexicon.EDGE_TRANSPARENCY) {
+                       setTransparency(((Number) value).intValue());
                } else if (vp == 
DVisualLexicon.EDGE_SOURCE_ARROW_SELECTED_PAINT) {
                        setSourceEdgeEndSelectedPaint((Paint) value);
                } else if (vp == 
DVisualLexicon.EDGE_TARGET_ARROW_SELECTED_PAINT) {

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
      2011-10-12 20:03:43 UTC (rev 27144)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
      2011-10-12 21:17:32 UTC (rev 27145)
@@ -282,13 +282,13 @@
                        m_unselectedPaint = paint;
 
                        if (!isSelected()) {
+                               m_unselectedPaint = new Color(((Color) 
m_unselectedPaint).getRed(),
+                                               ((Color) 
m_unselectedPaint).getGreen(), ((Color) m_unselectedPaint).getBlue(), 
transparency);
+                               
                                
graphView.m_nodeDetails.overrideFillPaint(m_inx, m_unselectedPaint);
 
-                               if (m_unselectedPaint instanceof Color) {
-                                       m_unselectedPaint = new Color(((Color) 
m_unselectedPaint).getRed(),
-                                                       ((Color) 
m_unselectedPaint).getGreen(), ((Color) m_unselectedPaint).getBlue(), 
transparency);
+                               if (m_unselectedPaint instanceof Color)
                                        
graphView.m_nodeDetails.overrideColorLowDetail(m_inx, (Color) 
m_unselectedPaint);
-                               }
 
                                graphView.m_contentChanged = true;
                        }

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/EdgeViewDefaultSupport.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/EdgeViewDefaultSupport.java
 2011-10-12 20:03:43 UTC (rev 27144)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/EdgeViewDefaultSupport.java
 2011-10-12 21:17:32 UTC (rev 27145)
@@ -28,6 +28,7 @@
 package org.cytoscape.ding.impl;
 
 
+import java.awt.Color;
 import java.awt.Font;
 import java.awt.Paint;
 import java.awt.Stroke;
@@ -52,6 +53,11 @@
        private float fontSize;
        private LineType lineType;
        private float strokeWidth;
+       
+       private int transparency;
+       
+       private Paint unselectedPaint;
+       private Paint selectedPaint;
 
        <T, V extends T> void setEdgeViewDefault(VisualProperty<? extends T> 
vp, V value) {
                
@@ -59,7 +65,10 @@
                        value = (V) vp.getDefault();
                
                if (vp == DVisualLexicon.EDGE_STROKE_SELECTED_PAINT) {
+                       
                        setSelectedPaint((Paint) value);
+               } else if (vp == DVisualLexicon.EDGE_TRANSPARENCY) {
+                       setTransparency(((Number) value).intValue());
                } else if (vp == DVisualLexicon.EDGE_STROKE_UNSELECTED_PAINT) {
                        setUnselectedPaint((Paint) value);
                } else if (vp == DVisualLexicon.EDGE_SELECTED_PAINT) {
@@ -113,6 +122,13 @@
        }
                
 
+       void setTransparency(int trans) {
+               transparency = trans;
+               setSelectedPaint(selectedPaint);
+               setUnselectedPaint(unselectedPaint);
+       }
+
+
        void setStrokeWidth(float width) {
                synchronized (lock) {
                        edgeDetails.setSegmentThicknessDefault(width);
@@ -127,16 +143,26 @@
 
        void setUnselectedPaint(final Paint paint) {
                synchronized (lock) {
-                       edgeDetails.setSegmentPaintDefault(paint);
-                       edgeDetails.setColorLowDetailDefault(paint);
+                       unselectedPaint = paint;
+                       final Paint transColor = getTransparentColor(paint);
+                       edgeDetails.setSegmentPaintDefault(transColor);
+                       edgeDetails.setColorLowDetailDefault(transColor);
                }
        }
 
        void setSelectedPaint(final Paint paint) {
                synchronized (lock) {
-                       edgeDetails.setSelectedPaintDefault(paint);
+                       selectedPaint = paint;
+                       
edgeDetails.setSelectedPaintDefault(getTransparentColor(paint));
                }
        }
+       
+       private Paint getTransparentColor(Paint p) {
+               if (p != null && p instanceof Color) 
+                       return new Color(((Color) p).getRed(), ((Color) 
p).getGreen(), ((Color) p).getBlue(), transparency);
+               else
+                       return p;
+       }
 
        public void setSourceEdgeEndSelectedPaint(Paint paint) {
                synchronized (lock) {

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