View | Details | Raw Unified | Return to bug 202849
Collapse All | Expand All

(-)src/org/eclipse/mylyn/zest/core/widgets/Graph.java (-4 / +30 lines)
Lines 21-28 Link Here
21
import org.eclipse.draw2d.FreeformLayer;
21
import org.eclipse.draw2d.FreeformLayer;
22
import org.eclipse.draw2d.FreeformLayout;
22
import org.eclipse.draw2d.FreeformLayout;
23
import org.eclipse.draw2d.FreeformViewport;
23
import org.eclipse.draw2d.FreeformViewport;
24
import org.eclipse.draw2d.Graphics;
24
import org.eclipse.draw2d.IFigure;
25
import org.eclipse.draw2d.IFigure;
25
import org.eclipse.draw2d.LayoutAnimator;
26
import org.eclipse.draw2d.LayoutAnimator;
27
import org.eclipse.draw2d.MouseListener;
26
import org.eclipse.draw2d.MouseMotionListener;
28
import org.eclipse.draw2d.MouseMotionListener;
27
import org.eclipse.draw2d.SWTEventDispatcher;
29
import org.eclipse.draw2d.SWTEventDispatcher;
28
import org.eclipse.draw2d.ScalableFigure;
30
import org.eclipse.draw2d.ScalableFigure;
Lines 101-106 Link Here
101
	LayoutAlgorithm layoutAlgorithm = null;
103
	LayoutAlgorithm layoutAlgorithm = null;
102
	private Dimension preferredSize = null;
104
	private Dimension preferredSize = null;
103
	int style = 0;
105
	int style = 0;
106
	private boolean antiAliasing;
104
107
105
	private ScalableFreeformLayeredPane rootlayer;
108
	private ScalableFreeformLayeredPane rootlayer;
106
	private ZestRootLayer zestRootLayer;
109
	private ZestRootLayer zestRootLayer;
Lines 161-167 Link Here
161
		});
164
		});
162
165
163
		this.setContents(createLayers());
166
		this.setContents(createLayers());
164
		DragSupport dragSupport = new DragSupport(this);
167
		IDragSupport dragSupport = createDragSupport();
165
		this.getLightweightSystem().getRootFigure().addMouseListener(dragSupport);
168
		this.getLightweightSystem().getRootFigure().addMouseListener(dragSupport);
166
		this.getLightweightSystem().getRootFigure().addMouseMotionListener(dragSupport);
169
		this.getLightweightSystem().getRootFigure().addMouseMotionListener(dragSupport);
167
170
Lines 465-474 Link Here
465
468
466
	}
469
	}
467
470
471
	public interface IDragSupport extends MouseMotionListener, MouseListener {
472
473
	}
474
475
	protected IDragSupport createDragSupport() {
476
		return new DragSupport(this);
477
	}
478
468
	// /////////////////////////////////////////////////////////////////////////////////
479
	// /////////////////////////////////////////////////////////////////////////////////
469
	// PRIVATE METHODS. These are NON API
480
	// PRIVATE METHODS. These are NON API
470
	// /////////////////////////////////////////////////////////////////////////////////
481
	// /////////////////////////////////////////////////////////////////////////////////
471
	class DragSupport implements MouseMotionListener, org.eclipse.draw2d.MouseListener {
482
	class DragSupport implements IDragSupport {
472
		/**
483
		/**
473
		 * 
484
		 * 
474
		 */
485
		 */
Lines 1043-1049 Link Here
1043
	}
1054
	}
1044
1055
1045
	private ScalableFigure createLayers() {
1056
	private ScalableFigure createLayers() {
1046
		rootlayer = new ScalableFreeformLayeredPane();
1057
		rootlayer = new ScalableFreeformLayeredPane() {
1058
			public void paint(Graphics graphics) {
1059
				if (isAntiAliasing()) {
1060
					graphics.setAntialias(SWT.ON);
1061
				}
1062
1063
				super.paint(graphics);
1064
			}
1065
		};
1047
		rootlayer.setLayoutManager(new FreeformLayout());
1066
		rootlayer.setLayoutManager(new FreeformLayout());
1048
		zestRootLayer = new ZestRootLayer();
1067
		zestRootLayer = new ZestRootLayer();
1049
1068
Lines 1164-1171 Link Here
1164
		return GraphItem.GRAPH;
1183
		return GraphItem.GRAPH;
1165
	}
1184
	}
1166
1185
1167
	GraphItem getGraphItem(IFigure figure) {
1186
	public GraphItem getGraphItem(IFigure figure) {
1168
		return (GraphItem) figure2ItemMap.get(figure);
1187
		return (GraphItem) figure2ItemMap.get(figure);
1169
	}
1188
	}
1170
1189
1190
	public boolean isAntiAliasing() {
1191
		return antiAliasing;
1192
	}
1193
1194
	public void setAntiAliasing(boolean antiAliasing) {
1195
		this.antiAliasing = antiAliasing;
1196
	}
1171
}
1197
}
(-)src/org/eclipse/mylyn/zest/examples/uml/UMLExample.java (-19 / +15 lines)
Lines 16-22 Link Here
16
import org.eclipse.mylyn.zest.core.widgets.GraphConnection;
16
import org.eclipse.mylyn.zest.core.widgets.GraphConnection;
17
import org.eclipse.mylyn.zest.core.widgets.GraphContainer;
17
import org.eclipse.mylyn.zest.core.widgets.GraphContainer;
18
import org.eclipse.mylyn.zest.core.widgets.GraphNode;
18
import org.eclipse.mylyn.zest.core.widgets.GraphNode;
19
import org.eclipse.mylyn.zest.core.widgets.IContainer;
20
import org.eclipse.mylyn.zest.core.widgets.ZestStyles;
19
import org.eclipse.mylyn.zest.core.widgets.ZestStyles;
21
import org.eclipse.mylyn.zest.layouts.LayoutStyles;
20
import org.eclipse.mylyn.zest.layouts.LayoutStyles;
22
import org.eclipse.mylyn.zest.layouts.algorithms.SpringLayoutAlgorithm;
21
import org.eclipse.mylyn.zest.layouts.algorithms.SpringLayoutAlgorithm;
Lines 80-100 Link Here
80
		return classFigure;
79
		return classFigure;
81
	}
80
	}
82
81
83
	static class UMLNode extends GraphNode {
84
85
		IFigure customFigure = null;
86
87
		public UMLNode(IContainer graphModel, int style, IFigure figure) {
88
			super(graphModel, style);
89
			this.customFigure = figure;
90
		}
91
92
		protected IFigure createFigureForModel() {
93
			return customFigure;
94
		}
95
96
	}
97
98
	/**
82
	/**
99
	 * @param args
83
	 * @param args
100
	 */
84
	 */
Lines 109-118 Link Here
109
		g.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
93
		g.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
110
		GraphContainer c = new GraphContainer(g, SWT.NONE);
94
		GraphContainer c = new GraphContainer(g, SWT.NONE);
111
		c.setText("A UML Container");
95
		c.setText("A UML Container");
112
		UMLNode n = new UMLNode(c, SWT.NONE, createClassFigure1());
96
		GraphNode n = new GraphNode(c, SWT.NONE) {
97
			protected IFigure createFigureForModel() {
98
				return createClassFigure1();
99
			}
100
		};
113
101
114
		GraphNode n1 = new UMLNode(g, SWT.NONE, createClassFigure1());
102
		GraphNode n1 = new GraphNode(g, SWT.NONE) {
115
		GraphNode n2 = new UMLNode(g, SWT.NONE, createClassFigure2());
103
			protected IFigure createFigureForModel() {
104
				return createClassFigure1();
105
			}
106
		};
107
		GraphNode n2 = new GraphNode(g, SWT.NONE) {
108
			protected IFigure createFigureForModel() {
109
				return createClassFigure2();
110
			}
111
		};
116
112
117
		new GraphConnection(g, SWT.NONE, n1, n2);
