comparison artifacts/src/main/java/org/dive4elements/river/exports/sq/SQOverviewGenerator.java @ 7077:0a337f0005c2 generator-refactoring

Extended init() of OutGenerator to take name of the out to serve.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 20 Sep 2013 16:34:09 +0200
parents 5c6fd2c010dd
children ada424214b02
comparison
equal deleted inserted replaced
7074:a2abd87c0d3b 7077:0a337f0005c2
60 60
61 protected CallContext context; 61 protected CallContext context;
62 62
63 protected List<JFreeChart> charts; 63 protected List<JFreeChart> charts;
64 64
65 protected String outName;
66
65 @Override 67 @Override
66 public void setup(Element config) { 68 public void setup(Element config) {
67 logger.debug("SQOverviewGenerator.setup"); 69 logger.debug("SQOverviewGenerator.setup");
68 } 70 }
69 71
77 ArtifactAndFacet artifactAndFacet, 79 ArtifactAndFacet artifactAndFacet,
78 ThemeDocument attr, 80 ThemeDocument attr,
79 boolean visible 81 boolean visible
80 ) { 82 ) {
81 logger.debug("doOut()"); 83 logger.debug("doOut()");
84
85 // TODO: Why not using outName for this.
82 86
83 String name = artifactAndFacet.getData(context).toString(); 87 String name = artifactAndFacet.getData(context).toString();
84 if(name != null) { 88 if(name != null) {
85 logger.debug("name: " + name); 89 logger.debug("name: " + name);
86 ChartGenerator g = 90 ChartGenerator g =
97 OutputHelper helper = new OutputHelper(master.identifier()); 101 OutputHelper helper = new OutputHelper(master.identifier());
98 Document collectionAttribute = collection.getAttribute(); 102 Document collectionAttribute = collection.getAttribute();
99 103
100 try { 104 try {
101 Document cAttr = getAttribute(context, collectionAttribute, name); 105 Document cAttr = getAttribute(context, collectionAttribute, name);
102 g.init(request, out, context); 106 g.init(name, request, out, context);
103 107
104 helper.doOut(g, name, name, cAttr, context); 108 helper.doOut(g, name, name, cAttr, context);
105 JFreeChart chart = g.generateChart(); 109 JFreeChart chart = g.generateChart();
106 chart.removeLegend(); 110 chart.removeLegend();
107 charts.add(chart); 111 charts.add(chart);
114 } 118 }
115 } 119 }
116 } 120 }
117 121
118 @Override 122 @Override
119 public void init(Document request, OutputStream out, CallContext context) { 123 public void init(String outName, Document request, OutputStream out, CallContext context) {
124 this.outName = outName;
120 this.request = request; 125 this.request = request;
121 this.out = out; 126 this.out = out;
122 this.context = context; 127 this.context = context;
123 charts = new ArrayList<JFreeChart>(); 128 charts = new ArrayList<JFreeChart>();
124 } 129 }
156 horPos = size[0]/2; 161 horPos = size[0]/2;
157 } 162 }
158 if (i > 1) { 163 if (i > 1) {
159 vertPos = (size[1] / 3) * (i / 2); 164 vertPos = (size[1] / 3) * (i / 2);
160 } 165 }
166 // TODO: Dispose Graphics object!
161 result.createGraphics().drawImage(img, horPos, vertPos, null); 167 result.createGraphics().drawImage(img, horPos, vertPos, null);
162 } 168 }
163 ImageIO.write(result, "png", out); 169 ImageIO.write(result, "png", out);
164 } 170 }
165 171

http://dive4elements.wald.intevation.org