X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Fgui%2Fprint%2FPrintableNoseCone.java;fp=core%2Fsrc%2Fnet%2Fsf%2Fopenrocket%2Fgui%2Fprint%2FPrintableNoseCone.java;h=2cfdfa688efdb0b6a0b7422106c080983bde18b2;hb=9349577cdfdff682b2aabd6daa24fdc3a7449b58;hp=78afe6f052cb747358eb60d05b986a69412ea3f9;hpb=30ba0a882f0c061176ba14dbf86d3d6fad096c02;p=debian%2Fopenrocket diff --git a/core/src/net/sf/openrocket/gui/print/PrintableNoseCone.java b/core/src/net/sf/openrocket/gui/print/PrintableNoseCone.java index 78afe6f0..2cfdfa68 100644 --- a/core/src/net/sf/openrocket/gui/print/PrintableNoseCone.java +++ b/core/src/net/sf/openrocket/gui/print/PrintableNoseCone.java @@ -1,54 +1,54 @@ package net.sf.openrocket.gui.print; +import net.sf.openrocket.gui.rocketfigure.TransitionShapes; +import net.sf.openrocket.rocketcomponent.NoseCone; +import net.sf.openrocket.util.Transformation; + import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.Shape; -import net.sf.openrocket.gui.rocketfigure.TransitionShapes; -import net.sf.openrocket.rocketcomponent.NoseCone; -import net.sf.openrocket.rocketcomponent.Transition; -import net.sf.openrocket.util.Transformation; +public class PrintableNoseCone extends AbstractPrintable { -public class PrintableNoseCone extends AbstractPrintableTransition { - /** * If the component to be drawn is a nose cone, save a reference to it. */ private NoseCone target; - + /** * Construct a printable nose cone. * * @param noseCone the component to print */ - public PrintableNoseCone(Transition noseCone) { + public PrintableNoseCone(NoseCone noseCone) { super(false, noseCone); } - + @Override - protected void init(Transition component) { - - target = (NoseCone) component; + protected void init(NoseCone component) { + + target = component; double radius = target.getForeRadius(); if (radius < target.getAftRadius()) { radius = target.getAftRadius(); } - setSize((int) PrintUnit.METERS.toPoints(2 * radius) + marginX, - (int) PrintUnit.METERS.toPoints(target.getLength() + target.getAftShoulderLength()) + marginY); + setSize((int) PrintUnit.METERS.toPoints(2 * radius) + 4, + (int) PrintUnit.METERS.toPoints(target.getLength() + target.getAftShoulderLength()) + 4); } - + /** - * Draw a nose cone. + * Draw a nose cone. Presumes that the graphics context has already had the x/y position translated based on + * where it should be drawn. * * @param g2 the graphics context */ @Override protected void draw(Graphics2D g2) { Shape[] shapes = TransitionShapes.getShapesSide(target, Transformation.rotate_x(0d), PrintUnit.METERS.toPoints(1)); - + if (shapes != null && shapes.length > 0) { Rectangle r = shapes[0].getBounds(); - g2.translate(marginX + r.getHeight() / 2, marginY); + g2.translate(r.getHeight() / 2, 0); g2.rotate(Math.PI / 2); for (Shape shape : shapes) { g2.draw(shape);