svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.symbology / org.gvsig.symbology.lib / org.gvsig.symbology.lib.impl / src / main / java / org / gvsig / symbology / fmap / mapcontext / rendering / symbol / impl / FSymbolFactory.java @ 40560
History | View | Annotate | Download (7.76 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
/*
|
25 |
* Created on 04-may-2004
|
26 |
*
|
27 |
* To change the template for this generated file go to
|
28 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
29 |
*/
|
30 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
31 |
*
|
32 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
33 |
*
|
34 |
* This program is free software; you can redistribute it and/or
|
35 |
* modify it under the terms of the GNU General Public License
|
36 |
* as published by the Free Software Foundation; either version 2
|
37 |
* of the License, or (at your option) any later version.
|
38 |
*
|
39 |
* This program is distributed in the hope that it will be useful,
|
40 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
41 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
42 |
* GNU General Public License for more details.
|
43 |
*
|
44 |
* You should have received a copy of the GNU General Public License
|
45 |
* along with this program; if not, write to the Free Software
|
46 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
47 |
*
|
48 |
* For more information, contact:
|
49 |
*
|
50 |
* Generalitat Valenciana
|
51 |
* Conselleria d'Infraestructures i Transport
|
52 |
* Av. Blasco Ib??ez, 50
|
53 |
* 46010 VALENCIA
|
54 |
* SPAIN
|
55 |
*
|
56 |
* +34 963862235
|
57 |
* gvsig@gva.es
|
58 |
* www.gvsig.gva.es
|
59 |
*
|
60 |
* or
|
61 |
*
|
62 |
* IVER T.I. S.A
|
63 |
* Salamanca 50
|
64 |
* 46005 Valencia
|
65 |
* Spain
|
66 |
*
|
67 |
* +34 963163400
|
68 |
* dac@iver.es
|
69 |
*/
|
70 |
package org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl; |
71 |
|
72 |
import java.awt.BasicStroke; |
73 |
import java.awt.Color; |
74 |
import java.awt.Graphics2D; |
75 |
import java.awt.Paint; |
76 |
import java.awt.Rectangle; |
77 |
import java.awt.TexturePaint; |
78 |
import java.awt.geom.Rectangle2D; |
79 |
import java.awt.image.BufferedImage; |
80 |
|
81 |
import org.gvsig.compat.CompatLocator; |
82 |
|
83 |
/**
|
84 |
* @author fjp
|
85 |
*
|
86 |
* To change the template for this generated type comment go to
|
87 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
88 |
* @deprecated
|
89 |
*/
|
90 |
public class FSymbolFactory { |
91 |
static int w, h; |
92 |
|
93 |
// Podr?amos pasarle tambi?n un color de fondo, y usarlo como background del
|
94 |
// graphics2D.
|
95 |
static private Graphics2D createG2(Color cRef, BufferedImage bi) |
96 |
{ |
97 |
Graphics2D big = bi.createGraphics();
|
98 |
Color color=new Color(0,0,0,0); |
99 |
big.setBackground(color); |
100 |
big.clearRect(0, 0, w, h); |
101 |
big.setColor(new Color(cRef.getRed(),cRef.getGreen(), cRef.getBlue(),cRef.getAlpha())); |
102 |
big.setStroke(new BasicStroke()); |
103 |
|
104 |
return big;
|
105 |
|
106 |
} |
107 |
|
108 |
|
109 |
static public Paint createPatternFill(int style, Color cRef) |
110 |
{ |
111 |
/* public final static int SYMBOL_STYLE_FILL_SOLID = 1;
|
112 |
public final static int SYMBOL_STYLE_FILL_TRANSPARENT = 2;
|
113 |
public final static int SYMBOL_STYLE_FILL_HORIZONTAL = 3;
|
114 |
public final static int SYMBOL_STYLE_FILL_VERTICAL = 4;
|
115 |
public final static int SYMBOL_STYLE_FILL_CROSS = 5;
|
116 |
public final static int SYMBOL_STYLE_FILL_UPWARD_DIAGONAL = 6;
|
117 |
public final static int SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL = 7;
|
118 |
public final static int SYMBOL_STYLE_FILL_CROSS_DIAGONAL = 8;
|
119 |
public final static int SYMBOL_STYLE_FILL_GRAYFILL = 9;
|
120 |
public final static int SYMBOL_STYLE_FILL_LIGHTGRAYFILL = 10;
|
121 |
public final static int SYMBOL_STYLE_FILL_DARKGRAYFILL = 11; */
|
122 |
|
123 |
|
124 |
w=7; h=7; |
125 |
|
126 |
BufferedImage bi = null; |
127 |
Graphics2D big = null; |
128 |
|
129 |
Rectangle2D rProv = new Rectangle(); |
130 |
rProv.setFrame(0, 0,w,h); |
131 |
|
132 |
Paint resulPatternFill = null; |
133 |
bi= CompatLocator.getGraphicsUtils().createBufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
134 |
big = createG2(cRef, bi); |
135 |
|
136 |
switch (style)
|
137 |
{ |
138 |
case FSymbol.SYMBOL_STYLE_FILL_SOLID:
|
139 |
return null; |
140 |
case FSymbol.SYMBOL_STYLE_FILL_TRANSPARENT:
|
141 |
return null; |
142 |
case FSymbol.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL:
|
143 |
big.drawLine(0,0,w,h); |
144 |
break;
|
145 |
case FSymbol.SYMBOL_STYLE_FILL_CROSS:
|
146 |
big.drawLine(w/2,0,w/2,h); |
147 |
big.drawLine(0,h/2,w,h/2); |
148 |
break;
|
149 |
case FSymbol.SYMBOL_STYLE_FILL_CROSS_DIAGONAL:
|
150 |
big.drawLine(0,0,w,h); |
151 |
big.drawLine(0,h,w,0); |
152 |
break;
|
153 |
case FSymbol.SYMBOL_STYLE_FILL_VERTICAL:
|
154 |
big.drawLine(w/2,0,w/2,h); |
155 |
break;
|
156 |
case FSymbol.SYMBOL_STYLE_FILL_HORIZONTAL:
|
157 |
big.drawLine(0,h/2,w,h/2); |
158 |
break;
|
159 |
case FSymbol.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL:
|
160 |
// DOWNWARD_DIAGONAL m?s ancho
|
161 |
w=15;h=15; |
162 |
rProv.setFrame(0, 0,w,h); |
163 |
bi= CompatLocator.getGraphicsUtils().createBufferedImage( |
164 |
w, h, BufferedImage.TYPE_INT_ARGB);
|
165 |
big = createG2(cRef, bi); |
166 |
big.drawLine(-1,h,w,-1); |
167 |
break;
|
168 |
|
169 |
} |
170 |
|
171 |
resulPatternFill = new TexturePaint(bi,rProv); |
172 |
|
173 |
return resulPatternFill;
|
174 |
|
175 |
} |
176 |
|
177 |
/**
|
178 |
* Al crear esto lo mejor ser?a mirar en un directorio y cargar todas las
|
179 |
* imagenes que tengamos predise?adas.
|
180 |
*
|
181 |
* @param cRef
|
182 |
* @return
|
183 |
*/
|
184 |
// static public Paint[] createPatternFills(Color cRef)
|
185 |
// {
|
186 |
//
|
187 |
// int aux = 3;
|
188 |
//
|
189 |
// w=7; h=7;
|
190 |
//
|
191 |
// BufferedImage bi = null;
|
192 |
// Graphics2D big = null;
|
193 |
//
|
194 |
// Rectangle2D rProv = new Rectangle();
|
195 |
// rProv.setFrame(0, 0,w,h);
|
196 |
//
|
197 |
// Paint[] patternFills = new Paint[8];
|
198 |
//
|
199 |
// // UPWARD_DIAGONAL
|
200 |
// bi= new Bu-f-f-eredImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
201 |
// big = createG2(cRef, bi);
|
202 |
// big.drawLine(0,0,w,h);
|
203 |
// patternFills[FStyle2D.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL-aux] =
|
204 |
// new TexturePaint(bi,rProv);
|
205 |
//
|
206 |
// // CROSS
|
207 |
// bi= new Bu-f-f-eredImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
208 |
// big = createG2(cRef, bi);
|
209 |
// big.drawLine(w/2,0,w/2,h);
|
210 |
// big.drawLine(0,h/2,w,h/2);
|
211 |
// patternFills[FConstant.SYMBOL_STYLE_FILL_CROSS-aux] =
|
212 |
// new TexturePaint(bi,rProv);
|
213 |
//
|
214 |
// // CROSS
|
215 |
// bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
216 |
// big = createG2(cRef, bi);
|
217 |
// big.drawLine(0,0,w,h);
|
218 |
// big.drawLine(0,h,w,0);
|
219 |
// patternFills[FConstant.SYMBOL_STYLE_FILL_CROSS_DIAGONAL-aux] =
|
220 |
// new TexturePaint(bi,rProv);
|
221 |
//
|
222 |
//
|
223 |
// // VERTICAL
|
224 |
// bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
225 |
// big = createG2(cRef, bi);
|
226 |
// big.drawLine(w/2,0,w/2,h);
|
227 |
// patternFills[FConstant.SYMBOL_STYLE_FILL_VERTICAL-aux] =
|
228 |
// new TexturePaint(bi,rProv);
|
229 |
//
|
230 |
// // HORIZONTAL
|
231 |
// bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
232 |
// big = createG2(cRef, bi);
|
233 |
// big.drawLine(0,h/2,w,h/2);
|
234 |
// patternFills[FConstant.SYMBOL_STYLE_FILL_HORIZONTAL-aux] =
|
235 |
// new TexturePaint(bi,rProv);
|
236 |
//
|
237 |
// // DOWNWARD_DIAGONAL m?s ancho
|
238 |
// w=15;h=15;
|
239 |
// rProv.setFrame(0, 0,w,h);
|
240 |
// bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
241 |
// big = createG2(cRef, bi);
|
242 |
// // big.setColor(Color.BLUE);
|
243 |
// big.drawLine(-1,h,w,-1);
|
244 |
// // big.setColor(Color.RED);
|
245 |
// // big.drawLine(0,0,w,h);
|
246 |
// patternFills[FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL-aux] =
|
247 |
// new TexturePaint(bi,rProv);
|
248 |
// int trans=((TexturePaint)patternFills[FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL-aux]).getTransparency();
|
249 |
//
|
250 |
// return patternFills;
|
251 |
// }
|
252 |
|
253 |
} |