Project

General

Profile

Download (2.36 KB) Statistics
| Branch: | Tag: | Revision:
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
 * A decoration on a Figure. A border may paint itself within the bounds of a
19
 * figure, and it may provide Insets which can affect how the figures children
20
 * are posiiton and painted.
21
 * <P>
22
 * A border instance may be used with multiple figure instances.
23
 */
24
public interface Border {
25

    
26
	/**
27
	 * Returns the Insets for this Border for the given Figure.
28
	 * 
29
	 * @param figure
30
	 *            The figure this border belongs to
31
	 * @return The insets
32
	 */
33
	Insets getInsets(IFigure figure);
34

    
35
	/**
36
	 * Returns the preferred width and height that this border would like to
37
	 * display itself properly.
38
	 * 
39
	 * @param figure
40
	 *            The figure
41
	 * @return The preferred size
42
	 */
43
	Dimension getPreferredSize(IFigure figure);
44

    
45
	/**
46
	 * Returns <code>true</code> if the Border completely fills the region
47
	 * defined in {@link #paint(IFigure, Graphics, Insets)}.
48
	 * 
49
	 * @return <code>true</code> if this border is opaque
50
	 */
51
	boolean isOpaque();
52

    
53
	/**
54
	 * Paints the border. The border should paint inside figure's
55
	 * {@link IFigure#getBounds()}, inset by the parameter <i>insets</i>. The
56
	 * border generally should not paint inside its own insets. More
57
	 * specifically, Border <i>b</i> should paint inside the rectangle:
58
	 * figure.getBounds().getCropped(insets) and outside of the rectangle:
59
	 * figure.getBounds().getCropped(insets).getCropped(getInsets()) where
60
	 * <i>inside</i> is defined as {@link Rectangle#contains(int, int)}.
61
	 * 
62
	 * @param figure
63
	 *            The figure this border belongs to
64
	 * @param graphics
65
	 *            The graphics object used for painting
66
	 * @param insets
67
	 *            The insets
68
	 */
69
	void paint(IFigure figure, Graphics graphics, Insets insets);
70

    
71
}
(26-26/171)