Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 334439
Collapse All | Expand All

(-)src/org/eclipse/draw2d/examples/cg/ObstructionExample.java (-24 / +24 lines)
Lines 66-78 Link Here
66
			addMouseListener(new MouseListener.Stub() {
66
			addMouseListener(new MouseListener.Stub() {
67
				public void mousePressed(MouseEvent event) {
67
				public void mousePressed(MouseEvent event) {
68
					event.consume();
68
					event.consume();
69
					offset.setWidth(event.x - getLocation().x());
69
					offset.width = event.x - getLocation().x;
70
					offset.setHeight(event.y - getLocation().y());
70
					offset.height = event.y - getLocation().y;
71
				}
71
				}
72
72
73
				public void mouseReleased(MouseEvent event) {
73
				public void mouseReleased(MouseEvent event) {
74
					offset.setWidth(0);
74
					offset.width = 0;
75
					offset.setHeight(0);
75
					offset.height = 0;
76
					if (event.button == 3) {
76
					if (event.button == 3) {
77
						getParent().remove(oFigure);
77
						getParent().remove(oFigure);
78
						getParent().remove(thisFigure);
78
						getParent().remove(thisFigure);
Lines 95-102 Link Here
95
			addMouseMotionListener(new MouseMotionListener.Stub() {
95
			addMouseMotionListener(new MouseMotionListener.Stub() {
96
				public void mouseDragged(MouseEvent event) {
96
				public void mouseDragged(MouseEvent event) {
97
					Rectangle rect = getBounds().getCopy();
97
					Rectangle rect = getBounds().getCopy();
98
					rect.setX(event.x - offset.width());
98
					rect.x = event.x - offset.width;
99
					rect.setY(event.y - offset.height());
99
					rect.y = event.y - offset.height;
100
					setBounds(rect);
100
					setBounds(rect);
101
					int index = 0;
101
					int index = 0;
102
					if (isSource) {
102
					if (isSource) {
Lines 105-111 Link Here
105
						router.removePath(path);
105
						router.removePath(path);
106
						paths.remove(path);
106
						paths.remove(path);
107
						sourceList.remove(loc);
107
						sourceList.remove(loc);
108
						loc = new Point(rect.x() + 10, rect.y() + 10);
108
						loc = new Point(rect.x + 10, rect.y + 10);
109
						sourceList.add(index, loc);
109
						sourceList.add(index, loc);
110
						path = new Path(loc, (Point) targetList.get(index));
110
						path = new Path(loc, (Point) targetList.get(index));
111
						router.addPath(path);
111
						router.addPath(path);
Lines 117-123 Link Here
117
						router.removePath(path);
117
						router.removePath(path);
118
						paths.remove(path);
118
						paths.remove(path);
119
						targetList.remove(loc);
119
						targetList.remove(loc);
120
						loc = new Point(rect.x() + 10, rect.y() + 10);
120
						loc = new Point(rect.x + 10, rect.y + 10);
121
						targetList.add(index, loc);
121
						targetList.add(index, loc);
122
						path = new Path((Point) sourceList.get(index), loc);
122
						path = new Path((Point) sourceList.get(index), loc);
123
						router.addPath(path);
123
						router.addPath(path);
Lines 148-160 Link Here
148
			addMouseListener(new MouseListener.Stub() {
148
			addMouseListener(new MouseListener.Stub() {
149
				public void mousePressed(MouseEvent event) {
149
				public void mousePressed(MouseEvent event) {
150
					event.consume();
150
					event.consume();
151
					offset.setWidth(event.x - getLocation().x());
151
					offset.width = event.x - getLocation().x;
152
					offset.setHeight(event.y - getLocation().y());
152
					offset.height = event.y - getLocation().y;
153
				}
153
				}
154
154
155
				public void mouseReleased(MouseEvent event) {
155
				public void mouseReleased(MouseEvent event) {
156
					offset.setWidth(0);
156
					offset.width = 0;
157
					offset.setHeight(0);
157
					offset.height = 0;
158
					if (event.button == 3) {
158
					if (event.button == 3) {
159
						getParent().remove(thisFigure);
159
						getParent().remove(thisFigure);
160
						router.removeObstacle((Rectangle) ObstructionExample.obstacleMap
160
						router.removeObstacle((Rectangle) ObstructionExample.obstacleMap
Lines 167-174 Link Here
167
				public void mouseDragged(MouseEvent event) {
167
				public void mouseDragged(MouseEvent event) {
168
168
169
					Rectangle rect = getBounds().getCopy();
169
					Rectangle rect = getBounds().getCopy();
170
					rect.setX(event.x - offset.width());
170
					rect.x = event.x - offset.width;
171
					rect.setY(event.y - offset.height());
171
					rect.y = event.y - offset.height;
172
					router.updateObstacle(
172
					router.updateObstacle(
173
							(Rectangle) ObstructionExample.obstacleMap
173
							(Rectangle) ObstructionExample.obstacleMap
174
									.get(thisFigure), rect);
174
									.get(thisFigure), rect);
Lines 183-191 Link Here
183
			super.paint(graphics);
183
			super.paint(graphics);
184
			Rectangle b = getBounds();
184
			Rectangle b = getBounds();
185
			Point p = b.getCenter().translate(-22, -15);
185
			Point p = b.getCenter().translate(-22, -15);
186
			graphics.drawString("y:" + b.y() + "h:" + b.height(), p);
186
			graphics.drawString("y:" + b.y + "h:" + b.height, p);
187
			p.setY(p.y() + 12);
187
			p.y = p.y + 12;
188
			graphics.drawString("x:" + b.x() + "w:" + b.width(), p);
188
			graphics.drawString("x:" + b.x + "w:" + b.width, p);
189
		}
189
		}
190
	}
190
	}
191
191
Lines 211-217 Link Here
211
211
212
				public void mouseReleased(MouseEvent event) {
212
				public void mouseReleased(MouseEvent event) {
213
					if (event.button == 1) {
213
					if (event.button == 1) {
214
						if (Math.abs(pPoint.x() - event.getLocation().x()) > 10) {
214
						if (Math.abs(pPoint.x - event.getLocation().x) > 10) {
215
							DragFigure f = new DragFigure();
215
							DragFigure f = new DragFigure();
216
							add(f);
216
							add(f);
217
217
Lines 229-237 Link Here
229
							targetList.add(event.getLocation());
229
							targetList.add(event.getLocation());
230
							EllipseDragFigure eFigure = new EllipseDragFigure(
230
							EllipseDragFigure eFigure = new EllipseDragFigure(
231
									event.getLocation(), false);
231
									event.getLocation(), false);
232
							eFigure.setBounds(new Rectangle(event.getLocation()
232
							eFigure.setBounds(new Rectangle(
233
									.x() - 10, event.getLocation().y() - 10,
233
									event.getLocation().x - 10, event
234
									20, 20));
234
											.getLocation().y - 10, 20, 20));
235
							add(eFigure);
235
							add(eFigure);
236
							firstPointCreated = false;
236
							firstPointCreated = false;
237
							figure.addOtherFigure(eFigure);
237
							figure.addOtherFigure(eFigure);
Lines 250-258 Link Here
250
							pressPoint = event.getLocation();
250
							pressPoint = event.getLocation();
251
							EllipseDragFigure eFigure = new EllipseDragFigure(
251
							EllipseDragFigure eFigure = new EllipseDragFigure(
252
									event.getLocation(), true);
252
									event.getLocation(), true);
253
							eFigure.setBounds(new Rectangle(event.getLocation()
253
							eFigure.setBounds(new Rectangle(
254
									.x() - 10, event.getLocation().y() - 10,
254
									event.getLocation().x - 10, event
255
									20, 20));
255
											.getLocation().y - 10, 20, 20));
256
							add(eFigure);
256
							add(eFigure);
257
							figure = eFigure;
257
							figure = eFigure;
258
							firstPointCreated = true;
258
							firstPointCreated = true;
(-)src/org/eclipse/draw2d/examples/graph/AbstractGraphDemo.java (-1 / +1 lines)
Lines 83-89 Link Here
83
			Point p;
83
			Point p;
84
			p = getOwner().getBounds().getCenter();
84
			p = getOwner().getBounds().getCenter();
85
			getOwner().translateToAbsolute(p);
85
			getOwner().translateToAbsolute(p);
86
			if (reference.x() < p.x())
86
			if (reference.x < p.x)
87
				p = getOwner().getBounds().getLeft();
87
				p = getOwner().getBounds().getLeft();
88
			else
88
			else
89
				p = getOwner().getBounds().getRight();
89
				p = getOwner().getBounds().getRight();
(-)src/org/eclipse/draw2d/examples/path/PathExample.java (-2 / +2 lines)
Lines 40-46 Link Here
40
		fig.setLayoutManager(new ToolbarLayout());
40
		fig.setLayoutManager(new ToolbarLayout());
41
41
42
		final ScrollBar bar = new ScrollBar();
42
		final ScrollBar bar = new ScrollBar();
43
		final Label l = new Label("«Zoom»");
43
		final Label l = new Label("�Zoom�");
44
44
45
		l.setBorder(new SchemeBorder(ButtonBorder.SCHEMES.BUTTON_SCROLLBAR));
45
		l.setBorder(new SchemeBorder(ButtonBorder.SCHEMES.BUTTON_SCROLLBAR));
46
		bar.setThumb(l);
46
		bar.setThumb(l);
Lines 70-76 Link Here
70
		polyline.setClosed(true);
70
		polyline.setClosed(true);
71
71
72
		Point c = polyline.getBounds().getCenter();
72
		Point c = polyline.getBounds().getCenter();
73
		polyline.setRotation(c.x(), c.y(), 45);
73
		polyline.setRotation(c.x, c.y, 45);
74
		zoomFigure.add(polyline, BorderLayout.CENTER);
74
		zoomFigure.add(polyline, BorderLayout.CENTER);
75
75
76
		bar.addPropertyChangeListener("value", new PropertyChangeListener() {
76
		bar.addPropertyChangeListener("value", new PropertyChangeListener() {
(-)src/org/eclipse/draw2d/examples/path/PathFigure.java (-12 / +12 lines)
Lines 90-101 Link Here
90
		double angle = degreesToRadians(degrees);
90
		double angle = degreesToRadians(degrees);
91
		double cos = (double) Math.cos(angle), sin = (double) Math.sin(angle);
91
		double cos = (double) Math.cos(angle), sin = (double) Math.sin(angle);
92
92
93
		PrecisionPoint p1 = getRotatedPoint(points.getFirstPoint().x(), points
93
		PrecisionPoint p1 = getRotatedPoint(points.getFirstPoint().x,
94
				.getFirstPoint().y(), cos, sin);
94
				points.getFirstPoint().y, cos, sin);
95
		path.moveTo((float) p1.preciseX(), (float) p1.preciseY());
95
		path.moveTo((float) p1.preciseX(), (float) p1.preciseY());
96
		for (int i = 1; i < points.size(); i++) {
96
		for (int i = 1; i < points.size(); i++) {
97
			PrecisionPoint p = getRotatedPoint(points.getPoint(i).x(), points
97
			PrecisionPoint p = getRotatedPoint(points.getPoint(i).x,
98
					.getPoint(i).y(), cos, sin);
98
					points.getPoint(i).y, cos, sin);
99
			path.lineTo((float) p.preciseX(), (float) p.preciseY());
99
			path.lineTo((float) p.preciseX(), (float) p.preciseY());
100
		}
100
		}
101
		if (isClosed())
101
		if (isClosed())
Lines 112-125 Link Here
112
		if (degrees == 0)
112
		if (degrees == 0)
113
			return p;
113
			return p;
114
114
115
		p.setPreciseX(p.preciseX() - cx);
115
		p.preciseX -= cx;
116
		p.setPreciseY(p.preciseY() - cy);
116
		p.preciseY -= cy;
117
117
118
		float x1 = (float) (p.preciseX() * cos - p.preciseY() * sin);
118
		float x1 = (float) (p.preciseX() * cos - p.preciseY() * sin);
119
		float y1 = (float) (p.preciseY() * cos + p.preciseX() * sin);
119
		float y1 = (float) (p.preciseY() * cos + p.preciseX() * sin);
120
120
121
		p.setPreciseX(x1 + cx);
121
		p.preciseX = x1 + cx;
122
		p.setPreciseY(y1 + cy);
122
		p.preciseY = y1 + cy;
123
		return p;
123
		return p;
124
	}
124
	}
125
125
Lines 131-142 Link Here
131
				double angle = degreesToRadians(degrees);
131
				double angle = degreesToRadians(degrees);
132
				double cos = (double) Math.cos(angle), sin = (double) Math
132
				double cos = (double) Math.cos(angle), sin = (double) Math
133
						.sin(angle);
133
						.sin(angle);
134
				PrecisionPoint p1 = getRotatedPoint(points.getFirstPoint().x(),
134
				PrecisionPoint p1 = getRotatedPoint(points.getFirstPoint().x,
135
						points.getFirstPoint().y(), cos, sin);
135
						points.getFirstPoint().y, cos, sin);
136
				bounds.setLocation(p1);
136
				bounds.setLocation(p1);
137
				for (int i = 1; i < points.size(); i++) {
137
				for (int i = 1; i < points.size(); i++) {
138
					PrecisionPoint p = getRotatedPoint(points.getPoint(i).x(),
138
					PrecisionPoint p = getRotatedPoint(points.getPoint(i).x,
139
							points.getPoint(i).y(), cos, sin);
139
							points.getPoint(i).y, cos, sin);
140
					bounds.union(p);
140
					bounds.union(p);
141
				}
141
				}
142
			}
142
			}
(-)src/org/eclipse/draw2d/examples/thumbnail/ThumbnailExample.java (-12 / +12 lines)
Lines 83-102 Link Here
83
		figure1.setBounds(new Rectangle(50, 50, 200, 200));
83
		figure1.setBounds(new Rectangle(50, 50, 200, 200));
84
		figure1.addMouseListener(new MouseListener.Stub() {
84
		figure1.addMouseListener(new MouseListener.Stub() {
85
			public void mousePressed(MouseEvent event) {
85
			public void mousePressed(MouseEvent event) {
86
				offset.setWidth(event.x - figure1.getLocation().x());
86
				offset.width = event.x - figure1.getLocation().x;
87
				offset.setHeight(event.y - figure1.getLocation().y());
87
				offset.height = event.y - figure1.getLocation().y;
88
			}
88
			}
89
89
90
			public void mouseReleased(MouseEvent event) {
90
			public void mouseReleased(MouseEvent event) {
91
				offset.setWidth(0);
91
				offset.width = 0;
92
				offset.setHeight(0);
92
				offset.height = 0;
93
			}
93
			}
94
		});
94
		});
95
		figure1.addMouseMotionListener(new MouseMotionListener.Stub() {
95
		figure1.addMouseMotionListener(new MouseMotionListener.Stub() {
96
			public void mouseDragged(MouseEvent event) {
96
			public void mouseDragged(MouseEvent event) {
97
				Rectangle rect = figure1.getBounds().getCopy();
97
				Rectangle rect = figure1.getBounds().getCopy();
98
				rect.setX(event.x - offset.width());
98
				rect.x = event.x - offset.width;
99
				rect.setY(event.y - offset.height());
99
				rect.y = event.y - offset.height;
100
				figure1.setBounds(rect);
100
				figure1.setBounds(rect);
101
			}
101
			}
102
		});
102
		});
Lines 106-125 Link Here
106
		figure2.setBounds(new Rectangle(350, 350, 150, 200));
106
		figure2.setBounds(new Rectangle(350, 350, 150, 200));
107
		figure2.addMouseListener(new MouseListener.Stub() {
107
		figure2.addMouseListener(new MouseListener.Stub() {
108
			public void mousePressed(MouseEvent event) {
108
			public void mousePressed(MouseEvent event) {
109
				offset.setWidth(event.x - figure2.getLocation().x());
109
				offset.width = event.x - figure2.getLocation().x;
110
				offset.setHeight(event.y - figure2.getLocation().y());
110
				offset.height = event.y - figure2.getLocation().y;
111
			}
111
			}
112
112
113
			public void mouseReleased(MouseEvent event) {
113
			public void mouseReleased(MouseEvent event) {
114
				offset.setWidth(0);
114
				offset.width = 0;
115
				offset.setHeight(0);
115
				offset.height = 0;
116
			}
116
			}
117
		});
117
		});
118
		figure2.addMouseMotionListener(new MouseMotionListener.Stub() {
118
		figure2.addMouseMotionListener(new MouseMotionListener.Stub() {
119
			public void mouseDragged(MouseEvent event) {
119
			public void mouseDragged(MouseEvent event) {
120
				Rectangle rect = figure2.getBounds().getCopy();
120
				Rectangle rect = figure2.getBounds().getCopy();
121
				rect.setX(event.x - offset.width());
121
				rect.x = event.x - offset.width;
122
				rect.setY(event.y - offset.height());
122
				rect.y = event.y - offset.height;
123
				figure2.setBounds(rect);
123
				figure2.setBounds(rect);
124
			}
124
			}
125
		});
125
		});
(-)src/org/eclipse/draw2d/examples/tree/HangingLayout.java (-7 / +7 lines)
Lines 127-133 Link Here
127
			IFigure node = branch.getNode();
127
			IFigure node = branch.getNode();
128
			IFigure contents = branch.getContentsPane();
128
			IFigure contents = branch.getContentsPane();
129
			int x = node.getBounds().right();
129
			int x = node.getBounds().right();
130
			int y = node.getBounds().y() + gap;
130
			int y = node.getBounds().y + gap;
131
			List children = contents.getChildren();
131
			List children = contents.getChildren();
132
			if (children.size() == 0)
132
			if (children.size() == 0)
133
				return;
133
				return;
Lines 135-149 Link Here
135
			for (int i = 0; i < children.size(); i++) {
135
			for (int i = 0; i < children.size(); i++) {
136
				Point pt = ((TreeBranch) children.get(i)).getNodeBounds()
136
				Point pt = ((TreeBranch) children.get(i)).getNodeBounds()
137
						.getTop();
137
						.getTop();
138
				g.drawLine(pt.x(), y, pt.x(), pt.y());
138
				g.drawLine(pt.x, y, pt.x, pt.y);
139
				right = Math.max(right, pt.x());
139
				right = Math.max(right, pt.x);
140
			}
140
			}
141
			g.drawLine(x, y, right, y);
141
			g.drawLine(x, y, right, y);
142
142
143
		} else {
143
		} else {
144
			IFigure node = branch.getNode();
144
			IFigure node = branch.getNode();
145
			IFigure contents = branch.getContentsPane();
145
			IFigure contents = branch.getContentsPane();
146
			int x = node.getBounds().x() + gap;
146
			int x = node.getBounds().x + gap;
147
			int y = node.getBounds().bottom();
147
			int y = node.getBounds().bottom();
148
			List children = contents.getChildren();
148
			List children = contents.getChildren();
149
			if (children.size() == 0)
149
			if (children.size() == 0)
Lines 152-159 Link Here
152
			for (int i = 0; i < children.size(); i++) {
152
			for (int i = 0; i < children.size(); i++) {
153
				Point pt = ((TreeBranch) children.get(i)).getNodeBounds()
153
				Point pt = ((TreeBranch) children.get(i)).getNodeBounds()
154
						.getLeft();
154
						.getLeft();
155
				g.drawLine(x, pt.y(), pt.x(), pt.y());
155
				g.drawLine(x, pt.y, pt.x, pt.y);
156
				bottom = Math.max(bottom, pt.y());
156
				bottom = Math.max(bottom, pt.y);
157
			}
157
			}
158
			g.drawLine(x, y, x, bottom);
158
			g.drawLine(x, y, x, bottom);
159
		}
159
		}
Lines 172-178 Link Here
172
		Rectangle nodeBounds = transposer.t(branch.getNodeBounds());
172
		Rectangle nodeBounds = transposer.t(branch.getNodeBounds());
173
		int rightEdge = clientArea.right();
173
		int rightEdge = clientArea.right();
174
174
175
		cachedContourLeft[0] = nodeBounds.x() - clientArea.x();
175
		cachedContourLeft[0] = nodeBounds.x - clientArea.x;
176
		cachedContourRight[0] = rightEdge - nodeBounds.right();
176
		cachedContourRight[0] = rightEdge - nodeBounds.right();
177
177
178
		if (!branch.isExpanded())
178
		if (!branch.isExpanded())

Return to bug 334439