113
		new GraphConnection(g, SWT.NONE, n1, n2);
118
		new GraphConnection(g, SWT.NONE, n, n1);
114
		new GraphConnection(g, SWT.NONE, n, n1);
(-)src/org/eclipse/mylyn/zest/core/viewers/GraphViewer.java (+47 lines)
Lines 19-24 Link Here
19
import org.eclipse.jface.viewers.ISelectionChangedListener;
19
import org.eclipse.jface.viewers.ISelectionChangedListener;
20
import org.eclipse.jface.viewers.ISelectionProvider;
20
import org.eclipse.jface.viewers.ISelectionProvider;
21
import org.eclipse.jface.viewers.SelectionChangedEvent;
21
import org.eclipse.jface.viewers.SelectionChangedEvent;
22
import org.eclipse.mylyn.zest.core.widgets.ConstraintAdapter;
22
import org.eclipse.mylyn.zest.core.widgets.Graph;
23
import org.eclipse.mylyn.zest.core.widgets.Graph;
23
import org.eclipse.mylyn.zest.core.widgets.GraphItem;
24
import org.eclipse.mylyn.zest.core.widgets.GraphItem;
24
import org.eclipse.mylyn.zest.core.widgets.ZestStyles;
25
import org.eclipse.mylyn.zest.core.widgets.ZestStyles;
Lines 73-78 Link Here
73
		hookControl(this.graph);
74
		hookControl(this.graph);
74
	}
75
	}
75
76
77
	public GraphViewer(Graph graphModel) {
78
		super(graphModel.getStyle());
79
		setControl(graphModel);
80
	}
81
76
	public void setControl(Graph graphModel) {
82
	public void setControl(Graph graphModel) {
77
		this.graph = graphModel;
83
		this.graph = graphModel;
78
		hookControl(this.graph);
84
		hookControl(this.graph);
Lines 296-299 Link Here
296
		return graph.getLayoutAlgorithm();
302
		return graph.getLayoutAlgorithm();
297
	}
303
	}
298
304
305
	/* (non-Javadoc)
306
	 * @see org.eclipse.mylyn.zest.core.viewers.internal.AbstractStructuredGraphViewer#addConstraintAdapter(org.eclipse.mylyn.zest.core.widgets.ConstraintAdapter)
307
	 */
308
	public void addConstraintAdapter(ConstraintAdapter constraintAdapter) {
309
		super.addConstraintAdapter(constraintAdapter);
310
	}
311
312
	/* (non-Javadoc)
313
	 * @see org.eclipse.mylyn.zest.core.viewers.internal.AbstractStructuredGraphViewer#addNode(java.lang.Object)
314
	 */
315
	public void addNode(Object element) {
316
		super.addNode(element);
317
	}
318
319
	/* (non-Javadoc)
320
	 * @see org.eclipse.mylyn.zest.core.viewers.internal.AbstractStructuredGraphViewer#addRelationship(java.lang.Object)
321
	 */
322
	public void addRelationship(Object connection) {
323
		super.addRelationship(connection);
324
	}
325
326
	/* (non-Javadoc)
327
	 * @see org.eclipse.mylyn.zest.core.viewers.internal.AbstractStructuredGraphViewer#removeNode(java.lang.Object)
328
	 */
329
	public void removeNode(Object element) {
330
		super.removeNode(element);
331
	}
332
333
	/* (non-Javadoc)
334
	 * @see org.eclipse.mylyn.zest.core.viewers.internal.AbstractStructuredGraphViewer#removeRelationship(java.lang.Object)
335
	 */
336
	public void removeRelationship(Object connection) {
337
		super.removeRelationship(connection);
338
	}
339
340
	/* (non-Javadoc)
341
	 * @see org.eclipse.mylyn.zest.core.viewers.AbstractZoomableViewer#zoomTo(int, int, int, int)
342
	 */
343
	public void zoomTo(int x, int y, int width, int height) {
344
		super.zoomTo(x, y, width, height);
345
	}
299
}
346
}

Return to bug 202849