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 255553 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/draw2d/figures/GeoShapeLineStyleBorder.java (-23 / +2 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2002, 2004 IBM Corporation and others.
2
 * Copyright (c) 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 18-32 Link Here
18
import org.eclipse.draw2d.geometry.Rectangle;
18
import org.eclipse.draw2d.geometry.Rectangle;
19
19
20
/**
20
/**
21
 * Extends {@link org.eclipse.draw2d.LineBorder} to support line style.
21
 * Extends {@link org.eclipse.draw2d.LineBorder} to customize painting.
22
 * 
22
 * 
23
 * @author Anthony Hunter
23
 * @author Anthony Hunter
24
 * @since 2.1
24
 * @since 2.1
25
 */
25
 */
26
public class GeoShapeLineStyleBorder extends LineBorder {
26
public class GeoShapeLineStyleBorder extends LineBorder {
27
27
28
	private int style = Graphics.LINE_SOLID;
29
30
	/**
28
	/**
31
	 * Constructs a default black LineBorder with a width of one pixel.
29
	 * Constructs a default black LineBorder with a width of one pixel.
32
	 * 
30
	 * 
Lines 36-60 Link Here
36
		super();
34
		super();
37
	}
35
	}
38
36
39
	/**
40
	 * Get the line style of this border.
41
	 * 
42
	 * @return The line style of this border.
43
	 */
44
	public int getStyle() {
45
		return style;
46
	}
47
48
	/**
49
	 * Set the line style of this border.
50
	 * 
51
	 * @param style
52
	 *            The line style of this border.
53
	 */
54
	public void setStyle(int style) {
55
		this.style = style;
56
	}
57
58
	/*
37
	/*
59
	 * @see org.eclipse.draw2d.LineBorder#paint(org.eclipse.draw2d.IFigure,
38
	 * @see org.eclipse.draw2d.LineBorder#paint(org.eclipse.draw2d.IFigure,
60
	 *      org.eclipse.draw2d.Graphics, org.eclipse.draw2d.geometry.Insets)
39
	 *      org.eclipse.draw2d.Graphics, org.eclipse.draw2d.geometry.Insets)
(-)src/org/eclipse/gmf/runtime/diagram/ui/geoshapes/internal/editparts/ShadowRectangleEditPart.java (+18 lines)
Lines 47-51 Link Here
47
	public IFigure getContentPane() {
47
	public IFigure getContentPane() {
48
		return ((GeoShapeFigure) getFigure()).getContentPane();
48
		return ((GeoShapeFigure) getFigure()).getContentPane();
49
	}
49
	}
50
	
51
	/**
52
	 * Sets the line width to the border as well.
53
	 * @see org.eclipse.gmf.runtime.diagram.ui.geoshapes.internal.editparts.GeoShapeEditPart#setLineWidth(int)
54
	 */
55
	protected void setLineWidth(int width) {
56
		super.setLineWidth(width);
57
		((RectangularDropShadowLineBorder)getFigure().getBorder()).setWidth(getMapMode().DPtoLP(width));
58
		getFigure().revalidate();
59
	}
60
	
61
	/** Sets the line type to the border.
62
	 * @see org.eclipse.gmf.runtime.diagram.ui.geoshapes.internal.editparts.GeoShapeEditPart#setLineType(int)
63
	 */
64
	protected void setLineType(int lineType) {
65
		super.setLineType(lineType);
66
		((RectangularDropShadowLineBorder)getFigure().getBorder()).setStyle(lineType);
67
	}	
50
68
51
}
69
}
(-)src/org/eclipse/gmf/runtime/diagram/ui/editparts/ResizableCompartmentEditPart.java (-2 / +34 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2002, 2006 IBM Corporation and others.
2
 * Copyright (c) 2002, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 11-17 Link Here
11
11
12
package org.eclipse.gmf.runtime.diagram.ui.editparts;
12
package org.eclipse.gmf.runtime.diagram.ui.editparts;
13
13
14
import org.eclipse.draw2d.Border;
14
import org.eclipse.draw2d.IFigure;
15
import org.eclipse.draw2d.IFigure;
16
import org.eclipse.draw2d.LineBorder;
15
import org.eclipse.emf.common.notify.Notification;
17
import org.eclipse.emf.common.notify.Notification;
16
import org.eclipse.emf.ecore.EObject;
18
import org.eclipse.emf.ecore.EObject;
17
import org.eclipse.gef.ExposeHelper;
19
import org.eclipse.gef.ExposeHelper;
Lines 70-75 Link Here
70
		refreshShowCompartmentTitle();
72
		refreshShowCompartmentTitle();
71
		refreshCollapsed();
73
		refreshCollapsed();
72
		refreshRatio();
74
		refreshRatio();
75
		refreshLineWidth();
76
		refreshLineType();		
73
	}
77
	}
