I18 changes
[debian/openrocket] / src / net / sf / openrocket / rocketcomponent / Rocket.java
1 package net.sf.openrocket.rocketcomponent;
2
3 import java.util.Collection;
4 import java.util.Collections;
5 import java.util.HashMap;
6 import java.util.Iterator;
7 import java.util.LinkedList;
8 import java.util.List;
9 import java.util.UUID;
10
11 import javax.swing.event.ChangeListener;
12 import javax.swing.event.EventListenerList;
13
14 import net.sf.openrocket.gui.main.ExceptionHandler;
15 import net.sf.openrocket.logging.LogHelper;
16 import net.sf.openrocket.motor.Motor;
17 import net.sf.openrocket.startup.Application;
18 import net.sf.openrocket.util.ArrayList;
19 import net.sf.openrocket.util.Chars;
20 import net.sf.openrocket.util.Coordinate;
21 import net.sf.openrocket.util.MathUtil;
22 import net.sf.openrocket.util.UniqueID;
23
24
25 /**
26  * Base for all rocket components.  This is the "starting point" for all rocket trees.
27  * It provides the actual implementations of several methods defined in RocketComponent
28  * (eg. the rocket listener lists) and the methods defined in RocketComponent call these.
29  * It also defines some other methods that concern the whole rocket, and helper methods
30  * that keep information about the program state.
31  * 
32  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
33  */
34
35 public class Rocket extends RocketComponent {
36         private static final LogHelper log = Application.getLogger();
37         
38         public static final double DEFAULT_REFERENCE_LENGTH = 0.01;
39         
40
41         /**
42          * List of component change listeners.
43          */
44         private EventListenerList listenerList = new EventListenerList();
45         
46         /**
47          * When freezeList != null, events are not dispatched but stored in the list.
48          * When the structure is thawed, a single combined event will be fired.
49          */
50         private List<ComponentChangeEvent> freezeList = null;
51         
52
53         private int modID;
54         private int massModID;
55         private int aeroModID;
56         private int treeModID;
57         private int functionalModID;
58         
59
60         private ReferenceType refType = ReferenceType.MAXIMUM; // Set in constructor
61         private double customReferenceLength = DEFAULT_REFERENCE_LENGTH;
62         
63
64         // The default configuration used in dialogs
65         private final Configuration defaultConfiguration;
66         
67
68         private String designer = "";
69         private String revision = "";
70         
71
72         // Motor configuration list
73         private ArrayList<String> motorConfigurationIDs = new ArrayList<String>();
74         private HashMap<String, String> motorConfigurationNames = new HashMap<String, String>();
75         {
76                 motorConfigurationIDs.add(null);
77         }
78         
79
80         // Does the rocket have a perfect finish (a notable amount of laminar flow)
81         private boolean perfectFinish = false;
82         
83         
84
85         /////////////  Constructor  /////////////
86         
87         public Rocket() {
88                 super(RocketComponent.Position.AFTER);
89                 modID = UniqueID.next();
90                 massModID = modID;
91                 aeroModID = modID;
92                 treeModID = modID;
93                 functionalModID = modID;
94                 defaultConfiguration = new Configuration(this);
95         }
96         
97         
98
99         public String getDesigner() {
100                 checkState();
101                 return designer;
102         }
103         
104         public void setDesigner(String s) {
105                 if (s == null)
106                         s = "";
107                 designer = s;
108                 fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
109         }
110         
111         
112         public String getRevision() {
113                 checkState();
114                 return revision;
115         }
116         
117         public void setRevision(String s) {
118                 if (s == null)
119                         s = "";
120                 revision = s;
121                 fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
122         }
123         
124         
125
126
127         /**
128          * Return the number of stages in this rocket.
129          * 
130          * @return   the number of stages in this rocket.
131          */
132         public int getStageCount() {
133                 checkState();
134                 return this.getChildCount();
135         }
136         
137         
138         /**
139          * Return the non-negative modification ID of this rocket.  The ID is changed
140          * every time any change occurs in the rocket.  This can be used to check 
141          * whether it is necessary to void cached data in cases where listeners can not
142          * or should not be used.
143          * <p>
144          * Three other modification IDs are also available, {@link #getMassModID()},
145          * {@link #getAerodynamicModID()} {@link #getTreeModID()}, which change every time 
146          * a mass change, aerodynamic change, or tree change occur.  Even though the values 
147          * of the different modification ID's may be equal, they should be treated totally 
148          * separate.
149          * <p>
150          * Note that undo events restore the modification IDs that were in use at the
151          * corresponding undo level.  Subsequent modifications, however, produce modIDs
152          * distinct from those already used.
153          * 
154          * @return   a unique ID number for this modification state.
155          */
156         public int getModID() {
157                 return modID;
158         }
159         
160         /**
161          * Return the non-negative mass modification ID of this rocket.  See
162          * {@link #getModID()} for details.
163          * 
164          * @return   a unique ID number for this mass-modification state.
165          */
166         public int getMassModID() {
167                 return massModID;
168         }
169         
170         /**
171          * Return the non-negative aerodynamic modification ID of this rocket.  See
172          * {@link #getModID()} for details.
173          * 
174          * @return   a unique ID number for this aerodynamic-modification state.
175          */
176         public int getAerodynamicModID() {
177                 return aeroModID;
178         }
179         
180         /**
181          * Return the non-negative tree modification ID of this rocket.  See
182          * {@link #getModID()} for details.
183          * 
184          * @return   a unique ID number for this tree-modification state.
185          */
186         public int getTreeModID() {
187                 return treeModID;
188         }
189         
190         /**
191          * Return the non-negative functional modificationID of this rocket.
192          * This changes every time a functional change occurs.
193          * 
194          * @return      a unique ID number for this functional modification state.
195          */
196         public int getFunctionalModID() {
197                 return functionalModID;
198         }
199         
200         
201
202
203         public ReferenceType getReferenceType() {
204                 checkState();
205                 return refType;
206         }
207         
208         public void setReferenceType(ReferenceType type) {
209                 if (refType == type)
210                         return;
211                 refType = type;
212                 fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
213         }
214         
215         
216         public double getCustomReferenceLength() {
217                 checkState();
218                 return customReferenceLength;
219         }
220         
221         public void setCustomReferenceLength(double length) {
222                 if (MathUtil.equals(customReferenceLength, length))
223                         return;
224                 
225                 this.customReferenceLength = Math.max(length, 0.001);
226                 
227                 if (refType == ReferenceType.CUSTOM) {
228                         fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
229                 }
230         }
231         
232         
233
234
235
236         /**
237          * Set whether the rocket has a perfect finish.  This will affect whether the
238          * boundary layer is assumed to be fully turbulent or not.
239          * 
240          * @param perfectFinish         whether the finish is perfect.
241          */
242         public void setPerfectFinish(boolean perfectFinish) {
243                 if (this.perfectFinish == perfectFinish)
244                         return;
245                 this.perfectFinish = perfectFinish;
246                 fireComponentChangeEvent(ComponentChangeEvent.AERODYNAMIC_CHANGE);
247         }
248         
249         
250
251         /**
252          * Get whether the rocket has a perfect finish.
253          * 
254          * @return the perfectFinish
255          */
256         public boolean isPerfectFinish() {
257                 return perfectFinish;
258         }
259         
260         
261
262
263
264         /**
265          * Make a deep copy of the Rocket structure.  This method is exposed as public to allow
266          * for undo/redo system functionality.
267          */
268         @SuppressWarnings("unchecked")
269         @Override
270         public Rocket copyWithOriginalID() {
271                 Rocket copy = (Rocket) super.copyWithOriginalID();
272                 copy.motorConfigurationIDs = this.motorConfigurationIDs.clone();
273                 copy.motorConfigurationNames =
274                                 (HashMap<String, String>) this.motorConfigurationNames.clone();
275                 copy.resetListeners();
276                 
277                 return copy;
278         }
279         
280         /**
281          * Load the rocket structure from the source.  The method loads the fields of this
282          * Rocket object and copies the references to siblings from the <code>source</code>.
283          * The object <code>source</code> should not be used after this call, as it is in
284          * an illegal state!
285          * <p>
286          * This method is meant to be used in conjunction with undo/redo functionality,
287          * and therefore fires an UNDO_EVENT, masked with all applicable mass/aerodynamic/tree
288          * changes.
289          */
290         @SuppressWarnings("unchecked")
291         public void loadFrom(Rocket r) {
292                 
293                 // Store list of components to invalidate after event has been fired
294                 List<RocketComponent> toInvalidate = this.copyFrom(r);
295                 
296                 int type = ComponentChangeEvent.UNDO_CHANGE | ComponentChangeEvent.NONFUNCTIONAL_CHANGE;
297                 if (this.massModID != r.massModID)
298                         type |= ComponentChangeEvent.MASS_CHANGE;
299                 if (this.aeroModID != r.aeroModID)
300                         type |= ComponentChangeEvent.AERODYNAMIC_CHANGE;
301                 // Loading a rocket is always a tree change since the component objects change
302                 type |= ComponentChangeEvent.TREE_CHANGE;
303                 
304                 this.modID = r.modID;
305                 this.massModID = r.massModID;
306                 this.aeroModID = r.aeroModID;
307                 this.treeModID = r.treeModID;
308                 this.functionalModID = r.functionalModID;
309                 this.refType = r.refType;
310                 this.customReferenceLength = r.customReferenceLength;
311                 
312                 this.motorConfigurationIDs = r.motorConfigurationIDs.clone();
313                 this.motorConfigurationNames =
314                                 (HashMap<String, String>) r.motorConfigurationNames.clone();
315                 this.perfectFinish = r.perfectFinish;
316                 
317                 String id = defaultConfiguration.getMotorConfigurationID();
318                 if (!this.motorConfigurationIDs.contains(id))
319                         defaultConfiguration.setMotorConfigurationID(null);
320                 
321                 this.checkComponentStructure();
322                 
323                 fireComponentChangeEvent(type);
324                 
325                 // Invalidate obsolete components after event
326                 for (RocketComponent c : toInvalidate) {
327                         c.invalidate();
328                 }
329         }
330         
331         
332
333
334         ///////  Implement the ComponentChangeListener lists
335         
336         /**
337          * Creates a new EventListenerList for this component.  This is necessary when cloning
338          * the structure.
339          */
340         public void resetListeners() {
341                 //              System.out.println("RESETTING LISTENER LIST of Rocket "+this);
342                 listenerList = new EventListenerList();
343         }
344         
345         
346         public void printListeners() {
347                 System.out.println("" + this + " has " + listenerList.getListenerCount() + " listeners:");
348                 Object[] list = listenerList.getListenerList();
349                 for (int i = 1; i < list.length; i += 2)
350                         System.out.println("  " + ((i + 1) / 2) + ": " + list[i]);
351         }
352         
353         @Override
354         public void addComponentChangeListener(ComponentChangeListener l) {
355                 checkState();
356                 listenerList.add(ComponentChangeListener.class, l);
357                 log.verbose("Added ComponentChangeListener " + l + ", current number of listeners is " +
358                                 listenerList.getListenerCount());
359         }
360         
361         @Override
362         public void removeComponentChangeListener(ComponentChangeListener l) {
363                 listenerList.remove(ComponentChangeListener.class, l);
364                 log.verbose("Removed ComponentChangeListener " + l + ", current number of listeners is " +
365                                 listenerList.getListenerCount());
366         }
367         
368         
369         @Override
370         public void addChangeListener(ChangeListener l) {
371                 checkState();
372                 listenerList.add(ChangeListener.class, l);
373                 log.verbose("Added ChangeListener " + l + ", current number of listeners is " +
374                                 listenerList.getListenerCount());
375         }
376         
377         @Override
378         public void removeChangeListener(ChangeListener l) {
379                 listenerList.remove(ChangeListener.class, l);
380                 log.verbose("Removed ChangeListener " + l + ", current number of listeners is " +
381                                 listenerList.getListenerCount());
382         }
383         
384         
385         @Override
386         protected void fireComponentChangeEvent(ComponentChangeEvent e) {
387                 mutex.lock("fireComponentChangeEvent");
388                 try {
389                         checkState();
390                         
391                         // Update modification ID's only for normal (not undo/redo) events
392                         if (!e.isUndoChange()) {
393                                 modID = UniqueID.next();
394                                 if (e.isMassChange())
395                                         massModID = modID;
396                                 if (e.isAerodynamicChange())
397                                         aeroModID = modID;
398                                 if (e.isTreeChange())
399                                         treeModID = modID;
400                                 if (e.getType() != ComponentChangeEvent.NONFUNCTIONAL_CHANGE)
401                                         functionalModID = modID;
402                         }
403                         
404                         // Check whether frozen
405                         if (freezeList != null) {
406                                 log.debug("Rocket is in frozen state, adding event " + e + " info freeze list");
407                                 freezeList.add(e);
408                                 return;
409                         }
410                         
411                         log.debug("Firing rocket change event " + e);
412                         
413                         // Notify all components first
414                         Iterator<RocketComponent> iterator = this.iterator(true);
415                         while (iterator.hasNext()) {
416                                 iterator.next().componentChanged(e);
417                         }
418                         
419                         // Notify all listeners
420                         Object[] listeners = listenerList.getListenerList();
421                         for (int i = listeners.length - 2; i >= 0; i -= 2) {
422                                 if (listeners[i] == ComponentChangeListener.class) {
423                                         ((ComponentChangeListener) listeners[i + 1]).componentChanged(e);
424                                 } else if (listeners[i] == ChangeListener.class) {
425                                         ((ChangeListener) listeners[i + 1]).stateChanged(e);
426                                 }
427                         }
428                 } finally {
429                         mutex.unlock("fireComponentChangeEvent");
430                 }
431         }
432         
433         
434         /**
435          * Freezes the rocket structure from firing any events.  This may be performed to
436          * combine several actions on the structure into a single large action.
437          * <code>thaw()</code> must always be called afterwards.
438          * 
439          * NOTE:  Always use a try/finally to ensure <code>thaw()</code> is called:
440          * <pre>
441          *     Rocket r = c.getRocket();
442          *     try {
443          *         r.freeze();
444          *         // do stuff
445          *     } finally {
446          *         r.thaw();
447          *     }
448          * </pre>
449          * 
450          * @see #thaw()
451          */
452         public void freeze() {
453                 checkState();
454                 if (freezeList == null) {
455                         freezeList = new LinkedList<ComponentChangeEvent>();
456                         log.debug("Freezing Rocket");
457                 } else {
458                         ExceptionHandler.handleErrorCondition("Attempting to freeze Rocket when it is already frozen, " +
459                                         "freezeList=" + freezeList);
460                 }
461         }
462         
463         /**
464          * Thaws a frozen rocket structure and fires a combination of the events fired during
465          * the freeze.  The event type is a combination of those fired and the source is the
466          * last component to have been an event source.
467          *
468          * @see #freeze()
469          */
470         public void thaw() {
471                 checkState();
472                 if (freezeList == null) {
473                         ExceptionHandler.handleErrorCondition("Attempting to thaw Rocket when it is not frozen");
474                         return;
475                 }
476                 if (freezeList.size() == 0) {
477                         log.warn("Thawing rocket with no changes made");
478                         freezeList = null;
479                         return;
480                 }
481                 
482                 log.debug("Thawing rocket, freezeList=" + freezeList);
483                 
484                 int type = 0;
485                 Object c = null;
486                 for (ComponentChangeEvent e : freezeList) {
487                         type = type | e.getType();
488                         c = e.getSource();
489                 }
490                 freezeList = null;
491                 
492                 fireComponentChangeEvent(new ComponentChangeEvent((RocketComponent) c, type));
493         }
494         
495         
496
497
498         ////////  Motor configurations  ////////
499         
500
501         /**
502          * Return the default configuration.  This should be used in the user interface
503          * to ensure a consistent rocket configuration between dialogs.  It should NOT
504          * be used in simulations not relating to the UI.
505          * 
506          * @return   the default {@link Configuration}.
507          */
508         public Configuration getDefaultConfiguration() {
509                 checkState();
510                 return defaultConfiguration;
511         }
512         
513         
514         /**
515          * Return an array of the motor configuration IDs.  This array is guaranteed
516          * to contain the <code>null</code> ID as the first element.
517          * 
518          * @return  an array of the motor configuration IDs.
519          */
520         public String[] getMotorConfigurationIDs() {
521                 checkState();
522                 return motorConfigurationIDs.toArray(new String[0]);
523         }
524         
525         /**
526          * Add a new motor configuration ID to the motor configurations.  The new ID
527          * is returned.
528          * 
529          * @return  the new motor configuration ID.
530          */
531         public String newMotorConfigurationID() {
532                 checkState();
533                 String id = UUID.randomUUID().toString();
534                 motorConfigurationIDs.add(id);
535                 fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
536                 return id;
537         }
538         
539         /**
540          * Add a specified motor configuration ID to the motor configurations.
541          * 
542          * @param id    the motor configuration ID.
543          * @return              true if successful, false if the ID was already used.
544          */
545         public boolean addMotorConfigurationID(String id) {
546                 checkState();
547                 if (id == null || motorConfigurationIDs.contains(id))
548                         return false;
549                 motorConfigurationIDs.add(id);
550                 fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
551                 return true;
552         }
553         
554         /**
555          * Remove a motor configuration ID from the configuration IDs.  The <code>null</code>
556          * ID cannot be removed, and an attempt to remove it will be silently ignored.
557          * 
558          * @param id   the motor configuration ID to remove
559          */
560         public void removeMotorConfigurationID(String id) {
561                 checkState();
562                 if (id == null)
563                         return;
564                 motorConfigurationIDs.remove(id);
565                 fireComponentChangeEvent(ComponentChangeEvent.MOTOR_CHANGE);
566         }
567         
568         
569         /**
570          * Check whether <code>id</code> is a valid motor configuration ID.
571          * 
572          * @param id    the configuration ID.
573          * @return              whether a motor configuration with that ID exists.
574          */
575         public boolean isMotorConfigurationID(String id) {
576                 checkState();
577                 return motorConfigurationIDs.contains(id);
578         }
579         
580         
581
582         /**
583          * Check whether the given motor configuration ID has motors defined for it.
584          * 
585          * @param id    the motor configuration ID (may be invalid).
586          * @return              whether any motors are defined for it.
587          */
588         public boolean hasMotors(String id) {
589                 checkState();
590                 if (id == null)
591                         return false;
592                 
593                 Iterator<RocketComponent> iterator = this.iterator();
594                 while (iterator.hasNext()) {
595                         RocketComponent c = iterator.next();
596                         
597                         if (c instanceof MotorMount) {
598                                 MotorMount mount = (MotorMount) c;
599                                 if (!mount.isMotorMount())
600                                         continue;
601                                 if (mount.getMotor(id) != null) {
602                                         return true;
603                                 }
604                         }
605                 }
606                 return false;
607         }
608         
609         
610         /**
611          * Return the user-set name of the motor configuration.  If no name has been set,
612          * returns an empty string (not null).
613          *  
614          * @param id   the motor configuration id
615          * @return         the configuration name
616          */
617         public String getMotorConfigurationName(String id) {
618                 checkState();
619                 if (!isMotorConfigurationID(id))
620                         return "";
621                 String s = motorConfigurationNames.get(id);
622                 if (s == null)
623                         return "";
624                 return s;
625         }
626         
627         
628         /**
629          * Set the name of the motor configuration.  A name can be unset by passing
630          * <code>null</code> or an empty string.
631          * 
632          * @param id    the motor configuration id
633          * @param name  the name for the motor configuration
634          */
635         public void setMotorConfigurationName(String id, String name) {
636                 checkState();
637                 motorConfigurationNames.put(id, name);
638                 fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
639         }
640         
641         
642         /**
643          * Return either the motor configuration name (if set) or its description. 
644          * 
645          * @param id  the motor configuration ID.
646          * @return    a textual representation of the configuration
647          */
648         public String getMotorConfigurationNameOrDescription(String id) {
649                 checkState();
650                 String name;
651                 
652                 name = getMotorConfigurationName(id);
653                 if (name != null && !name.equals(""))
654                         return name;
655                 
656                 return getMotorConfigurationDescription(id);
657         }
658         
659         /**
660          * Return a description for the motor configuration, generated from the motor 
661          * designations of the components.
662          * 
663          * @param id  the motor configuration ID.
664          * @return    a textual representation of the configuration
665          */
666         @SuppressWarnings("null")
667         public String getMotorConfigurationDescription(String id) {
668                 checkState();
669                 String name;
670                 int motorCount = 0;
671                 
672                 // Generate the description
673                 
674                 // First iterate over each stage and store the designations of each motor
675                 List<List<String>> list = new ArrayList<List<String>>();
676                 List<String> currentList = null;
677                 
678                 Iterator<RocketComponent> iterator = this.iterator();
679                 while (iterator.hasNext()) {
680                         RocketComponent c = iterator.next();
681                         
682                         if (c instanceof Stage) {
683                                 
684                                 currentList = new ArrayList<String>();
685                                 list.add(currentList);
686                                 
687                         } else if (c instanceof MotorMount) {
688                                 
689                                 MotorMount mount = (MotorMount) c;
690                                 Motor motor = mount.getMotor(id);
691                                 
692                                 if (mount.isMotorMount() && motor != null) {
693                                         String designation = motor.getDesignation(mount.getMotorDelay(id));
694                                         
695                                         for (int i = 0; i < mount.getMotorCount(); i++) {
696                                                 currentList.add(designation);
697                                                 motorCount++;
698                                         }
699                                 }
700                                 
701                         }
702                 }
703                 
704                 if (motorCount == 0) {
705                         return "[No motors]";
706                 }
707                 
708                 // Change multiple occurrences of a motor to n x motor 
709                 List<String> stages = new ArrayList<String>();
710                 
711                 for (List<String> stage : list) {
712                         String stageName = "";
713                         String previous = null;
714                         int count = 0;
715                         
716                         Collections.sort(stage);
717                         for (String current : stage) {
718                                 if (current.equals(previous)) {
719                                         
720                                         count++;
721                                         
722                                 } else {
723                                         
724                                         if (previous != null) {
725                                                 String s = "";
726                                                 if (count > 1) {
727                                                         s = "" + count + Chars.TIMES + previous;
728                                                 } else {
729                                                         s = previous;
730                                                 }
731                                                 
732                                                 if (stageName.equals(""))
733                                                         stageName = s;
734                                                 else
735                                                         stageName = stageName + "," + s;
736                                         }
737                                         
738                                         previous = current;
739                                         count = 1;
740                                         
741                                 }
742                         }
743                         if (previous != null) {
744                                 String s = "";
745                                 if (count > 1) {
746                                         s = "" + count + Chars.TIMES + previous;
747                                 } else {
748                                         s = previous;
749                                 }
750                                 
751                                 if (stageName.equals(""))
752                                         stageName = s;
753                                 else
754                                         stageName = stageName + "," + s;
755                         }
756                         
757                         stages.add(stageName);
758                 }
759                 
760                 name = "[";
761                 for (int i = 0; i < stages.size(); i++) {
762                         String s = stages.get(i);
763                         if (s.equals(""))
764                                 s = "None";
765                         if (i == 0)
766                                 name = name + s;
767                         else
768                                 name = name + "; " + s;
769                 }
770                 name += "]";
771                 return name;
772         }
773         
774         
775
776         ////////  Obligatory component information
777         
778
779         @Override
780         public String getComponentName() {
781                 return "Rocket";
782         }
783         
784         @Override
785         public Coordinate getComponentCG() {
786                 return new Coordinate(0, 0, 0, 0);
787         }
788         
789         @Override
790         public double getComponentMass() {
791                 return 0;
792         }
793         
794         @Override
795         public double getLongitudinalUnitInertia() {
796                 return 0;
797         }
798         
799         @Override
800         public double getRotationalUnitInertia() {
801                 return 0;
802         }
803         
804         @Override
805         public Collection<Coordinate> getComponentBounds() {
806                 return Collections.emptyList();
807         }
808         
809         @Override
810         public boolean isAerodynamic() {
811                 return false;
812         }
813         
814         @Override
815         public boolean isMassive() {
816                 return false;
817         }
818         
819         @Override
820         public boolean allowsChildren() {
821                 return true;
822         }
823         
824         /**
825          * Allows only <code>Stage</code> components to be added to the type Rocket.
826          */
827         @Override
828         public boolean isCompatible(Class<? extends RocketComponent> type) {
829                 return (Stage.class.isAssignableFrom(type));
830         }
831         
832         /**
833          * Accept a visitor to this Rocket in the component hierarchy.
834          * 
835          * @param theVisitor  the visitor that will be called back with a reference to this Rocket
836          */
837         @Override
838         public void accept(final ComponentVisitor theVisitor) {
839                 theVisitor.visit(this);
840         }
841 }