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.rocketcomponent.Transition;
6 import net.sf.openrocket.util.Transformation;
10 public class PrintableNoseCone extends AbstractPrintableTransition {
13 * If the component to be drawn is a nose cone, save a reference to it.
15 private NoseCone target;
18 * Construct a printable nose cone.
20 * @param noseCone the component to print
22 public PrintableNoseCone(Transition noseCone) {
23 super(false, noseCone);
27 protected void init(Transition component) {
29 target = (NoseCone) component;
30 double radius = target.getForeRadius();
31 if (radius < target.getAftRadius()) {
32 radius = target.getAftRadius();
34 setSize((int) PrintUnit.METERS.toPoints(2 * radius) + marginX,
35 (int) PrintUnit.METERS.toPoints(target.getLength() + target.getAftShoulderLength()) + marginY);
41 * @param g2 the graphics context
43 protected void draw(Graphics2D g2) {
44 Shape[] shapes = TransitionShapes.getShapesSide(target, Transformation.rotate_x(0d), PrintUnit.METERS.toPoints(1));
46 if (shapes != null && shapes.length > 0) {
47 Rectangle r = shapes[0].getBounds();
48 g2.translate(marginX + r.getHeight() / 2, marginY);
49 g2.rotate(Math.PI / 2);
50 for (Shape shape : shapes) {
53 g2.rotate(-Math.PI / 2);