Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / 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 @ 34294

History | View | Annotate | Download (6.8 KB)

1
/*
2
 * Created on 04-may-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
package org.gvsig.symbology.fmap.mapcontext.rendering.symbol.impl;
48

    
49
import java.awt.BasicStroke;
50
import java.awt.Color;
51
import java.awt.Graphics2D;
52
import java.awt.Paint;
53
import java.awt.Rectangle;
54
import java.awt.TexturePaint;
55
import java.awt.geom.Rectangle2D;
56
import java.awt.image.BufferedImage;
57

    
58
import org.gvsig.compat.CompatLocator;
59

    
60
/**
61
 * @author fjp
62
 *
63
 * To change the template for this generated type comment go to
64
 * Window>Preferences>Java>Code Generation>Code and Comments
65
 * @deprecated
66
 */
67
public class FSymbolFactory {
68
        static int w, h;
69

    
70
        // Podr?amos pasarle tambi?n un color de fondo, y usarlo como background del
71
        // graphics2D.
72
        static private Graphics2D createG2(Color cRef, BufferedImage bi)
73
        {
74
                   Graphics2D big = bi.createGraphics();
75
                   Color color=new Color(0,0,0,0);
76
                   big.setBackground(color);
77
                   big.clearRect(0, 0, w, h);
78
                   big.setColor(new Color(cRef.getRed(),cRef.getGreen(), cRef.getBlue(),cRef.getAlpha()));
79
                   big.setStroke(new BasicStroke());
80

    
81
                   return big;
82

    
83
        }
84

    
85

    
86
        static public Paint createPatternFill(int style, Color cRef)
87
        {
88
                /* public final static int SYMBOL_STYLE_FILL_SOLID = 1;
89
                public final static int SYMBOL_STYLE_FILL_TRANSPARENT = 2;
90
                public final static int SYMBOL_STYLE_FILL_HORIZONTAL = 3;
91
                public final static int SYMBOL_STYLE_FILL_VERTICAL = 4;
92
                public final static int SYMBOL_STYLE_FILL_CROSS = 5;
93
                public final static int SYMBOL_STYLE_FILL_UPWARD_DIAGONAL = 6;
94
                public final static int SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL = 7;
95
                public final static int SYMBOL_STYLE_FILL_CROSS_DIAGONAL = 8;
96
                public final static int SYMBOL_STYLE_FILL_GRAYFILL = 9;
97
                public final static int SYMBOL_STYLE_FILL_LIGHTGRAYFILL = 10;
98
                public final static int SYMBOL_STYLE_FILL_DARKGRAYFILL = 11; */
99

    
100

    
101
                w=7; h=7;
102

    
103
                BufferedImage bi = null;
104
                Graphics2D big = null;
105

    
106
                Rectangle2D rProv = new Rectangle();
107
                rProv.setFrame(0, 0,w,h);
108

    
109
                Paint resulPatternFill = null;
110
                bi= CompatLocator.getGraphicsUtils().createBufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
111
                big = createG2(cRef, bi);
112

    
113
                switch (style)
114
                {
115
                        case FSymbol.SYMBOL_STYLE_FILL_SOLID:
116
                            return null;
117
                        case FSymbol.SYMBOL_STYLE_FILL_TRANSPARENT:
118
                            return null;
119
                        case FSymbol.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL:
120
                            big.drawLine(0,0,w,h);
121
                                break;
122
                        case FSymbol.SYMBOL_STYLE_FILL_CROSS:
123
                                big.drawLine(w/2,0,w/2,h);
124
                                big.drawLine(0,h/2,w,h/2);
125
                                break;
126
                        case FSymbol.SYMBOL_STYLE_FILL_CROSS_DIAGONAL:
127
                                big.drawLine(0,0,w,h);
128
                                big.drawLine(0,h,w,0);
129
                                break;
130
                        case FSymbol.SYMBOL_STYLE_FILL_VERTICAL:
131
                                big.drawLine(w/2,0,w/2,h);
132
                                break;
133
                        case FSymbol.SYMBOL_STYLE_FILL_HORIZONTAL:
134
                                big.drawLine(0,h/2,w,h/2);
135
                                break;
136
                        case FSymbol.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL:
137
                                // DOWNWARD_DIAGONAL m?s ancho
138
                                w=15;h=15;
139
                                rProv.setFrame(0, 0,w,h);
140
                                bi= CompatLocator.getGraphicsUtils().createBufferedImage(
141
                                                w, h, BufferedImage.TYPE_INT_ARGB);
142
                                big = createG2(cRef, bi);
143
                                big.drawLine(-1,h,w,-1);
144
                                break;
145

    
146
                }
147

    
148
                resulPatternFill = new TexturePaint(bi,rProv);
149

    
150
                return resulPatternFill;
151

    
152
        }
153

    
154
        /**
155
         * Al crear esto lo mejor ser?a mirar en un directorio y cargar todas las
156
         * imagenes que tengamos predise?adas.
157
         *
158
         * @param cRef
159
         * @return
160
         */
161
//        static public Paint[] createPatternFills(Color cRef)
162
//        {
163
//
164
//                int aux = 3;
165
//
166
//                w=7; h=7;
167
//
168
//                BufferedImage bi = null;
169
//                Graphics2D big = null;
170
//
171
//                Rectangle2D rProv = new Rectangle();
172
//                rProv.setFrame(0, 0,w,h);
173
//
174
//                Paint[] patternFills = new Paint[8];
175
//
176
//                // UPWARD_DIAGONAL
177
//                bi= new Bu-f-f-eredImage(w, h, BufferedImage.TYPE_INT_ARGB);
178
//                big = createG2(cRef, bi);
179
//                big.drawLine(0,0,w,h);
180
//                patternFills[FStyle2D.SYMBOL_STYLE_FILL_UPWARD_DIAGONAL-aux] =
181
//                                new TexturePaint(bi,rProv);
182
//
183
//                // CROSS
184
//                bi= new Bu-f-f-eredImage(w, h, BufferedImage.TYPE_INT_ARGB);
185
//                big = createG2(cRef, bi);
186
//                big.drawLine(w/2,0,w/2,h);
187
//                big.drawLine(0,h/2,w,h/2);
188
//                patternFills[FConstant.SYMBOL_STYLE_FILL_CROSS-aux] =
189
//                                new TexturePaint(bi,rProv);
190
//
191
//                // CROSS
192
//                bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
193
//                big = createG2(cRef, bi);
194
//                big.drawLine(0,0,w,h);
195
//                big.drawLine(0,h,w,0);
196
//                patternFills[FConstant.SYMBOL_STYLE_FILL_CROSS_DIAGONAL-aux] =
197
//                                new TexturePaint(bi,rProv);
198
//
199
//
200
//                // VERTICAL
201
//                bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
202
//                big = createG2(cRef, bi);
203
//                big.drawLine(w/2,0,w/2,h);
204
//                patternFills[FConstant.SYMBOL_STYLE_FILL_VERTICAL-aux] =
205
//                                new TexturePaint(bi,rProv);
206
//
207
//                // HORIZONTAL
208
//                bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
209
//                big = createG2(cRef, bi);
210
//                big.drawLine(0,h/2,w,h/2);
211
//                patternFills[FConstant.SYMBOL_STYLE_FILL_HORIZONTAL-aux] =
212
//                                new TexturePaint(bi,rProv);
213
//
214
//                // DOWNWARD_DIAGONAL m?s ancho
215
//                w=15;h=15;
216
//                rProv.setFrame(0, 0,w,h);
217
//                bi= new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
218
//                big = createG2(cRef, bi);
219
//                // big.setColor(Color.BLUE);
220
//                big.drawLine(-1,h,w,-1);
221
//                // big.setColor(Color.RED);
222
//                // big.drawLine(0,0,w,h);
223
//                patternFills[FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL-aux] =
224
//                                new TexturePaint(bi,rProv);
225
//                int trans=((TexturePaint)patternFills[FConstant.SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL-aux]).getTransparency();
226
//
227
//                return patternFills;
228
//        }
229

    
230
}