1 package net.sf.openrocket.rocketcomponent;
3 import java.util.EventObject;
5 public class ComponentChangeEvent extends EventObject {
6 private static final long serialVersionUID = 1L;
9 /** A change that does not affect simulation results in any way (name, color, etc.) */
10 public static final int NONFUNCTIONAL_CHANGE = 1;
11 /** A change that affects the mass properties of the rocket */
12 public static final int MASS_CHANGE = 2;
13 /** A change that affects the aerodynamic properties of the rocket */
14 public static final int AERODYNAMIC_CHANGE = 4;
15 /** A change that affects the mass and aerodynamic properties of the rocket */
16 public static final int BOTH_CHANGE = MASS_CHANGE | AERODYNAMIC_CHANGE; // Mass & Aerodynamic
18 /** A change that affects the rocket tree structure */
19 public static final int TREE_CHANGE = 8;
20 /** A change caused by undo/redo. */
21 public static final int UNDO_CHANGE = 16;
22 /** A change in the motor configurations or names */
23 public static final int MOTOR_CHANGE = 32;
24 /** A change that affects the events occurring during flight. */
25 public static final int EVENT_CHANGE = 64;
27 /** A bit-field that contains all possible change types. */
28 public static final int ALL_CHANGE = 0xFFFFFFFF;
30 private final int type;
33 public ComponentChangeEvent(RocketComponent component, int type) {
36 throw new IllegalArgumentException("no event type provided");
43 * Return the source component of this event as specified in the constructor.
46 public RocketComponent getSource() {
47 return (RocketComponent) super.getSource();
51 public boolean isAerodynamicChange() {
52 return (type & AERODYNAMIC_CHANGE) != 0;
55 public boolean isMassChange() {
56 return (type & MASS_CHANGE) != 0;
59 public boolean isOtherChange() {
60 return (type & BOTH_CHANGE) == 0;
63 public boolean isTreeChange() {
64 return (type & TREE_CHANGE) != 0;
67 public boolean isUndoChange() {
68 return (type & UNDO_CHANGE) != 0;
71 public boolean isMotorChange() {
72 return (type & MOTOR_CHANGE) != 0;
75 public int getType() {
80 public String toString() {
83 if ((type & NONFUNCTIONAL_CHANGE) != 0)
87 if (isAerodynamicChange())
95 if ((type & EVENT_CHANGE) != 0)
101 return "ComponentChangeEvent[" + s + "]";