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