Project

General

Profile

Download (1.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.Rectangle;
14

    
15
/**
16
 * Draws a rectangle whose size is determined by the bounds set to it.
17
 */
18
public class RectangleFigure extends Shape {
19
	/**
20
	 * Creates a RectangleFigure.
21
	 */
22
	public RectangleFigure() {
23
	}
24

    
25
	/**
26
	 * @see Shape#fillShape(Graphics)
27
	 */
28
	protected void fillShape(Graphics graphics) {
29
		graphics.fillRectangle(getBounds());
30
	}
31

    
32
	/**
33
	 * @see Shape#outlineShape(Graphics)
34
	 */
35
	protected void outlineShape(Graphics graphics) {
36
		float lineInset = Math.max(1.0f, getLineWidthFloat()) / 2.0f;
37
		int inset1 = (int) Math.floor(lineInset);
38
		int inset2 = (int) Math.ceil(lineInset);
39

    
40
		Rectangle r = Rectangle.SINGLETON.setBounds(getBounds());
41
		r.x += inset1;
42
		r.y += inset1;
43
		r.width -= inset1 + inset2;
44
		r.height -= inset1 + inset2;
45

    
46
		graphics.drawRectangle(r);
47
	}
48
}
(127-127/171)