root / branches / dal_time_support / libraries / libFMap_mapcontext / src-test / org / gvsig / fmap / mapcontext / rendering / symbol / DummyVectorLegend.java @ 35333
History | View | Annotate | Download (6.14 KB)
1 |
package org.gvsig.fmap.mapcontext.rendering.symbol; |
---|---|
2 |
|
3 |
import java.awt.Color; |
4 |
import java.awt.Graphics2D; |
5 |
import java.awt.image.BufferedImage; |
6 |
import java.util.Iterator; |
7 |
import java.util.Map; |
8 |
|
9 |
import org.cresques.cts.ICoordTrans; |
10 |
|
11 |
import org.gvsig.compat.print.PrintAttributes; |
12 |
import org.gvsig.fmap.dal.exception.DataException; |
13 |
import org.gvsig.fmap.dal.feature.Feature; |
14 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
15 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
16 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
17 |
import org.gvsig.fmap.geom.Geometry.TYPES; |
18 |
import org.gvsig.fmap.mapcontext.ViewPort; |
19 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
20 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
21 |
import org.gvsig.fmap.mapcontext.rendering.legend.LegendException; |
22 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.LegendContentsChangedListener; |
23 |
import org.gvsig.fmap.mapcontext.rendering.legend.events.SymbolLegendEvent; |
24 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
25 |
import org.gvsig.tools.ToolsLocator; |
26 |
import org.gvsig.tools.dynobject.DynStruct; |
27 |
import org.gvsig.tools.evaluator.Evaluator; |
28 |
import org.gvsig.tools.observer.Observer; |
29 |
import org.gvsig.tools.persistence.PersistenceManager; |
30 |
import org.gvsig.tools.persistence.PersistentState; |
31 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
32 |
import org.gvsig.tools.task.Cancellable; |
33 |
|
34 |
public class DummyVectorLegend implements IVectorLegend { |
35 |
|
36 |
private long shpType = -1; |
37 |
|
38 |
private ISymbol sym = new DummySymbol(Color.RED, TYPES.SOLID); |
39 |
|
40 |
public DummyVectorLegend() {
|
41 |
shpType = System.currentTimeMillis() % 1000000; |
42 |
} |
43 |
|
44 |
public DummyVectorLegend(int type) { |
45 |
shpType = type; // System.currentTimeMillis() % 1000000;
|
46 |
} |
47 |
|
48 |
public void draw(BufferedImage image, Graphics2D graphics2D, |
49 |
ViewPort viewPort, Cancellable cancel, double scale,
|
50 |
Map queryParameters, ICoordTrans coordTrans,
|
51 |
FeatureStore featureStore, FeatureQuery featureQuery) throws LegendException {
|
52 |
|
53 |
} |
54 |
public void draw(BufferedImage image, Graphics2D graphics2D, |
55 |
ViewPort viewPort, Cancellable cancel, double scale,
|
56 |
Map queryParameters, ICoordTrans coordTrans,
|
57 |
FeatureStore featureStore) throws LegendException {
|
58 |
|
59 |
try {
|
60 |
FeatureSet fs = featureStore.getFeatureSet(); |
61 |
Iterator iter = fs.iterator();
|
62 |
Feature feat = null;
|
63 |
ISymbol symb = null;
|
64 |
while (iter.hasNext()) {
|
65 |
feat = (Feature) iter.next(); |
66 |
symb = this.getSymbolByFeature(feat);
|
67 |
symb.draw(graphics2D, viewPort.getAffineTransform(), feat.getDefaultGeometry(), feat, null);
|
68 |
} |
69 |
} catch (DataException e) {
|
70 |
// TODO Auto-generated catch block
|
71 |
e.printStackTrace(); |
72 |
} |
73 |
// TODO Auto-generated method stub
|
74 |
|
75 |
} |
76 |
|
77 |
public int getShapeType() { |
78 |
// TODO Auto-generated method stub
|
79 |
return (int) shpType; |
80 |
} |
81 |
|
82 |
public ISymbol getSymbolByFeature(Feature feat) {
|
83 |
return sym;
|
84 |
} |
85 |
|
86 |
public boolean isSuitableForShapeType(int shapeType) { |
87 |
return sym.getSymbolType() == shapeType;
|
88 |
} |
89 |
|
90 |
public boolean isUseDefaultSymbol() { |
91 |
return true; |
92 |
} |
93 |
|
94 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
95 |
double scale, Object object, ICoordTrans coordTrans, |
96 |
FeatureStore featureStore, Evaluator evaluator, PrintAttributes properties) |
97 |
throws LegendException {
|
98 |
// TODO Auto-generated method stub
|
99 |
|
100 |
} |
101 |
|
102 |
public void setDefaultSymbol(ISymbol s) throws IllegalArgumentException { |
103 |
sym = s; |
104 |
} |
105 |
|
106 |
public void setShapeType(int shapeType) { |
107 |
shpType = shapeType; |
108 |
} |
109 |
|
110 |
public void useDefaultSymbol(boolean b) { |
111 |
} |
112 |
|
113 |
public void addLegendListener(LegendContentsChangedListener listener) { |
114 |
// TODO Auto-generated method stub
|
115 |
|
116 |
} |
117 |
|
118 |
public ILegend cloneLegend() {
|
119 |
// TODO Auto-generated method stub
|
120 |
return null; |
121 |
} |
122 |
|
123 |
public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) { |
124 |
// TODO Auto-generated method stub
|
125 |
|
126 |
} |
127 |
|
128 |
public ISymbol getDefaultSymbol() {
|
129 |
return sym;
|
130 |
} |
131 |
|
132 |
public LegendContentsChangedListener[] getListeners() { |
133 |
// TODO Auto-generated method stub
|
134 |
return null; |
135 |
} |
136 |
|
137 |
public void removeLegendListener(LegendContentsChangedListener listener) { |
138 |
// TODO Auto-generated method stub
|
139 |
|
140 |
} |
141 |
|
142 |
public String getClassName() { |
143 |
return this.getClass().getName(); |
144 |
} |
145 |
|
146 |
|
147 |
|
148 |
|
149 |
public void addDrawingObserver(Observer observer) { |
150 |
// TODO Auto-generated method stub
|
151 |
|
152 |
} |
153 |
|
154 |
public void deleteDrawingObserver(Observer observer) { |
155 |
// TODO Auto-generated method stub
|
156 |
|
157 |
} |
158 |
|
159 |
public void deleteDrawingObservers() { |
160 |
// TODO Auto-generated method stub
|
161 |
|
162 |
} |
163 |
|
164 |
public void loadFromState(PersistentState state) throws PersistenceException { |
165 |
shpType = state.getLong("shpType");
|
166 |
} |
167 |
|
168 |
|
169 |
public void saveToState(PersistentState state) throws PersistenceException { |
170 |
state.set("shpType", shpType);
|
171 |
} |
172 |
|
173 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
174 |
double scale, Map queryParameters, ICoordTrans coordTrans, |
175 |
FeatureStore featureStore, FeatureQuery featureQuery, PrintAttributes properties) |
176 |
throws LegendException {
|
177 |
// TODO Auto-generated method stub
|
178 |
|
179 |
} |
180 |
|
181 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, |
182 |
double scale, Map queryParameters, ICoordTrans coordTrans, |
183 |
FeatureStore featureStore, PrintAttributes properties) |
184 |
throws LegendException {
|
185 |
// TODO Auto-generated method stub
|
186 |
|
187 |
} |
188 |
|
189 |
public static void registerPersistent() { |
190 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
191 |
DynStruct definition = manager.addDefinition( |
192 |
DummyVectorLegend.class, |
193 |
"DummyVectorLegend",
|
194 |
"DummyVectorLegend Persistence definition",
|
195 |
null,
|
196 |
null
|
197 |
); |
198 |
definition.addDynFieldLong("shpType")
|
199 |
.setMandatory(true);
|
200 |
} |
201 |
|
202 |
|
203 |
public Object clone() throws CloneNotSupportedException { |
204 |
return super.clone(); |
205 |
} |
206 |
|
207 |
|
208 |
} |