Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/AxisSection.java @ 2058:f97cf2e350c9
Some refactoring done: all Sections subclass TypeSection now to be able to use the convinience methods for string, integer, double and boolean attributes.
flys-artifacts/trunk@3550 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 27 Dec 2011 11:37:23 +0000 |
parents | f9a972d375ba |
children | ca8997aa683e |
comparison
equal
deleted
inserted
replaced
2057:49b7c2b1a6a7 | 2058:f97cf2e350c9 |
---|---|
10 | 10 |
11 | 11 |
12 /** | 12 /** |
13 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 13 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
14 */ | 14 */ |
15 public class AxisSection extends DefaultSection { | 15 public class AxisSection extends TypeSection { |
16 | 16 |
17 public static final String IDENTIFIER_ATTR = "id"; | 17 public static final String IDENTIFIER_ATTR = "id"; |
18 public static final String LABEL_ATTR = "label"; | 18 public static final String LABEL_ATTR = "label"; |
19 public static final String FONTSIZE_ATTR = "font-size"; | 19 public static final String FONTSIZE_ATTR = "font-size"; |
20 public static final String FIXATION_ATTR = "fixation"; | 20 public static final String FIXATION_ATTR = "fixation"; |
26 super("axis"); | 26 super("axis"); |
27 } | 27 } |
28 | 28 |
29 | 29 |
30 public void setIdentifier(String identifier) { | 30 public void setIdentifier(String identifier) { |
31 if (identifier == null || identifier.length() == 0) { | 31 setStringValue(IDENTIFIER_ATTR, identifier); |
32 return; | |
33 } | |
34 | |
35 Attribute attr = getAttribute(IDENTIFIER_ATTR); | |
36 if (attr == null) { | |
37 attr = new StringAttribute(IDENTIFIER_ATTR, identifier, false); | |
38 addAttribute(IDENTIFIER_ATTR, attr); | |
39 } | |
40 else { | |
41 attr.setValue(identifier); | |
42 } | |
43 } | 32 } |
44 | 33 |
45 | 34 |
46 public String getIdentifier() { | 35 public String getIdentifier() { |
47 StringAttribute attr = (StringAttribute) getAttribute(IDENTIFIER_ATTR); | 36 return getStringValue(IDENTIFIER_ATTR); |
48 | |
49 return attr != null ? (String) attr.getValue() : null; | |
50 } | 37 } |
51 | 38 |
52 | 39 |
53 public void setLabel(String label) { | 40 public void setLabel(String label) { |
54 if (label == null) { | 41 setStringValue(LABEL_ATTR, label); |
55 return; | |
56 } | |
57 | |
58 Attribute attr = getAttribute(LABEL_ATTR); | |
59 if (attr == null) { | |
60 attr = new StringAttribute(LABEL_ATTR, label, true); | |
61 addAttribute(LABEL_ATTR, attr); | |
62 } | |
63 else { | |
64 attr.setValue(label); | |
65 } | |
66 } | 42 } |
67 | 43 |
68 | 44 |
69 public String getLabel() { | 45 public String getLabel() { |
70 StringAttribute attr = (StringAttribute) getAttribute(LABEL_ATTR); | 46 return getStringValue(LABEL_ATTR); |
71 return attr != null ? (String) attr.getValue() : null; | |
72 } | 47 } |
73 | 48 |
74 | 49 |
75 public void setFontSize(int fontSize) { | 50 public void setFontSize(int fontSize) { |
76 if (fontSize <= 0) { | 51 if (fontSize <= 0) { |
77 return; | 52 return; |
78 } | 53 } |
79 | 54 |
80 Attribute attr = getAttribute(FONTSIZE_ATTR); | 55 setIntegerValue(FONTSIZE_ATTR, fontSize); |
81 if (attr == null) { | |
82 attr = new IntegerAttribute(FONTSIZE_ATTR, fontSize, true); | |
83 addAttribute(FONTSIZE_ATTR, attr); | |
84 } | |
85 else { | |
86 attr.setValue(fontSize); | |
87 } | |
88 } | 56 } |
89 | 57 |
90 | 58 |
91 public Integer getFontSize() { | 59 public Integer getFontSize() { |
92 IntegerAttribute attr = (IntegerAttribute) getAttribute(FONTSIZE_ATTR); | 60 return getIntegerValue(FONTSIZE_ATTR); |
93 return attr != null ? (Integer) attr.getValue() : null; | |
94 } | 61 } |
95 | 62 |
96 | 63 |
97 public void setFixed(boolean fixed) { | 64 public void setFixed(boolean fixed) { |
98 Attribute attr = getAttribute(FIXATION_ATTR); | 65 setBooleanValue(FIXATION_ATTR, fixed); |
99 if (attr == null) { | |
100 attr = new BooleanAttribute(FIXATION_ATTR, fixed, true); | |
101 addAttribute(FIXATION_ATTR, attr); | |
102 } | |
103 else { | |
104 attr.setValue(fixed); | |
105 } | |
106 } | 66 } |
107 | 67 |
108 | 68 |
109 public Boolean isFixed() { | 69 public Boolean isFixed() { |
110 BooleanAttribute attr = (BooleanAttribute) getAttribute(FIXATION_ATTR); | 70 return getBooleanValue(FIXATION_ATTR); |
111 return attr != null ? (Boolean) attr.getValue() : null; | |
112 } | 71 } |
113 | 72 |
114 | 73 |
115 public void setUpperRange(double upperRange) { | 74 public void setUpperRange(double upperRange) { |
116 Attribute attr = getAttribute(UPPERRANGE_ATTR); | 75 setDoubleValue(UPPERRANGE_ATTR, upperRange); |
117 if (attr == null) { | |
118 attr = new DoubleAttribute(UPPERRANGE_ATTR, upperRange, true); | |
119 addAttribute(UPPERRANGE_ATTR, attr); | |
120 } | |
121 else { | |
122 attr.setValue(upperRange); | |
123 } | |
124 } | 76 } |
125 | 77 |
126 | 78 |
127 public Double getUpperRange() { | 79 public Double getUpperRange() { |
128 DoubleAttribute attr = (DoubleAttribute) getAttribute(UPPERRANGE_ATTR); | 80 return getDoubleValue(UPPERRANGE_ATTR); |
129 | |
130 return attr != null ? (Double) attr.getValue() : null; | |
131 } | 81 } |
132 | 82 |
133 | 83 |
134 public void setLowerRange(double lowerRange) { | 84 public void setLowerRange(double lowerRange) { |
135 Attribute attr = getAttribute(LOWERRANGE_ATTR); | 85 setDoubleValue(LOWERRANGE_ATTR, lowerRange); |
136 if (attr == null) { | |
137 attr = new DoubleAttribute(LOWERRANGE_ATTR, lowerRange, true); | |
138 addAttribute(LOWERRANGE_ATTR, attr); | |
139 } | |
140 else { | |
141 attr.setValue(lowerRange); | |
142 } | |
143 } | 86 } |
144 | 87 |
145 | 88 |
146 public Double getLowerRange() { | 89 public Double getLowerRange() { |
147 DoubleAttribute attr = (DoubleAttribute) getAttribute(LOWERRANGE_ATTR); | 90 return getDoubleValue(LOWERRANGE_ATTR); |
148 | |
149 return attr != null ? (Double) attr.getValue() : null; | |
150 } | 91 } |
151 | 92 |
152 | 93 |
153 @Override | 94 @Override |
154 public void toXML(Node parent) { | 95 public void toXML(Node parent) { |