Revision 35333 branches/dal_time_support/libraries/libFMap_mapcontext/src-test/org/gvsig/fmap/mapcontext/rendering/symbol/DummyVectorLegend.java

View differences:

DummyVectorLegend.java
11 11
import org.gvsig.compat.print.PrintAttributes;
12 12
import org.gvsig.fmap.dal.exception.DataException;
13 13
import org.gvsig.fmap.dal.feature.Feature;
14
import org.gvsig.fmap.dal.feature.FeatureQuery;
14 15
import org.gvsig.fmap.dal.feature.FeatureSet;
15 16
import org.gvsig.fmap.dal.feature.FeatureStore;
16 17
import org.gvsig.fmap.geom.Geometry.TYPES;
......
32 33

  
33 34
public class DummyVectorLegend implements IVectorLegend {
34 35

  
35
	private long shpType = -1;
36
    private long shpType = -1;
36 37

  
37
	private ISymbol sym = new DummySymbol(Color.RED, TYPES.SOLID);
38
    private ISymbol sym = new DummySymbol(Color.RED, TYPES.SOLID);
38 39

  
39
	public DummyVectorLegend() {
40
		shpType = System.currentTimeMillis() % 1000000;
41
	}
42
	
43
	public DummyVectorLegend(int type) {
44
		shpType = type; // System.currentTimeMillis() % 1000000;
45
	}
46
	
47
	public void draw(BufferedImage image, Graphics2D graphics2D,
48
			ViewPort viewPort, Cancellable cancel, double scale,
49
			Map queryParameters, ICoordTrans coordTrans,
50
			FeatureStore featureStore, Evaluator evaluator) throws LegendException {
51
		
52
		try {
53
			FeatureSet fs = featureStore.getFeatureSet();
54
			Iterator iter = fs.iterator();
55
			Feature feat = null;
56
			ISymbol symb = null;
57
			while (iter.hasNext()) {
58
				feat = (Feature) iter.next();
59
				symb = this.getSymbolByFeature(feat);
60
				symb.draw(graphics2D, viewPort.getAffineTransform(), feat.getDefaultGeometry(), feat, null);
61
			}
62
		} catch (DataException e) {
63
			// TODO Auto-generated catch block
64
			e.printStackTrace();
65
		}
66
		// TODO Auto-generated method stub
40
    public DummyVectorLegend() {
41
        shpType = System.currentTimeMillis() % 1000000;
42
    }
67 43

  
68
	}
44
    public DummyVectorLegend(int type) {
45
        shpType = type; // System.currentTimeMillis() % 1000000;
46
    }
69 47

  
70
	public int getShapeType() {
71
		// TODO Auto-generated method stub
72
		return (int) shpType;
73
	}
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 {
74 52

  
75
	public ISymbol getSymbolByFeature(Feature feat) {
76
		return sym;
77
	}
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 {
78 58

  
79
	public boolean isSuitableForShapeType(int shapeType) {
80
		return sym.getSymbolType() == shapeType;
81
	}
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
82 74

  
83
	public boolean isUseDefaultSymbol() {
84
		return true;
85
	}
75
    }
86 76

  
87
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
88
			double scale, Object object, ICoordTrans coordTrans,
89
			FeatureStore featureStore, Evaluator evaluator, PrintAttributes properties)
90
			throws LegendException {
91
		// TODO Auto-generated method stub
77
    public int getShapeType() {
78
        // TODO Auto-generated method stub
79
        return (int) shpType;
80
    }
92 81

  
93
	}
82
    public ISymbol getSymbolByFeature(Feature feat) {
83
        return sym;
84
    }
94 85

  
95
	public void setDefaultSymbol(ISymbol s) throws IllegalArgumentException {
96
		sym = s;
97
	}
86
    public boolean isSuitableForShapeType(int shapeType) {
87
        return sym.getSymbolType() == shapeType;
88
    }
98 89

  
99
	public void setShapeType(int shapeType) {
100
		shpType = shapeType;
101
	}
90
    public boolean isUseDefaultSymbol() {
91
        return true;
92
    }
102 93

  
103
	public void useDefaultSymbol(boolean b) {
104
	}
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
105 99

  
106
	public void addLegendListener(LegendContentsChangedListener listener) {
107
		// TODO Auto-generated method stub
100
    }
108 101

  
109
	}