74
78
75
	/**
79
	/**
Lines 138-144 Link Here
138
                NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) ||
142
                NotationPackage.eINSTANCE.getFontStyle_Bold().equals(feature) ||
139
                NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
143
                NotationPackage.eINSTANCE.getFontStyle_Italic().equals(feature)) {
140
			refreshFont();
144
			refreshFont();
141
		} else
145
        } else if (NotationPackage.eINSTANCE.getLineStyle_LineWidth().equals(feature)){
146
			refreshLineWidth();
147
		} else if (NotationPackage.eINSTANCE.getLineTypeStyle_LineType().equals(feature)) {
148
			refreshLineType();
149
		} else 
142
			super.handleNotificationEvent(event);
150
			super.handleNotificationEvent(event);
143
	}
151
	}
144
		
152
		
Lines 229-234 Link Here
229
		if (getCompartmentFigure()!=null)
237
		if (getCompartmentFigure()!=null)
230
			getCompartmentFigure().setFontColor(color);
238
			getCompartmentFigure().setFontColor(color);
231
	}
239
	}
240
	
241
	/**
242
	 * Sets the line width for the shape's border
243
	 * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#setLineWidth(int)
244
	 */
245
	protected void setLineWidth(int width) {
246
		Border border = getFigure().getBorder();
247
		if (border instanceof LineBorder) {
248
			((LineBorder) border).setWidth(getMapMode().DPtoLP(width));
249
			getFigure().revalidate();
250
		}		
251
	}
252
	
253
	/**
254
	 * Sets the line type for the shape's border
255
	 * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#setLineType(int)
256
	 */
257
	protected void setLineType(int type) {
258
		Border border = getFigure().getBorder();
259
		if (border instanceof LineBorder) {
260
			((LineBorder) border).setStyle(type);
261
			//getFigure().repaint();
262
		}
263
	}	
232
264
233
	/**
265
	/**
234
	 * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#addNotationalListeners()
266
	 * @see org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart#addNotationalListeners()
(-)src/org/eclipse/draw2d/LineBorder.java (-4 / +41 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2005 IBM Corporation and others.
2
 * Copyright (c) 2000, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 23-28 Link Here
23
23
24
private int width = 1;
24
private int width = 1;
25
private Color color;
25
private Color color;
26
private int style = Graphics.LINE_SOLID;
27
28
/**
29
 * Constructs a LineBorder with the specified color and of the specified width and style.
30
 *
31
 * @param color The color of the border.
32
 * @param width The width of the border in pixels.
33
 * @param style The style of the border. For the list of valid values, see 
34
 * {@link org.eclipse.draw2d.Graphics}
35
 * @since 3.5
36
 */
37
public LineBorder(Color color, int width, int style) {
38
	setColor(color);
39
	setWidth(width);
40
	setStyle(style);
41
}
42
26
43
27
/**
44
/**
28
 * Constructs a LineBorder with the specified color and of the specified width.
45
 * Constructs a LineBorder with the specified color and of the specified width.
Lines 32-39 Link Here
32
 * @since 2.0
49
 * @since 2.0
33
 */
