git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@136 180e2...
[debian/openrocket] / src / net / sf / openrocket / gui / print / OpenRocketPrintable.java
1 /*
2  * OpenRocketPrintable.java
3  */
4 package net.sf.openrocket.gui.print;
5 import net.sf.openrocket.l10n.Translator;
6 import net.sf.openrocket.startup.Application;
7
8 /**
9  * This enumeration identifies the various types of information that may be printed.
10  */
11
12 public enum OpenRocketPrintable {
13     //PARTS_LIST("Parts list", true, 0),
14         //// Parts detail
15     PARTS_DETAIL("OpenRocketPrintable.Partsdetail", true, 1),
16     ////
17     FIN_TEMPLATE("OpenRocketPrintable.Fintemplates", true, 2),
18     //// Design Report
19     DESIGN_REPORT("OpenRocketPrintable.DesignReport", false, 3);
20
21     /**
22      * The description - will be displayed in the JTree.
23      */
24     private String description;
25
26     /**
27      * Flag that indicates if the enum value is different depending upon stage.
28      */
29     private boolean stageSpecific;
30
31     /**
32      * The order of the item as it appears in the printed document.
33      */
34     private int order;
35
36     /**
37      * Constructor.
38      *
39      * @param s      the displayable description
40      * @param staged indicates if the printable is stage dependent
41      * @param idx    the relative print order
42      */
43     OpenRocketPrintable (String s, boolean staged, int idx) {
44         description = s;
45         stageSpecific = staged;
46         order = idx;
47     }
48
49     /**
50      * Get the description of this printable.
51      *
52      * @return a displayable string
53      */
54     public String getDescription () {
55         final Translator trans = Application.getTranslator();
56         return trans.get(description);
57     }
58
59     /**
60      * Answers if this enum value has different meaning depending upon the stage.
61      *
62      * @return true if the printable is stage dependent
63      */
64     public boolean isStageSpecific () {
65         return stageSpecific;
66     }
67
68     /**
69      * Answer the print order.  This is relative to other enum values.  No two enum values will have the same print
70      * order value.
71      *
72      * @return a 0 based order (0 being first, or highest)
73      */
74     public int getPrintOrder () {
75         return order;
76     }
77
78     /**
79      * Look up an enum value based on the description.
80      *
81      * @param target the description
82      *
83      * @return an instance of this enum class or null if not found
84      */
85     public static OpenRocketPrintable findByDescription (String target) {
86         OpenRocketPrintable[] values = values();
87         for (OpenRocketPrintable value : values) {
88             if (value.getDescription().equalsIgnoreCase(target)) {
89                 return value;
90             }
91         }
92         return null;
93     }
94 }