Revision 32367 branches/v2_0_0_prep/libraries/org.gvsig.arcims/src/org/gvsig/remoteclient/arcims/styling/renderers/ArcImsFLegendFactory.java
ArcImsFLegendFactory.java | ||
---|---|---|
28 | 28 |
|
29 | 29 |
package org.gvsig.remoteclient.arcims.styling.renderers; |
30 | 30 |
|
31 |
import com.hardcode.gdbms.engine.values.Value; |
|
32 | 31 |
|
33 |
import com.iver.cit.gvsig.fmap.core.ISymbol; |
|
34 |
import com.iver.cit.gvsig.fmap.core.v02.FConstant; |
|
35 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
|
36 |
import com.iver.cit.gvsig.fmap.rendering.ClassifiedLegend; |
|
37 |
import com.iver.cit.gvsig.fmap.rendering.FInterval; |
|
38 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
|
39 |
import com.iver.cit.gvsig.fmap.rendering.LegendFactory; |
|
40 |
import com.iver.cit.gvsig.fmap.rendering.NullIntervalValue; |
|
41 |
import com.iver.cit.gvsig.fmap.rendering.NullUniqueValue; |
|
42 |
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend; |
|
43 |
import com.iver.cit.gvsig.fmap.rendering.VectorialIntervalLegend; |
|
44 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
|
45 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
|
46 | 32 |
|
47 | 33 |
import org.slf4j.Logger; |
48 | 34 |
import org.slf4j.LoggerFactory; |
... | ... | |
52 | 38 |
import org.gvsig.remoteclient.arcims.exceptions.ArcImsException; |
53 | 39 |
import org.gvsig.remoteclient.arcims.styling.symbols.ArcImsFSymbolFactory; |
54 | 40 |
import org.gvsig.remoteclient.arcims.styling.symbols.IArcIMSSymbol; |
55 |
import org.gvsig.remoteclient.arcims.utils.ArcImsValueFactory; |
|
56 | 41 |
import org.gvsig.remoteclient.arcims.utils.FieldInformation; |
57 | 42 |
import org.gvsig.remoteclient.arcims.utils.ServiceInfoTags; |
58 | 43 |
import org.gvsig.remoteclient.arcims.utils.ServiceInformation; |
... | ... | |
76 | 61 |
private ServiceInformationLayerFeatures silf; |
77 | 62 |
private ServiceInformation si; |
78 | 63 |
|
79 |
//We use a class variable to overwrite every label definition |
|
80 |
private VectorialLegend auxLabelsOuter = null; |
|
81 |
|
|
82 |
// private String PATRON = ArcXML.PATRON; |
|
83 |
// DecimalFormat formatter; |
|
84 |
private int featType; |
|
85 |
|
|
86 |
/** |
|
87 |
* @param ds Decimal separator char |
|
88 |
* @param msilf An object with all the information to build |
|
89 |
* the legend of a vectorial layer |
|
90 |
* @see org.gvsig.remoteclient.arcims.utils.ServiceInformationLayerFeatures |
|
91 |
*/ |
|
92 |
public ArcImsFLegendFactory(ServiceInformation msi, String layerId) { |
|
93 |
si = msi; |
|
94 |
ds = msi.getSeparators().getDs(); |
|
95 |
ArcImsFSymbolFactory.ds = ds; |
|
96 |
|
|
97 |
silf = (ServiceInformationLayerFeatures) this.si.getLayerById(layerId); |
|
98 |
this.featType = getSymbType(silf.getFclasstype()); |
|
99 |
|
|
100 |
DecimalFormatSymbols dfs = new DecimalFormatSymbols(); |
|
101 |
dfs.setDecimalSeparator(ds); |
|
102 |
|
|
103 |
// formatter = new DecimalFormat(PATRON,dfs); |
|
104 |
} |
|
105 |
|
|
106 |
/** |
|
107 |
* Main method on this class. It calls proper getLegend method |
|
108 |
* based on type of render. |
|
109 |
* @param render |
|
110 |
* @return |
|
111 |
* @throws ArcImsException |
|
112 |
*/ |
|
113 |
public ILegend getMainLegend() throws ArcImsException { |
|
114 |
logger.info("======Start creating main layer Legend======"); |
|
115 |
|
|
116 |
Renderer render = silf.getLayerMainRenderer(); |
|
117 |
ILegend leg = getLegend(render, true); |
|
118 |
logger.info("======Getting main Legend (" + |
|
119 |
getClassName(leg.getClass()) + ")======"); |
|
120 |
|
|
121 |
return leg; |
|
122 |
} |
|
123 |
|
|
124 |
/** |
|
125 |
* Main method that calls proper getLengend methods according to the type |
|
126 |
* of renderer is passed. |
|
127 |
* @param render |
|
128 |
* @param isMainRender |
|
129 |
* @return |
|
130 |
* @throws ArcImsException |
|
131 |
*/ |
|
132 |
private VectorialLegend getLegend(Renderer render, boolean isMainRender) |
|
133 |
throws ArcImsException { |
|
134 |
VectorialLegend leg = null; |
|
135 |
|
|
136 |
/* |
|
137 |
if (render instanceof SimpleRenderer) { |
|
138 |
SimpleRenderer srender = (SimpleRenderer) render; |
|
139 |
leg = getLegend(srender); |
|
140 |
} |
|
141 |
else if (render instanceof ValueMapRenderer) { |
|
142 |
ValueMapRenderer srender = (ValueMapRenderer) render; |
|
143 |
leg = getLegend(srender); |
|
144 |
} |
|
145 |
// In the main legend, a ScaleDependent and a GroupRenderer can be |
|
146 |
// treated in the same way |
|
147 |
else if (isMainRender && (render instanceof GroupRenderer)) { |
|
148 |
GroupRenderer groupRender = (GroupRenderer) render; |
|
149 |
leg = getLegend(groupRender); |
|
150 |
} |
|
151 |
// Otherwise, we will use their proper method |
|
152 |
else if (!isMainRender && (render instanceof GroupRenderer)) { |
|
153 |
if (render instanceof ScaleDependentRenderer) { |
|
154 |
ScaleDependentRenderer sdRender = (ScaleDependentRenderer) render; |
|
155 |
leg = getLegend(sdRender); |
|
156 |
} |
|
157 |
|
|
158 |
// In the main legend, a ScaleDependent and a GroupRenderer can be |
|
159 |
// treated in the same way |
|
160 |
else if (render instanceof GroupRenderer) { |
|
161 |
GroupRenderer groupRender = (GroupRenderer) render; |
|
162 |
leg = getLegend(groupRender); |
|
163 |
} |
|
164 |
} |
|
165 |
else |
|
166 |
leg = getDefaultLegend(); |
|
167 |
*/ |
|
168 |
if (render instanceof SimpleRenderer) { |
|
169 |
SimpleRenderer srender = (SimpleRenderer) render; |
|
170 |
leg = getLegend(srender); |
|
171 |
} else if (render instanceof ValueMapRenderer) { |
|
172 |
ValueMapRenderer srender = (ValueMapRenderer) render; |
|
173 |
leg = getLegend(srender); |
|
174 |
} |
|
175 |
// In the main legend, a ScaleDependent and a GroupRenderer can be |
|
176 |
// treated in the same way (ScaleDependent inherits from GroupRenderer) |
|
177 |
else if (render instanceof GroupRenderer) { |
|
178 |
GroupRenderer groupRender = (GroupRenderer) render; |
|
179 |
leg = getLegend(groupRender); |
|
180 |
} else { |
|
181 |
leg = getDefaultLegend(); |
|
182 |
} |
|
183 |
|
|
184 |
if (leg != null) { |
|
185 |
logger.info("Getting Render of type: " + |
|
186 |
getClassName(render.getClass())); |
|
187 |
|
|
188 |
return leg; |
|
189 |
} else { |
|
190 |
throw new ArcImsException("arcims_legend_error"); |
|
191 |
} |
|
192 |
} |
|
193 |
|
|
194 |
/** |
|
195 |
* Method to generate a valid simple legend. |
|
196 |
* @return |
|
197 |
*/ |
|
198 |
private VectorialLegend getDefaultLegend() { |
|
199 |
SingleSymbolLegend leg = new SingleSymbolLegend(); |
|
200 |
leg.setDefaultSymbol(ArcImsFSymbolFactory.getDefaultFSymbol(featType)); |
|
201 |
leg.setShapeType(featType); |
|
202 |
logger.info("Getting default legend"); |
|
203 |
|
|
204 |
return leg; |
|
205 |
} |
|
206 |
|
|
207 |
/** |
|
208 |
* Gets a simple Legend with only one symbol |
|
209 |
* @see com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend |
|
210 |
* @param renderer |
|
211 |
* @return |
|
212 |
*/ |
|
213 |
private VectorialLegend getLegend(SimpleRenderer renderer) { |
|
214 |
//Get the ArcIMS Simbol |
|
215 |
IArcIMSSymbol imsSimb = renderer.getSymbol(); |
|
216 |
|
|
217 |
//Get the FSymbol of the renderer |
|
218 |
FSymbol simb = imsSimb.getFSymbol(); |
|
219 |
|
|
220 |
//Creates the legend |
|
221 |
SingleSymbolLegend leg = new SingleSymbolLegend(); |
|
222 |
leg.setDefaultSymbol(simb); |
|
223 |
leg.setShapeType(this.featType); |
|
224 |
logger.info("Getting a Simple Renderer"); |
|
225 |
|
|
226 |
return (VectorialLegend) leg; |
|
227 |
} |
|
228 |
|
|
229 |
/** |
|
230 |
* Gets a Legend based on intervals |
|
231 |
* @see com.iver.cit.gvsig.fmap.rendering.VectorialIntervalLegend |
|
232 |
* @param renderer |
|
233 |
* @return |
|
234 |
* @throws ArcImsException |
|
235 |
*/ |
|
236 |
private VectorialLegend getLegend(ValueMapRenderer renderer) |
|
237 |
throws ArcImsException { |
|
238 |
//Get the proper Field Information object |
|
239 |
FieldInformation fi = silf.getFieldInformation(renderer.getLookupfield()); |
|
240 |
|
|
241 |
//Gets the array of ranges |
|
242 |
ArrayList values = renderer.getValues(); |
|
243 |
Iterator it = values.iterator(); |
|
244 |
|
|
245 |
//Creates the two types of legends |
|
246 |
VectorialIntervalLegend viLeg = new VectorialIntervalLegend(); |
|
247 |
VectorialUniqueValueLegend vuLeg = new VectorialUniqueValueLegend(); |
|
248 |
|
|
249 |
//Initialize counters |
|
250 |
int nIntervals = 0; |
|
251 |
int nUniques = 0; |
|
252 |
|
|
253 |
//Create a default simbol |
|
254 |
FSymbol defSimb = ArcImsFSymbolFactory.getDefaultFSymbol(this.featType); |
|
255 |
defSimb.setDescription("Default"); |
|
256 |
|
|
257 |
boolean hasDefSymbol = false; |
|
258 |
|
|
259 |
//Fills with intervals and symbols |
|
260 |
while (it.hasNext()) { |
|
261 |
//Only RangeValueMaps are allowed |
|
262 |
TypeValueMap tvm = (TypeValueMap) it.next(); |
|
263 |
|
|
264 |
//Gets the symbol |
|
265 |
IArcIMSSymbol simb = tvm.getSymbol(); |
|
266 |
FSymbol fsimb = simb.getFSymbol(); |
|
267 |
|
|
268 |
//Set the description |
|
269 |
String descr = tvm.getLabel(); |
|
270 |
|
|
271 |
if (descr == null) { |
|
272 |
descr = ""; |
|
273 |
} |
|
274 |
|
|
275 |
fsimb.setDescription(descr); |
|
276 |
|
|
277 |
if (tvm instanceof RangeValueMap) { |
|
278 |
RangeValueMap rvm = (RangeValueMap) tvm; |
|
279 |
|
|
280 |
//Get the bounds of the intverval |
|
281 |
String sFrom = rvm.getLower(); |
|
282 |
String sTo = rvm.getUpper(); |
|
283 |
double from = Double.parseDouble(sFrom.replace(ds, '.')); |
|
284 |
double to = Double.parseDouble(sTo.replace(ds, '.')); |
|
285 |
|
|
286 |
if (descr == null) { |
|
287 |
fsimb.setDescription(sFrom + "-" + sTo); |
|
288 |
} |
|
289 |
|
|
290 |
//Creates the Interval |
|
291 |
FInterval interv = new FInterval(from, to); |
|
292 |
|
|
293 |
//Adds the symbol to the legend |
|
294 |
viLeg.addSymbol(interv, fsimb); |
|
295 |
|
|
296 |
// viLeg.setIntervalSymbol(interv,fsimb); |
|
297 |
nIntervals++; |
|
298 |
} else if (tvm instanceof ExactValueMap) { |
|
299 |
ExactValueMap evm = (ExactValueMap) tvm; |
|
300 |
|
|
301 |
//We have to build a Value object |
|
302 |
String strVal = evm.getValue(); |
|
303 |
|
|
304 |
try { |
|
305 |
Value val = ArcImsValueFactory.createValueByType(strVal, |
|
306 |
fi.getType(), this.ds); |
|
307 |
vuLeg.addSymbol(val, fsimb); |
|
308 |
} catch (ParseException e) { |
|
309 |
logger.error(e.getMessage(), e); |
|
310 |
throw new ArcImsException("arcims_legend_error"); |
|
311 |
} |
|
312 |
|
|
313 |
nUniques++; |
|
314 |
} else if (tvm instanceof OtherValueMap) { |
|
315 |
hasDefSymbol = true; |
|
316 |
defSimb = fsimb; |
|
317 |
} |
|
318 |
} |
|
319 |
|
|
320 |
/* |
|
321 |
* Determine what type of legend the method will return (Unique or Interval) |
|
322 |
* The condition will be the legend with more classes (intervals, values) |
|
323 |
*/ |
|
324 |
VectorialLegend leg = null; |
|
325 |
ClassifiedLegend cleg = null; |
|
326 |
|
|
327 |
if (nUniques >= nIntervals) { |
|
328 |
leg = vuLeg; |
|
329 |
cleg = vuLeg; |
|
330 |
} else { |
|
331 |
leg = viLeg; |
|
332 |
cleg = viLeg; |
|
333 |
} |
|
334 |
|
|
335 |
/* |
|
336 |
* Finally we can add the field name and default symbol |
|
337 |
*/ |
|
338 |
|
|
339 |
//Set the field name |
|
340 |
cleg.setFieldName(ArcXML.replaceUnwantedCharacters(fi.getName())); |
|
341 |
|
|
342 |
// Set the default symbol, if it is used and asign the symbol to a nullvalue |
|
343 |
leg.setDefaultSymbol(defSimb); |
|
344 |
leg.useDefaultSymbol(hasDefSymbol); |
|
345 |
|
|
346 |
if (hasDefSymbol) { |
|
347 |
if (leg instanceof VectorialUniqueValueLegend) { |
|
348 |
vuLeg.addSymbol(new NullUniqueValue(), leg.getDefaultSymbol()); |
|
349 |
} else { |
|
350 |
viLeg.addSymbol(new NullIntervalValue(), leg.getDefaultSymbol()); |
|
351 |
} |
|
352 |
} |
|
353 |
|
|
354 |
logger.info("Getting a Value Map Renderer"); |
|
355 |
|
|
356 |
return leg; |
|
357 |
} |
|
358 |
|
|
359 |
// /** |
|
360 |
// * Gets the most detailed legend from the ScaleDependentRender |
|
361 |
// * @param sdrender |
|
362 |
// * @return |
|
363 |
// */ |
|
364 |
// private VectorialLegend getLegend(ScaleDependentRenderer sdrender) throws ArcImsException { |
|
365 |
// VectorialLegend leg = getLegend((GroupRenderer) sdrender); |
|
366 |
// logger.info("Getting a ScaleDependent Renderer"); |
|
367 |
// return leg; |
|
368 |
// } |
|
369 |
private VectorialLegend getLegend(GroupRenderer groupRender) |
|
370 |
throws ArcImsException { |
|
371 |
ArrayList renderers = groupRender.renderers; |
|
372 |
ArrayList legends = new ArrayList(); |
|
373 |
VectorialLegend biggerScale = null; |
|
374 |
VectorialLegend leg = null; |
|
375 |
double[] limit = { Double.MAX_VALUE, 0 }; |
|
376 |
Iterator it = renderers.iterator(); |
|
377 |
|
|
378 |
//We use a class variable to overwrite every label definition |
|
379 |
VectorialLegend auxLabelsInner = null; |
|
380 |
|
|
381 |
while (it.hasNext()) { |
|
382 |
leg = null; |
|
383 |
|
|
384 |
Renderer iRender = (Renderer) it.next(); |
|
385 |
|
|
386 |
//If we don't have a Label renderer use the generic method |
|
387 |
if (!(iRender instanceof ILabelRenderer)) { |
|
388 |
leg = getLegend(iRender, false); |
|
389 |
} |
|
390 |
//Otherwise, use the specific method for labels |
|
391 |
else { |
|
392 |
auxLabelsInner = getLegend((ILabelRenderer) iRender); |
|
393 |
} |
|
394 |
|
|
395 |
//If renderer is Scale Dependent, we inspect their scale limits |
|
396 |
if (iRender instanceof ScaleDependentRenderer) { |
|
397 |
ScaleDependentRenderer iSDRender = (ScaleDependentRenderer) iRender; |
|
398 |
String strLow = iSDRender.getLower(); |
|
399 |
String strUpp = iSDRender.getUpper(); |
|
400 |
double low = 0; |
|
401 |
double upp = Double.MAX_VALUE; |
|
402 |
|
|
403 |
if (strLow != null) { |
|
404 |
low = Double.parseDouble(strLow.replace(ds, '.')); |
|
405 |
} |
|
406 |
|
|
407 |
if (strUpp != null) { |
|
408 |
upp = Double.parseDouble(strUpp.replace(ds, '.')); |
|
409 |
} |
|
410 |
|
|
411 |
//First loop |
|
412 |
if (biggerScale == null) { |
|
413 |
biggerScale = leg; |
|
414 |
limit[0] = low; |
|
415 |
limit[1] = upp; |
|
416 |
} |
|
417 |
/* |
|
418 |
* Next loops we allways get the minimum interval |
|
419 |
* If lower bounds are equal, we get the lower upper value |
|
420 |
*/ |
|
421 |
else if ((low <= limit[0]) && (upp <= limit[1])) { |
|
422 |
limit[0] = low; |
|
423 |
limit[1] = upp; |
|
424 |
biggerScale = leg; |
|
425 |
} |
|
426 |
} |
|
427 |
|
|
428 |
if (leg != null) { |
|
429 |
legends.add(leg); |
|
430 |
} |
|
431 |
} |
|
432 |
|
|
433 |
/* |
|
434 |
* TODO At this time we will return the first (bottom) legend of the ArrayList |
|
435 |
* or the most detailed legend if there are any ScaleDependentRenderers |
|
436 |
* Probably I will add more "logic" into this code |
|
437 |
*/ |
|
438 |
VectorialLegend finalLegend = null; |
|
439 |
boolean onlyLabels = false; |
|
440 |
|
|
441 |
/* |
|
442 |
* Check if auxLabels is equal to the last element of the array Legends and if |
|
443 |
* it's true, merge it with the first one (its label definition) |
|
444 |
*/ |
|
445 |
if (auxLabelsOuter!=null && legends.size()>0){ |
|
446 |
|
|
447 |
for (int i=0;i<legends.size();i++){ |
|
448 |
// FSymbol simb1 = auxLabelsOuter.getDefaultSymbol(); |
|
449 |
// FSymbol simb2 = ((VectorialLegend) legends.get(i)).getDefaultSymbol(); |
|
450 |
FSymbol simb1 = (FSymbol) auxLabelsOuter.getDefaultSymbol(); |
|
451 |
FSymbol simb2 = (FSymbol) ((VectorialLegend) legends.get(i)).getDefaultSymbol(); |
|
452 |
|
|
453 |
if (simb1==simb2){ |
|
454 |
//Null the biggerScale to force the next if statement |
|
455 |
biggerScale = null; |
|
456 |
//Merge the auxLabels object into the first legend of the arrayList |
|
457 |
VectorialLegend legend = setLabelDefIntoSymbol(auxLabelsOuter,(VectorialLegend) legends.get(0)); |
|
458 |
legends.set(0,legend); |
|
459 |
//Null the auxlabelsinner to avoid the last if |
|
460 |
auxLabelsInner = null; |
|
461 |
break; |
|
462 |
} |
|
463 |
} |
|
464 |
|
|
465 |
|
|
466 |
} |
|
467 |
|
|
468 |
//We don't have any scaledependent |
|
469 |
if (((biggerScale == null) && (legends.size() > 0))) { |
|
470 |
//if (!(groupRender instanceof ScaleDependentRenderer)){ |
|
471 |
logger.info("Getting the bottom renderer of the Group Renderer"); |
|
472 |
finalLegend = (VectorialLegend) legends.get(0); |
|
473 |
} |
|
474 |
//We have any scaledpendent |
|
475 |
else if (biggerScale != null) { |
|
476 |
logger.info( |
|
477 |
"Getting the most detailed ScaleDependent renderer of the Group Renderer"); |
|
478 |
finalLegend = biggerScale; |
|
479 |
} |
|
480 |
//We don't have any legend parsed (maybe the layer only have label definitions |
|
481 |
else { |
|
482 |
finalLegend = LegendFactory.createSingleSymbolLegend(this.featType); |
|
483 |
onlyLabels = true; |
|
484 |
} |
|
485 |
|
|
486 |
/* |
|
487 |
* Finally if some label renderer is found, we have to pass the label |
|
488 |
* properties to the final legend |
|
489 |
*/ |
|
490 |
if (auxLabelsInner != null) { |
|
491 |
finalLegend = setLabelDefIntoSymbol(auxLabelsInner,finalLegend); |
|
492 |
|
|
493 |
// finalLegend.getDefaultSymbol().setShapeVisible(!onlyLabels); |
|
494 |
((FSymbol) finalLegend.getDefaultSymbol()).setShapeVisible(!onlyLabels); |
|
495 |
|
|
496 |
auxLabelsOuter = finalLegend; |
|
497 |
} |
|
498 |
return finalLegend; |
|
499 |
} |
|
500 |
|
|
501 |
/** |
|
502 |
* Method that returns a SingleSymboLegend with Font definition and |
|
503 |
* field to retrieve labels. These properties will be transferred to the |
|
504 |
* main layer legend. |
|
505 |
* @param renderer |
|
506 |
* @return |
|
507 |
*/ |
|
508 |
private VectorialLegend getLegend(ILabelRenderer renderer) { |
|
509 |
//Get the proper Field Information object |
|
510 |
FieldInformation fi = silf.getFieldInformation(renderer.getField()); |
|
511 |
|
|
512 |
//Create a legend |
|
513 |
SingleSymbolLegend leg = (SingleSymbolLegend) LegendFactory.createSingleSymbolLegend(this.featType); |
|
514 |
IArcIMSSymbol arcSimb = null; |
|
515 |
|
|
516 |
//Get the ArcIMS Symbol with Font definition |
|
517 |
if (renderer instanceof SimpleLabelRenderer) { |
|
518 |
SimpleLabelRenderer slrender = (SimpleLabelRenderer) renderer; |
|
519 |
arcSimb = slrender.getSymbol(); |
|
520 |
} else if (renderer instanceof ValueMapLabelRenderer) { |
|
521 |
ValueMapLabelRenderer vmlrender = (ValueMapLabelRenderer) renderer; |
|
522 |
arcSimb = vmlrender.getValue(0).getSymbol(); |
|
523 |
} |
|
524 |
|
|
525 |
//Asign it (or a default) to the legend |
|
526 |
if (arcSimb != null) { |
|
527 |
leg.setDefaultSymbol(arcSimb.getFSymbol()); |
|
528 |
} else { |
|
529 |
leg.setDefaultSymbol(ArcImsFSymbolFactory.getDefaultFSymbol( |
|
530 |
this.featType)); |
|
531 |
} |
|
532 |
|
|
533 |
//Set the label field |
|
534 |
leg.setLabelField(ArcXML.replaceUnwantedCharacters(fi.getName())); |
|
535 |
|
|
536 |
//Return the legend |
|
537 |
return leg; |
|
538 |
} |
|
539 |
|
|
540 |
/** |
|
541 |
* @return Returns the featType. |
|
542 |
*/ |
|
543 |
public int getFeatType() { |
|
544 |
return featType; |
|
545 |
} |
|
546 |
|
|
547 |
/** |
|
548 |
* @param featType The featType to set. |
|
549 |
*/ |
|
550 |
public void setFeatType(int featType) { |
|
551 |
this.featType = featType; |
|
552 |
} |
|
553 |
|
|
554 |
/** |
|
555 |
* Gets the simple class name |
|
556 |
* @param mclass |
|
557 |
* @return |
|
558 |
*/ |
|
559 |
private String getClassName(Class mclass) { |
|
560 |
String[] classSplitted = mclass.getName().split("\\."); |
|
561 |
|
|
562 |
return classSplitted[classSplitted.length - 1]; |
|
563 |
} |
|
564 |
|
|
565 |
/** |
|
566 |
* Private method to set into a legend the label definition of another legend |
|
567 |
* @param withLabels |
|
568 |
* @param finalLegend |
|
569 |
* @return |
|
570 |
*/ |
|
571 |
private VectorialLegend setLabelDefIntoSymbol(VectorialLegend withLabels, |
|
572 |
VectorialLegend finalLegend) { |
|
573 |
|
|
574 |
//Set the label |
|
575 |
finalLegend.setLabelField(withLabels.getLabelField()); |
|
576 |
//Get simbol with font definition |
|
577 |
|
|
578 |
// FSymbol simbWithFont = withLabels.getDefaultSymbol(); |
|
579 |
FSymbol simbWithFont = (FSymbol) withLabels.getDefaultSymbol(); |
|
580 |
|
|
581 |
//Get simbol to insert font definition |
|
582 |
// FSymbol simb = finalLegend.getDefaultSymbol(); |
|
583 |
FSymbol simb = (FSymbol) finalLegend.getDefaultSymbol(); |
|
584 |
|
|
585 |
//Insert into simb the font properties |
|
586 |
simb.setFont(simbWithFont.getFont()); |
|
587 |
simb.setFontColor(simbWithFont.getFontColor()); |
|
588 |
simb.setFontSize(simbWithFont.getFontSize()); |
|
589 |
simb.setFontSizeInPixels(true); |
|
590 |
//Set simbol modified into final legend to return |
|
591 |
finalLegend.setDefaultSymbol(simb); |
|
592 |
|
|
593 |
return finalLegend; |
|
594 |
} |
|
595 |
|
|
596 |
/** |
|
597 |
* Converts ArcIMS feature type to a FConstant value |
|
598 |
* @param fclasstype |
|
599 |
* @return |
|
600 |
*/ |
|
601 |
private int getSymbType(String fclasstype) { |
|
602 |
if (fclasstype.equals(ServiceInfoTags.aPOLYGON)) { |
|
603 |
return FConstant.SYMBOL_TYPE_FILL; |
|
604 |
} |
|
605 |
|
|
606 |
if (fclasstype.equals(ServiceInfoTags.aPOLYLINE)) { |
|
607 |
return FConstant.SYMBOL_TYPE_LINE; |
|
608 |
} |
|
609 |
|
|
610 |
if (fclasstype.equals(ServiceInfoTags.aMULTIPOINT)) { |
|
611 |
return FConstant.SYMBOL_TYPE_POINT; |
|
612 |
} |
|
613 |
|
|
614 |
return FConstant.SHAPE_TYPE_NULL; |
|
615 |
} |
|
64 |
// //We use a class variable to overwrite every label definition
|
|
65 |
// private VectorialLegend auxLabelsOuter = null;
|
|
66 |
// |
|
67 |
// // private String PATRON = ArcXML.PATRON;
|
|
68 |
// // DecimalFormat formatter;
|
|
69 |
// private int featType;
|
|
70 |
// |
|
71 |
// /**
|
|
72 |
// * @param ds Decimal separator char
|
|
73 |
// * @param msilf An object with all the information to build
|
|
74 |
// * the legend of a vectorial layer
|
|
75 |
// * @see org.gvsig.remoteclient.arcims.utils.ServiceInformationLayerFeatures
|
|
76 |
// */
|
|
77 |
// public ArcImsFLegendFactory(ServiceInformation msi, String layerId) {
|
|
78 |
// si = msi;
|
|
79 |
// ds = msi.getSeparators().getDs();
|
|
80 |
// ArcImsFSymbolFactory.ds = ds;
|
|
81 |
// |
|
82 |
// silf = (ServiceInformationLayerFeatures) this.si.getLayerById(layerId);
|
|
83 |
// this.featType = getSymbType(silf.getFclasstype());
|
|
84 |
// |
|
85 |
// DecimalFormatSymbols dfs = new DecimalFormatSymbols();
|
|
86 |
// dfs.setDecimalSeparator(ds);
|
|
87 |
// |
|
88 |
// // formatter = new DecimalFormat(PATRON,dfs);
|
|
89 |
// }
|
|
90 |
// |
|
91 |
// /**
|
|
92 |
// * Main method on this class. It calls proper getLegend method
|
|
93 |
// * based on type of render.
|
|
94 |
// * @param render
|
|
95 |
// * @return
|
|
96 |
// * @throws ArcImsException
|
|
97 |
// */
|
|
98 |
// public ILegend getMainLegend() throws ArcImsException {
|
|
99 |
// logger.info("======Start creating main layer Legend======");
|
|
100 |
// |
|
101 |
// Renderer render = silf.getLayerMainRenderer();
|
|
102 |
// ILegend leg = getLegend(render, true);
|
|
103 |
// logger.info("======Getting main Legend (" +
|
|
104 |
// getClassName(leg.getClass()) + ")======");
|
|
105 |
// |
|
106 |
// return leg;
|
|
107 |
// }
|
|
108 |
// |
|
109 |
// /**
|
|
110 |
// * Main method that calls proper getLengend methods according to the type
|
|
111 |
// * of renderer is passed.
|
|
112 |
// * @param render
|
|
113 |
// * @param isMainRender
|
|
114 |
// * @return
|
|
115 |
// * @throws ArcImsException
|
|
116 |
// */
|
|
117 |
// private VectorialLegend getLegend(Renderer render, boolean isMainRender)
|
|
118 |
// throws ArcImsException {
|
|
119 |
// VectorialLegend leg = null;
|
|
120 |
// |
|
121 |
// /*
|
|
122 |
// if (render instanceof SimpleRenderer) {
|
|
123 |
// SimpleRenderer srender = (SimpleRenderer) render;
|
|
124 |
// leg = getLegend(srender);
|
|
125 |
// }
|
|
126 |
// else if (render instanceof ValueMapRenderer) {
|
|
127 |
// ValueMapRenderer srender = (ValueMapRenderer) render;
|
|
128 |
// leg = getLegend(srender);
|
|
129 |
// }
|
|
130 |
// // In the main legend, a ScaleDependent and a GroupRenderer can be
|
|
131 |
// // treated in the same way
|
|
132 |
// else if (isMainRender && (render instanceof GroupRenderer)) {
|
|
133 |
// GroupRenderer groupRender = (GroupRenderer) render;
|
|
134 |
// leg = getLegend(groupRender);
|
|
135 |
// }
|
|
136 |
// // Otherwise, we will use their proper method
|
|
137 |
// else if (!isMainRender && (render instanceof GroupRenderer)) {
|
|
138 |
// if (render instanceof ScaleDependentRenderer) {
|
|
139 |
// ScaleDependentRenderer sdRender = (ScaleDependentRenderer) render;
|
|
140 |
// leg = getLegend(sdRender);
|
|
141 |
// }
|
|
142 |
// |
|
143 |
// // In the main legend, a ScaleDependent and a GroupRenderer can be
|
|
144 |
// // treated in the same way
|
|
145 |
// else if (render instanceof GroupRenderer) {
|
|
146 |
// GroupRenderer groupRender = (GroupRenderer) render;
|
|
147 |
// leg = getLegend(groupRender);
|
|
148 |
// }
|
|
149 |
// }
|
|
150 |
// else
|
|
151 |
// leg = getDefaultLegend();
|
|
152 |
// */
|
|
153 |
// if (render instanceof SimpleRenderer) {
|
|
154 |
// SimpleRenderer srender = (SimpleRenderer) render;
|
|
155 |
// leg = getLegend(srender);
|
|
156 |
// } else if (render instanceof ValueMapRenderer) {
|
|
157 |
// ValueMapRenderer srender = (ValueMapRenderer) render;
|
|
158 |
// leg = getLegend(srender);
|
|
159 |
// }
|
|
160 |
// // In the main legend, a ScaleDependent and a GroupRenderer can be
|
|
161 |
// // treated in the same way (ScaleDependent inherits from GroupRenderer)
|
|
162 |
// else if (render instanceof GroupRenderer) {
|
|
163 |
// GroupRenderer groupRender = (GroupRenderer) render;
|
|
164 |
// leg = getLegend(groupRender);
|
|
165 |
// } else {
|
|
166 |
// leg = getDefaultLegend();
|
|
167 |
// }
|
|
168 |
// |
|
169 |
// if (leg != null) {
|
|
170 |
// logger.info("Getting Render of type: " +
|
|
171 |
// getClassName(render.getClass()));
|
|
172 |
// |
|
173 |
// return leg;
|
|
174 |
// } else {
|
|
175 |
// throw new ArcImsException("arcims_legend_error");
|
|
176 |
// }
|
|
177 |
// }
|
|
178 |
// |
|
179 |
// /**
|
|
180 |
// * Method to generate a valid simple legend.
|
|
181 |
// * @return
|
|
182 |
// */
|
|
183 |
// private VectorialLegend getDefaultLegend() {
|
|
184 |
// SingleSymbolLegend leg = new SingleSymbolLegend();
|
|
185 |
// leg.setDefaultSymbol(ArcImsFSymbolFactory.getDefaultFSymbol(featType));
|
|
186 |
// leg.setShapeType(featType);
|
|
187 |
// logger.info("Getting default legend");
|
|
188 |
// |
|
189 |
// return leg;
|
|
190 |
// }
|
|
191 |
// |
|
192 |
// /**
|
|
193 |
// * Gets a simple Legend with only one symbol
|
|
194 |
// * @see com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend
|
|
195 |
// * @param renderer
|
|
196 |
// * @return
|
|
197 |
// */
|
|
198 |
// private VectorialLegend getLegend(SimpleRenderer renderer) {
|
|
199 |
// //Get the ArcIMS Simbol
|
|
200 |
// IArcIMSSymbol imsSimb = renderer.getSymbol();
|
|
201 |
// |
|
202 |
// //Get the FSymbol of the renderer
|
|
203 |
// FSymbol simb = imsSimb.getFSymbol();
|
|
204 |
// |
|
205 |
// //Creates the legend
|
|
206 |
// SingleSymbolLegend leg = new SingleSymbolLegend();
|
|
207 |
// leg.setDefaultSymbol(simb);
|
|
208 |
// leg.setShapeType(this.featType);
|
|
209 |
// logger.info("Getting a Simple Renderer");
|
|
210 |
// |
|
211 |
// return (VectorialLegend) leg;
|
|
212 |
// }
|
|
213 |
// |
|
214 |
// /**
|
|
215 |
// * Gets a Legend based on intervals
|
|
216 |
// * @see com.iver.cit.gvsig.fmap.rendering.VectorialIntervalLegend
|
|
217 |
// * @param renderer
|
|
218 |
// * @return
|
|
219 |
// * @throws ArcImsException
|
|
220 |
// */
|
|
221 |
// private VectorialLegend getLegend(ValueMapRenderer renderer)
|
|
222 |
// throws ArcImsException {
|
|
223 |
// //Get the proper Field Information object
|
|
224 |
// FieldInformation fi = silf.getFieldInformation(renderer.getLookupfield());
|
|
225 |
// |
|
226 |
// //Gets the array of ranges
|
|
227 |
// ArrayList values = renderer.getValues();
|
|
228 |
// Iterator it = values.iterator();
|
|
229 |
// |
|
230 |
// //Creates the two types of legends
|
|
231 |
// VectorialIntervalLegend viLeg = new VectorialIntervalLegend();
|
|
232 |
// VectorialUniqueValueLegend vuLeg = new VectorialUniqueValueLegend();
|
|
233 |
// |
|
234 |
// //Initialize counters
|
|
235 |
// int nIntervals = 0;
|
|
236 |
// int nUniques = 0;
|
|
237 |
// |
|
238 |
// //Create a default simbol
|
|
239 |
// FSymbol defSimb = ArcImsFSymbolFactory.getDefaultFSymbol(this.featType);
|
|
240 |
// defSimb.setDescription("Default");
|
|
241 |
// |
|
242 |
// boolean hasDefSymbol = false;
|
|
243 |
// |
|
244 |
// //Fills with intervals and symbols
|
|
245 |
// while (it.hasNext()) {
|
|
246 |
// //Only RangeValueMaps are allowed
|
|
247 |
// TypeValueMap tvm = (TypeValueMap) it.next();
|
|
248 |
// |
|
249 |
// //Gets the symbol
|
|
250 |
// IArcIMSSymbol simb = tvm.getSymbol();
|
|
251 |
// FSymbol fsimb = simb.getFSymbol();
|
|
252 |
// |
|
253 |
// //Set the description
|
|
254 |
// String descr = tvm.getLabel();
|
|
255 |
// |
|
256 |
// if (descr == null) {
|
|
257 |
// descr = "";
|
|
258 |
// }
|
|
259 |
// |
|
260 |
// fsimb.setDescription(descr);
|
|
261 |
// |
|
262 |
// if (tvm instanceof RangeValueMap) {
|
|
263 |
// RangeValueMap rvm = (RangeValueMap) tvm;
|
|
264 |
// |
|
265 |
// //Get the bounds of the intverval
|
|
266 |
// String sFrom = rvm.getLower();
|
|
267 |
// String sTo = rvm.getUpper();
|
|
268 |
// double from = Double.parseDouble(sFrom.replace(ds, '.'));
|
|
269 |
// double to = Double.parseDouble(sTo.replace(ds, '.'));
|
|
270 |
// |
|
271 |
// if (descr == null) {
|
|
272 |
// fsimb.setDescription(sFrom + "-" + sTo);
|
|
273 |
// }
|
|
274 |
// |
|
275 |
// //Creates the Interval
|
|
276 |
// FInterval interv = new FInterval(from, to);
|
|
277 |
// |
|
278 |
// //Adds the symbol to the legend
|
|
279 |
// viLeg.addSymbol(interv, fsimb);
|
|
280 |
// |
|
281 |
// // viLeg.setIntervalSymbol(interv,fsimb);
|
|
282 |
// nIntervals++;
|
|
283 |
// } else if (tvm instanceof ExactValueMap) {
|
|
284 |
// ExactValueMap evm = (ExactValueMap) tvm;
|
|
285 |
// |
|
286 |
// //We have to build a Value object
|
|
287 |
// String strVal = evm.getValue();
|
|
288 |
// |
|
289 |
// try {
|
|
290 |
// Value val = ArcImsValueFactory.createValueByType(strVal,
|
|
291 |
// fi.getType(), this.ds);
|
|
292 |
// vuLeg.addSymbol(val, fsimb);
|
|
293 |
// } catch (ParseException e) {
|
|
294 |
// logger.error(e.getMessage(), e);
|
|
295 |
// throw new ArcImsException("arcims_legend_error");
|
|
296 |
// }
|
|
297 |
// |
|
298 |
// nUniques++;
|
|
299 |
// } else if (tvm instanceof OtherValueMap) {
|
|
300 |
// hasDefSymbol = true;
|
|
301 |
// defSimb = fsimb;
|
|
302 |
// }
|
|
303 |
// }
|
|
304 |
// |
|
305 |
// /*
|
|
306 |
// * Determine what type of legend the method will return (Unique or Interval)
|
|
307 |
// * The condition will be the legend with more classes (intervals, values)
|
|
308 |
// */
|
|
309 |
// VectorialLegend leg = null;
|
|
310 |
// ClassifiedLegend cleg = null;
|
|
311 |
// |
|
312 |
// if (nUniques >= nIntervals) {
|
|
313 |
// leg = vuLeg;
|
|
314 |
// cleg = vuLeg;
|
|
315 |
// } else {
|
|
316 |
// leg = viLeg;
|
|
317 |
// cleg = viLeg;
|
|
318 |
// }
|
|
319 |
// |
|
320 |
// /*
|
|
321 |
// * Finally we can add the field name and default symbol
|
|
322 |
// */
|
|
323 |
// |
|
324 |
// //Set the field name
|
|
325 |
// cleg.setFieldName(ArcXML.replaceUnwantedCharacters(fi.getName()));
|
|
326 |
// |
|
327 |
// // Set the default symbol, if it is used and asign the symbol to a nullvalue
|
|
328 |
// leg.setDefaultSymbol(defSimb);
|
|
329 |
// leg.useDefaultSymbol(hasDefSymbol);
|
|
330 |
// |
|
331 |
// if (hasDefSymbol) {
|
|
332 |
// if (leg instanceof VectorialUniqueValueLegend) {
|
|
333 |
// vuLeg.addSymbol(new NullUniqueValue(), leg.getDefaultSymbol());
|
|
334 |
// } else {
|
|
335 |
// viLeg.addSymbol(new NullIntervalValue(), leg.getDefaultSymbol());
|
|
336 |
// }
|
|
337 |
// }
|
|
338 |
// |
|
339 |
// logger.info("Getting a Value Map Renderer");
|
|
340 |
// |
|
341 |
// return leg;
|
|
342 |
// }
|
|
343 |
// |
|
344 |
// // /**
|
|
345 |
// // * Gets the most detailed legend from the ScaleDependentRender
|
|
346 |
// // * @param sdrender
|
|
347 |
// // * @return
|
|
348 |
// // */
|
|
349 |
// // private VectorialLegend getLegend(ScaleDependentRenderer sdrender) throws ArcImsException {
|
|
350 |
// // VectorialLegend leg = getLegend((GroupRenderer) sdrender);
|
|
351 |
// // logger.info("Getting a ScaleDependent Renderer");
|
|
352 |
// // return leg;
|
|
353 |
// // }
|
|
354 |
// private VectorialLegend getLegend(GroupRenderer groupRender)
|
|
355 |
// throws ArcImsException {
|
|
356 |
// ArrayList renderers = groupRender.renderers;
|
|
357 |
// ArrayList legends = new ArrayList();
|
|
358 |
// VectorialLegend biggerScale = null;
|
|
359 |
// VectorialLegend leg = null;
|
|
360 |
// double[] limit = { Double.MAX_VALUE, 0 };
|
|
361 |
// Iterator it = renderers.iterator();
|
|
362 |
// |
|
363 |
// //We use a class variable to overwrite every label definition
|
|
364 |
// VectorialLegend auxLabelsInner = null;
|
|
365 |
// |
|
366 |
// while (it.hasNext()) {
|
|
367 |
// leg = null;
|
|
368 |
// |
|
369 |
// Renderer iRender = (Renderer) it.next();
|
|
370 |
// |
|
371 |
// //If we don't have a Label renderer use the generic method
|
|
372 |
// if (!(iRender instanceof ILabelRenderer)) {
|
|
373 |
// leg = getLegend(iRender, false);
|
|
374 |
// }
|
|
375 |
// //Otherwise, use the specific method for labels
|
|
376 |
// else {
|
|
377 |
// auxLabelsInner = getLegend((ILabelRenderer) iRender);
|
|
378 |
// }
|
|
379 |
// |
|
380 |
// //If renderer is Scale Dependent, we inspect their scale limits
|
|
381 |
// if (iRender instanceof ScaleDependentRenderer) {
|
|
382 |
// ScaleDependentRenderer iSDRender = (ScaleDependentRenderer) iRender;
|
|
383 |
// String strLow = iSDRender.getLower();
|
|
384 |
// String strUpp = iSDRender.getUpper();
|
|
385 |
// double low = 0;
|
|
386 |
// double upp = Double.MAX_VALUE;
|
|
387 |
// |
|
388 |
// if (strLow != null) {
|
|
389 |
// low = Double.parseDouble(strLow.replace(ds, '.'));
|
|
390 |
// }
|
|
391 |
// |
|
392 |
// if (strUpp != null) {
|
|
393 |
// upp = Double.parseDouble(strUpp.replace(ds, '.'));
|
|
394 |
// }
|
|
395 |
// |
|
396 |
// //First loop
|
|
397 |
// if (biggerScale == null) {
|
|
398 |
// biggerScale = leg;
|
|
399 |
// limit[0] = low;
|
|
400 |
// limit[1] = upp;
|
|
401 |
// }
|
|
402 |
// /*
|
|
403 |
// * Next loops we allways get the minimum interval
|
|
404 |
// * If lower bounds are equal, we get the lower upper value
|
|
405 |
// */
|
|
406 |
// else if ((low <= limit[0]) && (upp <= limit[1])) {
|
|
407 |
// limit[0] = low;
|
|
408 |
// limit[1] = upp;
|
|
409 |
// biggerScale = leg;
|
|
410 |
// }
|
|
411 |
// }
|
|
412 |
// |
|
413 |
// if (leg != null) {
|
|
414 |
// legends.add(leg);
|
|
415 |
// }
|
|
416 |
// }
|
|
417 |
// |
|
418 |
// /*
|
|
419 |
// * TODO At this time we will return the first (bottom) legend of the ArrayList
|
|
420 |
// * or the most detailed legend if there are any ScaleDependentRenderers
|
|
421 |
// * Probably I will add more "logic" into this code
|
|
422 |
// */
|
|
423 |
// VectorialLegend finalLegend = null;
|
|
424 |
// boolean onlyLabels = false;
|
|
425 |
// |
|
426 |
// /*
|
|
427 |
// * Check if auxLabels is equal to the last element of the array Legends and if
|
|
428 |
// * it's true, merge it with the first one (its label definition)
|
|
429 |
// */
|
|
430 |
// if (auxLabelsOuter!=null && legends.size()>0){
|
|
431 |
// |
|
432 |
// for (int i=0;i<legends.size();i++){
|
|
433 |
//// FSymbol simb1 = auxLabelsOuter.getDefaultSymbol();
|
|
434 |
//// FSymbol simb2 = ((VectorialLegend) legends.get(i)).getDefaultSymbol();
|
|
435 |
// FSymbol simb1 = (FSymbol) auxLabelsOuter.getDefaultSymbol();
|
|
436 |
// FSymbol simb2 = (FSymbol) ((VectorialLegend) legends.get(i)).getDefaultSymbol();
|
|
437 |
// |
|
438 |
// if (simb1==simb2){
|
|
439 |
// //Null the biggerScale to force the next if statement
|
|
440 |
// biggerScale = null;
|
|
441 |
// //Merge the auxLabels object into the first legend of the arrayList
|
|
442 |
// VectorialLegend legend = setLabelDefIntoSymbol(auxLabelsOuter,(VectorialLegend) legends.get(0));
|
|
443 |
// legends.set(0,legend);
|
|
444 |
// //Null the auxlabelsinner to avoid the last if
|
|
445 |
// auxLabelsInner = null;
|
|
446 |
// break;
|
|
447 |
// }
|
|
448 |
// }
|
|
449 |
// |
|
450 |
// |
|
451 |
// }
|
|
452 |
// |
|
453 |
// //We don't have any scaledependent
|
|
454 |
// if (((biggerScale == null) && (legends.size() > 0))) {
|
|
455 |
// //if (!(groupRender instanceof ScaleDependentRenderer)){
|
|
456 |
// logger.info("Getting the bottom renderer of the Group Renderer");
|
|
457 |
// finalLegend = (VectorialLegend) legends.get(0);
|
|
458 |
// }
|
|
459 |
// //We have any scaledpendent
|
|
460 |
// else if (biggerScale != null) {
|
|
461 |
// logger.info(
|
|
462 |
// "Getting the most detailed ScaleDependent renderer of the Group Renderer");
|
|
463 |
// finalLegend = biggerScale;
|
|
464 |
// }
|
|
465 |
// //We don't have any legend parsed (maybe the layer only have label definitions
|
|
466 |
// else {
|
|
467 |
// finalLegend = LegendFactory.createSingleSymbolLegend(this.featType);
|
|
468 |
// onlyLabels = true;
|
|
469 |
// }
|
|
470 |
// |
|
471 |
// /*
|
|
472 |
// * Finally if some label renderer is found, we have to pass the label
|
|
473 |
// * properties to the final legend
|
|
474 |
// */
|
|
475 |
// if (auxLabelsInner != null) {
|
|
476 |
// finalLegend = setLabelDefIntoSymbol(auxLabelsInner,finalLegend);
|
|
477 |
// |
|
478 |
// // finalLegend.getDefaultSymbol().setShapeVisible(!onlyLabels);
|
|
479 |
// ((FSymbol) finalLegend.getDefaultSymbol()).setShapeVisible(!onlyLabels);
|
|
480 |
// |
|
481 |
// auxLabelsOuter = finalLegend;
|
|
482 |
// }
|
|
483 |
// return finalLegend;
|
|
484 |
// }
|
|
485 |
// |
|
486 |
// /**
|
|
487 |
// * Method that returns a SingleSymboLegend with Font definition and
|
|
488 |
// * field to retrieve labels. These properties will be transferred to the
|
|
489 |
// * main layer legend.
|
|
490 |
// * @param renderer
|
|
491 |
// * @return
|
|
492 |
// */
|
|
493 |
// private VectorialLegend getLegend(ILabelRenderer renderer) {
|
|
494 |
// //Get the proper Field Information object
|
|
495 |
// FieldInformation fi = silf.getFieldInformation(renderer.getField());
|
|
496 |
// |
|
497 |
// //Create a legend
|
|
498 |
// SingleSymbolLegend leg = (SingleSymbolLegend) LegendFactory.createSingleSymbolLegend(this.featType);
|
|
499 |
// IArcIMSSymbol arcSimb = null;
|
|
500 |
// |
|
501 |
// //Get the ArcIMS Symbol with Font definition
|
|
502 |
// if (renderer instanceof SimpleLabelRenderer) {
|
|
503 |
// SimpleLabelRenderer slrender = (SimpleLabelRenderer) renderer;
|
|
504 |
// arcSimb = slrender.getSymbol();
|
|
505 |
// } else if (renderer instanceof ValueMapLabelRenderer) {
|
|
506 |
// ValueMapLabelRenderer vmlrender = (ValueMapLabelRenderer) renderer;
|
|
507 |
// arcSimb = vmlrender.getValue(0).getSymbol();
|
|
508 |
// }
|
|
509 |
// |
|
510 |
// //Asign it (or a default) to the legend
|
|
511 |
// if (arcSimb != null) {
|
|
512 |
// leg.setDefaultSymbol(arcSimb.getFSymbol());
|
|
513 |
// } else {
|
|
514 |
// leg.setDefaultSymbol(ArcImsFSymbolFactory.getDefaultFSymbol(
|
|
515 |
// this.featType));
|
|
516 |
// }
|
|
517 |
// |
|
518 |
// //Set the label field
|
|
519 |
// leg.setLabelField(ArcXML.replaceUnwantedCharacters(fi.getName()));
|
|
520 |
// |
|
521 |
// //Return the legend
|
|
522 |
// return leg;
|
|
523 |
// }
|
|
524 |
// |
|
525 |
// /**
|
|
526 |
// * @return Returns the featType.
|
|
527 |
// */
|
|
528 |
// public int getFeatType() {
|
|
529 |
// return featType;
|
|
530 |
// }
|
|
531 |
// |
|
532 |
// /**
|
|
533 |
// * @param featType The featType to set.
|
|
534 |
// */
|
|
535 |
// public void setFeatType(int featType) {
|
|
536 |
// this.featType = featType;
|
|
537 |
// }
|
|
538 |
// |
|
539 |
// /**
|
|
540 |
// * Gets the simple class name
|
|
541 |
// * @param mclass
|
|
542 |
// * @return
|
|
543 |
// */
|
|
544 |
// private String getClassName(Class mclass) {
|
|
545 |
// String[] classSplitted = mclass.getName().split("\\.");
|
|
546 |
// |
|
547 |
// return classSplitted[classSplitted.length - 1];
|
|
548 |
// }
|
|
549 |
// |
|
550 |
// /**
|
|
551 |
// * Private method to set into a legend the label definition of another legend
|
|
552 |
// * @param withLabels
|
|
553 |
// * @param finalLegend
|
|
554 |
// * @return
|
|
555 |
// */
|
|
556 |
// private VectorialLegend setLabelDefIntoSymbol(VectorialLegend withLabels,
|
|
557 |
// VectorialLegend finalLegend) {
|
|
558 |
// |
|
559 |
// //Set the label
|
|
560 |
// finalLegend.setLabelField(withLabels.getLabelField());
|
|
561 |
// //Get simbol with font definition
|
|
562 |
// |
|
563 |
// // FSymbol simbWithFont = withLabels.getDefaultSymbol();
|
|
564 |
// FSymbol simbWithFont = (FSymbol) withLabels.getDefaultSymbol();
|
|
565 |
// |
|
566 |
// //Get simbol to insert font definition
|
|
567 |
// // FSymbol simb = finalLegend.getDefaultSymbol();
|
|
568 |
// FSymbol simb = (FSymbol) finalLegend.getDefaultSymbol();
|
|
569 |
// |
|
570 |
// //Insert into simb the font properties
|
|
571 |
// simb.setFont(simbWithFont.getFont());
|
|
572 |
// simb.setFontColor(simbWithFont.getFontColor());
|
|
573 |
// simb.setFontSize(simbWithFont.getFontSize());
|
|
574 |
// simb.setFontSizeInPixels(true);
|
|
575 |
// //Set simbol modified into final legend to return
|
|
576 |
// finalLegend.setDefaultSymbol(simb);
|
|
577 |
// |
|
578 |
// return finalLegend;
|
|
579 |
// }
|
|
580 |
// |
|
581 |
// /**
|
|
582 |
// * Converts ArcIMS feature type to a FConstant value
|
|
583 |
// * @param fclasstype
|
|
584 |
// * @return
|
|
585 |
// */
|
|
586 |
// private int getSymbType(String fclasstype) {
|
|
587 |
// if (fclasstype.equals(ServiceInfoTags.aPOLYGON)) {
|
|
588 |
// return FConstant.SYMBOL_TYPE_FILL;
|
|
589 |
// }
|
|
590 |
// |
|
591 |
// if (fclasstype.equals(ServiceInfoTags.aPOLYLINE)) {
|
|
592 |
// return FConstant.SYMBOL_TYPE_LINE;
|
|
593 |
// }
|
|
594 |
// |
|
595 |
// if (fclasstype.equals(ServiceInfoTags.aMULTIPOINT)) {
|
|
596 |
// return FConstant.SYMBOL_TYPE_POINT;
|
|
597 |
// }
|
|
598 |
// |
|
599 |
// return FConstant.SHAPE_TYPE_NULL;
|
|
600 |
// }
|
|
616 | 601 |
} |
Also available in: Unified diff