50
 */
34
public LineBorder(Color color, int width) {
51
public LineBorder(Color color, int width) {
35
	setColor(color);
52
	this(color, width, Graphics.LINE_SOLID);
36
	setWidth(width);
37
}
53
}
38
54
39
/**
55
/**
Lines 109-114 Link Here
109
	}
125
	}
110
	tempRect.shrink(getWidth() / 2, getWidth() / 2);
126
	tempRect.shrink(getWidth() / 2, getWidth() / 2);
111
	graphics.setLineWidth(getWidth());
127
	graphics.setLineWidth(getWidth());
128
	graphics.setLineStyle(getStyle());
112
	if (getColor() != null)
129
	if (getColor() != null)
113
		graphics.setForegroundColor(getColor());
130
		graphics.setForegroundColor(getColor());
114
	graphics.drawRectangle(tempRect);
131
	graphics.drawRectangle(tempRect);
Lines 127-133 Link Here
127
 * @param width The line width
144
 * @param width The line width
128
 */
145
 */
129
public void setWidth(int width) {
146
public void setWidth(int width) {
130
	this.width = width;
147
	if (width > 0) {
148
		this.width = width;
149
	}
150
}
151
152
/**
153
 * Returns the line style for this border.
154
 * @return The line style for this border
155
 * @since 3.5
156
 */
157
public int getStyle() {
158
	return style;
159
}
160
161
/**
162
 * Sets the line type of this border.
163
 * @param style For the list of valid values, see {@link org.eclipse.draw2d.Graphics}
164
 * @since 3.5
165
 */
166
public void setStyle(int style) {
167
	this.style = style;
131
}
168
}
132
169
133
}
170
}
(-)src/org/eclipse/gmf/runtime/draw2d/ui/figures/OneLineBorder.java (-4 / +16 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2002, 2003 IBM Corporation and others.
2
 * Copyright (c) 2002, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 117-135 Link Here
117
			tempRect.width--;
117
			tempRect.width--;
118
			tempRect.height--;
118
			tempRect.height--;
119
		}
119
		}
120
		tempRect.shrink(getWidth() / 2, getWidth() / 2);
121
		graphics.setLineWidth(getWidth());
120
		graphics.setLineWidth(getWidth());
121
		graphics.setLineStyle(getStyle());
122
		switch (position) {
122
		switch (position) {
123
			case PositionConstants.TOP :
123
			case PositionConstants.TOP :
124
				graphics.drawLine(tempRect.getTopLeft(), tempRect.getTopRight());
124
				// move down by width/2 to ensure the border will fit;
125
				// no need to change x
126
				tempRect.y += getWidth() / 2;				
127
				graphics.drawLine(tempRect.getTopLeft(), tempRect.getTopRight());				
125
				break;
128
				break;
126
			case PositionConstants.BOTTOM :
129
			case PositionConstants.BOTTOM :	
130
				// move up by width/2 to ensure the border will fit;
131
				// no need to change x			
132
				tempRect.y -= getWidth() / 2;
127
				graphics.drawLine(tempRect.getBottomLeft(), tempRect.getBottomRight());
133
				graphics.drawLine(tempRect.getBottomLeft(), tempRect.getBottomRight());
128
				break;
134
				break;
129
			case PositionConstants.LEFT :
135
			case PositionConstants.LEFT :
136
				// move right by width/2 to ensure the border will fit;
137
				// no need to change y			
138
				tempRect.x += getWidth() / 2;
130
				graphics.drawLine(tempRect.getTopLeft(), tempRect.getBottomLeft());
139
				graphics.drawLine(tempRect.getTopLeft(), tempRect.getBottomLeft());
131
				break;
140
				break;
132
			case PositionConstants.RIGHT :
141
			case PositionConstants.RIGHT :
142
				// move left by width/2 to ensure the border will fit;
143
				// no need to change y						
144
				tempRect.x -= getWidth() / 2;
133
				graphics.drawLine(tempRect.getTopRight(), tempRect.getBottomRight());
145
				graphics.drawLine(tempRect.getTopRight(), tempRect.getBottomRight());
134
				break;
146
				break;
135
		}
147
		}
