create changelog entry
[debian/openrocket] / core / src / net / sf / openrocket / gui / print / TemplateProperties.java
1 /*
2  * TemplateProperties.java
3  */
4 package net.sf.openrocket.gui.print;
5
6 import java.awt.Color;
7
8 import javax.swing.UIManager;
9
10 /**
11  * This class is responsible for managing various properties of print templates (fin, nose cone, transitions, etc.).
12  * 
13  * TODO: HIGH:  Remove this entire class, and instead pass the PrintSettings object to the print methods.
14  */
15 public class TemplateProperties {
16         
17         /**
18          * The property that defines the fill color.
19          */
20         public static final String TEMPLATE_FILL_COLOR_PROPERTY = "template.fill.color";
21         
22         /**
23          * The property that defines the line color.
24          */
25         public static final String TEMPLATE_LINE_COLOR_PROPERTY = "template.line.color";
26         
27         /**
28          * Get the current fill color.
29          * 
30          * @return  a color to be used as the fill in template shapes
31          */
32         public static Color getFillColor() {
33                 Color fillColor = UIManager.getColor(TemplateProperties.TEMPLATE_FILL_COLOR_PROPERTY);
34                 if (fillColor == null) {
35                         fillColor = Color.lightGray;
36                 }
37                 return fillColor;
38         }
39         
40         
41         /**
42          * Set the template fill color.
43          */
44         public static void setFillColor(Color c) {
45                 UIManager.put(TemplateProperties.TEMPLATE_FILL_COLOR_PROPERTY, c);
46         }
47         
48         
49         /**
50          * Get the current line color.
51          * 
52          * @return  a color to be used as the line in template shapes
53          */
54         public static Color getLineColor() {
55                 Color lineColor = UIManager.getColor(TemplateProperties.TEMPLATE_LINE_COLOR_PROPERTY);
56                 if (lineColor == null) {
57                         lineColor = Color.darkGray;
58                 }
59                 return lineColor;
60         }
61         
62         /**
63          * Set the template line color.
64          */
65         public static void setLineColor(Color c) {
66                 UIManager.put(TemplateProperties.TEMPLATE_LINE_COLOR_PROPERTY, c);
67         }
68         
69         /**
70          * Set the template colors from the print settings.
71          */
72         public static void setColors(PrintSettings settings) {
73                 setFillColor(settings.getTemplateFillColor());
74                 setLineColor(settings.getTemplateBorderColor());
75         }
76 }