svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src-test / org / gvsig / fmap / mapcontext / rendering / symbol / DummyVectorLegend.java @ 35329
History | View | Annotate | Download (6.14 KB)
1 | 30595 | jldominguez | 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 | 35198 | jpiera | |
11 | 30595 | jldominguez | import org.gvsig.compat.print.PrintAttributes; |
12 | import org.gvsig.fmap.dal.exception.DataException; |
||
13 | import org.gvsig.fmap.dal.feature.Feature; |
||
14 | 35329 | jpiera | import org.gvsig.fmap.dal.feature.FeatureQuery; |
15 | 30595 | jldominguez | 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 | 32880 | jjdelcerro | import org.gvsig.tools.dynobject.DynStruct; |
27 | 35198 | jpiera | import org.gvsig.tools.evaluator.Evaluator; |
28 | 30595 | jldominguez | import org.gvsig.tools.observer.Observer; |
29 | 32880 | jjdelcerro | import org.gvsig.tools.persistence.PersistenceManager; |
30 | 30595 | jldominguez | import org.gvsig.tools.persistence.PersistentState; |
31 | 32880 | jjdelcerro | import org.gvsig.tools.persistence.exception.PersistenceException; |
32 | 30595 | jldominguez | import org.gvsig.tools.task.Cancellable; |
33 | |||
34 | public class DummyVectorLegend implements IVectorLegend { |
||
35 | |||
36 | 35329 | jpiera | private long shpType = -1; |
37 | 30595 | jldominguez | |
38 | 35329 | jpiera | private ISymbol sym = new DummySymbol(Color.RED, TYPES.SOLID); |
39 | 30595 | jldominguez | |
40 | 35329 | jpiera | public DummyVectorLegend() {
|
41 | shpType = System.currentTimeMillis() % 1000000; |
||
42 | } |
||
43 | 30595 | jldominguez | |
44 | 35329 | jpiera | public DummyVectorLegend(int type) { |
45 | shpType = type; // System.currentTimeMillis() % 1000000;
|
||
46 | } |
||
47 | 30595 | jldominguez | |
48 | 35329 | jpiera | 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 | 30595 | jldominguez | |
53 | 35329 | jpiera | } |
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 | 30595 | jldominguez | |
59 | 35329 | jpiera | 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 | 30595 | jldominguez | |
75 | 35329 | jpiera | } |
76 | 30595 | jldominguez | |
77 | 35329 | jpiera | public int getShapeType() { |
78 | // TODO Auto-generated method stub
|
||
79 | return (int) shpType; |
||
80 | } |
||
81 | 30595 | jldominguez | |
82 | 35329 | jpiera | public ISymbol getSymbolByFeature(Feature feat) {
|
83 | return sym;
|
||
84 | } |
||
85 | 30595 | jldominguez | |
86 | 35329 | jpiera | public boolean isSuitableForShapeType(int shapeType) { |
87 | return sym.getSymbolType() == shapeType;
|
||
88 | } |
||
89 | 30595 | jldominguez | |
90 | 35329 | jpiera | public boolean isUseDefaultSymbol() { |
91 | return true; |
||
92 | } |
||
93 | 30595 | jldominguez | |
94 | 35329 | jpiera | 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 | 30595 | jldominguez | |
100 | 35329 | jpiera | } |
101 | 30595 | jldominguez | |
102 | 35329 | jpiera | public void setDefaultSymbol(ISymbol s) throws IllegalArgumentException { |
103 | sym = s; |
||
104 | } |
||
105 | 30595 | jldominguez | |
106 | 35329 | jpiera | public void setShapeType(int shapeType) { |
107 | shpType = shapeType; |
||
108 | } |
||
109 | 30595 | jldominguez | |
110 | 35329 | jpiera | public void useDefaultSymbol(boolean b) { |
111 | } |
||
112 | 30595 | jldominguez | |
113 | 35329 | jpiera | public void addLegendListener(LegendContentsChangedListener listener) { |
114 | // TODO Auto-generated method stub
|
||
115 | 30595 | jldominguez | |
116 | 35329 | jpiera | } |
117 | 30595 | jldominguez | |
118 | 35329 | jpiera | public ILegend cloneLegend() {
|
119 | // TODO Auto-generated method stub
|
||
120 | return null; |
||
121 | } |
||
122 | 30595 | jldominguez | |
123 | 35329 | jpiera | public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) { |
124 | // TODO Auto-generated method stub
|
||
125 | 30595 | jldominguez | |
126 | 35329 | jpiera | } |
127 | 30595 | jldominguez | |
128 | 35329 | jpiera | public ISymbol getDefaultSymbol() {
|
129 | return sym;
|
||
130 | } |
||
131 | 30595 | jldominguez | |
132 | 35329 | jpiera | public LegendContentsChangedListener[] getListeners() { |
133 | // TODO Auto-generated method stub
|
||
134 | return null; |
||
135 | } |
||
136 | 30595 | jldominguez | |
137 | 35329 | jpiera | public void removeLegendListener(LegendContentsChangedListener listener) { |
138 | // TODO Auto-generated method stub
|
||
139 | 30595 | jldominguez | |
140 | 35329 | jpiera | } |
141 | 30595 | jldominguez | |
142 | 35329 | jpiera | public String getClassName() { |
143 | return this.getClass().getName(); |
||
144 | } |
||
145 | 30595 | jldominguez | |
146 | |||
147 | |||
148 | |||
149 | 35329 | jpiera | public void addDrawingObserver(Observer observer) { |
150 | // TODO Auto-generated method stub
|
||
151 | 30595 | jldominguez | |
152 | 35329 | jpiera | } |
153 | 30595 | jldominguez | |
154 | 35329 | jpiera | public void deleteDrawingObserver(Observer observer) { |
155 | // TODO Auto-generated method stub
|
||
156 | 30595 | jldominguez | |
157 | 35329 | jpiera | } |
158 | 30595 | jldominguez | |
159 | 35329 | jpiera | public void deleteDrawingObservers() { |
160 | // TODO Auto-generated method stub
|
||
161 | 30595 | jldominguez | |
162 | 35329 | jpiera | } |
163 | 30595 | jldominguez | |
164 | 35329 | jpiera | public void loadFromState(PersistentState state) throws PersistenceException { |
165 | shpType = state.getLong("shpType");
|
||
166 | } |
||
167 | 30595 | jldominguez | |
168 | |||
169 | 35329 | jpiera | public void saveToState(PersistentState state) throws PersistenceException { |
170 | state.set("shpType", shpType);
|
||
171 | } |
||
172 | 30595 | jldominguez | |
173 | 35329 | jpiera | 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 | 30595 | jldominguez | } |