comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java @ 412:046bd86ae41d

Improved the OutGenerator interface to set a master artifact for the out generation. flys-artifacts/trunk@1874 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Tue, 10 May 2011 10:26:26 +0000
parents fc3ac59c3c8b
children bab867fb37e8
comparison
equal deleted inserted replaced
411:6ab62e5b05b5 412:046bd86ae41d
6 import org.apache.log4j.Logger; 6 import org.apache.log4j.Logger;
7 7
8 import org.w3c.dom.Document; 8 import org.w3c.dom.Document;
9 9
10 import de.intevation.artifacts.Artifact; 10 import de.intevation.artifacts.Artifact;
11 import de.intevation.artifacts.CallContext;
12
13 import de.intevation.flys.model.River;
14
15 import de.intevation.flys.artifacts.FLYSArtifact;
11 import de.intevation.flys.artifacts.resources.Resources; 16 import de.intevation.flys.artifacts.resources.Resources;
12 import de.intevation.artifacts.CallContext;
13 17
14 18
15 /** 19 /**
16 * The base class for chart creation. It should provide some basic things that 20 * The base class for chart creation. It should provide some basic things that
17 * equal in all chart types. 21 * equal in all chart types.
30 protected OutputStream out; 34 protected OutputStream out;
31 35
32 /** The CallContext object.*/ 36 /** The CallContext object.*/
33 protected CallContext context; 37 protected CallContext context;
34 38
39 /** The artifact that is used to decorate the chart with meta information.*/
40 protected Artifact master;
41
35 42
36 public void init(Document request, OutputStream out, CallContext context) { 43 public void init(Document request, OutputStream out, CallContext context) {
37 logger.debug("ChartGenerator.init"); 44 logger.debug("ChartGenerator.init");
38 45
39 this.request = request; 46 this.request = request;
40 this.out = out; 47 this.out = out;
41 this.context = context; 48 this.context = context;
42 } 49 }
43 50
44 51
52 public void setMasterArtifact(Artifact master) {
53 this.master = master;
54 }
55
56
45 protected String msg(String key, String def) { 57 protected String msg(String key, String def) {
46 return Resources.getMsg(context.getMeta(), key, def); 58 return Resources.getMsg(context.getMeta(), key, def);
59 }
60
61
62 protected String msg(String key, String def, Object[] args) {
63 return Resources.getMsg(context.getMeta(), key, def, args);
64 }
65
66
67 protected String getRiverName() {
68 FLYSArtifact flys = (FLYSArtifact) master;
69
70 River river = flys.getRiver();
71 return river != null ? river.getName() : "";
72 }
73
74
75 protected double[] getRange() {
76 FLYSArtifact flys = (FLYSArtifact) master;
77
78 return flys.getDistance();
47 } 79 }
48 80
49 81
50 public abstract void doOut(Artifact artifact, String facet, Document attr); 82 public abstract void doOut(Artifact artifact, String facet, Document attr);
51 83

http://dive4elements.wald.intevation.org