svn-gvsig-desktop / branches / v2_0_0_prep / libraries / org.gvsig.arcims / src / org / gvsig / remoteclient / arcims / styling / symbols / ArcImsFSymbolFactory.java @ 32367
History | View | Annotate | Download (23.2 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2010 Prodevelop S.L. main development
|
26 |
* http://www.prodevelop.es
|
27 |
*/
|
28 |
|
29 |
package org.gvsig.remoteclient.arcims.styling.symbols; |
30 |
|
31 |
|
32 |
import org.slf4j.Logger; |
33 |
import org.slf4j.LoggerFactory; |
34 |
|
35 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
36 |
import org.gvsig.remoteclient.arcims.utils.ArcImsDownloadUtils; |
37 |
import org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl.FConstant; |
38 |
|
39 |
import java.awt.BasicStroke; |
40 |
import java.awt.Color; |
41 |
import java.awt.Font; |
42 |
import java.awt.Graphics2D; |
43 |
import java.awt.Paint; |
44 |
import java.awt.Rectangle; |
45 |
import java.awt.TexturePaint; |
46 |
import java.awt.geom.Rectangle2D; |
47 |
import java.awt.image.BufferedImage; |
48 |
|
49 |
import java.io.File; |
50 |
import java.io.IOException; |
51 |
|
52 |
import java.net.ConnectException; |
53 |
import java.net.MalformedURLException; |
54 |
import java.net.URI; |
55 |
import java.net.URL; |
56 |
import java.net.UnknownHostException; |
57 |
|
58 |
import java.util.ArrayList; |
59 |
|
60 |
import javax.swing.ImageIcon; |
61 |
|
62 |
|
63 |
/**
|
64 |
* Factory class to produce FSymbol's from ArcIMS Symbol defintions
|
65 |
* @author jsanz
|
66 |
*
|
67 |
*/
|
68 |
public class ArcImsFSymbolFactory { |
69 |
private static Logger logger = LoggerFactory.getLogger(ArcImsFSymbolFactory.class.getName()); |
70 |
public static char ds = '.'; |
71 |
private static ArrayList initialColors = new ArrayList(); |
72 |
|
73 |
static {
|
74 |
initialColors.add(new Color(179, 226, 205)); |
75 |
initialColors.add(new Color(253, 205, 172)); |
76 |
initialColors.add(new Color(203, 213, 232)); |
77 |
initialColors.add(new Color(230, 245, 201)); |
78 |
initialColors.add(new Color(141, 211, 199)); |
79 |
initialColors.add(new Color(255, 255, 179)); |
80 |
initialColors.add(new Color(190, 186, 218)); |
81 |
initialColors.add(new Color(251, 128, 114)); |
82 |
initialColors.add(new Color(128, 177, 211)); |
83 |
} |
84 |
|
85 |
//This code is copy&paste from com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory;
|
86 |
static int w; |
87 |
|
88 |
//This code is copy&paste from com.iver.cit.gvsig.fmap.core.v02.FSymbolFactory;
|
89 |
static int h; |
90 |
|
91 |
/**
|
92 |
* Returns a point FSymbol
|
93 |
* @param simb
|
94 |
* @return
|
95 |
*/
|
96 |
protected static ISymbol getFSymbol(SimpleMarkerSymbol simb) { |
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; |
109 |
} |
110 |
|
111 |
/**
|
112 |
* Returns a point FSymbol with a remote image
|
113 |
* @param symb
|
114 |
* @return
|
115 |
*/
|
116 |
protected static ISymbol getFSymbol(RasterMarkerSymbol symb) { |
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; |
160 |
} |
161 |
|
162 |
/**
|
163 |
* Returns a line FSymbol
|
164 |
* @param simb
|
165 |
* @return
|
166 |
*/
|
167 |
protected static ISymbol getFSymbol(SimpleLineSymbol simb) { |
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; |
195 |
} |
196 |
|
197 |
/**
|
198 |
* The hasline symbol seems as a railroad, as gvSIG doesn't supports
|
199 |
* railroad symbols, this method will return a simple line with the
|
200 |
* same color and width
|
201 |
* @param symbol
|
202 |
* @return
|
203 |
*/
|
204 |
protected static ISymbol getFSymbol(HashLineSymbol symbol) { |
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; |
214 |
} |
215 |
|
216 |
/**
|
217 |
* Returns a polygon FSymbol with proper fill
|
218 |
* @param simb
|
219 |
* @return
|
220 |
*/
|
221 |
protected static ISymbol getFSymbol(SimplePolygonSymbol simb) { |
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; |
273 |
} |
274 |
|
275 |
/**
|
276 |
* A this time, this symbol will be promoted into a genery polygon symbol
|
277 |
* with the intermediate color between start and finish color and an outline
|
278 |
* "darker" color
|
279 |
* @param simb
|
280 |
* @return
|
281 |
*/
|
282 |
protected static ISymbol getFSymbol(GradientFillSymbol simb) { |
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; |
335 |
} |
336 |
|
337 |
protected static ISymbol getFSymbol(RasterFillSymbol simb) { |
338 |
//Get the icon file
|
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; |
380 |
} |
381 |
|
382 |
/**
|
383 |
* Return a Font Symbol
|
384 |
* @param symbol
|
385 |
* @return
|
386 |
*/
|
387 |
protected static ISymbol getFSymbol(TextSymbol symb) { |
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; |
404 |
} |
405 |
|
406 |
/**
|
407 |
* @param symbol
|
408 |
* @return
|
409 |
*/
|
410 |
protected static ISymbol getFSymbol(TextMarkerSymbol symbol) { |
411 |
logger.info("Getting ArcIMS TextSymbol as a random point symbol");
|
412 |
|
413 |
// return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT);
|
414 |
return null; |
415 |
} |
416 |
|
417 |
protected static ISymbol getFSymbol(TrueTypeMarkerSymbol symbol) { |
418 |
logger.info("Getting ArcIMS TextSymbol as a random point symbol");
|
419 |
|
420 |
// return getDefaultFSymbol(FConstant.SYMBOL_TYPE_POINT);
|
421 |
return null; |
422 |
} |
423 |
|
424 |
/**
|
425 |
* This method will return a null value as
|
426 |
* this kind of symbol cannot be promoted to other
|
427 |
* supported symbol
|
428 |
* @param symbol
|
429 |
* @return null
|
430 |
*/
|
431 |
protected static ISymbol getFSymbol(ChartSymbol symbol) { |
432 |
return null; |
433 |
} |
434 |
|
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 |
|
722 |
} |