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