2 * MotorMountVisitor.java
4 package net.sf.openrocket.gui.print.visitor;
6 import com.itextpdf.text.Document;
7 import net.sf.openrocket.motor.Motor;
8 import net.sf.openrocket.rocketcomponent.BodyTube;
9 import net.sf.openrocket.rocketcomponent.InnerTube;
10 import net.sf.openrocket.rocketcomponent.MotorMount;
12 import java.util.ArrayList;
13 import java.util.List;
16 * A visitor strategy for finding data about motor configurations. This visitor accumulates information about the
17 * motors currently 'installed' into each motor mount in the rocket. When the visitor is complete, invoke {@link
18 * #getMotors()} to obtain the list of Motor instances that correspond to the motor configuration.
20 public class MotorMountVisitorStrategy extends BaseVisitorStrategy {
23 * The motor configuration identifier.
27 /** The accumulating list of motors. */
28 private List<Motor> motors = new ArrayList<Motor>();
33 * @param doc the iText document
34 * @param motorConfigID the motor configuration ID
36 public MotorMountVisitorStrategy (Document doc,
37 String motorConfigID) {
43 * Override the method that determines if the visiting should be going deep.
45 * @param stageNumber a stage number
47 * @return true, always
49 public boolean shouldVisitStage (int stageNumber) {
57 public void visit (final BodyTube visitable) {
58 if (visitable.isMotorMount()) {
70 public void visit (final InnerTube visitable) {
71 if (visitable.isMotorMount()) {
77 * The core behavior of this visitor.
79 * @param visitable the object to extract info about; a graphical image of the fin shape is drawn to the document
81 private void doVisit (final MotorMount visitable) {
82 final Motor motor = visitable.getMotor(mid);
89 * Answer with the list of motors that have been accumulated from visiting all of the motor mount components in the
90 * rocket component hierarchy.
92 * @return a list of motors
94 public List<Motor> getMotors () {