102
    public void setDefaultSymbol(ISymbol s) throws IllegalArgumentException {
103
        sym = s;
104
    }
110 105

  
111
	public ILegend cloneLegend() {
112
		// TODO Auto-generated method stub
113
		return null;
114
	}
106
    public void setShapeType(int shapeType) {
107
        shpType = shapeType;
108
    }
115 109

  
116
	public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) {
117
		// TODO Auto-generated method stub
110
    public void useDefaultSymbol(boolean b) {
111
    }
118 112

  
119
	}
113
    public void addLegendListener(LegendContentsChangedListener listener) {
114
        // TODO Auto-generated method stub
120 115

  
121
	public ISymbol getDefaultSymbol() {
122
		return sym;
123
	}
116
    }
124 117

  
125
	public LegendContentsChangedListener[] getListeners() {
126
		// TODO Auto-generated method stub
127
		return null;
128
	}
118
    public ILegend cloneLegend() {
119
        // TODO Auto-generated method stub
120
        return null;
121
    }
129 122

  
130
	public void removeLegendListener(LegendContentsChangedListener listener) {
131
		// TODO Auto-generated method stub
123
    public void fireDefaultSymbolChangedEvent(SymbolLegendEvent event) {
124
        // TODO Auto-generated method stub
132 125

  
133
	}
126
    }
134 127

  
135
	public String getClassName() {
136
		return this.getClass().getName();
137
	}
128
    public ISymbol getDefaultSymbol() {
129
        return sym;
130
    }
138 131

  
132
    public LegendContentsChangedListener[] getListeners() {
133
        // TODO Auto-generated method stub
134
        return null;
135
    }
139 136

  
137
    public void removeLegendListener(LegendContentsChangedListener listener) {
138
        // TODO Auto-generated method stub
140 139

  
140
    }
141 141

  
142
	public void addDrawingObserver(Observer observer) {
143
		// TODO Auto-generated method stub
142
    public String getClassName() {
143
        return this.getClass().getName();
144
    }
144 145

  
145
	}
146 146

  
147
	public void deleteDrawingObserver(Observer observer) {
148
		// TODO Auto-generated method stub
149 147

  
150
	}
151 148

  
152
	public void deleteDrawingObservers() {
153
		// TODO Auto-generated method stub
149
    public void addDrawingObserver(Observer observer) {
150
        // TODO Auto-generated method stub
154 151

  
155
	}
152
    }
156 153

  
157
	public void loadFromState(PersistentState state) throws PersistenceException {
158
		shpType = state.getLong("shpType");
159
	}
154
    public void deleteDrawingObserver(Observer observer) {
155
        // TODO Auto-generated method stub
160 156

  
157
    }
161 158

  
162
	public void saveToState(PersistentState state) throws PersistenceException {
163
		state.set("shpType", shpType);
164
	}
159
    public void deleteDrawingObservers() {
160
        // TODO Auto-generated method stub
165 161

  
166
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,
167
			double scale, Map queryParameters, ICoordTrans coordTrans,
168
			FeatureStore featureStore, Evaluator evaluator, PrintAttributes properties)
169
			throws LegendException {
170
		// TODO Auto-generated method stub
171
		
172
	}
173
	
174
	public static void registerPersistent() {
175
		PersistenceManager manager = ToolsLocator.getPersistenceManager();
176
		DynStruct definition = manager.addDefinition(
177
				DummyVectorLegend.class,
178
				"DummyVectorLegend",
179
				"DummyVectorLegend Persistence definition",
180
				null, 
181
				null
182
		);
183
		definition.addDynFieldLong("shpType")
184
			.setMandatory(true);
185
	}
162
    }
186 163

  
164
    public void loadFromState(PersistentState state) throws PersistenceException {
165
        shpType = state.getLong("shpType");
166
    }
187 167

  
188
	public Object clone() throws CloneNotSupportedException {
189
		return super.clone();
190
	}
191 168

  
169
    public void saveToState(PersistentState state) throws PersistenceException {
170
        state.set("shpType", shpType);
171
    }
192 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

  
193 208
}

Also available in: Unified diff