1 package net.sf.openrocket.rocketcomponent;
3 import javax.swing.event.ChangeEvent;
5 public class ComponentChangeEvent extends ChangeEvent {
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 in 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");
42 public boolean isAerodynamicChange() {
43 return (type & AERODYNAMIC_CHANGE) != 0;
46 public boolean isMassChange() {
47 return (type & MASS_CHANGE) != 0;
50 public boolean isOtherChange() {
51 return (type & BOTH_CHANGE) == 0;
54 public boolean isTreeChange() {
55 return (type & TREE_CHANGE) != 0;
58 public boolean isUndoChange() {
59 return (type & UNDO_CHANGE) != 0;
62 public boolean isMotorChange() {
63 return (type & MOTOR_CHANGE) != 0;
66 public int getType() {
71 public String toString() {
74 if ((type & NONFUNCTIONAL_CHANGE) != 0)
78 if (isAerodynamicChange())
86 if ((type & EVENT_CHANGE) != 0)
92 return "ComponentChangeEvent[" + s + "]";