2 * OpenRocketPrintable.java
4 package net.sf.openrocket.gui.print;
6 import java.util.ArrayList;
9 import net.sf.openrocket.l10n.Translator;
10 import net.sf.openrocket.startup.Application;
13 * This enumeration identifies the various types of information that may be printed.
16 public enum OpenRocketPrintable {
18 DESIGN_REPORT("OpenRocketPrintable.DesignReport", false, 1),
20 PARTS_DETAIL("OpenRocketPrintable.Partsdetail", true, 2),
21 // Nose Cone Templates
22 NOSE_CONE_TEMPLATE("OpenRocketPrintable.Noseconetemplates", false, 3),
23 // Transition Templates
24 TRANSITION_TEMPLATE("OpenRocketPrintable.Transitiontemplates", false, 4),
25 // Centering Ring Templates
26 CENTERING_RING_TEMPLATE("OpenRocketPrintable.Centeringringtemplates", false, 5),
28 FIN_TEMPLATE("OpenRocketPrintable.Fintemplates", true, 6),
30 FIN_MARKING_GUIDE("OpenRocketPrintable.Finmarkingguide", false, 7);
33 private static final Translator trans = Application.getTranslator();
36 * The description - will be displayed in the JTree.
38 private String description;
41 * Flag that indicates if the enum value is different depending upon stage.
43 private boolean stageSpecific;
46 * The order of the item as it appears in the printed document.
53 * @param s the displayable description
54 * @param staged indicates if the printable is stage dependent
55 * @param idx the relative print order
57 OpenRocketPrintable(String s, boolean staged, int idx) {
59 stageSpecific = staged;
64 * Get the description of this printable.
66 * @return a displayable string
68 public String getDescription() {
69 return trans.get(description);
73 * Answers if this enum value has different meaning depending upon the stage.
75 * @return true if the printable is stage dependent
77 public boolean isStageSpecific() {
82 * Answer the print order. This is relative to other enum values. No two enum values will have the same print
85 * @return a 0 based order (0 being first, or highest)
87 public int getPrintOrder() {
92 * Look up an enum value based on the description.
94 * @param target the description
96 * @return an instance of this enum class or null if not found
98 public static OpenRocketPrintable findByDescription(String target) {
99 OpenRocketPrintable[] values = values();
100 for (OpenRocketPrintable value : values) {
101 if (value.getDescription().equalsIgnoreCase(target)) {
109 * Get a list of ordered enum values that do not have stage affinity.
111 * @return a list of OpenRocketPrintable
113 public static List<OpenRocketPrintable> getUnstaged() {
114 List<OpenRocketPrintable> unstaged = new ArrayList<OpenRocketPrintable>();
115 OpenRocketPrintable[] values = values();
116 for (OpenRocketPrintable value : values) {
117 if (!value.isStageSpecific()) {