/[cashew-s-editor]/cashews/src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java
ViewVC logotype

Diff of /cashews/src/nongnu/cashews/eclipse/composer/parts/ConnectionPart.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by gnu_andrew, Thu Mar 31 17:35:21 2005 UTC revision 1.2 by gnu_andrew, Thu May 5 23:47:58 2005 UTC
# Line 37  to any source code in the Content. Line 37  to any source code in the Content.
37    
38  package nongnu.cashews.eclipse.composer.parts;  package nongnu.cashews.eclipse.composer.parts;
39    
40  import nongnu.cashews.eclipse.composer.model.Connection;  import nongnu.cashews.eclipse.composer.figures.PerformanceNodeFigure;
41    import nongnu.cashews.eclipse.composer.model.ConnectionElement;
42    import nongnu.cashews.eclipse.composer.model.PerformanceElement;
43    import nongnu.cashews.eclipse.composer.model.Node;
44    
45    import org.eclipse.draw2d.Ellipse;
46    import org.eclipse.draw2d.FigureListener;
47    import org.eclipse.draw2d.IFigure;
48    import org.eclipse.draw2d.Label;
49  import org.eclipse.draw2d.PolygonDecoration;  import org.eclipse.draw2d.PolygonDecoration;
50  import org.eclipse.draw2d.PolylineConnection;  import org.eclipse.draw2d.PolylineConnection;
51    import org.eclipse.draw2d.RoundedRectangle;
52    import org.eclipse.draw2d.geometry.Dimension;
53    import org.eclipse.draw2d.geometry.Point;
54  import org.eclipse.draw2d.geometry.PointList;  import org.eclipse.draw2d.geometry.PointList;
55    import org.eclipse.draw2d.geometry.Rectangle;
56    import org.eclipse.gef.GraphicalEditPart;
57  import org.eclipse.gef.editparts.AbstractConnectionEditPart;  import org.eclipse.gef.editparts.AbstractConnectionEditPart;
58    import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
59    
60  public class ConnectionPart  public class ConnectionPart
61    extends AbstractConnectionEditPart    extends AbstractConnectionEditPart
# Line 51  public class ConnectionPart Line 64  public class ConnectionPart
64    // ------------------------------------------------------------------------    // ------------------------------------------------------------------------
65    // Abstract methods from AbstractEditPart    // Abstract methods from AbstractEditPart
66    
67      private String name;
68    
69      private Ellipse ellipseFigure;
70    
71      private Label label;
72    
73    protected void createEditPolicies()    protected void createEditPolicies()
74    {    {
75      // none at present      // none at present
# Line 58  public class ConnectionPart Line 77  public class ConnectionPart
77    
78    protected void refreshVisuals()    protected void refreshVisuals()
79    {    {
80      PolylineConnection figure = (PolylineConnection) getFigure();        try
81      Connection connx = (Connection) getModel();        {
82            PolylineConnection figure = (PolylineConnection) getFigure();
83            ConnectionElement connx = (ConnectionElement) getModel();
84      // figure.setRoutingConstraint(MagicHelper.getConnectionBendpoints(connx));      // figure.setRoutingConstraint(MagicHelper.getConnectionBendpoints(connx));
85    
86      PolygonDecoration decoration = new PolygonDecoration();      PolygonDecoration decoration = new PolygonDecoration();
# Line 71  public class ConnectionPart Line 92  public class ConnectionPart
92      decoration.setFill(true);      decoration.setFill(true);
93      decoration.setTemplate(decorationPointList);      decoration.setTemplate(decorationPointList);
94      figure.setTargetDecoration(decoration);      figure.setTargetDecoration(decoration);
95        
96        if (figure.getChildren().size() > 1)
97        {
98         figure.remove(ellipseFigure);  
99        }
100        
101        ellipseFigure = new Ellipse();
102        Dimension d = new Dimension(40, 40);
103        label = new Label();
104        
105        ellipseFigure.setLocation(midPoint(connx.getSource().getLocation(), connx.getTarget().getLocation()));
106        
107        
108        figure.add(ellipseFigure);
109        
110        figure.addFigureListener
111        (
112                new FigureListener()
113                {
114    
115                  public void figureMoved(IFigure source)
116                  {
117                    ConnectionElement connx = (ConnectionElement) getModel();
118                    ellipseFigure.setLocation(midPoint(connx.getSource().getLocation(), connx.getTarget().getLocation()));
119                  }
120                    
121                }
122        );
123    
124          }
125          catch(Exception e)
126          {
127            e.printStackTrace();
128            System.out.println("Refresh Visuals");
129          }
130        
131      }
132      public Point midPoint(Point x, Point y)
133      {
134          Point p = new Point ( (x.x + y.x)/2, (x.y + y.y) /2 );
135          return p;
136    }    }
137  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26