comparison artifacts/src/main/java/org/dive4elements/river/exports/DiagramAttributes.java @ 7049:165ea04b1545 generator-refactoring

Added alignment rules for diagrams.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 19 Sep 2013 11:08:43 +0200
parents a43137dfdcac
children f9d5020af0af
comparison
equal deleted inserted replaced
7048:a43137dfdcac 7049:165ea04b1545
26 public class DiagramAttributes 26 public class DiagramAttributes
27 { 27 {
28 private static Logger log = Logger.getLogger(DiagramAttributes.class); 28 private static Logger log = Logger.getLogger(DiagramAttributes.class);
29 29
30 public static class AxisAttributes { 30 public static class AxisAttributes {
31 // TODO: More Attributes 31 private String name;
32 private String name; 32 private boolean isLeftAlign;
33 private boolean forceAlign;
33 34
34 public AxisAttributes() { 35 public AxisAttributes() {
35 } 36 }
36 37
37 public AxisAttributes(String name) { 38 public AxisAttributes(
38 this.name = name; 39 String name,
40 boolean isLeftAlign,
41 boolean forceAlign
42 ) {
43 this.name = name;
44 this.isLeftAlign = isLeftAlign;
45 this.forceAlign = forceAlign;
39 } 46 }
40 47
41 public String getName() { 48 public String getName() {
42 return name; 49 return name;
50 }
51
52 public boolean isLeftAlign() {
53 return isLeftAlign;
54 }
55
56 public boolean forceAlign() {
57 return forceAlign;
43 } 58 }
44 } // class AxisAttributes 59 } // class AxisAttributes
45 60
46 public static class AxisProcessor { 61 public static class AxisProcessor {
47 private Processor processor; 62 private Processor processor;
158 public DiagramAttributes(Element config) { 173 public DiagramAttributes(Element config) {
159 this(); 174 this();
160 parseAxis(config); 175 parseAxis(config);
161 parseProcessors(config); 176 parseProcessors(config);
162 parseTitle(config); 177 parseTitle(config);
178 parseSubtitle(config);
163 } 179 }
164 180
165 private void parseAxis(Element config) { 181 private void parseAxis(Element config) {
166 NodeList axisNodes = config.getElementsByTagName("axis"); 182 NodeList axisNodes = config.getElementsByTagName("axis");
167 183
168 for (int i = 0, N = axisNodes.getLength(); i < N; ++i) { 184 for (int i = 0, N = axisNodes.getLength(); i < N; ++i) {
169 Element axisElement = (Element)axisNodes.item(i); 185 Element axisElement = (Element)axisNodes.item(i);
170 String name = axisElement.getAttribute("name").trim(); 186 String name = axisElement.getAttribute("name").trim();
171 if (!name.isEmpty()) { 187 String align = axisElement.getAttribute("align").trim();
172 axesAttrs.add(new AxisAttributes(name)); 188 if (name.isEmpty()) {
173 } 189 continue;
190 }
191 boolean isleftAlign = false;
192 boolean forceAlign = false;
193 for (String part: align.split("[\\s,]")) {
194 part = part.trim();
195 if ("left" .equals(part)) isleftAlign = true;
196 else if ("right".equals(part)) isleftAlign = false;
197 else if ("force".equals(part)) forceAlign = true;
198 }
199 axesAttrs.add(new AxisAttributes(name, isleftAlign, forceAlign));
174 } 200 }
175 } 201 }
176 202
177 public List<AxisProcessor> getAxesProcessors() { 203 public List<AxisProcessor> getAxesProcessors() {
178 return axesProcessors; 204 return axesProcessors;

http://dive4elements.wald.intevation.org