From: rodinia814 Date: Fri, 17 Sep 2010 02:55:12 +0000 (+0000) Subject: DGP - fix for MassObject X-Git-Tag: upstream/1.1.4^2~10^2~1 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=2474e3374794b1776215dd67f1f16f9146bd643e;p=debian%2Fopenrocket DGP - fix for MassObject git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/branches/printing@85 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/src/net/sf/openrocket/gui/print/DesignReport.java b/src/net/sf/openrocket/gui/print/DesignReport.java index 36f9c200..1da0bd00 100644 --- a/src/net/sf/openrocket/gui/print/DesignReport.java +++ b/src/net/sf/openrocket/gui/print/DesignReport.java @@ -219,7 +219,9 @@ public class DesignReport extends BaseVisitorStrategy { * * @return the scale of the diagram */ - private double paintRocketDiagram (final int thePageImageableWidth, final int thePageImageableHeight, final PdfContentByte theCanvas, final PrintFigure theFigure, final FigureElement theCp, final FigureElement theCg) { + private double paintRocketDiagram (final int thePageImageableWidth, final int thePageImageableHeight, + final PdfContentByte theCanvas, final PrintFigure theFigure, + final FigureElement theCp, final FigureElement theCg) { theFigure.clearAbsoluteExtra(); theFigure.clearRelativeExtra(); theFigure.addRelativeExtra(theCp); diff --git a/src/net/sf/openrocket/gui/print/PrintController.java b/src/net/sf/openrocket/gui/print/PrintController.java index 41d4ffa1..1cb64c43 100644 --- a/src/net/sf/openrocket/gui/print/PrintController.java +++ b/src/net/sf/openrocket/gui/print/PrintController.java @@ -22,25 +22,24 @@ import java.util.Iterator; import java.util.Set; /** - * This is the main active object for printing. It performs all actions necessary to create and populate the print file. + * This is the main active object for printing. It performs all actions necessary to create and populate the print + * file. */ public class PrintController { /** * Print the selected components to a PDF document. - * - * @param doc the OR document - * @param toBePrinted the user chosen items to print - * @param outputFile the file being written to - * @param msn the paper size + * + * @param doc the OR document + * @param toBePrinted the user chosen items to print + * @param outputFile the file being written to + * @param msn the paper size */ public void print (OpenRocketDocument doc, Iterator toBePrinted, OutputStream outputFile, MediaSizeName msn) { Document idoc = new Document(convertWithDefault(msn)); PdfWriter writer = null; -// OutputStream fileOutputStream = null; try { -// fileOutputStream = outputFile; writer = PdfWriter.getInstance(idoc, outputFile); writer.setStrictImageSequence(true); @@ -78,15 +77,16 @@ public class PrintController { detailVisitor.close(); idoc.newPage(); break; - /* case PARTS_LIST: - final ComponentVisitor partsVisitor = new ComponentVisitor(new PartsListVisitorStrategy(idoc, - writer, - stages)); - partsVisitor.visit(doc.getRocket()); - partsVisitor.close(); - idoc.newPage(); - break; - */} + /* case PARTS_LIST: + final ComponentVisitor partsVisitor = new ComponentVisitor(new PartsListVisitorStrategy(idoc, + writer, + stages)); + partsVisitor.visit(doc.getRocket()); + partsVisitor.close(); + idoc.newPage(); + break; + */ + } } //Stupid iText throws a really nasty exception if there is no data when close is called. if (writer.getCurrentDocumentSize() <= 140) { @@ -108,7 +108,8 @@ public class PrintController { } } } - */ } + */ + } private Rectangle convertWithDefault (final MediaSizeName msn) { Rectangle result = PaperSize.convert(msn); diff --git a/src/net/sf/openrocket/gui/print/PrintableFinSet.java b/src/net/sf/openrocket/gui/print/PrintableFinSet.java index 56992fdc..9326c41c 100644 --- a/src/net/sf/openrocket/gui/print/PrintableFinSet.java +++ b/src/net/sf/openrocket/gui/print/PrintableFinSet.java @@ -30,9 +30,13 @@ public class PrintableFinSet extends JPanel implements Printable { private GeneralPath polygon = null; /** - * The margin. + * The X margin. */ - private final int margin = 10; + private int marginX = 25; + /** + * The Y margin. + */ + private int marginY = 25; /** * Constructor. @@ -80,7 +84,13 @@ public class PrintableFinSet extends JPanel implements Printable { } polygon.closePath(); - setSize(maxX - minX + margin, maxY - minY + margin); + if (minX < 0) { + marginX += Math.abs(minX); + } + if (minY < 0) { + marginY += Math.abs(minY); + } + setSize(maxX - minX + marginX, maxY - minY + marginY); } /** @@ -126,8 +136,8 @@ public class PrintableFinSet extends JPanel implements Printable { * @return an awt image of the fin set */ public Image createImage () { - int width = getWidth() + margin; - int height = getHeight() + margin; + int width = getWidth() + marginX; + int height = getHeight() + marginY; // Create a buffered image in which to draw BufferedImage bufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB); // Create a graphics contents on the buffered image @@ -153,7 +163,7 @@ public class PrintableFinSet extends JPanel implements Printable { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g; - g2d.translate(margin, margin); + g2d.translate(marginX, marginY); g2d.setPaint(TemplateProperties.getFillColor()); g2d.fill(polygon); g2d.setPaint(TemplateProperties.getLineColor()); diff --git a/src/net/sf/openrocket/gui/print/visitor/BaseVisitorStrategy.java b/src/net/sf/openrocket/gui/print/visitor/BaseVisitorStrategy.java index 1f7852b5..c6a30e00 100644 --- a/src/net/sf/openrocket/gui/print/visitor/BaseVisitorStrategy.java +++ b/src/net/sf/openrocket/gui/print/visitor/BaseVisitorStrategy.java @@ -14,6 +14,7 @@ import net.sf.openrocket.rocketcomponent.ExternalComponent; import net.sf.openrocket.rocketcomponent.FreeformFinSet; import net.sf.openrocket.rocketcomponent.InnerTube; import net.sf.openrocket.rocketcomponent.LaunchLug; +import net.sf.openrocket.rocketcomponent.MassObject; import net.sf.openrocket.rocketcomponent.NoseCone; import net.sf.openrocket.rocketcomponent.RadiusRingComponent; import net.sf.openrocket.rocketcomponent.RingComponent; @@ -27,8 +28,8 @@ import java.util.HashSet; import java.util.Set; /** - * This abstract class contains boilerplate functionality to support visiting the components of a rocket. - * It is a visitor strategy, not a visitor per se. + * This abstract class contains boilerplate functionality to support visiting the components of a rocket. It is a + * visitor strategy, not a visitor per se. */ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { @@ -51,7 +52,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { * The stages selected. */ protected Set stages; - + /** * State variable to track the level of hierarchy. */ @@ -65,8 +66,8 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * Constructor. - * - * @param doc the iText document + * + * @param doc the iText document */ public BaseVisitorStrategy (Document doc) { this(doc, null); @@ -74,9 +75,9 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * Constructor. - * - * @param doc the iText document - * @param theWriter an iText byte writer + * + * @param doc the iText document + * @param theWriter an iText byte writer */ public BaseVisitorStrategy (Document doc, PdfWriter theWriter) { this(doc, theWriter, new HashSet()); @@ -84,10 +85,10 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * Constructor. - * - * @param doc the iText document - * @param theWriter an iText byte writer - * @param theStages a set of stage numbers + * + * @param doc the iText document + * @param theWriter an iText byte writer + * @param theStages a set of stage numbers */ public BaseVisitorStrategy (Document doc, PdfWriter theWriter, Set theStages) { document = doc; @@ -97,10 +98,10 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * Determine if the visitor strategy's set of stage numbers (to print) contains the specified stage. - * + * * @param stageNumber a stage number - * - * @return true if the visitor strategy contains the stage number provided + * + * @return true if the visitor strategy contains the stage number provided */ public boolean shouldVisitStage (int stageNumber) { if (stages == null || stages.isEmpty()) { @@ -112,14 +113,14 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { return true; } } - + return false; } - + /** * Recurse through the given rocket component. - * - * @param root the root component; all children will be visited recursively + * + * @param root the root component; all children will be visited recursively */ protected void goDeep (final RocketComponent root) { RocketComponent[] rc = root.getChildren(); @@ -128,11 +129,11 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** - * Recurse through the given rocket component. - * - * @param theRc an array of rocket components; all children will be visited recursively - */ - protected void goDeep (final RocketComponent[] theRc) { + * Recurse through the given rocket component. + * + * @param theRc an array of rocket components; all children will be visited recursively + */ + protected void goDeep (final RocketComponent[] theRc) { level++; for (RocketComponent rocketComponent : theRc) { rocketComponent.accept(parent); @@ -142,10 +143,10 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * Get the dimensions of the paper page. - * + * * @return an internal Dimension */ - protected Dimension getPageSize() { + protected Dimension getPageSize () { return new Dimension(document.getPageSize().getWidth(), document.getPageSize().getHeight()); } @@ -153,7 +154,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final Rocket visitable) { goDeep(visitable); } @@ -161,7 +162,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final RocketComponent visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -171,7 +172,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final Stage visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -181,7 +182,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final ExternalComponent visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -191,7 +192,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final BodyComponent visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -201,7 +202,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final RingComponent visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -211,7 +212,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final InnerTube visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -221,7 +222,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final LaunchLug visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -231,7 +232,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final Transition visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -241,7 +242,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final RadiusRingComponent visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -251,7 +252,17 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override + public void visit (final MassObject visitable) { + if (shouldVisitStage(visitable.getStageNumber())) { + goDeep(visitable); + } + } + + /** + * {@inheritDoc} + */ + @Override public void visit (final NoseCone visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -261,7 +272,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final BodyTube visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -271,7 +282,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final TrapezoidFinSet visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -281,7 +292,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final EllipticalFinSet visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -291,7 +302,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void visit (final FreeformFinSet visitable) { if (shouldVisitStage(visitable.getStageNumber())) { goDeep(visitable); @@ -309,7 +320,7 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { /** * {@inheritDoc} */ - @Override + @Override public void close () { } } @@ -317,17 +328,17 @@ public abstract class BaseVisitorStrategy implements ComponentVisitorStrategy { class Dimension { public float width; public float height; - - public Dimension(float w, float h) { + + public Dimension (float w, float h) { width = w; height = h; } - - public float getWidth() { + + public float getWidth () { return width; } - - public float getHeight() { + + public float getHeight () { return height; } } \ No newline at end of file diff --git a/src/net/sf/openrocket/gui/print/visitor/PartsDetailVisitorStrategy.java b/src/net/sf/openrocket/gui/print/visitor/PartsDetailVisitorStrategy.java index 274f8d31..8cbfb697 100644 --- a/src/net/sf/openrocket/gui/print/visitor/PartsDetailVisitorStrategy.java +++ b/src/net/sf/openrocket/gui/print/visitor/PartsDetailVisitorStrategy.java @@ -29,6 +29,7 @@ import net.sf.openrocket.rocketcomponent.FinSet; import net.sf.openrocket.rocketcomponent.FreeformFinSet; import net.sf.openrocket.rocketcomponent.InnerTube; import net.sf.openrocket.rocketcomponent.LaunchLug; +import net.sf.openrocket.rocketcomponent.MassObject; import net.sf.openrocket.rocketcomponent.NoseCone; import net.sf.openrocket.rocketcomponent.RadiusRingComponent; import net.sf.openrocket.rocketcomponent.RingComponent; @@ -94,7 +95,7 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy { goDeep(rc); } - + /** * {@inheritDoc} */ @@ -209,6 +210,28 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy { goDeep(rc); } + /** + * {@inheritDoc} + */ + @Override + public void visit (final MassObject visitable) { + PdfPCell cell = ITextHelper.createCell(); + cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); + cell.setPaddingBottom(12f); + + grid.addCell(iconToImage(visitable)); + final PdfPCell nameCell = createNameCell(visitable.getName(), true); + nameCell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); + nameCell.setPaddingBottom(12f); + grid.addCell(nameCell); + grid.addCell(cell); + grid.addCell(cell); + grid.addCell(cell); + grid.addCell(createMassCell(visitable.getMass())); + RocketComponent[] rc = visitable.getChildren(); + goDeep(rc); + } + /** * {@inheritDoc} */ @@ -334,10 +357,10 @@ public class PartsDetailVisitorStrategy extends BaseVisitorStrategy { img = Image.getInstance(writer, awtImage, 0.25f); } catch (BadElementException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + e.printStackTrace(); } catch (IOException e) { - e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. + e.printStackTrace(); } grid.addCell(iconToImage(visitable)); diff --git a/src/net/sf/openrocket/gui/print/visitor/StageVisitorStrategy.java b/src/net/sf/openrocket/gui/print/visitor/StageVisitorStrategy.java index 19e81e73..f0aeb1b8 100644 --- a/src/net/sf/openrocket/gui/print/visitor/StageVisitorStrategy.java +++ b/src/net/sf/openrocket/gui/print/visitor/StageVisitorStrategy.java @@ -12,6 +12,7 @@ import net.sf.openrocket.rocketcomponent.ExternalComponent; import net.sf.openrocket.rocketcomponent.FreeformFinSet; import net.sf.openrocket.rocketcomponent.InnerTube; import net.sf.openrocket.rocketcomponent.LaunchLug; +import net.sf.openrocket.rocketcomponent.MassObject; import net.sf.openrocket.rocketcomponent.NoseCone; import net.sf.openrocket.rocketcomponent.RadiusRingComponent; import net.sf.openrocket.rocketcomponent.RingComponent; @@ -183,6 +184,15 @@ public class StageVisitorStrategy implements ComponentVisitorStrategy { goDeep(visitable); } + /** + * {@inheritDoc} + */ + @Override + public void visit (final MassObject visitable) { + mass += visitable.getMass(); + goDeep(visitable); + } + /** * {@inheritDoc} */ diff --git a/src/net/sf/openrocket/rocketcomponent/ComponentVisitor.java b/src/net/sf/openrocket/rocketcomponent/ComponentVisitor.java index 636f5f07..5a69f751 100644 --- a/src/net/sf/openrocket/rocketcomponent/ComponentVisitor.java +++ b/src/net/sf/openrocket/rocketcomponent/ComponentVisitor.java @@ -15,8 +15,8 @@ public class ComponentVisitor implements Visitor - * Subclasses of this class need only implement the {@link #getComponentMass()}, - * {@link #getComponentName()} and {@link #isCompatible(RocketComponent)} - * methods. - * + * A MassObject is an internal component that can a specific weight, but not necessarily a strictly bound shape. It is + * represented as a homogeneous cylinder and drawn in the rocket figure with rounded corners. + *

+ * Subclasses of this class need only implement the {@link #getComponentMass()}, {@link #getComponentName()} and {@link + * #isCompatible(RocketComponent)} methods. + * * @author Sampo Niskanen */ public abstract class MassObject extends InternalComponent { - private double radius; - - private double radialPosition; - private double radialDirection; - - private double shiftY = 0; - private double shiftZ = 0; - - - public MassObject() { - this(0.03, 0.015); - } - - public MassObject(double length, double radius) { - super(); - - this.length = length; - this.radius = radius; - - this.setRelativePosition(Position.TOP); - this.setPositionValue(0.0); - } - - - - - public void setLength(double length) { - length = Math.max(length, 0); - if (MathUtil.equals(this.length, length)) - return; - this.length = length; - fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); - } - - - - public final double getRadius() { - return radius; - } - - - public final void setRadius(double radius) { - radius = Math.max(radius, 0); - if (MathUtil.equals(this.radius, radius)) - return; - this.radius = radius; - fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); - } - - - - public final double getRadialPosition() { - return radialPosition; - } - - public final void setRadialPosition(double radialPosition) { - radialPosition = Math.max(radialPosition, 0); - if (MathUtil.equals(this.radialPosition, radialPosition)) - return; - this.radialPosition = radialPosition; - shiftY = radialPosition * Math.cos(radialDirection); - shiftZ = radialPosition * Math.sin(radialDirection); - fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); - } - - public final double getRadialDirection() { - return radialDirection; - } - - public final void setRadialDirection(double radialDirection) { - radialDirection = MathUtil.reduce180(radialDirection); - if (MathUtil.equals(this.radialDirection, radialDirection)) - return; - this.radialDirection = radialDirection; - shiftY = radialPosition * Math.cos(radialDirection); - shiftZ = radialPosition * Math.sin(radialDirection); - fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); - } - - - - - /** - * Shift the coordinates according to the radial position and direction. - */ - @Override - public final Coordinate[] shiftCoordinates(Coordinate[] array) { - for (int i=0; i < array.length; i++) { - array[i] = array[i].add(0, shiftY, shiftZ); - } - return array; - } - - @Override - public final Coordinate getComponentCG() { - return new Coordinate(length/2, shiftY, shiftZ, getComponentMass()); - } - - @Override - public final double getLongitudalUnitInertia() { - return (3*pow2(radius) + pow2(length)) / 12; - } - - @Override - public final double getRotationalUnitInertia() { - return pow2(radius) / 2; - } - - @Override - public final Collection getComponentBounds() { - Collection c = new ArrayList(); - addBound(c, 0, radius); - addBound(c, length, radius); - return c; - } + private double radius; + + private double radialPosition; + private double radialDirection; + + private double shiftY = 0; + private double shiftZ = 0; + + + public MassObject () { + this(0.03, 0.015); + } + + public MassObject (double length, double radius) { + super(); + + this.length = length; + this.radius = radius; + + this.setRelativePosition(Position.TOP); + this.setPositionValue(0.0); + } + + + public void setLength (double length) { + length = Math.max(length, 0); + if (MathUtil.equals(this.length, length)) { + return; + } + this.length = length; + fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); + } + + + public final double getRadius () { + return radius; + } + + + public final void setRadius (double radius) { + radius = Math.max(radius, 0); + if (MathUtil.equals(this.radius, radius)) { + return; + } + this.radius = radius; + fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); + } + + + public final double getRadialPosition () { + return radialPosition; + } + + public final void setRadialPosition (double radialPosition) { + radialPosition = Math.max(radialPosition, 0); + if (MathUtil.equals(this.radialPosition, radialPosition)) { + return; + } + this.radialPosition = radialPosition; + shiftY = radialPosition * Math.cos(radialDirection); + shiftZ = radialPosition * Math.sin(radialDirection); + fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); + } + + public final double getRadialDirection () { + return radialDirection; + } + + public final void setRadialDirection (double radialDirection) { + radialDirection = MathUtil.reduce180(radialDirection); + if (MathUtil.equals(this.radialDirection, radialDirection)) { + return; + } + this.radialDirection = radialDirection; + shiftY = radialPosition * Math.cos(radialDirection); + shiftZ = radialPosition * Math.sin(radialDirection); + fireComponentChangeEvent(ComponentChangeEvent.MASS_CHANGE); + } + + + /** + * Shift the coordinates according to the radial position and direction. + */ + @Override + public final Coordinate[] shiftCoordinates (Coordinate[] array) { + for (int i = 0; i < array.length; i++) { + array[i] = array[i].add(0, shiftY, shiftZ); + } + return array; + } + + @Override + public final Coordinate getComponentCG () { + return new Coordinate(length / 2, shiftY, shiftZ, getComponentMass()); + } + + @Override + public final double getLongitudalUnitInertia () { + return (3 * pow2(radius) + pow2(length)) / 12; + } + + @Override + public final double getRotationalUnitInertia () { + return pow2(radius) / 2; + } + + @Override + public final Collection getComponentBounds () { + Collection c = new ArrayList(); + addBound(c, 0, radius); + addBound(c, length, radius); + return c; + } + + /** + * Accept a visitor to this MassObject in the component hierarchy. + * + * @param theVisitor the visitor that will be called back with a reference to this MassObject + */ + @Override + public void accept (final ComponentVisitor theVisitor) { + theVisitor.visit(this); + } + }