1 package net.sf.openrocket.gui.print;
3 import java.awt.Graphics2D;
4 import java.awt.Rectangle;
7 import net.sf.openrocket.gui.rocketfigure.TransitionShapes;
8 import net.sf.openrocket.rocketcomponent.NoseCone;
9 import net.sf.openrocket.rocketcomponent.Transition;
10 import net.sf.openrocket.util.Transformation;
12 public class PrintableNoseCone extends AbstractPrintableTransition {
15 * If the component to be drawn is a nose cone, save a reference to it.
17 private NoseCone target;
20 * Construct a printable nose cone.
22 * @param noseCone the component to print
24 public PrintableNoseCone(Transition noseCone) {
25 super(false, noseCone);
29 protected void init(Transition component) {
31 target = (NoseCone) component;
32 double radius = target.getForeRadius();
33 if (radius < target.getAftRadius()) {
34 radius = target.getAftRadius();
36 setSize((int) PrintUnit.METERS.toPoints(2 * radius) + marginX,
37 (int) PrintUnit.METERS.toPoints(target.getLength() + target.getAftShoulderLength()) + marginY);
43 * @param g2 the graphics context
46 protected void draw(Graphics2D g2) {
47 Shape[] shapes = TransitionShapes.getShapesSide(target, Transformation.rotate_x(0d), PrintUnit.METERS.toPoints(1));
49 if (shapes != null && shapes.length > 0) {
50 Rectangle r = shapes[0].getBounds();
51 g2.translate(marginX + r.getHeight() / 2, marginY);
52 g2.rotate(Math.PI / 2);
53 for (Shape shape : shapes) {
56 g2.rotate(-Math.PI / 2);