Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/exports/sq/SQOverviewGenerator.java @ 8202:e4606eae8ea5
sed src/**/*.java 's/logger/log/g'
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 05 Sep 2014 12:58:17 +0200 |
parents | fe32a7f9655e |
children | 1d3d61c8f596 |
comparison
equal
deleted
inserted
replaced
8201:4b8c5a08de04 | 8202:e4606eae8ea5 |
---|---|
41 import org.dive4elements.river.themes.ThemeDocument; | 41 import org.dive4elements.river.themes.ThemeDocument; |
42 | 42 |
43 public class SQOverviewGenerator | 43 public class SQOverviewGenerator |
44 implements OutGenerator | 44 implements OutGenerator |
45 { | 45 { |
46 private static Logger logger = Logger.getLogger(SQOverviewGenerator.class); | 46 private static Logger log = Logger.getLogger(SQOverviewGenerator.class); |
47 | 47 |
48 public static final String XPATH_CHART_SIZE = | 48 public static final String XPATH_CHART_SIZE = |
49 "/art:action/art:attributes/art:size"; | 49 "/art:action/art:attributes/art:size"; |
50 | 50 |
51 protected D4EArtifactCollection collection; | 51 protected D4EArtifactCollection collection; |
64 | 64 |
65 protected String outName; | 65 protected String outName; |
66 | 66 |
67 @Override | 67 @Override |
68 public void setup(Object config) { | 68 public void setup(Object config) { |
69 logger.debug("SQOverviewGenerator.setup"); | 69 log.debug("SQOverviewGenerator.setup"); |
70 } | 70 } |
71 | 71 |
72 /** | 72 /** |
73 * Produce output. | 73 * Produce output. |
74 * @param artifactAndFacet current facet and artifact. | 74 * @param artifactAndFacet current facet and artifact. |
78 public void doOut( | 78 public void doOut( |
79 ArtifactAndFacet artifactAndFacet, | 79 ArtifactAndFacet artifactAndFacet, |
80 ThemeDocument attr, | 80 ThemeDocument attr, |
81 boolean visible | 81 boolean visible |
82 ) { | 82 ) { |
83 logger.debug("doOut()"); | 83 log.debug("doOut()"); |
84 | 84 |
85 // TODO: Why not using outName for this. | 85 // TODO: Why not using outName for this. |
86 | 86 |
87 String name = artifactAndFacet.getData(context).toString(); | 87 String name = artifactAndFacet.getData(context).toString(); |
88 if(name != null) { | 88 if(name != null) { |
89 logger.debug("name: " + name); | 89 log.debug("name: " + name); |
90 ChartGenerator2 g = | 90 ChartGenerator2 g = |
91 (ChartGenerator2)RiverContext.getOutGenerator( | 91 (ChartGenerator2)RiverContext.getOutGenerator( |
92 context, | 92 context, |
93 name, | 93 name, |
94 null); | 94 null); |
95 /* Make sure master is also set in those */ | 95 /* Make sure master is also set in those */ |
96 g.setMasterArtifact(master); | 96 g.setMasterArtifact(master); |
97 | 97 |
98 if (g == null) { | 98 if (g == null) { |
99 logger.debug("generator is null."); | 99 log.debug("generator is null."); |
100 return; | 100 return; |
101 } | 101 } |
102 | 102 |
103 OutputHelper helper = new OutputHelper(master.identifier()); | 103 OutputHelper helper = new OutputHelper(master.identifier()); |
104 Document collectionAttribute = collection.getAttribute(); | 104 Document collectionAttribute = collection.getAttribute(); |
111 JFreeChart chart = g.generateChart(); | 111 JFreeChart chart = g.generateChart(); |
112 chart.removeLegend(); | 112 chart.removeLegend(); |
113 charts.add(chart); | 113 charts.add(chart); |
114 } | 114 } |
115 catch (IOException e) { | 115 catch (IOException e) { |
116 logger.warn(e); | 116 log.warn(e); |
117 } | 117 } |
118 catch (ArtifactDatabaseException e) { | 118 catch (ArtifactDatabaseException e) { |
119 logger.warn(e); | 119 log.warn(e); |
120 } | 120 } |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 @Override | 124 @Override |
140 this.collection = collection; | 140 this.collection = collection; |
141 } | 141 } |
142 | 142 |
143 @Override | 143 @Override |
144 public void generate() throws IOException { | 144 public void generate() throws IOException { |
145 logger.debug("SQOverviewGenerator.generate"); | 145 log.debug("SQOverviewGenerator.generate"); |
146 | 146 |
147 int[] size = getSize(); | 147 int[] size = getSize(); |
148 | 148 |
149 if (size == null) { | 149 if (size == null) { |
150 size = new int[] {400, 600}; | 150 size = new int[] {400, 600}; |
151 } | 151 } |
152 BufferedImage result = | 152 BufferedImage result = |
153 new BufferedImage(size[0], size[1], BufferedImage.TYPE_INT_RGB); | 153 new BufferedImage(size[0], size[1], BufferedImage.TYPE_INT_RGB); |
154 for (int i = 0, S = charts.size(); i < S; i++) { | 154 for (int i = 0, S = charts.size(); i < S; i++) { |
155 logger.debug("index: " + i); | 155 log.debug("index: " + i); |
156 JFreeChart chart = charts.get(i); | 156 JFreeChart chart = charts.get(i); |
157 ChartRenderingInfo info = new ChartRenderingInfo(); | 157 ChartRenderingInfo info = new ChartRenderingInfo(); |
158 BufferedImage img = | 158 BufferedImage img = |
159 chart.createBufferedImage(size[0]/2, size[1]/3, info); | 159 chart.createBufferedImage(size[0]/2, size[1]/3, info); |
160 int horPos = 0; | 160 int horPos = 0; |
196 CallContext context, | 196 CallContext context, |
197 Document attr, | 197 Document attr, |
198 String output) | 198 String output) |
199 throws ArtifactDatabaseException | 199 throws ArtifactDatabaseException |
200 { | 200 { |
201 logger.debug("find specific XML node for Output: " + output); | 201 log.debug("find specific XML node for Output: " + output); |
202 | 202 |
203 Map<String, String> vars = new HashMap<String, String>(); | 203 Map<String, String> vars = new HashMap<String, String>(); |
204 vars.put("output", output); | 204 vars.put("output", output); |
205 | 205 |
206 Node out = (Node) XMLUtils.xpath( | 206 Node out = (Node) XMLUtils.xpath( |
247 try { | 247 try { |
248 size[0] = Integer.parseInt(w); | 248 size[0] = Integer.parseInt(w); |
249 size[1] = Integer.parseInt(h); | 249 size[1] = Integer.parseInt(h); |
250 } | 250 } |
251 catch (NumberFormatException nfe) { | 251 catch (NumberFormatException nfe) { |
252 logger.warn("Wrong values for chart width/height."); | 252 log.warn("Wrong values for chart width/height."); |
253 } | 253 } |
254 } | 254 } |
255 } | 255 } |
256 | 256 |
257 return size[0] > 0 && size[1] > 0 ? size : null; | 257 return size[0] > 0 && size[1] > 0 ? size : null; |