1 package net.sf.openrocket.gui.print;
3 import net.sf.openrocket.gui.rocketfigure.TransitionShapes;
4 import net.sf.openrocket.rocketcomponent.NoseCone;
5 import net.sf.openrocket.util.Transformation;
7 import java.awt.Graphics2D;
8 import java.awt.Rectangle;
11 public class PrintableNoseCone extends AbstractPrintable<NoseCone> {
14 * If the component to be drawn is a nose cone, save a reference to it.
16 private NoseCone target;
19 * Construct a printable nose cone.
21 * @param noseCone the component to print
23 public PrintableNoseCone(NoseCone noseCone) {
24 super(false, noseCone);
28 protected void init(NoseCone component) {
31 double radius = target.getForeRadius();
32 if (radius < target.getAftRadius()) {
33 radius = target.getAftRadius();
35 setSize((int) PrintUnit.METERS.toPoints(2 * radius) + marginX,
36 (int) PrintUnit.METERS.toPoints(target.getLength() + target.getAftShoulderLength()) + marginY);
42 * @param g2 the graphics context
45 protected void draw(Graphics2D g2) {
46 Shape[] shapes = TransitionShapes.getShapesSide(target, Transformation.rotate_x(0d), PrintUnit.METERS.toPoints(1));
48 if (shapes != null && shapes.length > 0) {
49 Rectangle r = shapes[0].getBounds();
50 g2.translate(marginX + r.getHeight() / 2 + getOffsetX(), marginY + getOffsetY());
51 g2.rotate(Math.PI / 2);
52 for (Shape shape : shapes) {
55 g2.rotate(-Math.PI / 2);