Revision 40
trunk/org.gvsig.app.document.layout.app/org.gvsig.app.document.layout.app.mainplugin/src/main/java/org/gvsig/app/project/documents/layout/fframes/FFrameLegend.java | ||
---|---|---|
45 | 45 |
import org.gvsig.fmap.mapcontext.layers.operations.Classifiable; |
46 | 46 |
import org.gvsig.fmap.mapcontext.layers.operations.IHasImageLegend; |
47 | 47 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend; |
48 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
48 | 49 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
49 | 50 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ITextSymbol; |
50 | 51 |
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
... | ... | |
238 | 239 |
n[0]++; |
239 | 240 |
drawLegendOrToFFrame(g, re, h, (FLayers) layer, n, layoutContext); |
240 | 241 |
n[0]++; |
241 |
} else |
|
242 |
if (layer instanceof Classifiable |
|
243 |
&& !(layer instanceof IHasImageLegend)) { |
|
244 |
Classifiable cO = (Classifiable) layer; |
|
242 |
} else { |
|
243 |
|
|
244 |
if (layer instanceof Classifiable) { |
|
245 |
Classifiable cla_layer = (Classifiable) layer; |
|
246 |
ILegend cla_legend = cla_layer.getLegend(); |
|
247 |
|
|
248 |
if (cla_legend instanceof IHasImageLegend) { |
|
249 |
|
|
250 |
// ============================================= |
|
251 |
// classifiable AND image legend |
|
245 | 252 |
|
246 |
if (cO.getLegend() instanceof IClassifiedLegend) {// && |
|
247 |
// !(cO |
|
248 |
// instanceof |
|
249 |
// FLyrAnnotation)) |
|
250 |
// { |
|
251 |
IClassifiedLegend cli = |
|
252 |
(IClassifiedLegend) cO.getLegend(); |
|
253 |
double dX = 0; |
|
254 |
double dY = n[0] * h; |
|
255 |
|
|
256 |
double xl = (re.getX() + dX); |
|
257 |
double yl = (re.getY() + dY); |
|
258 |
if (layoutContext != null) { |
|
259 |
toFFrameText(layoutContext, layer.getName(), re, |
|
260 |
sizefont, (xl - (re.getWidth() / 5)), yl, h); |
|
261 |
} else { |
|
262 |
drawNameLegend(g, layer.getName(), re, |
|
263 |
sizefont, (xl - (re.getWidth() / 5)), yl, h); |
|
264 |
} |
|
265 |
n[0]++; |
|
266 |
String[] descriptions = cli.getDescriptions(); |
|
267 |
ISymbol[] symbols = cli.getSymbols(); |
|
268 |
for (int j = 0; j < descriptions.length; j++) { |
|
269 |
dY = n[0] * h; |
|
270 |
|
|
271 |
xl = (re.getX() + dX); |
|
272 |
yl = (re.getY() + dY); |
|
273 |
|
|
274 |
String s = descriptions[j]; |
|
275 |
if (layoutContext != null) { |
|
276 |
toFFrameText(layoutContext, s, re, sizefont, xl, |
|
277 |
yl, h); |
|
278 |
} else { |
|
279 |
drawNameLegend(g, s, re, sizefont, xl, yl, |
|
280 |
h); |
|
281 |
} |
|
282 |
ISymbol fs2d = symbols[j]; |
|
283 |
if (layoutContext != null) { |
|
284 |
try { |
|
285 |
toFFrameSymbol(layoutContext, re, xl, yl, |
|
286 |
fs2d, sizefont, h, |
|
287 |
cO.getShapeType()); |
|
288 |
} catch (ReadException e) { |
|
289 |
e.printStackTrace(); |
|
290 |
} |
|
291 |
} else { |
|
292 |
drawSymbolLegend(g, re, xl, yl, fs2d, |
|
293 |
sizefont, h); |
|
294 |
} |
|
295 |
n[0]++; |
|
296 |
} |
|
297 |
} else { |
|
298 |
double dX = 0; |
|
299 |
double dY = n[0] * h; |
|
300 |
|
|
301 |
double xl = (re.getX() + dX); |
|
302 |
double yl = (re.getY() + dY); |
|
303 |
if (layoutContext != null) { |
|
304 |
toFFrameText(layoutContext, layer.getName(), re, |
|
305 |
sizefont, xl, yl, h); |
|
306 |
} else { |
|
307 |
drawNameLegend(g, layer.getName(), re, |
|
308 |
sizefont, xl, yl, h); |
|
309 |
} |
|
310 |
// TO DO: CAMBIAR TO_DO ESTO PARA QUE ACEPTE ISYMBOL |
|
311 |
// TODO: comprovar que no es trenca res |
|
312 |
if (cO.getLegend() != null) { |
|
313 |
ISymbol fs2d = |
|
314 |
cO.getLegend().getDefaultSymbol(); |
|
315 |
|
|
316 |
if (layoutContext != null) { |
|
317 |
try { |
|
318 |
toFFrameSymbol(layoutContext, re, xl, yl, |
|
319 |
fs2d, sizefont, h, |
|
320 |
cO.getShapeType()); |
|
321 |
} catch (ReadException e) { |
|
322 |
e.printStackTrace(); |
|
323 |
} |
|
324 |
} else { |
|
325 |
drawSymbolLegend(g, re, xl, yl, fs2d, |
|
326 |
sizefont, h); |
|
327 |
} |
|
328 |
} |
|
329 |
n[0]++; |
|
330 |
} |
|
331 |
} else |
|
332 |
if (layer instanceof IHasImageLegend) { |
|
333 | 253 |
Image image = |
334 |
((IHasImageLegend) layer).getImageLegend();
|
|
254 |
((IHasImageLegend) cla_legend).getImageLegend();
|
|
335 | 255 |
String path = |
336 |
((IHasImageLegend) layer).getPathImage(); |
|
256 |
((IHasImageLegend) cla_legend).getPathImage(); |
|
257 |
|
|
337 | 258 |
if (image != null) { |
338 | 259 |
FFramePicture picture = |
339 | 260 |
(FFramePicture) layoutManager |
... | ... | |
350 | 271 |
Rectangle2D rectImage = |
351 | 272 |
new Rectangle2D.Double(re.getX(), re.getY() |
352 | 273 |
+ dY, re.getWidth(), h); |
353 |
if (layoutContext != null) { |
|
274 |
if (path != null && layoutContext != null) {
|
|
354 | 275 |
picture |
355 | 276 |
.setBoundBox(FLayoutUtilities |
356 | 277 |
.toSheetRect(rectImage, |
... | ... | |
364 | 285 |
picture.draw(g, new AffineTransform(), re, |
365 | 286 |
bi); |
366 | 287 |
} |
288 |
} else { |
|
289 |
// ======================== |
|
290 |
// no image was returned |
|
291 |
double dX = 0; |
|
292 |
double dY = n[0] * h; |
|
293 |
double xl = (re.getX() + dX); |
|
294 |
double yl = (re.getY() + dY); |
|
295 |
if (layoutContext != null) { |
|
296 |
toFFrameText(layoutContext, layer.getName(), re, sizefont, xl, yl, h); |
|
297 |
} else { |
|
298 |
drawNameLegend(g, layer.getName(), re, sizefont, xl, yl, h); |
|
299 |
} |
|
300 |
// ======================== |
|
367 | 301 |
} |
368 | 302 |
n[0]++; |
303 |
|
|
304 |
// classifiable AND image legend (end) |
|
305 |
// ============================================= |
|
306 |
|
|
369 | 307 |
} else { |
370 |
double dX = 0; |
|
371 |
double dY = n[0] * h; |
|
308 |
|
|
309 |
// ============================================= |
|
310 |
// classifiable and NOT image legend |
|
372 | 311 |
|
373 |
double xl = (re.getX() + dX); |
|
374 |
double yl = (re.getY() + dY); |
|
375 |
if (layoutContext != null) { |
|
376 |
toFFrameText(layoutContext, layer.getName(), re, |
|
377 |
sizefont, xl, yl, h); |
|
312 |
if (cla_legend instanceof IClassifiedLegend) { |
|
313 |
|
|
314 |
IClassifiedLegend cli = (IClassifiedLegend) cla_legend; |
|
315 |
double dX = 0; |
|
316 |
double dY = n[0] * h; |
|
317 |
|
|
318 |
double xl = (re.getX() + dX); |
|
319 |
double yl = (re.getY() + dY); |
|
320 |
if (layoutContext != null) { |
|
321 |
toFFrameText(layoutContext, layer.getName(), re, |
|
322 |
sizefont, (xl - (re.getWidth() / 5)), yl, h); |
|
323 |
} else { |
|
324 |
drawNameLegend(g, layer.getName(), re, |
|
325 |
sizefont, (xl - (re.getWidth() / 5)), yl, h); |
|
326 |
} |
|
327 |
n[0]++; |
|
328 |
String[] descriptions = cli.getDescriptions(); |
|
329 |
ISymbol[] symbols = cli.getSymbols(); |
|
330 |
for (int j = 0; j < descriptions.length; j++) { |
|
331 |
dY = n[0] * h; |
|
332 |
|
|
333 |
xl = (re.getX() + dX); |
|
334 |
yl = (re.getY() + dY); |
|
335 |
|
|
336 |
String s = descriptions[j]; |
|
337 |
if (layoutContext != null) { |
|
338 |
toFFrameText(layoutContext, s, re, sizefont, xl, |
|
339 |
yl, h); |
|
340 |
} else { |
|
341 |
drawNameLegend(g, s, re, sizefont, xl, yl, |
|
342 |
h); |
|
343 |
} |
|
344 |
ISymbol fs2d = symbols[j]; |
|
345 |
if (layoutContext != null) { |
|
346 |
try { |
|
347 |
toFFrameSymbol(layoutContext, re, xl, yl, |
|
348 |
fs2d, sizefont, h, |
|
349 |
cla_layer.getShapeType()); |
|
350 |
} catch (ReadException e) { |
|
351 |
e.printStackTrace(); |
|
352 |
} |
|
353 |
} else { |
|
354 |
drawSymbolLegend(g, re, xl, yl, fs2d, |
|
355 |
sizefont, h); |
|
356 |
} |
|
357 |
n[0]++; |
|
358 |
} |
|
378 | 359 |
} else { |
379 |
drawNameLegend(g, layer.getName(), re, |
|
380 |
sizefont, xl, yl, h); |
|
360 |
double dX = 0; |
|
361 |
double dY = n[0] * h; |
|
362 |
|
|
363 |
double xl = (re.getX() + dX); |
|
364 |
double yl = (re.getY() + dY); |
|
365 |
if (layoutContext != null) { |
|
366 |
toFFrameText(layoutContext, layer.getName(), re, |
|
367 |
sizefont, xl, yl, h); |
|
368 |
} else { |
|
369 |
drawNameLegend(g, layer.getName(), re, |
|
370 |
sizefont, xl, yl, h); |
|
371 |
} |
|
372 |
// TO DO: CAMBIAR TO_DO ESTO PARA QUE ACEPTE ISYMBOL |
|
373 |
// TODO: comprovar que no es trenca res |
|
374 |
if (cla_legend != null) { |
|
375 |
ISymbol fs2d = cla_legend.getDefaultSymbol(); |
|
376 |
|
|
377 |
if (layoutContext != null) { |
|
378 |
try { |
|
379 |
toFFrameSymbol(layoutContext, re, xl, yl, |
|
380 |
fs2d, sizefont, h, |
|
381 |
cla_layer.getShapeType()); |
|
382 |
} catch (ReadException e) { |
|
383 |
e.printStackTrace(); |
|
384 |
} |
|
385 |
} else { |
|
386 |
drawSymbolLegend(g, re, xl, yl, fs2d, |
|
387 |
sizefont, h); |
|
388 |
} |
|
389 |
} |
|
390 |
n[0]++; |
|
381 | 391 |
} |
382 |
n[0]++; |
|
392 |
|
|
393 |
// classifiable and NOT image legend (end) |
|
394 |
// ============================================= |
|
395 |
|
|
383 | 396 |
} |
397 |
|
|
398 |
} else { |
|
399 |
// =================================== |
|
400 |
// NOT classifiable |
|
401 |
double dX = 0; |
|
402 |
double dY = n[0] * h; |
|
403 |
double xl = (re.getX() + dX); |
|
404 |
double yl = (re.getY() + dY); |
|
405 |
if (layoutContext != null) { |
|
406 |
toFFrameText(layoutContext, layer.getName(), re, sizefont, xl, yl, h); |
|
407 |
} else { |
|
408 |
drawNameLegend(g, layer.getName(), re, sizefont, xl, yl, h); |
|
409 |
} |
|
410 |
n[0]++; |
|
411 |
// NOT classifiable (end) |
|
412 |
// =================================== |
|
413 |
} |
|
414 |
} |
|
384 | 415 |
} |
385 | 416 |
} |
386 | 417 |
} |
Also available in: Unified diff