create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / gui / figureelements / Caret.java
1 package net.sf.openrocket.gui.figureelements;
2
3
4 import java.awt.Color;
5 import java.awt.Graphics2D;
6 import java.awt.Rectangle;
7 import java.awt.geom.AffineTransform;
8 import java.awt.geom.Area;
9
10 public abstract class Caret implements FigureElement {
11         private double x,y;
12         
13         /**
14          * Creates a new caret at the specified coordinates.
15          */
16         public Caret(double x, double y) {
17                 this.x = x;
18                 this.y = y;
19         }
20
21         /**
22          * Sets the position of the caret to the new coordinates.
23          */
24         public void setPosition(double x, double y) {
25                 this.x = x;
26                 this.y = y;
27         }
28
29         /**
30          * Paints the caret to the Graphics2D element.
31          */
32         public void paint(Graphics2D g2, double scale) {
33                 Area caret = getCaret();
34                 AffineTransform t = new AffineTransform(1.0/scale, 0, 0, 1.0/scale, x, y);
35                 caret.transform(t);
36
37                 g2.setColor(getColor());
38                 g2.fill(caret);
39         }
40
41         
42         public void paint(Graphics2D g2, double scale, Rectangle visible) {
43                 throw new UnsupportedOperationException("paint() with rectangle unsupported.");
44         }
45
46         /**
47          * Return the Area object corresponding to the mark.
48          */
49         protected abstract Area getCaret();
50         
51         /**
52          * Return the color to be used when drawing the mark.
53          */
54         protected abstract Color getColor();
55 }