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),
26 FIN_TEMPLATE("OpenRocketPrintable.Fintemplates", true, 5),
28 FIN_MARKING_GUIDE("OpenRocketPrintable.Finmarkingguide", false, 6);
31 private static final Translator trans = Application.getTranslator();
34 * The description - will be displayed in the JTree.
36 private String description;
39 * Flag that indicates if the enum value is different depending upon stage.
41 private boolean stageSpecific;
44 * The order of the item as it appears in the printed document.
51 * @param s the displayable description
52 * @param staged indicates if the printable is stage dependent
53 * @param idx the relative print order
55 OpenRocketPrintable(String s, boolean staged, int idx) {
57 stageSpecific = staged;
62 * Get the description of this printable.
64 * @return a displayable string
66 public String getDescription() {
67 return trans.get(description);
71 * Answers if this enum value has different meaning depending upon the stage.
73 * @return true if the printable is stage dependent
75 public boolean isStageSpecific() {
80 * Answer the print order. This is relative to other enum values. No two enum values will have the same print
83 * @return a 0 based order (0 being first, or highest)
85 public int getPrintOrder() {
90 * Look up an enum value based on the description.
92 * @param target the description
94 * @return an instance of this enum class or null if not found
96 public static OpenRocketPrintable findByDescription(String target) {
97 OpenRocketPrintable[] values = values();
98 for (OpenRocketPrintable value : values) {
99 if (value.getDescription().equalsIgnoreCase(target)) {
107 * Get a list of ordered enum values that do not have stage affinity.
109 * @return a list of OpenRocketPrintable
111 public static List<OpenRocketPrintable> getUnstaged() {
112 List<OpenRocketPrintable> unstaged = new ArrayList<OpenRocketPrintable>();
113 OpenRocketPrintable[] values = values();
114 for (OpenRocketPrintable value : values) {
115 if (!value.isStageSpecific()) {