1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2000, 2010 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
*******************************************************************************/
|
11
|
package org.eclipse.draw2d;
|
12
|
|
13
|
import org.eclipse.draw2d.geometry.Dimension;
|
14
|
import org.eclipse.draw2d.geometry.Insets;
|
15
|
import org.eclipse.draw2d.geometry.Rectangle;
|
16
|
|
17
|
/**
|
18
|
* Provides generic support for borders.
|
19
|
*
|
20
|
* @author hudsonr
|
21
|
*/
|
22
|
public abstract class AbstractBorder implements Border {
|
23
|
|
24
|
private static final Dimension EMPTY = new Dimension();
|
25
|
|
26
|
/** A temporary Rectangle */
|
27
|
protected static Rectangle tempRect = new Rectangle();
|
28
|
|
29
|
/**
|
30
|
* Returns a temporary rectangle representing the figure's bounds cropped by
|
31
|
* the specified insets. This method exists for convenience and performance;
|
32
|
* the method does not new any Objects and returns a rectangle which the
|
33
|
* caller can manipulate.
|
34
|
*
|
35
|
* @since 2.0
|
36
|
* @param figure
|
37
|
* Figure for which the paintable rectangle is needed
|
38
|
* @param insets
|
39
|
* The insets
|
40
|
* @return The paintable region on the Figure f
|
41
|
*/
|
42
|
protected static final Rectangle getPaintRectangle(IFigure figure,
|
43
|
Insets insets) {
|
44
|
tempRect.setBounds(figure.getBounds());
|
45
|
return tempRect.crop(insets);
|
46
|
}
|
47
|
|
48
|
/**
|
49
|
* @see org.eclipse.draw2d.Border#getPreferredSize(IFigure)
|
50
|
*/
|
51
|
public Dimension getPreferredSize(IFigure f) {
|
52
|
return EMPTY;
|
53
|
}
|
54
|
|
55
|
/**
|
56
|
* @see org.eclipse.draw2d.Border#isOpaque()
|
57
|
*/
|
58
|
public boolean isOpaque() {
|
59
|
return false;
|
60
|
}
|
61
|
|
62
|
}
|