Mercurial > mxd2map
comparison src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java @ 337:ee77a3ae0201
* src/java/de/intevation/mxd/reader/UniqueValueRendererReader.java:
Log as UniqueValueRendererReader, add support for default class,
Fix splitting of values.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 06 Nov 2012 12:05:26 +0100 |
parents | df4e0946ef02 |
children |
comparison
equal
deleted
inserted
replaced
336:a46adb3697fa | 337:ee77a3ae0201 |
---|---|
40 | 40 |
41 /** | 41 /** |
42 * The logger. | 42 * The logger. |
43 */ | 43 */ |
44 private static final Logger logger = | 44 private static final Logger logger = |
45 Logger.getLogger(FeatureLayerReader.class); | 45 Logger.getLogger(UniqueValueRendererReader.class); |
46 | 46 |
47 /** | 47 /** |
48 * Private Member. | 48 * Private Member. |
49 */ | 49 */ |
50 private UniqueValueRenderer renderer; | 50 private UniqueValueRenderer renderer; |
89 * Reads the renderer attributes. | 89 * Reads the renderer attributes. |
90 * | 90 * |
91 * @return The parent XML node. | 91 * @return The parent XML node. |
92 */ | 92 */ |
93 public Element read() { | 93 public Element read() { |
94 logger.debug("read()"); | |
95 int count = 0; | 94 int count = 0; |
96 try { | 95 try { |
97 count = renderer.getClassCount(); | 96 count = renderer.getClassCount(); |
98 if(renderer.isUseDefaultSymbol()) { | 97 logger.debug("Renderer with " + count + " classes."); |
99 count--; | |
100 } | |
101 } | 98 } |
102 catch(IOException ioe) { | 99 catch(IOException ioe) { |
103 logger.error( | 100 logger.error( |
104 "Could not read class count."+ | 101 "Could not read class count."+ |
105 " Stopped reading renderer."); | 102 " Stopped reading renderer."); |
106 return layer; | 103 return layer; |
107 } | 104 } |
108 for(int i = 0; i < count; i++) { | 105 for(int i = 0; i < count; i++) { |
109 Element rendererElement = util.addRenderer(layer); | 106 Element rendererElement = util.addRenderer(layer); |
107 ISymbol sym; | |
108 try { | |
109 if (!renderer.isUseDefaultSymbol() || i != count - 1) { | |
110 // When a default symbol exists the last class is the default class | |
111 String value = renderer.getValue(i); | |
112 String fieldSep = renderer.getFieldDelimiter(); | |
113 if(value.indexOf(fieldSep) > 0) { | |
114 int j = 0; | |
115 while(value.indexOf(fieldSep) > 0) { | |
116 String v = value.substring(0, value.indexOf(fieldSep)); | |
117 rendererElement.setAttribute("value_" + j, v); | |
118 value = value.substring( | |
119 value.indexOf(fieldSep) + fieldSep.length(), | |
120 value.length()); | |
121 j++; | |
122 } | |
123 rendererElement.setAttribute("value_" + j, value); | |
124 } | |
125 else { | |
126 rendererElement.setAttribute("value", value); | |
127 } | |
110 | 128 |
111 try { | 129 value = renderer.getValue(i); |
112 String value = renderer.getValue(i); | 130 rendererElement.setAttribute("name", renderer.esri_getClass(i)); |
113 value = value.replaceAll(", ", ","); | 131 rendererElement.setAttribute("description", |
114 if(value.indexOf(",") > 0) { | 132 renderer.getDescription(value)); |
115 int j = 0; | 133 |
116 while(value.indexOf(",") > 0) { | 134 rendererElement.setAttribute("label", renderer.getLabel(value)); |
117 String v = value.substring(0, value.indexOf(",")); | 135 rendererElement.setAttribute( |
118 rendererElement.setAttribute("value_" + j, v); | 136 "field_count", |
119 value = value.substring( | 137 String.valueOf(renderer.getFieldCount())); |
120 value.indexOf(",") + 1, | 138 for(int j = 0; j < renderer.getFieldCount(); j++) { |
121 value.length()); | 139 rendererElement.setAttribute( |
122 j++; | 140 "expression_field_" + j, |
141 renderer.getField(j)); | |
123 } | 142 } |
124 rendererElement.setAttribute("value_" + j, value); | 143 rendererElement.setAttribute("expression_operator", "="); |
144 sym = renderer.getSymbol(value); | |
145 } else { | |
146 sym = renderer.getDefaultSymbol(); | |
125 } | 147 } |
126 else { | |
127 rendererElement.setAttribute("value", value); | |
128 } | |
129 | |
130 value = renderer.getValue(i); | |
131 rendererElement.setAttribute("name", renderer.esri_getClass(i)); | |
132 rendererElement.setAttribute("description", | |
133 renderer.getDescription(value)); | |
134 | |
135 rendererElement.setAttribute("label", renderer.getLabel(value)); | |
136 rendererElement.setAttribute( | |
137 "field_count", | |
138 String.valueOf(renderer.getFieldCount())); | |
139 for(int j = 0; j < renderer.getFieldCount(); j++) { | |
140 rendererElement.setAttribute( | |
141 "expression_field_" + j, | |
142 renderer.getField(j)); | |
143 } | |
144 rendererElement.setAttribute("expression_operator", "="); | |
145 | |
146 ISymbol sym = renderer.getSymbol(value); | |
147 MarkerSymbolReader markerReader = new MarkerSymbolReader(); | 148 MarkerSymbolReader markerReader = new MarkerSymbolReader(); |
148 LineSymbolReader lineReader = new LineSymbolReader(); | 149 LineSymbolReader lineReader = new LineSymbolReader(); |
149 FillSymbolReader fillReader = new FillSymbolReader(); | 150 FillSymbolReader fillReader = new FillSymbolReader(); |
150 if(markerReader.canRead(sym)) { | 151 if(markerReader.canRead(sym)) { |
151 markerReader.setSymbol(sym); | 152 markerReader.setSymbol(sym); |