root / branches / Mobile_Compatible_Hito_1 / libFMap / src / es / prodevelop / gvsig / mobile / fmap / symbol / FSymbol.java @ 21606
History | View | Annotate | Download (5.4 KB)
1 |
/*
|
---|---|
2 |
* Created on 19-feb-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
/************************************************
|
48 |
* *
|
49 |
* Modfied By: *
|
50 |
* Prodevelop Integraci?n de Tecnolog?as SL *
|
51 |
* Conde Salvatierra de ?lava , 34-10 *
|
52 |
* 46004 Valencia *
|
53 |
* Spain *
|
54 |
* *
|
55 |
* +34 963 510 612 *
|
56 |
* +34 963 510 968 *
|
57 |
* gis@prodevelop.es *
|
58 |
* http://www.prodevelop.es *
|
59 |
* *
|
60 |
* gvSIG Mobile Team 2006 *
|
61 |
* *
|
62 |
************************************************/
|
63 |
package es.prodevelop.gvsig.mobile.fmap.symbol; |
64 |
|
65 |
import java.awt.Color; |
66 |
|
67 |
import org.apache.log4j.Logger; |
68 |
|
69 |
/**
|
70 |
* Simplified symbol object.
|
71 |
*
|
72 |
* @author jldominguez
|
73 |
*
|
74 |
*/
|
75 |
public class FSymbol { |
76 |
|
77 |
private static Logger logger = Logger.getLogger(FSymbol.class); |
78 |
/**
|
79 |
* Symbol used for selected features
|
80 |
*/
|
81 |
public static final FSymbol SELECTION_SYMBOL = getSymbolForSelection(); |
82 |
/**
|
83 |
* Symbol uised for the polyline shown during measurements
|
84 |
*/
|
85 |
public static final FSymbol MEASURE_SYMBOL = getMeasureSymbol(); |
86 |
|
87 |
private boolean filled = true; |
88 |
private Color borderColor = new Color(0, 0, 0); |
89 |
private Color fillColor = new Color(0, 0, 0); |
90 |
private int strokeWidth = 1; |
91 |
|
92 |
/**
|
93 |
*
|
94 |
* @return the selection symbol
|
95 |
*/
|
96 |
public static FSymbol getSymbolForSelection() { |
97 |
return new FSymbol(Color.YELLOW.darker(), Color.YELLOW, true, 1); |
98 |
} |
99 |
|
100 |
/**
|
101 |
*
|
102 |
* @return the measurement symbol
|
103 |
*/
|
104 |
public static FSymbol getMeasureSymbol() { |
105 |
return new FSymbol(Color.ORANGE, Color.ORANGE, false, 1); |
106 |
} |
107 |
|
108 |
/**
|
109 |
*
|
110 |
* @return the default symbol object
|
111 |
*/
|
112 |
public static FSymbol getDefaultSymbol() { |
113 |
return new FSymbol(Color.BLUE, Color.GREEN, false, 1); |
114 |
} |
115 |
|
116 |
/**
|
117 |
* Constructor
|
118 |
*
|
119 |
* @param bc border color
|
120 |
* @param fc fill color
|
121 |
* @param _filled wherher the polygon has to be filled
|
122 |
* @param strokeW stroke width
|
123 |
*/
|
124 |
public FSymbol(Color bc, Color fc, boolean _filled, int strokeW) { |
125 |
filled = _filled; |
126 |
borderColor = bc; |
127 |
fillColor = fc; |
128 |
strokeWidth = strokeW; |
129 |
} |
130 |
|
131 |
/**
|
132 |
* Constructor with default values.
|
133 |
*
|
134 |
*/
|
135 |
public FSymbol() {
|
136 |
} |
137 |
|
138 |
/**
|
139 |
*
|
140 |
* @return whether this symbol is filled
|
141 |
*/
|
142 |
public boolean isFilled() { |
143 |
return filled;
|
144 |
} |
145 |
|
146 |
/**
|
147 |
* Sets the filled property
|
148 |
* @param f the new filled property
|
149 |
*/
|
150 |
public void setFilled(boolean f) { |
151 |
filled = f; |
152 |
} |
153 |
|
154 |
|
155 |
|
156 |
/**
|
157 |
*
|
158 |
* @return the border color
|
159 |
*/
|
160 |
public Color getBorderColor() { |
161 |
return borderColor;
|
162 |
} |
163 |
|
164 |
/**
|
165 |
* Gets the border color
|
166 |
* @param color the new border color
|
167 |
*/
|
168 |
public void setBorderColor(Color color) { |
169 |
borderColor = color; |
170 |
} |
171 |
|
172 |
/**
|
173 |
*
|
174 |
* @return the fill color
|
175 |
*/
|
176 |
public Color getFillColor() { |
177 |
return fillColor;
|
178 |
} |
179 |
|
180 |
/**
|
181 |
* Sets the fill color
|
182 |
* @param color the new fill color
|
183 |
*/
|
184 |
public void setFillColor(Color color) { |
185 |
fillColor = color; |
186 |
} |
187 |
|
188 |
/**
|
189 |
*
|
190 |
* @return the stroke width
|
191 |
*/
|
192 |
public int getStrokeWidth() { |
193 |
return strokeWidth;
|
194 |
} |
195 |
|
196 |
/**
|
197 |
* Sets the stroke width
|
198 |
* @param w the new stroke width
|
199 |
*/
|
200 |
public void setStrokeWidth(int w) { |
201 |
strokeWidth = w; |
202 |
} |
203 |
|
204 |
/**
|
205 |
* Array of good taste colors (from Brewer)
|
206 |
*/
|
207 |
public static Color[] validColor; |
208 |
|
209 |
private static int validColorInd = 0; |
210 |
|
211 |
static {
|
212 |
validColor = new Color[9]; |
213 |
try {
|
214 |
validColor[0] = new Color(166, 206, 227); |
215 |
validColor[1] = new Color(178, 223, 138); |
216 |
validColor[2] = new Color(251, 154, 153); |
217 |
validColor[3] = new Color(51, 160, 44); |
218 |
validColor[4] = new Color(227, 26, 28); |
219 |
validColor[5] = new Color(31, 120, 180); |
220 |
validColor[6] = new Color(253, 191, 111); |
221 |
validColor[7] = new Color(255, 127, 0); |
222 |
validColor[8] = new Color(202, 178, 214); |
223 |
} catch (Throwable th) { |
224 |
logger.error("COLOR ERROR: " + th.getMessage());
|
225 |
} |
226 |
} |
227 |
|
228 |
/**
|
229 |
*
|
230 |
* @return a randomly chosen color (among good colors)
|
231 |
*/
|
232 |
public static Color getRandomColor() { |
233 |
return validColor[(validColorInd++) % validColor.length];
|
234 |
} |
235 |
|
236 |
/**
|
237 |
* creates random symbol
|
238 |
* @param filled whether it has to be filled or not
|
239 |
* @return a random symbol (stroke width = 1)
|
240 |
*/
|
241 |
public static FSymbol createRandomSymbol(boolean filled) { |
242 |
Color c = getRandomColor();
|
243 |
return new FSymbol(c.darker(), c, filled, 1); |
244 |
} |
245 |
|
246 |
|
247 |
|
248 |
} |