create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / gui / figureelements / CPCaret.java
1 package net.sf.openrocket.gui.figureelements;
2
3 import java.awt.Color;
4 import java.awt.geom.Area;
5 import java.awt.geom.Ellipse2D;
6
7 /**
8  * A mark indicating the position of the center of pressure.  It is a red filled circle
9  * inside a slightly larger red circle.
10  * 
11  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
12  */
13
14 public class CPCaret extends Caret {
15         private static final float RADIUS = 7;
16         
17         private static Area caret = null;
18         
19         /**
20          * Create a new CPCaret at the specified coordinates.
21          */
22         public CPCaret(double x, double y) {
23                 super(x,y);
24         }
25
26         /**
27          * Returns the Area object of the caret.  The Area object is created only once,
28          * after which new copies are cloned from it.
29          */
30         @Override
31         protected Area getCaret() {
32                 if (caret != null) {
33                         return (Area)caret.clone();
34                 }
35
36                 Ellipse2D.Float e = new Ellipse2D.Float(-RADIUS,-RADIUS,2*RADIUS,2*RADIUS);
37                 caret = new Area(e);
38
39                 caret.subtract(new Area(new Ellipse2D.Float(-RADIUS*0.9f,-RADIUS*0.9f,
40                                 2*0.9f*RADIUS,2*0.9f*RADIUS)));
41                 
42                 caret.add(new Area(new Ellipse2D.Float(-RADIUS*0.75f,-RADIUS*0.75f,
43                                 2*0.75f*RADIUS,2*0.75f*RADIUS)));
44                 
45                 return (Area) caret.clone();
46         }
47
48         
49         /**
50          * Return the color of the caret (red).
51          */
52         @Override
53         protected Color getColor() {
54                 return Color.RED;
55         }
56 }