(-)src/org/eclipse/gmf/runtime/draw2d/ui/figures/RectangularDropShadowLineBorder.java (-16 / +14 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2002, 2004 IBM Corporation and others.
2
 * Copyright (c) 2002, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 42-48 Link Here
42
	 * Constructs a LineBorder 
42
	 * Constructs a LineBorder 
43
	 * of the specified width.
43
	 * of the specified width.
44
	 *
44
	 *
45
	 * @param w  Width of inset for border
45
	 * @param w  Width of inset for border in logic points
46
	 * 
46
	 * 
47
	 */
47
	 */
48
	public RectangularDropShadowLineBorder(int w) {
48
	public RectangularDropShadowLineBorder(int w) {
Lines 90-100 Link Here
90
	 * @return Insets the Insets for the border on the given figure.
90
	 * @return Insets the Insets for the border on the given figure.
91
	 */
91
	 */
92
	public Insets getInsets(IFigure figure) {
92
	public Insets getInsets(IFigure figure) {
93
		Insets insetsNew = super.getInsets(figure);
93
		// take into account line width
94
		insetsNew.top = 0;
94
		Insets insetsNew = new Insets(getWidth());		
95
		insetsNew.left = 0;
95
		IMapMode mm = MapModeUtil.getMapMode(figure);
96
		insetsNew.bottom = MapModeUtil.getMapMode(figure).DPtoLP(insetsNew.bottom + getShadowHeight());
96
		insetsNew.bottom += mm.DPtoLP(getShadowHeight());
97
		insetsNew.right = MapModeUtil.getMapMode(figure).DPtoLP(insetsNew.right + getShadowWidth());
97
		insetsNew.right += mm.DPtoLP(getShadowWidth());
98
98
99
		return insetsNew;
99
		return insetsNew;
100
	}
100
	}
Lines 153-164 Link Here
153
	 * @param insets Insets value that contrains how the border will be painted.
153
	 * @param insets Insets value that contrains how the border will be painted.
154
	 */
154
	 */
155
	public void paintLineBorder(IFigure figure, Graphics g, Insets insets) {
155
	public void paintLineBorder(IFigure figure, Graphics g, Insets insets) {
156
157
		// will not paint line border if width is 0
156
		// will not paint line border if width is 0
158
		if (getWidth() > 0) { 
157
		if (getWidth() > 0) { 
159
			tempRect.setBounds(getPaintRectangle(figure, insets));
158
			tempRect.setBounds(getPaintRectangle(figure, insets));
159
			tempRect.shrink(getWidth()/2, getWidth()/2);
160
			g.setLineWidth(getWidth());
160
			g.setLineWidth(getWidth());
161
			g.drawRectangle(tempRect);
161
			g.setLineStyle(getStyle());
162
			g.drawRectangle(tempRect);			
162
		}
163
		}
163
	}
164
	}
164
	
165
	
Lines 182-193 Link Here
182
			tempRect.setBounds(getPaintRectangle(figure, insets));
183
			tempRect.setBounds(getPaintRectangle(figure, insets));
183
			tempRect.width -= mm.DPtoLP(getShadowWidth());
184
			tempRect.width -= mm.DPtoLP(getShadowWidth());
184
			tempRect.height -= mm.DPtoLP(getShadowHeight());
185
			tempRect.height -= mm.DPtoLP(getShadowHeight());
185
			if (getWidth() % 2 == 1) {
186
			tempRect.shrink(getWidth() / 2, getWidth() / 2);
186
				tempRect.width -= mm.DPtoLP(1);
187
				tempRect.height -= mm.DPtoLP(1);
188
			}
189
			tempRect.shrink(mm.DPtoLP(getWidth() / 2), mm.DPtoLP(getWidth() / 2));
190
			g.setLineWidth(getWidth());
187
			g.setLineWidth(getWidth());
188
			g.setLineStyle(getStyle());			
191
189
192
			if (getColor() != null) {
190
			if (getColor() != null) {
193
				g.setForegroundColor(getColor());
191
				g.setForegroundColor(getColor());
Lines 202-208 Link Here
202
	 * Overridden method for painting the border on the shape.
200
	 * Overridden method for painting the border on the shape.
203
	 * @param figure Figure that the border will be painted on
201
	 * @param figure Figure that the border will be painted on
204
	 * @param g Graphics context 
202
	 * @param g Graphics context 
205
	 * @param insets Insets value that contrains how the border will be painted.
203
	 * @param insets Insets value that constrains how the border will be painted.
206
	 */
204
	 */
207
	public void paint(IFigure figure, Graphics g, Insets insets) {
205
	public void paint(IFigure figure, Graphics g, Insets insets) {
208
206
Lines 233-239 Link Here
233
	}
231
	}
234
232
235
	/**
233
	/**
236
	 * @return Returns the drip shadow iamge.
234
	 * @return Returns the drop shadow image.
237
	 */
235
	 */
238
	protected RectangularDropShadow getDropShadow() {
236
	protected RectangularDropShadow getDropShadow() {
239
		return dropShadow;
237
		return dropShadow;
(-)src/org/eclipse/gmf/runtime/draw2d/ui/internal/figures/LineBorderEx.java (-8 / +8 lines)
Lines 1-5 Link Here
1
/******************************************************************************
1
/******************************************************************************
2
 * Copyright (c) 2002, 2004 IBM Corporation and others.
2
 * Copyright (c) 2002, 2008 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 16-21 Link Here
16
import org.eclipse.draw2d.IFigure;
16
import org.eclipse.draw2d.IFigure;
17
import org.eclipse.draw2d.LineBorder;
17
import org.eclipse.draw2d.LineBorder;
18
import org.eclipse.draw2d.geometry.Insets;
18
import org.eclipse.draw2d.geometry.Insets;
19
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
19
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
20
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
20
import org.eclipse.swt.graphics.Color;
21
import org.eclipse.swt.graphics.Color;
21
22
Lines 70-83 Link Here
70
	 */
71
	 */
71
	public void paint(IFigure figure, Graphics graphics, Insets insets) {
72
	public void paint(IFigure figure, Graphics graphics, Insets insets) {
72
		tempRect.setBounds(getPaintRectangle(figure, insets));
73
		tempRect.setBounds(getPaintRectangle(figure, insets));
73
		if (getWidth() % 2 == 1) {
74
		IMapMode mm = MapModeUtil.getMapMode(figure);
74
			tempRect.width -= MapModeUtil.getMapMode(figure).DPtoLP(1);
75
		// width is in pixels (as stated in constructors), convert it
75
			tempRect.height -= MapModeUtil.getMapMode(figure).DPtoLP(1);
76
		int lpWidth = mm.DPtoLP(getWidth());
76
		}
77
		tempRect.shrink(lpWidth / 2, lpWidth / 2);
77
		int shrinkWidth = MapModeUtil.getMapMode(figure).DPtoLP( getWidth() / 2 );
78
		tempRect.shrink(shrinkWidth, shrinkWidth);
79
78
80
		graphics.setLineWidth(getWidth());
79
		graphics.setLineWidth(lpWidth);
80
		graphics.setLineStyle(getStyle());
81
		if (getColor() != null)
81
		if (getColor() != null)
82
			graphics.setForegroundColor(getColor());
82
			graphics.setForegroundColor(getColor());
83
83

Return to bug 255553