1 /*******************************************************************************
2 * Copyright 2005-2006, CHISEL Group, University of Victoria, Victoria, BC, Canada.
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 * The Chisel Group, University of Victoria
10 *******************************************************************************/
11 package pl.edu.agh.cast.tool;
12
13 import org.eclipse.draw2d.Graphics;
14 import org.eclipse.draw2d.Shape;
15 import org.eclipse.draw2d.geometry.Point;
16 import org.eclipse.draw2d.geometry.Rectangle;
17
18 /**
19 * TODO comment
20 * @author Del Myers
21 *
22 */
23 public class TargetShape extends Shape {
24
25 /* (non-Javadoc)
26 * @see org.eclipse.draw2d.Shape#fillShape(org.eclipse.draw2d.Graphics)
27 */
28 protected void fillShape(Graphics graphics) {
29 //does nothing.
30
31 }
32
33 /* (non-Javadoc)
34 * @see org.eclipse.draw2d.Shape#outlineShape(org.eclipse.draw2d.Graphics)
35 */
36 protected void outlineShape(Graphics graphics) {
37 Rectangle bounds = getClientArea().getCopy();
38 //reduce the bounds by one pixel so that it can be properly
39 //drawn within the clipping region.
40 //graphics.setXORMode(true);
41 bounds.width -= 1;
42 bounds.height -= 1;
43 Point center = bounds.getCenter();
44 Point bottom = new Point(bounds.x+bounds.width, bounds.height+bounds.y);
45 Point top = new Point(bounds.x, bounds.y);
46 //draw the crosshairs
47 graphics.drawLine(center.x, top.y, center.x, center.y-2);
48 graphics.drawLine(center.x+2, center.y, bottom.x, center.y);
49 graphics.drawLine(center.x, center.y+2, center.x, bottom.y);
50 graphics.drawLine(top.x, center.y, center.x-2, center.y);
51 //draw the circle target.
52 bounds.shrink(bounds.width/4, bounds.height/4);
53 bounds.width -=1;
54 bounds.height -=1;
55 // bounds.x+=1;
56 // bounds.y+=1;
57 graphics.drawOval(bounds);
58
59 }
60
61 }