Author: rozagh
Date: 2012-06-18 15:24:24 -0700 (Mon, 18 Jun 2012)
New Revision: 29610

Modified:
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
Log:
fixes #1117 applying node aspect ratio for vector type custom graphics 

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
      2012-06-18 22:01:14 UTC (rev 29609)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DNodeView.java
      2012-06-18 22:24:24 UTC (rev 29610)
@@ -1295,9 +1295,9 @@
                        // Assume it's a Ding layer
                        CustomGraphic newCG = layer.getLayerObject();
                        CustomGraphic finalCG = newCG;
-                       
+
                        if (sync) {
-                               // Size is locked to node size.
+                               // Size is locked to node size.                 
        
                                finalCG = syncSize(customGraphics, newCG);
                        }
                        finalCG = moveCustomGraphicsToNewPosition(finalCG, 
positionValue);
@@ -1310,11 +1310,11 @@
        }
 
        private void applyCustomGraphicsPosition(final VisualProperty<?> vp, 
final ObjectPosition position) {
-               
+
                // No need to modify
                if (position == null)
                        return;
-               
+
                // Use dependency to retrieve its parent.
                final VisualLexiconNode lexNode = 
lexicon.getVisualLexiconNode(vp);
                final Collection<VisualLexiconNode> leavs = 
lexNode.getParent().getChildren();
@@ -1362,11 +1362,16 @@
                final AffineTransform scale;
                final float fit = graphics.getFitRatio();
 
-               // Case 1: node height value is larger than width
-               if (nodeW >= nodeH) {
-                       scale = AffineTransform.getScaleInstance(fit * (nodeW / 
cgW) * (nodeH / nodeW), fit * nodeH / cgH);
+               // Case 1: if custom graphic is a vector fit width and length
+               if (graphics instanceof VectorCustomGraphics) {
+                       scale = AffineTransform.getScaleInstance(fit * nodeW / 
cgW, fit * nodeH / cgH);
                } else {
-                       scale = AffineTransform.getScaleInstance(fit * nodeW / 
cgW, fit * (nodeH / cgH) * (nodeW / nodeH));
+                       // Case 2: node height value is larger than width
+                       if (nodeW >= nodeH) {
+                               scale = AffineTransform.getScaleInstance(fit * 
(nodeW / cgW) * (nodeH / nodeW), fit * nodeH / cgH);
+                       } else {
+                               scale = AffineTransform.getScaleInstance(fit * 
nodeW / cgW, fit * (nodeH / cgH) * (nodeW / nodeH));
+                       }
                }
                return new 
CustomGraphic(scale.createTransformedShape(originalShape), 
cg.getPaintFactory());
        }

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