Mercurial > mxd2map
diff src/java/de/intevation/mxd/reader/TextSymbolReader.java @ 317:5a2b5bc066eb
Implement Label Styles and Labels with background
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Thu, 20 Sep 2012 12:55:21 +0200 |
parents | 2cb2f26d0d54 |
children | a46adb3697fa |
line wrap: on
line diff
--- a/src/java/de/intevation/mxd/reader/TextSymbolReader.java Mon Sep 17 17:10:44 2012 +0200 +++ b/src/java/de/intevation/mxd/reader/TextSymbolReader.java Thu Sep 20 12:55:21 2012 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 by Intevation GmbH, Germany <info@intevation.de> + * Copyright (c) 2012 by Intevation GmbH, Germany <info@intevation.de> * * This file is part of MXD2map. * @@ -15,6 +15,7 @@ * Raimund Renkert <raimund.renkert@intevation.de> * Bjoern Schilberg <bjoern.schilberg@intevation.de> * Stephan Holl <stephan.holl@intevation.de> + * Andre Heinecke <aheinecke@intevation.de> */ package de.intevation.mxd.reader; @@ -27,6 +28,9 @@ import com.esri.arcgis.display.TextSymbol; import com.esri.arcgis.display.IRgbColor; import com.esri.arcgis.display.RgbColor; +import com.esri.arcgis.display.LineCallout; +import com.esri.arcgis.display.ITextBackground; +import com.esri.arcgis.display.IColor; import com.esri.arcgis.support.ms.stdole.Font; import org.w3c.dom.Element; @@ -119,8 +123,8 @@ String.valueOf(symbol.getSize())); } catch(IOException ioe) { - logger.warn("Could not read size. Setting size to 1."); - symbolElement.setAttribute("size", "1"); + logger.warn("Could not read size. Setting size to 10."); + symbolElement.setAttribute("size", "10"); } try { @@ -158,6 +162,45 @@ symbolElement.setAttribute("font", "FreeSans"); } symbolElement.setAttribute("type", "text"); + + // Background + try { + ITextBackground background = symbol.getBackground(); + if (background != null) { + if (background instanceof LineCallout) { + LineCallout lc = (LineCallout)background; + IColor pcolor = lc.getBorder().getColor(); + if(pcolor instanceof IRgbColor) { + IRgbColor color = (IRgbColor)pcolor; + Color c = new Color ( + color.getRed(), + color.getGreen(), + color.getBlue()); + symbolElement.setAttribute("bg_color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("bg_transparency", + String.valueOf(color.getTransparency())); + } + else { + RgbColor col = new RgbColor(); + col.setRGB(pcolor.getRGB()); + Color c = new Color ( + col.getRed(), + col.getGreen(), + col.getBlue()); + symbolElement.setAttribute("bg_color", String.valueOf(c.getRGB())); + symbolElement.setAttribute("bg_transparency", + String.valueOf(col.getTransparency())); + } + } else { + logger.warn("Unhandled background of class: " + + background.getClass().toString()); + } + } + } + catch(Exception e) { + logger.warn("Could not read backgroundcolor."); + } + return symbolElement; } }