Author: kono
Date: 2012-06-19 13:26:22 -0700 (Tue, 19 Jun 2012)
New Revision: 29620

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/DEdgeView.java
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
   
core3/impl/trunk/ding-impl/ding-presentation-impl/src/test/java/org/cytoscape/ding/EdgeBendTest.java
Log:
fixes #1119 Editing on the network view directly creates individual Edge Bend 
information.

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
   2012-06-19 19:40:31 UTC (rev 29619)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeDetails.java
   2012-06-19 20:26:22 UTC (rev 29620)
@@ -783,14 +783,23 @@
        }
 
 
+       public Bend bend(final CyEdge edge) {   
+               return bend(edge, false);
+       }
+       
        /**
         * Returns current Edge Bend value.
         * @param edge
         * @return edge Bend
         */
-       public Bend bend(final CyEdge edge) {           
+       public Bend bend(final CyEdge edge, boolean forceCreate) {              
                Bend bend = m_edgeBends.get(edge);
                
+               if(bend == null && forceCreate) {
+                       bend = new BendImpl();
+                       m_edgeBends.put(edge, bend);
+               }
+               
                if(bend == null) {
                        if (m_edgeBendDefault == null)
                                return EdgeBendVisualProperty.DEFAULT_EDGE_BEND;

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
      2012-06-19 19:40:31 UTC (rev 29619)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/DEdgeView.java
      2012-06-19 20:26:22 UTC (rev 29620)
@@ -550,7 +550,9 @@
        protected int addHandlePoint(final Point2D pt) {
                synchronized (m_view.m_lock) {
                        
-                       final Bend bend = m_view.m_edgeDetails.bend(model);
+                       // Obtain existing Bend object
+                       final Bend bend = m_view.m_edgeDetails.bend(model, 
true);
+                       
                        if (bend.getAllHandles().size() == 0) {
                                // anchors object is empty. Add first handle.
                                addHandleInternal(0, pt);

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
    2012-06-19 19:40:31 UTC (rev 29619)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/main/java/org/cytoscape/ding/impl/InnerCanvas.java
    2012-06-19 20:26:22 UTC (rev 29620)
@@ -47,6 +47,7 @@
 import java.awt.geom.GeneralPath;
 import java.awt.geom.Line2D;
 import java.awt.geom.Point2D;
+import java.awt.geom.Point2D.Float;
 import java.awt.image.BufferedImage;
 
 import javax.swing.JComponent;
@@ -437,8 +438,9 @@
        }
        
        
-       private void toggleChosenAnchor (long chosenAnchor, MouseEvent e) {
-               if (e.isControlDown()) {
+       private void toggleChosenAnchor (long chosenAnchor, MouseEvent e) {     
        
+               if (e.isAltDown() || e.isMetaDown()) {
+                       // Remove handle
                        final long edge = chosenAnchor >>> 6;
                        final int anchorInx = (int)(chosenAnchor & 
0x000000000000003f);
                        // Save remove handle
@@ -466,7 +468,7 @@
        private int toggleSelectedEdge(long chosenEdge, MouseEvent e) {
                int chosenEdgeSelected = 0;
                
-               // Set Edge Bend.
+               // Add new Handle for Edge Bend.
                if ((e.isAltDown() || e.isMetaDown()) && ((m_lastRenderDetail & 
GraphRenderer.LOD_EDGE_ANCHORS) != 0)) {
                        
                        m_view.m_selectedAnchors.empty();
@@ -475,8 +477,8 @@
                        m_view.xformComponentToNodeCoords(m_ptBuff);
                        // Store current handle list
                        m_undoable_edit = new ViewChangeEdit(m_view, 
ViewChangeEdit.SavedObjs.SELECTED_EDGES, "Add Edge Handle", m_undo);
-                       final int chosenInx = 
m_view.getDEdgeView(chosenEdge).addHandlePoint(new Point2D.Float(
-                                       (float) m_ptBuff[0], (float) 
m_ptBuff[1]));
+                       final Point2D newHandlePoint = new 
Point2D.Float((float) m_ptBuff[0], (float) m_ptBuff[1]);
+                       final int chosenInx = 
m_view.getDEdgeView(chosenEdge).addHandlePoint(newHandlePoint);
                        
                        m_view.m_selectedAnchors.insert(((chosenEdge) << 6) | 
chosenInx);
                }
@@ -512,7 +514,6 @@
                return chosenEdgeSelected;
        }
        
-
        private long[] setSelectedNodes() {
                long [] selectedNodes = null;
                
@@ -943,7 +944,6 @@
                                final long edge = edgeAndAnchor >>> 6;
                                final int anchorInx = (int)(edgeAndAnchor & 
0x000000000000003f);
                                final DEdgeView ev = (DEdgeView) 
m_view.getDEdgeView(edge);
-                               //ev.getHandleInternal(anchorInx, m_floatBuff1);
                                
                                final Bend bend = ev.getBend();
                                final Handle handle = 
bend.getAllHandles().get(anchorInx);
@@ -1084,14 +1084,6 @@
        
                @Override
                void singleLeftControlClick(MouseEvent e) {
-                       //System.out.println("MousePressed ----> 
singleLeftControlClick");
-                       
-                       /* clicking on empty space
-                       if ((getChosenNode() < 0) && (getChosenEdge() < 0) && 
(getChosenAnchor() < 0)) {
-                               popup.createEmptySpaceMenu(e.getX(), 
e.getY(),"NEW"); 
-                       }
-                       */
-                       
                        // Cascade
                        this.singleLeftClick(e);
                }
@@ -1306,8 +1298,6 @@
                                                final int anchorInx = 
(int)(edgeAndAnchor & 0x000000000000003f);
                                                final DEdgeView ev = 
(DEdgeView) m_view.getDEdgeView(edge);
                                                
-                                               
//ev.getHandleInternal(anchorInx, m_floatBuff1);
-                                               
                                                final Bend bend = ev.getBend();
                                                final Handle handle = 
bend.getAllHandles().get(anchorInx);
                                                final Point2D newPoint = 
handle.calculateHandleLocation(m_view.getViewModel(),ev);

Modified: 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/test/java/org/cytoscape/ding/EdgeBendTest.java
===================================================================
--- 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/test/java/org/cytoscape/ding/EdgeBendTest.java
        2012-06-19 19:40:31 UTC (rev 29619)
+++ 
core3/impl/trunk/ding-impl/ding-presentation-impl/src/test/java/org/cytoscape/ding/EdgeBendTest.java
        2012-06-19 20:26:22 UTC (rev 29620)
@@ -22,7 +22,6 @@
        @Test
        public void testEdgeBend() {
                Bend bend1 = new BendImpl();
-               
                bend1.insertHandleAt(0, new HandleImpl(10, 20));
        }
 

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