Revision 32367 branches/v2_0_0_prep/libraries/org.gvsig.arcims/src/org/gvsig/remoteclient/arcims/styling/symbols/ArcImsFSymbolFactory.java
ArcImsFSymbolFactory.java | ||
---|---|---|
34 | 34 |
|
35 | 35 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
36 | 36 |
import org.gvsig.remoteclient.arcims.utils.ArcImsDownloadUtils; |
37 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.FConstant; |
|
37 | 38 |
|
38 | 39 |
import java.awt.BasicStroke; |
39 | 40 |
import java.awt.Color; |
... | ... | |
93 | 94 |
* @return |
94 | 95 |
*/ |
95 | 96 |
protected static ISymbol getFSymbol(SimpleMarkerSymbol simb) { |
96 |
Color mcolor = SymbolUtils.getColor(simb.getColor(), 1); |
|
97 |
int pointWidth = Integer.parseInt(simb.getWidth()); |
|
98 |
int pointStyle = getPointType(simb.getType()); |
|
99 |
|
|
100 |
ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_POINT, mcolor); |
|
101 |
mSimb.setSizeInPixels(true); |
|
102 |
mSimb.setSize(pointWidth); |
|
103 |
mSimb.setStyle(pointStyle); |
|
104 |
logger.info("Getting ArcIMS simple point symbol"); |
|
105 |
|
|
106 |
return mSimb; |
|
97 |
// Color mcolor = SymbolUtils.getColor(simb.getColor(), 1); |
|
98 |
// int pointWidth = Integer.parseInt(simb.getWidth()); |
|
99 |
// int pointStyle = getPointType(simb.getType()); |
|
100 |
// |
|
101 |
// ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_POINT, mcolor); |
|
102 |
// mSimb.setSizeInPixels(true); |
|
103 |
// mSimb.setSize(pointWidth); |
|
104 |
// mSimb.setStyle(pointStyle); |
|
105 |
// logger.info("Getting ArcIMS simple point symbol"); |
|
106 |
// |
|
107 |
// return mSimb; |
|
108 |
return null; |
|
107 | 109 |
} |
108 | 110 |
|
109 | 111 |
/** |
... | ... | |
112 | 114 |
* @return |
113 | 115 |
*/ |
114 | 116 |
protected static ISymbol getFSymbol(RasterMarkerSymbol symb) { |
115 |
String surl = symb.getUrl(); |
|
116 |
|
|
117 |
// Get the icon size |
|
118 |
float size = 0; |
|
119 |
|
|
120 |
if (symb.getSize() != null) { |
|
121 |
String[] tams = symb.getSize().split(","); |
|
122 |
int ntams = tams.length; |
|
123 |
|
|
124 |
if (ntams != 0) { |
|
125 |
for (int i = 0; i < ntams; i++) |
|
126 |
size += Float.parseFloat(tams[i]); // Sums different sizes |
|
127 |
|
|
128 |
size = size / ntams; // Get the mean |
|
129 |
} |
|
130 |
} else { |
|
131 |
size = 15; // Default size |
|
132 |
} |
|
133 |
|
|
134 |
// Get the icon file |
|
135 |
File img = getIconFile(surl); |
|
136 |
|
|
137 |
// If is an image, we build the symbol |
|
138 |
ImageFilter filter = new ImageFilter(); |
|
139 |
|
|
140 |
if (filter.accept(img)) { |
|
141 |
ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
142 |
mSimb.setStyle(FStyle2D.SYMBOL_STYLE_MARKER_IMAGEN); |
|
143 |
|
|
144 |
URI theUri = img.toURI(); |
|
145 |
mSimb.setIconURI(theUri); |
|
146 |
mSimb.setSizeInPixels(true); |
|
147 |
mSimb.setSize((int) size); |
|
148 |
|
|
149 |
logger.info("Getting ArcIMS raster marker point symbol"); |
|
150 |
|
|
151 |
return mSimb; |
|
152 |
} else { |
|
153 |
logger.info("Getting random point symbol"); |
|
154 |
|
|
155 |
return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
156 |
} |
|
117 |
// String surl = symb.getUrl(); |
|
118 |
// |
|
119 |
// // Get the icon size |
|
120 |
// float size = 0; |
|
121 |
// |
|
122 |
// if (symb.getSize() != null) { |
|
123 |
// String[] tams = symb.getSize().split(","); |
|
124 |
// int ntams = tams.length; |
|
125 |
// |
|
126 |
// if (ntams != 0) { |
|
127 |
// for (int i = 0; i < ntams; i++) |
|
128 |
// size += Float.parseFloat(tams[i]); // Sums different sizes |
|
129 |
// |
|
130 |
// size = size / ntams; // Get the mean |
|
131 |
// } |
|
132 |
// } else { |
|
133 |
// size = 15; // Default size |
|
134 |
// } |
|
135 |
// |
|
136 |
// // Get the icon file |
|
137 |
// File img = getIconFile(surl); |
|
138 |
// |
|
139 |
// // If is an image, we build the symbol |
|
140 |
// ImageFilter filter = new ImageFilter(); |
|
141 |
// |
|
142 |
// if (filter.accept(img)) { |
|
143 |
// ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
144 |
// mSimb.setStyle(FStyle2D.SYMBOL_STYLE_MARKER_IMAGEN); |
|
145 |
// |
|
146 |
// URI theUri = img.toURI(); |
|
147 |
// mSimb.setIconURI(theUri); |
|
148 |
// mSimb.setSizeInPixels(true); |
|
149 |
// mSimb.setSize((int) size); |
|
150 |
// |
|
151 |
// logger.info("Getting ArcIMS raster marker point symbol"); |
|
152 |
// |
|
153 |
// return mSimb; |
|
154 |
// } else { |
|
155 |
// logger.info("Getting random point symbol"); |
|
156 |
// |
|
157 |
// return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
158 |
// } |
|
159 |
return null; |
|
157 | 160 |
} |
158 | 161 |
|
159 | 162 |
/** |
... | ... | |
162 | 165 |
* @return |
163 | 166 |
*/ |
164 | 167 |
protected static ISymbol getFSymbol(SimpleLineSymbol simb) { |
165 |
String sTrans = simb.getTransparency(); |
|
166 |
|
|
167 |
if (ds != '.') { |
|
168 |
sTrans = sTrans.replace(ds, '.'); |
|
169 |
} |
|
170 |
|
|
171 |
float trans = Float.parseFloat(sTrans); |
|
172 |
|
|
173 |
Color mcolor = SymbolUtils.getColor(simb.getColor(), trans); |
|
174 |
int lineWidth = Integer.parseInt(simb.getWidth()); |
|
175 |
int intCapType = getCapType(simb.getCaptype()); |
|
176 |
int intJoin = getJoinType(simb.getJointype()); |
|
177 |
String linePattern = getLinePattern(simb.getType()); |
|
178 |
|
|
179 |
BasicStroke bStroke = new BasicStroke(lineWidth, intCapType, intJoin, |
|
180 |
1.0f, ISymbol.toArray(linePattern, lineWidth), 0); |
|
181 |
|
|
182 |
ISymbol theSymbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE, mcolor); |
|
183 |
theSymbol.setSizeInPixels(true); |
|
184 |
theSymbol.setSize(Integer.parseInt(simb.getWidth())); |
|
185 |
theSymbol.setSizeInPixels(true); |
|
186 |
theSymbol.setStroke(bStroke); |
|
187 |
|
|
188 |
logger.info("Getting ArcIMS simple line symbol"); |
|
189 |
|
|
190 |
return theSymbol; |
|
168 |
// String sTrans = simb.getTransparency(); |
|
169 |
// |
|
170 |
// if (ds != '.') { |
|
171 |
// sTrans = sTrans.replace(ds, '.'); |
|
172 |
// } |
|
173 |
// |
|
174 |
// float trans = Float.parseFloat(sTrans); |
|
175 |
// |
|
176 |
// Color mcolor = SymbolUtils.getColor(simb.getColor(), trans); |
|
177 |
// int lineWidth = Integer.parseInt(simb.getWidth()); |
|
178 |
// int intCapType = getCapType(simb.getCaptype()); |
|
179 |
// int intJoin = getJoinType(simb.getJointype()); |
|
180 |
// String linePattern = getLinePattern(simb.getType()); |
|
181 |
// |
|
182 |
// BasicStroke bStroke = new BasicStroke(lineWidth, intCapType, intJoin, |
|
183 |
// 1.0f, ISymbol.toArray(linePattern, lineWidth), 0); |
|
184 |
// |
|
185 |
// ISymbol theSymbol = new FSymbol(FConstant.SYMBOL_TYPE_LINE, mcolor); |
|
186 |
// theSymbol.setSizeInPixels(true); |
|
187 |
// theSymbol.setSize(Integer.parseInt(simb.getWidth())); |
|
188 |
// theSymbol.setSizeInPixels(true); |
|
189 |
// theSymbol.setStroke(bStroke); |
|
190 |
// |
|
191 |
// logger.info("Getting ArcIMS simple line symbol"); |
|
192 |
// |
|
193 |
// return theSymbol; |
|
194 |
return null; |
|
191 | 195 |
} |
192 | 196 |
|
193 | 197 |
/** |
... | ... | |
198 | 202 |
* @return |
199 | 203 |
*/ |
200 | 204 |
protected static ISymbol getFSymbol(HashLineSymbol symbol) { |
201 |
SimpleLineSymbol line = new SimpleLineSymbol(); |
|
202 |
line.setColor(symbol.getColor()); |
|
203 |
line.setWidth(symbol.getLinethickness()); |
|
204 |
line.setType(SymbolUtils.LINE_TYPE_SOLID); |
|
205 |
|
|
206 |
logger.info("Getting ArcIMS hashline as a simple line symbol"); |
|
207 |
|
|
208 |
return line.getFSymbol(); |
|
205 |
// SimpleLineSymbol line = new SimpleLineSymbol(); |
|
206 |
// line.setColor(symbol.getColor()); |
|
207 |
// line.setWidth(symbol.getLinethickness()); |
|
208 |
// line.setType(SymbolUtils.LINE_TYPE_SOLID); |
|
209 |
// |
|
210 |
// logger.info("Getting ArcIMS hashline as a simple line symbol"); |
|
211 |
// |
|
212 |
// return line.getFSymbol(); |
|
213 |
return null; |
|
209 | 214 |
} |
210 | 215 |
|
211 | 216 |
/** |
... | ... | |
214 | 219 |
* @return |
215 | 220 |
*/ |
216 | 221 |
protected static ISymbol getFSymbol(SimplePolygonSymbol simb) { |
217 |
String sTrans = simb.getFilltransparency(); |
|
218 |
|
|
219 |
if (ds != '.') { |
|
220 |
sTrans = sTrans.replace(ds, '.'); |
|
221 |
} |
|
222 |
|
|
223 |
float trans = Float.parseFloat(sTrans); |
|
224 |
|
|
225 |
Color fColor = SymbolUtils.getColor(simb.getFillcolor(), trans); |
|
226 |
ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_FILL, fColor); |
|
227 |
|
|
228 |
//Set the type of fill |
|
229 |
int type = getFillStyle(simb.getFilltype()); |
|
230 |
|
|
231 |
switch (type) { |
|
232 |
case FConstant.SYMBOL_STYLE_FILL_GRAYFILL: |
|
233 |
mSimb.setColor(getGray(fColor)); |
|
234 |
|
|
235 |
break; |
|
236 |
|
|
237 |
case FConstant.SYMBOL_STYLE_FILL_LIGHTGRAYFILL: |
|
238 |
mSimb.setColor(getLightGray(fColor)); |
|
239 |
|
|
240 |
break; |
|
241 |
|
|
242 |
case FConstant.SYMBOL_STYLE_FILL_DARKGRAYFILL: |
|
243 |
mSimb.setColor(getDarkGray(fColor)); |
|
244 |
|
|
245 |
break; |
|
246 |
|
|
247 |
default: |
|
248 |
|
|
249 |
Paint fill = createPatternFill(type, fColor); |
|
250 |
mSimb.setFill(fill); |
|
251 |
} |
|
252 |
|
|
253 |
if (simb.isHasBoundary()) { |
|
254 |
ISymbol bSimb = simb.getBoundary().getFSymbol(); |
|
255 |
|
|
256 |
mSimb.setOutlined(true); |
|
257 |
mSimb.setOutlineColor(bSimb.getColor()); |
|
258 |
mSimb.setStroke(bSimb.getStroke()); |
|
259 |
|
|
260 |
int mStyle = getFillStyle(simb.getFilltype()); |
|
261 |
mSimb.setStyle(mStyle); |
|
262 |
} |
|
263 |
|
|
264 |
logger.info("Getting ArcIMS simple polygon symbol"); |
|
265 |
|
|
266 |
return mSimb; |
|
222 |
// String sTrans = simb.getFilltransparency(); |
|
223 |
// |
|
224 |
// if (ds != '.') { |
|
225 |
// sTrans = sTrans.replace(ds, '.'); |
|
226 |
// } |
|
227 |
// |
|
228 |
// float trans = Float.parseFloat(sTrans); |
|
229 |
// |
|
230 |
// Color fColor = SymbolUtils.getColor(simb.getFillcolor(), trans); |
|
231 |
// ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_FILL, fColor); |
|
232 |
// |
|
233 |
// //Set the type of fill |
|
234 |
// int type = getFillStyle(simb.getFilltype()); |
|
235 |
// |
|
236 |
// switch (type) { |
|
237 |
// case FConstant.SYMBOL_STYLE_FILL_GRAYFILL: |
|
238 |
// mSimb.setColor(getGray(fColor)); |
|
239 |
// |
|
240 |
// break; |
|
241 |
// |
|
242 |
// case FConstant.SYMBOL_STYLE_FILL_LIGHTGRAYFILL: |
|
243 |
// mSimb.setColor(getLightGray(fColor)); |
|
244 |
// |
|
245 |
// break; |
|
246 |
// |
|
247 |
// case FConstant.SYMBOL_STYLE_FILL_DARKGRAYFILL: |
|
248 |
// mSimb.setColor(getDarkGray(fColor)); |
|
249 |
// |
|
250 |
// break; |
|
251 |
// |
|
252 |
// default: |
|
253 |
// |
|
254 |
// Paint fill = createPatternFill(type, fColor); |
|
255 |
// mSimb.setFill(fill); |
|
256 |
// } |
|
257 |
// |
|
258 |
// if (simb.isHasBoundary()) { |
|
259 |
// ISymbol bSimb = simb.getBoundary().getFSymbol(); |
|
260 |
// |
|
261 |
// mSimb.setOutlined(true); |
|
262 |
// mSimb.setOutlineColor(bSimb.getColor()); |
|
263 |
// mSimb.setStroke(bSimb.getStroke()); |
|
264 |
// |
|
265 |
// int mStyle = getFillStyle(simb.getFilltype()); |
|
266 |
// mSimb.setStyle(mStyle); |
|
267 |
// } |
|
268 |
// |
|
269 |
// logger.info("Getting ArcIMS simple polygon symbol"); |
|
270 |
// |
|
271 |
// return mSimb; |
|
272 |
return null; |
|
267 | 273 |
} |
268 | 274 |
|
269 | 275 |
/** |
... | ... | |
274 | 280 |
* @return |
275 | 281 |
*/ |
276 | 282 |
protected static ISymbol getFSymbol(GradientFillSymbol simb) { |
277 |
String sTrans = simb.getTransparency(); |
|
278 |
|
|
279 |
if (ds != '.') { |
|
280 |
sTrans = sTrans.replace(ds, '.'); |
|
281 |
} |
|
282 |
|
|
283 |
float trans = Float.parseFloat(sTrans); |
|
284 |
|
|
285 |
Color startColor = SymbolUtils.getColor(simb.getStartcolor(), trans); |
|
286 |
Color finishColor = SymbolUtils.getColor(simb.getFinishcolor(), trans); |
|
287 |
Color avgColor = mixColors(startColor, finishColor); |
|
288 |
|
|
289 |
ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_FILL, avgColor); |
|
290 |
mSimb.setOutlineColor(avgColor.darker()); |
|
291 |
|
|
292 |
//Until gvSIG supports gradients, this code is useless |
|
293 |
/* |
|
294 |
int type = getFillStyle(simb.getType()); |
|
295 |
|
|
296 |
Point2D startP2D = null; |
|
297 |
Point2D finishP2D = null; |
|
298 |
|
|
299 |
double ratio = 150; |
|
300 |
|
|
301 |
switch (type) { |
|
302 |
case FConstant.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL: |
|
303 |
startP2D = new Point2D.Double(0.0*ratio,0.0*ratio); |
|
304 |
finishP2D = new Point2D.Double(1.0*ratio,1.0*ratio); |
|
305 |
break; |
|
306 |
case FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL: |
|
307 |
startP2D = new Point2D.Double(0.0*ratio,1.0*ratio); |
|
308 |
finishP2D = new Point2D.Double(1.0*ratio,0.0*ratio); |
|
309 |
break; |
|
310 |
case FConstant.SYMBOL_STYLE_FILL_VERTICAL: |
|
311 |
startP2D = new Point2D.Double(0.5*ratio,0.0*ratio); |
|
312 |
finishP2D = new Point2D.Double(0.5*ratio,1.0*ratio); |
|
313 |
break; |
|
314 |
case FConstant.SYMBOL_STYLE_FILL_HORIZONTAL: |
|
315 |
startP2D = new Point2D.Double(0.0*ratio,0.5*ratio); |
|
316 |
finishP2D = new Point2D.Double(1.0*ratio,0.5*ratio); |
|
317 |
break; |
|
318 |
} |
|
319 |
|
|
320 |
//Set the paint |
|
321 |
mSimb.setFill((Paint) new GradientPaint(startP2D,startColor,finishP2D,finishColor)); |
|
322 |
//Remove the outline |
|
323 |
mSimb.setOutlined(false); |
|
324 |
*/ |
|
325 |
logger.info("Getting ArcIMS gradient fill as a simple polygon symbol"); |
|
326 |
|
|
327 |
return mSimb; |
|
283 |
// String sTrans = simb.getTransparency(); |
|
284 |
// |
|
285 |
// if (ds != '.') { |
|
286 |
// sTrans = sTrans.replace(ds, '.'); |
|
287 |
// } |
|
288 |
// |
|
289 |
// float trans = Float.parseFloat(sTrans); |
|
290 |
// |
|
291 |
// Color startColor = SymbolUtils.getColor(simb.getStartcolor(), trans); |
|
292 |
// Color finishColor = SymbolUtils.getColor(simb.getFinishcolor(), trans); |
|
293 |
// Color avgColor = mixColors(startColor, finishColor); |
|
294 |
// |
|
295 |
// ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_FILL, avgColor); |
|
296 |
// mSimb.setOutlineColor(avgColor.darker()); |
|
297 |
// |
|
298 |
// //Until gvSIG supports gradients, this code is useless |
|
299 |
// /* |
|
300 |
// int type = getFillStyle(simb.getType()); |
|
301 |
// |
|
302 |
// Point2D startP2D = null; |
|
303 |
// Point2D finishP2D = null; |
|
304 |
// |
|
305 |
// double ratio = 150; |
|
306 |
// |
|
307 |
// switch (type) { |
|
308 |
// case FConstant.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL: |
|
309 |
// startP2D = new Point2D.Double(0.0*ratio,0.0*ratio); |
|
310 |
// finishP2D = new Point2D.Double(1.0*ratio,1.0*ratio); |
|
311 |
// break; |
|
312 |
// case FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL: |
|
313 |
// startP2D = new Point2D.Double(0.0*ratio,1.0*ratio); |
|
314 |
// finishP2D = new Point2D.Double(1.0*ratio,0.0*ratio); |
|
315 |
// break; |
|
316 |
// case FConstant.SYMBOL_STYLE_FILL_VERTICAL: |
|
317 |
// startP2D = new Point2D.Double(0.5*ratio,0.0*ratio); |
|
318 |
// finishP2D = new Point2D.Double(0.5*ratio,1.0*ratio); |
|
319 |
// break; |
|
320 |
// case FConstant.SYMBOL_STYLE_FILL_HORIZONTAL: |
|
321 |
// startP2D = new Point2D.Double(0.0*ratio,0.5*ratio); |
|
322 |
// finishP2D = new Point2D.Double(1.0*ratio,0.5*ratio); |
|
323 |
// break; |
|
324 |
// } |
|
325 |
// |
|
326 |
// //Set the paint |
|
327 |
// mSimb.setFill((Paint) new GradientPaint(startP2D,startColor,finishP2D,finishColor)); |
|
328 |
// //Remove the outline |
|
329 |
// mSimb.setOutlined(false); |
|
330 |
// */ |
|
331 |
// logger.info("Getting ArcIMS gradient fill as a simple polygon symbol"); |
|
332 |
// |
|
333 |
// return mSimb; |
|
334 |
return null; |
|
328 | 335 |
} |
329 | 336 |
|
330 | 337 |
protected static ISymbol getFSymbol(RasterFillSymbol simb) { |
331 | 338 |
//Get the icon file |
332 |
String surl = simb.getUrl(); |
|
333 |
File img = getIconFile(surl); |
|
334 |
|
|
335 |
//Get the transparency |
|
336 |
String sTrans = simb.getTransparency(); |
|
337 |
|
|
338 |
if (ds != '.') { |
|
339 |
sTrans = sTrans.replace(ds, '.'); |
|
340 |
} |
|
341 |
|
|
342 |
float trans = Float.parseFloat(sTrans); |
|
343 |
Color fColor = new Color(1.0f, 1.0f, 1.0f, trans); |
|
344 |
|
|
345 |
ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_FILL, fColor); |
|
346 |
|
|
347 |
// If is an image, we build the paint |
|
348 |
ImageFilter filter = new ImageFilter(); |
|
349 |
|
|
350 |
if (filter.accept(img)) { |
|
351 |
//Creates the BufferedImage object |
|
352 |
BufferedImage bi; |
|
353 |
ImageIcon icon = new ImageIcon(img.getAbsolutePath()); |
|
354 |
int w = icon.getIconWidth(); |
|
355 |
int h = icon.getIconHeight(); |
|
356 |
bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); |
|
357 |
|
|
358 |
// Draw the image in the BufferedImage object |
|
359 |
Graphics2D big = createG2(fColor, bi); |
|
360 |
big.drawImage(icon.getImage(), 0, 0, null); |
|
361 |
|
|
362 |
Rectangle2D rProv = new Rectangle(); |
|
363 |
rProv.setFrame(0, 0, w, h); |
|
364 |
|
|
365 |
mSimb.setFill(new TexturePaint(bi, rProv)); |
|
366 |
mSimb.setOutlined(false); |
|
367 |
} |
|
368 |
|
|
369 |
logger.info("Getting ArcIMS raster fill symbol"); |
|
370 |
|
|
371 |
return mSimb; |
|
339 |
// String surl = simb.getUrl(); |
|
340 |
// File img = getIconFile(surl); |
|
341 |
// |
|
342 |
// //Get the transparency |
|
343 |
// String sTrans = simb.getTransparency(); |
|
344 |
// |
|
345 |
// if (ds != '.') { |
|
346 |
// sTrans = sTrans.replace(ds, '.'); |
|
347 |
// } |
|
348 |
// |
|
349 |
// float trans = Float.parseFloat(sTrans); |
|
350 |
// Color fColor = new Color(1.0f, 1.0f, 1.0f, trans); |
|
351 |
// |
|
352 |
// ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_FILL, fColor); |
|
353 |
// |
|
354 |
// // If is an image, we build the paint |
|
355 |
// ImageFilter filter = new ImageFilter(); |
|
356 |
// |
|
357 |
// if (filter.accept(img)) { |
|
358 |
// //Creates the BufferedImage object |
|
359 |
// BufferedImage bi; |
|
360 |
// ImageIcon icon = new ImageIcon(img.getAbsolutePath()); |
|
361 |
// int w = icon.getIconWidth(); |
|
362 |
// int h = icon.getIconHeight(); |
|
363 |
// bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); |
|
364 |
// |
|
365 |
// // Draw the image in the BufferedImage object |
|
366 |
// Graphics2D big = createG2(fColor, bi); |
|
367 |
// big.drawImage(icon.getImage(), 0, 0, null); |
|
368 |
// |
|
369 |
// Rectangle2D rProv = new Rectangle(); |
|
370 |
// rProv.setFrame(0, 0, w, h); |
|
371 |
// |
|
372 |
// mSimb.setFill(new TexturePaint(bi, rProv)); |
|
373 |
// mSimb.setOutlined(false); |
|
374 |
// } |
|
375 |
// |
|
376 |
// logger.info("Getting ArcIMS raster fill symbol"); |
|
377 |
// |
|
378 |
// return mSimb; |
|
379 |
return null; |
|
372 | 380 |
} |
373 | 381 |
|
374 | 382 |
/** |
... | ... | |
377 | 385 |
* @return |
378 | 386 |
*/ |
379 | 387 |
protected static ISymbol getFSymbol(TextSymbol symb) { |
380 |
ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
381 |
|
|
382 |
String font = symb.getFont(); |
|
383 |
int fontSize = Integer.parseInt(symb.getFontSize()); |
|
384 |
Color fontColor = SymbolUtils.getColor(symb.getFontColor(), 1); |
|
385 |
int fontStyle = SymbolUtils.getFontStyle(symb.getFontStyle()); |
|
386 |
|
|
387 |
mSimb.setFont(new Font(font, fontStyle, fontSize)); |
|
388 |
mSimb.setFontColor(fontColor); |
|
389 |
mSimb.setFontSize(fontSize); |
|
390 |
|
|
391 |
logger.info( |
|
392 |
"Getting ArcIMS TextSymbol as point symbol with Font properties"); |
|
393 |
|
|
394 |
return mSimb; |
|
388 |
// ISymbol mSimb = new FSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
389 |
// |
|
390 |
// String font = symb.getFont(); |
|
391 |
// int fontSize = Integer.parseInt(symb.getFontSize()); |
|
392 |
// Color fontColor = SymbolUtils.getColor(symb.getFontColor(), 1); |
|
393 |
// int fontStyle = SymbolUtils.getFontStyle(symb.getFontStyle()); |
|
394 |
// |
|
395 |
// mSimb.setFont(new Font(font, fontStyle, fontSize)); |
|
396 |
// mSimb.setFontColor(fontColor); |
|
397 |
// mSimb.setFontSize(fontSize); |
|
398 |
// |
|
399 |
// logger.info( |
|
400 |
// "Getting ArcIMS TextSymbol as point symbol with Font properties"); |
|
401 |
// |
|
402 |
// return mSimb; |
|
403 |
return null; |
|
395 | 404 |
} |
396 | 405 |
|
397 | 406 |
/** |
... | ... | |
401 | 410 |
protected static ISymbol getFSymbol(TextMarkerSymbol symbol) { |
402 | 411 |
logger.info("Getting ArcIMS TextSymbol as a random point symbol"); |
403 | 412 |
|
404 |
return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
413 |
// return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
414 |
return null; |
|
405 | 415 |
} |
406 | 416 |
|
407 | 417 |
protected static ISymbol getFSymbol(TrueTypeMarkerSymbol symbol) { |
408 | 418 |
logger.info("Getting ArcIMS TextSymbol as a random point symbol"); |
409 | 419 |
|
410 |
return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
420 |
// return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT); |
|
421 |
return null; |
|
411 | 422 |
} |
412 | 423 |
|
413 | 424 |
/** |
... | ... | |
421 | 432 |
return null; |
422 | 433 |
} |
423 | 434 |
|
424 |
public static ISymbol getDefaultFSymbol(int featType) { |
|
425 |
ISymbol mSimb = null; |
|
426 |
int colorind = (int) (System.currentTimeMillis() % ((long) initialColors.size())); |
|
427 |
Color randomColor = (Color) initialColors.get(colorind); |
|
428 |
mSimb = new FSymbol(featType, randomColor); |
|
429 |
mSimb.setFont(new Font("Arial", Font.PLAIN, 10)); |
|
430 |
mSimb.setFontColor(Color.BLACK); |
|
431 |
mSimb.setSize(10); |
|
432 |
mSimb.setSizeInPixels(true); |
|
433 |
|
|
434 |
return mSimb; |
|
435 |
} |
|
436 |
|
|
437 |
/* |
|
438 |
* Supporting private methods |
|
439 |
*/ |
|
440 |
|
|
441 |
/** |
|
442 |
* Gets the correct constant for a ArcIMS point type |
|
443 |
* @param type |
|
444 |
* @return |
|
445 |
*/ |
|
446 |
private static int getPointType(String type) { |
|
447 |
//Default symbol, as gvsig doesn't paints stars |
|
448 |
int mtype = FConstant.SYMBOL_STYLE_MARKER_CIRCLE; |
|
449 |
|
|
450 |
if (type.equals(SymbolUtils.POINT_TYPE_CIRCLE)) { |
|
451 |
mtype = FConstant.SYMBOL_STYLE_MARKER_CIRCLE; |
|
452 |
} else if (type.equals(SymbolUtils.POINT_TYPE_CROSS)) { |
|
453 |
mtype = FConstant.SYMBOL_STYLE_MARKER_CROSS; |
|
454 |
} else if (type.equals(SymbolUtils.POINT_TYPE_SQUARE)) { |
|
455 |
mtype = FConstant.SYMBOL_STYLE_MARKER_SQUARE; |
|
456 |
} else if (type.equals(SymbolUtils.POINT_TYPE_TRIANGLE)) { |
|
457 |
mtype = FConstant.SYMBOL_STYLE_MARKER_TRIANGLE; |
|
458 |
} |
|
459 |
|
|
460 |
return mtype; |
|
461 |
} |
|
462 |
|
|
463 |
/** |
|
464 |
* Method to translate from ArcIMS type to a string of values that will be parsed |
|
465 |
* @return a correct string for the line type definition as "1,3" for dots |
|
466 |
*/ |
|
467 |
private static String getLinePattern(String type) { |
|
468 |
return (String) SymbolUtils.LINE_TYPES.get(type); |
|
469 |
} |
|
470 |
|
|
471 |
/** |
|
472 |
* Translates ArcIMS line end style into BasicStroke line end constants |
|
473 |
* @see java.awt.BasicStroke#getEndCap() |
|
474 |
* @param captype |
|
475 |
* @return |
|
476 |
*/ |
|
477 |
private static int getCapType(String captype) { |
|
478 |
int resp = BasicStroke.CAP_BUTT; |
|
479 |
|
|
480 |
if (captype.equals(SymbolUtils.CAP_TYPE_BUTT)) { |
|
481 |
resp = BasicStroke.CAP_BUTT; |
|
482 |
} else if (captype.equals(SymbolUtils.CAP_TYPE_ROUND)) { |
|
483 |
resp = BasicStroke.CAP_ROUND; |
|
484 |
} else if (captype.equals(SymbolUtils.CAP_TYPE_SQUARE)) { |
|
485 |
resp = BasicStroke.CAP_SQUARE; |
|
486 |
} |
|
487 |
|
|
488 |
return resp; |
|
489 |
} |
|
490 |
|
|
491 |
/** |
|
492 |
* Translate ArcIMS joining line types into BasicStroke join line constants |
|
493 |
* @see java.awt.BasicStroke#getLineJoin() |
|
494 |
* @param jointype |
|
495 |
* @return |
|
496 |
*/ |
|
497 |
private static int getJoinType(String jointype) { |
|
498 |
int resp = BasicStroke.CAP_BUTT; |
|
499 |
|
|
500 |
if (jointype.equals(SymbolUtils.JOIN_TYPE_ROUND)) { |
|
501 |
resp = BasicStroke.JOIN_ROUND; |
|
502 |
} else if (jointype.equals(SymbolUtils.JOIN_TYPE_MITER)) { |
|
503 |
resp = BasicStroke.JOIN_MITER; |
|
504 |
} else if (jointype.equals(SymbolUtils.JOIN_TYPE_BEVEL)) { |
|
505 |
resp = BasicStroke.JOIN_BEVEL; |
|
506 |
} |
|
507 |
|
|
508 |
return resp; |
|
509 |
} |
|
510 |
|
|
511 |
/** |
|
512 |
* Gets a valid FConstant integer to translate an ArcIMS fill style |
|
513 |
* @param filltype |
|
514 |
* @return |
|
515 |
*/ |
|
516 |
private static int getFillStyle(String filltype) { |
|
517 |
int style = FConstant.SYMBOL_STYLE_FILL_SOLID; |
|
518 |
|
|
519 |
if (filltype.equals(SymbolUtils.FILL_TYPE_SOLID)) { |
|
520 |
style = FConstant.SYMBOL_STYLE_FILL_SOLID; |
|
521 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_BDIAG)) { |
|
522 |
style = FConstant.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL; |
|
523 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_FDIAG)) { |
|
524 |
style = FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL; |
|
525 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_CROSS)) { |
|
526 |
style = FConstant.SYMBOL_STYLE_FILL_CROSS; |
|
527 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_DIAGC)) { |
|
528 |
style = FConstant.SYMBOL_STYLE_FILL_CROSS_DIAGONAL; |
|
529 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_HORIZ)) { |
|
530 |
style = FConstant.SYMBOL_STYLE_FILL_HORIZONTAL; |
|
531 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_VERT)) { |
|
532 |
style = FConstant.SYMBOL_STYLE_FILL_VERTICAL; |
|
533 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_GRAYFILL)) { |
|
534 |
style = FConstant.SYMBOL_STYLE_FILL_GRAYFILL; |
|
535 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_LIGHTGRAYFILL)) { |
|
536 |
style = FConstant.SYMBOL_STYLE_FILL_LIGHTGRAYFILL; |
|
537 |
} else if (filltype.equals(SymbolUtils.FILL_TYPE_DARKGRAYFILL)) { |
|
538 |
style = FConstant.SYMBOL_STYLE_FILL_DARKGRAYFILL; |
|
539 |
} |
|
540 |
|
|
541 |
return style; |
|
542 |
} |
|
543 |
|
|
544 |
/** |
|
545 |
* @see com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory |
|
546 |
* @param cRef |
|
547 |
* @param bi |
|
548 |
* @return |
|
549 |
*/ |
|
550 |
static private Graphics2D createG2(Color cRef, BufferedImage bi) { |
|
551 |
Graphics2D big = bi.createGraphics(); |
|
552 |
Color color = new Color(0, 0, 0, 0); |
|
553 |
big.setBackground(color); |
|
554 |
big.clearRect(0, 0, w, h); |
|
555 |
big.setColor(new Color(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), |
|
556 |
cRef.getAlpha())); |
|
557 |
big.setStroke(new BasicStroke()); |
|
558 |
|
|
559 |
return big; |
|
560 |
} |
|
561 |
|
|
562 |
/** |
|
563 |
* @see com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory |
|
564 |
* @param style |
|
565 |
* @param cRef |
|
566 |
* @return |
|
567 |
*/ |
|
568 |
private static Paint createPatternFill(int style, Color cRef) { |
|
569 |
w = 7; |
|
570 |
h = 7; |
|
571 |
|
|
572 |
BufferedImage bi = null; |
|
573 |
Graphics2D big = null; |
|
574 |
|
|
575 |
Rectangle2D rProv = new Rectangle(); |
|
576 |
rProv.setFrame(0, 0, w, h); |
|
577 |
|
|
578 |
Paint resulPatternFill = null; |
|
579 |
bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); |
|
580 |
big = createG2(cRef, bi); |
|
581 |
|
|
582 |
switch (style) { |
|
583 |
case FConstant.SYMBOL_STYLE_FILL_SOLID: |
|
584 |
return null; |
|
585 |
|
|
586 |
case FConstant.SYMBOL_STYLE_FILL_TRANSPARENT: |
|
587 |
return null; |
|
588 |
|
|
589 |
case FConstant.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL: |
|
590 |
big.drawLine(0, 0, w, h); |
|
591 |
|
|
592 |
break; |
|
593 |
|
|
594 |
case FConstant.SYMBOL_STYLE_FILL_CROSS: |
|
595 |
big.drawLine(w / 2, 0, w / 2, h); |
|
596 |
big.drawLine(0, h / 2, w, h / 2); |
|
597 |
|
|
598 |
break; |
|
599 |
|
|
600 |
case FConstant.SYMBOL_STYLE_FILL_CROSS_DIAGONAL: |
|
601 |
big.drawLine(0, 0, w, h); |
|
602 |
big.drawLine(0, h, w, 0); |
|
603 |
|
|
604 |
break; |
|
605 |
|
|
606 |
case FConstant.SYMBOL_STYLE_FILL_VERTICAL: |
|
607 |
big.drawLine(w / 2, 0, w / 2, h); |
|
608 |
|
|
609 |
break; |
|
610 |
|
|
611 |
case FConstant.SYMBOL_STYLE_FILL_HORIZONTAL: |
|
612 |
big.drawLine(0, h / 2, w, h / 2); |
|
613 |
|
|
614 |
break; |
|
615 |
|
|
616 |
case FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL: |
|
617 |
big.drawLine(0, h, w, 0); |
|
618 |
|
|
619 |
break; |
|
620 |
} |
|
621 |
|
|
622 |
resulPatternFill = new TexturePaint(bi, rProv); |
|
623 |
|
|
624 |
return resulPatternFill; |
|
625 |
} |
|
626 |
|
|
627 |
/** |
|
628 |
* Gets the hue of a color and returns the color |
|
629 |
* with 75% of saturation and 50% of brightness |
|
630 |
* @param cRef |
|
631 |
* @return |
|
632 |
*/ |
|
633 |
private static Color getGray(Color cRef) { |
|
634 |
float[] hsbvals = new float[3]; |
|
635 |
Color.RGBtoHSB(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), hsbvals); |
|
636 |
|
|
637 |
return new Color(Color.HSBtoRGB(hsbvals[0], 0.75f, 0.5f)); |
|
638 |
} |
|
639 |
|
|
640 |
/** |
|
641 |
* Gets the hue of a color and returns the color |
|
642 |
* with 75% of saturation and 25% of brightness |
|
643 |
* @param cRef |
|
644 |
* @return |
|
645 |
*/ |
|
646 |
private static Color getLightGray(Color cRef) { |
|
647 |
float[] hsbvals = new float[3]; |
|
648 |
Color.RGBtoHSB(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), hsbvals); |
|
649 |
|
|
650 |
return new Color(Color.HSBtoRGB(hsbvals[0], 0.25f, 0.75f)); |
|
651 |
} |
|
652 |
|
|
653 |
/** |
|
654 |
* Gets the hue of a color and returns the color |
|
655 |
* with 75% of saturation and 75% of brightness |
|
656 |
* @param cRef |
|
657 |
* @return |
|
658 |
*/ |
|
659 |
private static Color getDarkGray(Color cRef) { |
|
660 |
float[] hsbvals = new float[3]; |
|
661 |
Color.RGBtoHSB(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), hsbvals); |
|
662 |
|
|
663 |
return new Color(Color.HSBtoRGB(hsbvals[0], 0.25f, 0.25f)); |
|
664 |
} |
|
665 |
|
|
666 |
/** |
|
667 |
* Get the average of two colours |
|
668 |
* @param a Color to mix |
|
669 |
* @param b Color to mix |
|
670 |
* @return (a+b)/2 |
|
671 |
*/ |
|
672 |
private static Color mixColors(Color a, Color b) { |
|
673 |
return new Color((a.getRed() + b.getRed()) / 2, |
|
674 |
(a.getGreen() + b.getGreen()) / 2, (a.getBlue() + b.getBlue()) / 2); |
|
675 |
} |
|
676 |
|
|
677 |
/** |
|
678 |
* Gets from an URL a File with the icon stored in a temporary directory |
|
679 |
* @param surl |
|
680 |
* @return |
|
681 |
*/ |
|
682 |
private static File getIconFile(String surl) { |
|
683 |
File img = null; |
|
684 |
|
|
685 |
try { |
|
686 |
URL url; |
|
687 |
url = new URL(surl); |
|
688 |
|
|
689 |
String[] partes = surl.split("/"); |
|
690 |
String realFilename = partes[partes.length - 1]; |
|
691 |
String[] realsplit = realFilename.split("\\."); |
|
692 |
|
|
693 |
String downFileName = realsplit[0] + |
|
694 |
Long.toString(System.currentTimeMillis()) + "." + realsplit[1]; |
|
695 |
|
|
696 |
img = ArcImsDownloadUtils.downloadFile(url, downFileName); |
|
697 |
} catch (MalformedURLException e) { |
|
698 |
logger.error(e.getMessage(), e); |
|
699 |
} catch (ConnectException e) { |
|
700 |
logger.error(e.getMessage(), e); |
|
701 |
} catch (UnknownHostException e) { |
|
702 |
logger.error(e.getMessage(), e); |
|
703 |
} catch (IOException e) { |
|
704 |
logger.error(e.getMessage(), e); |
|
705 |
} |
|
706 |
|
|
707 |
return img; |
|
708 |
} |
|
435 |
// public static ISymbol getDefaultFSymbol(int featType) { |
|
436 |
// ISymbol mSimb = null; |
|
437 |
// int colorind = (int) (System.currentTimeMillis() % ((long) initialColors.size())); |
|
438 |
// Color randomColor = (Color) initialColors.get(colorind); |
|
439 |
// mSimb = new FSymbol(featType, randomColor); |
|
440 |
// mSimb.setFont(new Font("Arial", Font.PLAIN, 10)); |
|
441 |
// mSimb.setFontColor(Color.BLACK); |
|
442 |
// mSimb.setSize(10); |
|
443 |
// mSimb.setSizeInPixels(true); |
|
444 |
// |
|
445 |
// return mSimb; |
|
446 |
// } |
|
447 |
// |
|
448 |
// /* |
|
449 |
// * Supporting private methods |
|
450 |
// */ |
|
451 |
// |
|
452 |
// /** |
|
453 |
// * Gets the correct constant for a ArcIMS point type |
|
454 |
// * @param type |
|
455 |
// * @return |
|
456 |
// */ |
|
457 |
// private static int getPointType(String type) { |
|
458 |
// //Default symbol, as gvsig doesn't paints stars |
|
459 |
// int mtype = FConstant.SYMBOL_STYLE_MARKER_CIRCLE; |
|
460 |
// |
|
461 |
// if (type.equals(SymbolUtils.POINT_TYPE_CIRCLE)) { |
|
462 |
// mtype = FConstant.SYMBOL_STYLE_MARKER_CIRCLE; |
|
463 |
// } else if (type.equals(SymbolUtils.POINT_TYPE_CROSS)) { |
|
464 |
// mtype = FConstant.SYMBOL_STYLE_MARKER_CROSS; |
|
465 |
// } else if (type.equals(SymbolUtils.POINT_TYPE_SQUARE)) { |
|
466 |
// mtype = FConstant.SYMBOL_STYLE_MARKER_SQUARE; |
|
467 |
// } else if (type.equals(SymbolUtils.POINT_TYPE_TRIANGLE)) { |
|
468 |
// mtype = FConstant.SYMBOL_STYLE_MARKER_TRIANGLE; |
|
469 |
// } |
|
470 |
// |
|
471 |
// return mtype; |
|
472 |
// } |
|
473 |
// |
|
474 |
// /** |
|
475 |
// * Method to translate from ArcIMS type to a string of values that will be parsed |
|
476 |
// * @return a correct string for the line type definition as "1,3" for dots |
|
477 |
// */ |
|
478 |
// private static String getLinePattern(String type) { |
|
479 |
// return (String) SymbolUtils.LINE_TYPES.get(type); |
|
480 |
// } |
|
481 |
// |
|
482 |
// /** |
|
483 |
// * Translates ArcIMS line end style into BasicStroke line end constants |
|
484 |
// * @see java.awt.BasicStroke#getEndCap() |
|
485 |
// * @param captype |
|
486 |
// * @return |
|
487 |
// */ |
|
488 |
// private static int getCapType(String captype) { |
|
489 |
// int resp = BasicStroke.CAP_BUTT; |
|
490 |
// |
|
491 |
// if (captype.equals(SymbolUtils.CAP_TYPE_BUTT)) { |
|
492 |
// resp = BasicStroke.CAP_BUTT; |
|
493 |
// } else if (captype.equals(SymbolUtils.CAP_TYPE_ROUND)) { |
|
494 |
// resp = BasicStroke.CAP_ROUND; |
|
495 |
// } else if (captype.equals(SymbolUtils.CAP_TYPE_SQUARE)) { |
|
496 |
// resp = BasicStroke.CAP_SQUARE; |
|
497 |
// } |
|
498 |
// |
|
499 |
// return resp; |
|
500 |
// } |
|
501 |
// |
|
502 |
// /** |
|
503 |
// * Translate ArcIMS joining line types into BasicStroke join line constants |
|
504 |
// * @see java.awt.BasicStroke#getLineJoin() |
|
505 |
// * @param jointype |
|
506 |
// * @return |
|
507 |
// */ |
|
508 |
// private static int getJoinType(String jointype) { |
|
509 |
// int resp = BasicStroke.CAP_BUTT; |
|
510 |
// |
|
511 |
// if (jointype.equals(SymbolUtils.JOIN_TYPE_ROUND)) { |
|
512 |
// resp = BasicStroke.JOIN_ROUND; |
|
513 |
// } else if (jointype.equals(SymbolUtils.JOIN_TYPE_MITER)) { |
|
514 |
// resp = BasicStroke.JOIN_MITER; |
|
515 |
// } else if (jointype.equals(SymbolUtils.JOIN_TYPE_BEVEL)) { |
|
516 |
// resp = BasicStroke.JOIN_BEVEL; |
|
517 |
// } |
|
518 |
// |
|
519 |
// return resp; |
|
520 |
// } |
|
521 |
// |
|
522 |
// /** |
|
523 |
// * Gets a valid FConstant integer to translate an ArcIMS fill style |
|
524 |
// * @param filltype |
|
525 |
// * @return |
|
526 |
// */ |
|
527 |
// private static int getFillStyle(String filltype) { |
|
528 |
// int style = FConstant.SYMBOL_STYLE_FILL_SOLID; |
|
529 |
// |
|
530 |
// if (filltype.equals(SymbolUtils.FILL_TYPE_SOLID)) { |
|
531 |
// style = FConstant.SYMBOL_STYLE_FILL_SOLID; |
|
532 |
// } else if (filltype.equals(SymbolUtils.FILL_TYPE_BDIAG)) { |
|
533 |
// style = FConstant.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL; |
|
534 |
// } else if (filltype.equals(SymbolUtils.FILL_TYPE_FDIAG)) { |
|
535 |
// style = FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL; |
|
536 |
// } else if (filltype.equals(SymbolUtils.FILL_TYPE_CROSS)) { |
|
537 |
// style = FConstant.SYMBOL_STYLE_FILL_CROSS; |
|
538 |
// } else if (filltype.equals(SymbolUtils.FILL_TYPE_DIAGC)) { |
|
539 |
// style = FConstant.SYMBOL_STYLE_FILL_CROSS_DIAGONAL; |
|
540 |
// } else if (filltype.equals(SymbolUtils.FILL_TYPE_HORIZ)) { |
|
541 |
// style = FConstant.SYMBOL_STYLE_FILL_HORIZONTAL; |
|
542 |
// } else if (filltype.equals(SymbolUtils.FILL_TYPE_VERT)) { |
|
543 |
// style = FConstant.SYMBOL_STYLE_FILL_VERTICAL; |
|
544 |
// } else if (filltype.equals(SymbolUtils.FILL_TYPE_GRAYFILL)) { |
|
545 |
// style = FConstant.SYMBOL_STYLE_FILL_GRAYFILL; |
|
546 |
// } else if (filltype.equals(SymbolUtils.FILL_TYPE_LIGHTGRAYFILL)) { |
|
547 |
// style = FConstant.SYMBOL_STYLE_FILL_LIGHTGRAYFILL; |
|
548 |
// } else if (filltype.equals(SymbolUtils.FILL_TYPE_DARKGRAYFILL)) { |
|
549 |
// style = FConstant.SYMBOL_STYLE_FILL_DARKGRAYFILL; |
|
550 |
// } |
|
551 |
// |
|
552 |
// return style; |
|
553 |
// } |
|
554 |
// |
|
555 |
// /** |
|
556 |
// * @see com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory |
|
557 |
// * @param cRef |
|
558 |
// * @param bi |
|
559 |
// * @return |
|
560 |
// */ |
|
561 |
// static private Graphics2D createG2(Color cRef, BufferedImage bi) { |
|
562 |
// Graphics2D big = bi.createGraphics(); |
|
563 |
// Color color = new Color(0, 0, 0, 0); |
|
564 |
// big.setBackground(color); |
|
565 |
// big.clearRect(0, 0, w, h); |
|
566 |
// big.setColor(new Color(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), |
|
567 |
// cRef.getAlpha())); |
|
568 |
// big.setStroke(new BasicStroke()); |
|
569 |
// |
|
570 |
// return big; |
|
571 |
// } |
|
572 |
// |
|
573 |
// /** |
|
574 |
// * @see com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory |
|
575 |
// * @param style |
|
576 |
// * @param cRef |
|
577 |
// * @return |
|
578 |
// */ |
|
579 |
// private static Paint createPatternFill(int style, Color cRef) { |
|
580 |
// w = 7; |
|
581 |
// h = 7; |
|
582 |
// |
|
583 |
// BufferedImage bi = null; |
|
584 |
// Graphics2D big = null; |
|
585 |
// |
|
586 |
// Rectangle2D rProv = new Rectangle(); |
|
587 |
// rProv.setFrame(0, 0, w, h); |
|
588 |
// |
|
589 |
// Paint resulPatternFill = null; |
|
590 |
// bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); |
|
591 |
// big = createG2(cRef, bi); |
|
592 |
// |
|
593 |
// switch (style) { |
|
594 |
// case FConstant.SYMBOL_STYLE_FILL_SOLID: |
|
595 |
// return null; |
|
596 |
// |
|
597 |
// case FConstant.SYMBOL_STYLE_FILL_TRANSPARENT: |
|
598 |
// return null; |
|
599 |
// |
|
600 |
// case FConstant.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL: |
|
601 |
// big.drawLine(0, 0, w, h); |
|
602 |
// |
|
603 |
// break; |
|
604 |
// |
|
605 |
// case FConstant.SYMBOL_STYLE_FILL_CROSS: |
|
606 |
// big.drawLine(w / 2, 0, w / 2, h); |
|
607 |
// big.drawLine(0, h / 2, w, h / 2); |
|
608 |
// |
|
609 |
// break; |
|
610 |
// |
|
611 |
// case FConstant.SYMBOL_STYLE_FILL_CROSS_DIAGONAL: |
|
612 |
// big.drawLine(0, 0, w, h); |
|
613 |
// big.drawLine(0, h, w, 0); |
|
614 |
// |
|
615 |
// break; |
|
616 |
// |
|
617 |
// case FConstant.SYMBOL_STYLE_FILL_VERTICAL: |
|
618 |
// big.drawLine(w / 2, 0, w / 2, h); |
|
619 |
// |
|
620 |
// break; |
|
621 |
// |
|
622 |
// case FConstant.SYMBOL_STYLE_FILL_HORIZONTAL: |
|
623 |
// big.drawLine(0, h / 2, w, h / 2); |
|
624 |
// |
|
625 |
// break; |
|
626 |
// |
|
627 |
// case FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL: |
|
628 |
// big.drawLine(0, h, w, 0); |
|
629 |
// |
|
630 |
// break; |
|
631 |
// } |
|
632 |
// |
|
633 |
// resulPatternFill = new TexturePaint(bi, rProv); |
|
634 |
// |
|
635 |
// return resulPatternFill; |
|
636 |
// } |
|
637 |
// |
|
638 |
// /** |
|
639 |
// * Gets the hue of a color and returns the color |
|
640 |
// * with 75% of saturation and 50% of brightness |
|
641 |
// * @param cRef |
|
642 |
// * @return |
|
643 |
// */ |
|
644 |
// private static Color getGray(Color cRef) { |
|
645 |
// float[] hsbvals = new float[3]; |
|
646 |
// Color.RGBtoHSB(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), hsbvals); |
|
647 |
// |
|
648 |
// return new Color(Color.HSBtoRGB(hsbvals[0], 0.75f, 0.5f)); |
|
649 |
// } |
|
650 |
// |
|
651 |
// /** |
|
652 |
// * Gets the hue of a color and returns the color |
|
653 |
// * with 75% of saturation and 25% of brightness |
|
654 |
// * @param cRef |
|
655 |
// * @return |
|
656 |
// */ |
|
657 |
// private static Color getLightGray(Color cRef) { |
|
658 |
// float[] hsbvals = new float[3]; |
|
659 |
// Color.RGBtoHSB(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), hsbvals); |
|
660 |
// |
|
661 |
// return new Color(Color.HSBtoRGB(hsbvals[0], 0.25f, 0.75f)); |
|
662 |
// } |
|
663 |
// |
|
664 |
// /** |
|
665 |
// * Gets the hue of a color and returns the color |
|
666 |
// * with 75% of saturation and 75% of brightness |
|
667 |
// * @param cRef |
|
668 |
// * @return |
|
669 |
// */ |
|
670 |
// private static Color getDarkGray(Color cRef) { |
|
671 |
// float[] hsbvals = new float[3]; |
|
672 |
// Color.RGBtoHSB(cRef.getRed(), cRef.getGreen(), cRef.getBlue(), hsbvals); |
|
673 |
// |
|
674 |
// return new Color(Color.HSBtoRGB(hsbvals[0], 0.25f, 0.25f)); |
|
675 |
// } |
|
676 |
// |
|
677 |
// /** |
|
678 |
// * Get the average of two colours |
|
679 |
// * @param a Color to mix |
|
680 |
// * @param b Color to mix |
|
681 |
// * @return (a+b)/2 |
|
682 |
// */ |
|
683 |
// private static Color mixColors(Color a, Color b) { |
|
684 |
// return new Color((a.getRed() + b.getRed()) / 2, |
|
685 |
// (a.getGreen() + b.getGreen()) / 2, (a.getBlue() + b.getBlue()) / 2); |
|
686 |
// } |
|
687 |
// |
|
688 |
// /** |
|
689 |
// * Gets from an URL a File with the icon stored in a temporary directory |
|
690 |
// * @param surl |
|
691 |
// * @return |
|
692 |
// */ |
|
693 |
// private static File getIconFile(String surl) { |
|
694 |
// File img = null; |
|
695 |
// |
|
696 |
// try { |
|
697 |
// URL url; |
|
698 |
// url = new URL(surl); |
|
699 |
// |
|
700 |
// String[] partes = surl.split("/"); |
|
701 |
// String realFilename = partes[partes.length - 1]; |
|
702 |
// String[] realsplit = realFilename.split("\\."); |
|
703 |
// |
|
704 |
// String downFileName = realsplit[0] + |
|
705 |
// Long.toString(System.currentTimeMillis()) + "." + realsplit[1]; |
|
706 |
// |
|
707 |
// img = ArcImsDownloadUtils.downloadFile(url, downFileName); |
|
708 |
// } catch (MalformedURLException e) { |
|
709 |
// logger.error(e.getMessage(), e); |
|
710 |
// } catch (ConnectException e) { |
|
711 |
// logger.error(e.getMessage(), e); |
|
712 |
// } catch (UnknownHostException e) { |
|
713 |
// logger.error(e.getMessage(), e); |
|
714 |
// } catch (IOException e) { |
|
715 |
// logger.error(e.getMessage(), e); |
|
716 |
// } |
|
717 |
// |
|
718 |
// return img; |
|
719 |
// } |
|
720 |
|
|
721 |
|
|
709 | 722 |
} |
Also available in: Unified diff