Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/ManualPointsArtifact.java @ 3761:066e2b4d69ca
Fix missing import
flys-artifacts/trunk@5462 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Christian Lins <christian.lins@intevation.de> |
---|---|
date | Thu, 13 Sep 2012 20:58:24 +0000 |
parents | afc7bfb4800b |
children | 6153c50f78cf |
comparison
equal
deleted
inserted
replaced
3760:312870fded7e | 3761:066e2b4d69ca |
---|---|
1 package de.intevation.flys.artifacts; | 1 package de.intevation.flys.artifacts; |
2 | 2 |
3 import java.awt.geom.Point2D; | |
3 import java.util.ArrayList; | 4 import java.util.ArrayList; |
4 import java.util.List; | 5 import java.util.List; |
5 | 6 |
6 import java.awt.geom.Point2D; | |
7 | |
8 import org.apache.log4j.Logger; | 7 import org.apache.log4j.Logger; |
9 | 8 import org.json.JSONArray; |
9 import org.json.JSONException; | |
10 import org.w3c.dom.Document; | 10 import org.w3c.dom.Document; |
11 | 11 |
12 import org.json.JSONArray; | |
13 import org.json.JSONException; | |
14 | |
15 import de.intevation.artifactdatabase.state.Facet; | 12 import de.intevation.artifactdatabase.state.Facet; |
16 | |
17 import de.intevation.artifacts.Artifact; | 13 import de.intevation.artifacts.Artifact; |
18 import de.intevation.artifacts.ArtifactFactory; | 14 import de.intevation.artifacts.ArtifactFactory; |
19 import de.intevation.artifacts.CallMeta; | 15 import de.intevation.artifacts.CallMeta; |
20 | 16 import de.intevation.flys.artifacts.geom.Lines; |
21 import de.intevation.flys.artifacts.model.FacetTypes; | 17 import de.intevation.flys.artifacts.model.FacetTypes; |
22 | |
23 import de.intevation.flys.artifacts.states.DefaultState; | 18 import de.intevation.flys.artifacts.states.DefaultState; |
24 | |
25 import de.intevation.flys.model.FastCrossSectionLine; | 19 import de.intevation.flys.model.FastCrossSectionLine; |
26 | |
27 import de.intevation.flys.artifacts.geom.Lines; | |
28 | 20 |
29 | 21 |
30 /** | 22 /** |
31 * Artifact to store user-added points and water lines. | 23 * Artifact to store user-added points and water lines. |
32 */ | 24 */ |
33 public class ManualPointsArtifact | 25 public class ManualPointsArtifact |
34 extends StaticFLYSArtifact | 26 extends StaticFLYSArtifact |
35 implements FacetTypes, WaterLineArtifact | 27 implements FacetTypes, WaterLineArtifact |
36 { | 28 { |
29 private static final long serialVersionUID = 7096025125474986011L; | |
30 | |
37 /** The logger for this class. */ | 31 /** The logger for this class. */ |
38 private static Logger logger = Logger.getLogger(ManualPointsArtifact.class); | 32 private static Logger logger = Logger.getLogger(ManualPointsArtifact.class); |
39 | 33 |
40 /** The name of the artifact. */ | 34 /** The name of the artifact. */ |
41 public static final String ARTIFACT_NAME = "manualpoints"; | 35 public static final String ARTIFACT_NAME = "manualpoints"; |
42 | 36 |
43 | 37 |
44 /** | |
45 * Trivial Constructor. | |
46 */ | |
47 public ManualPointsArtifact() { | 38 public ManualPointsArtifact() { |
48 logger.debug("ManualPointsArtifact.ManualPointsArtifact()"); | 39 logger.debug("ManualPointsArtifact.ManualPointsArtifact()"); |
49 } | 40 } |
50 | 41 |
51 | 42 |
52 /** | 43 /** |
53 * Gets called from factory, to set things up. | 44 * Gets called from factory to set things up. |
54 */ | 45 */ |
55 @Override | 46 @Override |
56 public void setup( | 47 public void setup( |
57 String identifier, | 48 String identifier, |
58 ArtifactFactory factory, | 49 ArtifactFactory factory, |
59 Object context, | 50 Object context, |
60 CallMeta callMeta, | 51 CallMeta callMeta, |
61 Document data) | 52 Document data) |
62 { | 53 { |
63 logger.debug("ManualPointsArtifact.setup"); | 54 logger.debug("ManualPointsArtifact.setup"); |
64 super.setup(identifier, factory, context, callMeta, data); | 55 super.setup(identifier, factory, context, callMeta, data); |
65 initialize(null, context, callMeta); | 56 initialize(null, context, callMeta); |
66 } | 57 } |
67 | 58 |
68 | 59 |
69 /** Return the name of this artifact. */ | 60 /** Return the name of this artifact. */ |
61 @Override | |
70 public String getName() { | 62 public String getName() { |
71 return ARTIFACT_NAME; | 63 return ARTIFACT_NAME; |
72 } | 64 } |
73 | 65 |
74 | 66 |
104 logger.debug("Facets to add in ManualPointsArtifact.initialize ."); | 96 logger.debug("Facets to add in ManualPointsArtifact.initialize ."); |
105 facets.put(getCurrentStateId(), fs); | 97 facets.put(getCurrentStateId(), fs); |
106 } | 98 } |
107 else { | 99 else { |
108 logger.debug("No facets to add in ManualPointsArtifact.initialize (" | 100 logger.debug("No facets to add in ManualPointsArtifact.initialize (" |
109 + state.getID() + ")."); | 101 + state.getID() + ")."); |
110 } | 102 } |
111 } | 103 } |
112 | 104 |
113 | 105 |
114 /** | 106 /** |
116 * @param index index in json array defining lines. | 108 * @param index index in json array defining lines. |
117 * @return water height of line at given index. | 109 * @return water height of line at given index. |
118 */ | 110 */ |
119 protected double getLine(int index) { | 111 protected double getLine(int index) { |
120 try { | 112 try { |
121 JSONArray lines = new JSONArray((String) getLinesData(null)); | 113 JSONArray lines = new JSONArray(getLinesData(null)); |
122 JSONArray array = lines.getJSONArray(index); | 114 JSONArray array = lines.getJSONArray(index); |
123 | 115 |
124 return array.getDouble(0); | 116 return array.getDouble(0); |
125 } | 117 } |
126 catch(JSONException e){ | 118 catch(JSONException e){ |
137 * @param a (ignored in this implementation). | 129 * @param a (ignored in this implementation). |
138 * @param b (ignored in this implementation). | 130 * @param b (ignored in this implementation). |
139 */ | 131 */ |
140 @Override | 132 @Override |
141 public Lines.LineData getWaterLines( | 133 public Lines.LineData getWaterLines( |
142 int index, | 134 int index, |
143 FastCrossSectionLine csl, | 135 FastCrossSectionLine csl, |
144 double a, double b | 136 double a, double b |
145 ) { | 137 ) { |
146 List<Point2D> points = csl.getPoints(); | 138 List<Point2D> points = csl.getPoints(); |
147 return Lines.createWaterLines(points, getLine(index)); | 139 return Lines.createWaterLines(points, getLine(index)); |
148 } | 140 } |
149 } | 141 } |
150 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 142 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |