1 package net.sf.openrocket.gui.rocketfigure;
4 import java.awt.geom.Ellipse2D;
5 import java.awt.geom.Path2D;
6 import java.awt.geom.Rectangle2D;
8 import net.sf.openrocket.rocketcomponent.Transition;
9 import net.sf.openrocket.util.Coordinate;
10 import net.sf.openrocket.util.Transformation;
13 public class TransitionShapes extends RocketComponentShapes {
15 // TODO: LOW: Uses only first component of cluster (not currently clusterable).
17 public static Shape[] getShapesSide(net.sf.openrocket.rocketcomponent.RocketComponent component,
18 Transformation transformation) {
19 net.sf.openrocket.rocketcomponent.Transition transition = (net.sf.openrocket.rocketcomponent.Transition)component;
23 // Simpler shape for conical transition, others use the method from SymmetricComponent
24 if (transition.getType() == Transition.Shape.CONICAL) {
25 double length = transition.getLength();
26 double r1 = transition.getForeRadius();
27 double r2 = transition.getAftRadius();
28 Coordinate start = transformation.transform(transition.
29 toAbsolute(Coordinate.NUL)[0]);
31 Path2D.Float path = new Path2D.Float();
32 path.moveTo(start.x*S, r1*S);
33 path.lineTo((start.x+length)*S, r2*S);
34 path.lineTo((start.x+length)*S, -r2*S);
35 path.lineTo(start.x*S, -r1*S);
38 mainShapes = new Shape[] { path };
40 mainShapes = SymmetricComponentShapes.getShapesSide(component, transformation);
43 Rectangle2D.Double shoulder1=null, shoulder2=null;
44 int arrayLength = mainShapes.length;
46 if (transition.getForeShoulderLength() > 0.0005) {
47 Coordinate start = transformation.transform(transition.
48 toAbsolute(Coordinate.NUL)[0]);
49 double r = transition.getForeShoulderRadius();
50 double l = transition.getForeShoulderLength();
51 shoulder1 = new Rectangle2D.Double((start.x-l)*S, -r*S, l*S, 2*r*S);
54 if (transition.getAftShoulderLength() > 0.0005) {
55 Coordinate start = transformation.transform(transition.
56 toAbsolute(new Coordinate(transition.getLength()))[0]);
57 double r = transition.getAftShoulderRadius();
58 double l = transition.getAftShoulderLength();
59 shoulder2 = new Rectangle2D.Double(start.x*S, -r*S, l*S, 2*r*S);
62 if (shoulder1==null && shoulder2==null)
65 Shape[] shapes = new Shape[arrayLength];
68 for (i=0; i < mainShapes.length; i++) {
69 shapes[i] = mainShapes[i];
71 if (shoulder1 != null) {
72 shapes[i] = shoulder1;
75 if (shoulder2 != null) {
76 shapes[i] = shoulder2;
82 public static Shape[] getShapesBack(net.sf.openrocket.rocketcomponent.RocketComponent component,
83 Transformation transformation) {
84 net.sf.openrocket.rocketcomponent.Transition transition = (net.sf.openrocket.rocketcomponent.Transition)component;
86 double r1 = transition.getForeRadius();
87 double r2 = transition.getAftRadius();
89 Shape[] s = new Shape[2];
90 s[0] = new Ellipse2D.Double(-r1*S,-r1*S,2*r1*S,2*r1*S);
91 s[1] = new Ellipse2D.Double(-r2*S,-r2*S,2*r2*S,2*r2*S);