Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / rendering / styling / FStyle2D.java @ 1094

History | View | Annotate | Download (11.4 KB)

1
/*
2
 * Created on 22-nov-2004
3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Generation - Code and Comments
6
 */
7
package com.iver.cit.gvsig.fmap.rendering.styling;
8

    
9
import java.awt.Color;
10
import java.awt.GradientPaint;
11
import java.awt.Graphics2D;
12
import java.awt.Rectangle;
13
import java.awt.TexturePaint;
14
import java.awt.image.BufferedImage;
15

    
16
import org.geotools.renderer.style.LineStyle2D;
17
import org.geotools.renderer.style.PolygonStyle2D;
18
import org.geotools.renderer.style.Style2D;
19

    
20
import com.iver.cit.gvsig.fmap.rendering.FStyledShapePainter;
21
import com.iver.utiles.StringUtilities;
22
import com.iver.utiles.XMLEntity;
23

    
24
/**
25
 * @author FJP
26
 *
27
 * TODO To change the template for this generated type comment go to
28
 * Window - Preferences - Java - Code Generation - Code and Comments
29
 * 
30
 */
31
public class FStyle2D {
32
        public static final int POINT = 1;
33
    public static final int LINE = 2;
34
    public static final int POLYGON = 4;
35
    public static final int TEXT = 8;
36
        
37
        public final static int SYMBOL_TYPE_POINT = 1;
38
        public final static int SYMBOL_TYPE_LINE = 3;
39
        public final static int SYMBOL_TYPE_FILL = 5;
40
        public final static int SYMBOL_TYPE_TEXT = 7;
41
        public final static int SYMBOL_TYPE_ICON = 9;
42
                
43
        public final static int SYMBOL_TYPE_POINTZ = 11;
44
        public final static int SYMBOL_TYPE_MULTIPOINT = 8;
45
        public final static int SYMBOL_STYLE_POINTZ = 0;
46
        public final static int SYMBOL_TYPE_POLYLINEZ = 13;
47
        public final static int SYMBOL_TYPE_POLYGONZ = 15;
48
        // Para s?mbolos de tipo pol?gono.
49
        public final static int SYMBOL_STYLE_FILL_SOLID = 1;
50
        public final static int SYMBOL_STYLE_FILL_TRANSPARENT = 2;
51
        public final static int SYMBOL_STYLE_FILL_HORIZONTAL = 3;
52
        public final static int SYMBOL_STYLE_FILL_VERTICAL = 4;
53
        public final static int SYMBOL_STYLE_FILL_CROSS = 5;
54
        public final static int SYMBOL_STYLE_FILL_UPWARD_DIAGONAL = 6;
55
        public final static int SYMBOL_STYLE_FILL_DOWNWARD_DIAGONAL = 7;
56
        public final static int SYMBOL_STYLE_FILL_CROSS_DIAGONAL = 8;
57
        public final static int SYMBOL_STYLE_FILL_GRAYFILL = 9;
58
        public final static int SYMBOL_STYLE_FILL_LIGHTGRAYFILL = 10;
59
        public final static int SYMBOL_STYLE_FILL_DARKGRAYFILL = 11;
60

    
61
        //        Para s?mbolos de tipo Punto
62
        public final static int SYMBOL_STYLE_MARKER_CIRCLE = 30;
63
        public final static int SYMBOL_STYLE_MARKER_SQUARE = 31;
64
        public final static int SYMBOL_STYLE_MARKER_TRIANGLE = 32;
65
        public final static int SYMBOL_STYLE_MARKER_CROSS = 33;
66
        public final static int SYMBOL_STYLE_MARKER_TRUETYPE = 34;
67
        public final static int SYMBOL_STYLE_MARKER_IMAGEN = 35;                      
68

    
69
        // Para s?mbolos de l?neas
70
        public final static int SYMBOL_STYLE_LINE_SOLID = 60;
71
        public final static int SYMBOL_STYLE_LINE_DASH = 61;
72
        public final static int SYMBOL_STYLE_LINE_DOT = 62;
73
        public final static int SYMBOL_STYLE_LINE_DASHDOT = 63;
74
        public final static int SYMBOL_STYLE_LINE_DASHDOTDOT = 64;
75
        public final static int SYMBOL_STYLE_LINE_RAIL = 65;
76
        public final static int SYMBOL_STYLE_LINE_ARROW = 66;
77
    
78
        // Para s?mbolos de tipo texto
79
        public final static int SYMBOL_STYLE_TEXT_NORMAL = 90;
80
        public final static int SYMBOL_STYLE_TEXT_CURSIVE = 91;
81
        public final static int SYMBOL_STYLE_TEXT_BOLD = 92;
82
        public final static int SYMBOL_STYLE_TEXT_BOLDCURSIVE = 93;
83
    
84
    /**
85
         * RGB (incluye transparencia) que se utilizar? para la aceleraci?n gr?fica
86
         */
87
        private int rgbPoint;
88
        private int rgbLine;
89
        private int rgbPolygon;
90
        private int rgbText;
91
        private Style2D pointStyle2D;
92
        private LineStyle2D lineStyle2D;
93
        private PolygonStyle2D polygonStyle2D;
94
        private Style2D textStyle2D;
95
        private static BufferedImage img = new BufferedImage(1,1,BufferedImage.TYPE_INT_ARGB);
96
        private static FStyledShapePainter shpPainter = new FStyledShapePainter();
97
        private static Rectangle rect = new Rectangle(0,0,1,1);
98
                
99
        /**
100
         * @return Returns the rgb (incluye transparencia) que se utilizar? para la aceleraci?n gr?fica.
101
         */
102
        public int getRgbPoint() {
103
                return rgbPoint;
104
        }
105
        /**
106
         * @return Returns the rgbLine.
107
         */
108
        public int getRgbLine() {
109
                return rgbLine;
110
        }
111
        /**
112
         * @return Returns the rgbPolygon.
113
         */
114
        public int getRgbPolygon() {
115
                return rgbPolygon;
116
        }
117
        /**
118
         * @return Returns the rgbText.
119
         */
120
        public int getRgbText() {
121
                return rgbText;
122
        }
123
        
124
        /**
125
         * @return Returns the style2D.
126
         */
127
        public synchronized LineStyle2D getLineStyle2D() {
128
                return lineStyle2D;
129
        }
130
        /**
131
         * @param style2D The style2D to set.
132
         */
133
        public synchronized void setLineStyle2D(LineStyle2D style2D) {
134
                lineStyle2D = style2D;
135
                // Recalculamos el RGB
136
                Graphics2D g2 = img.createGraphics();
137
                
138
                shpPainter.paint(g2,rect,style2D,0);                
139
                rgbLine = img.getRGB(0,0);
140
                
141
        }
142
        
143
        /**
144
         * @return Returns the style2D.
145
         */
146
        public synchronized PolygonStyle2D getPolygonStyle2D() {
147
                return polygonStyle2D;
148
        }
149
        /**
150
         * @param style2D The style2D to set.
151
         */
152
        public synchronized void setPolygonStyle2D(PolygonStyle2D style2D) {
153
                polygonStyle2D = style2D;
154
                // Recalculamos el RGB
155
                Graphics2D g2 = img.createGraphics();
156
                
157
                shpPainter.paint(g2,rect,style2D,0);                
158
                rgbPolygon = img.getRGB(0,0);
159
                
160
        }
161
        
162
        /**
163
         * @return Returns the style2D.
164
         */
165
        public synchronized Style2D getPointStyle2D() {
166
                return pointStyle2D;
167
        }
168
        /**
169
         * @param style2D The style2D to set.
170
         */
171
        public synchronized void setPointStyle2D(Style2D style2D) {
172
                pointStyle2D = style2D;
173
                // Recalculamos el RGB
174
                Graphics2D g2 = img.createGraphics();
175
                
176
                shpPainter.paint(g2,rect,style2D,0);                
177
                rgbPoint = img.getRGB(0,0);
178
                
179
        }
180
        
181
        /**
182
         * @return Returns the style2D.
183
         */
184
        public synchronized Style2D getTextStyle2D() {
185
                return textStyle2D;
186
        }
187
        /**
188
         * @param style2D The style2D to set.
189
         */
190
        public synchronized void setTextStyle2D(Style2D style2D) {
191
                textStyle2D = style2D;
192
                // Recalculamos el RGB
193
                Graphics2D g2 = img.createGraphics();
194
                
195
                shpPainter.paint(g2,rect,style2D,0);                
196
                rgbText = img.getRGB(0,0);
197
                
198
        }
199
public XMLEntity getXMLEntity(){
200
        XMLEntity xml = new XMLEntity();
201
        xml.putProperty("className",this.getClass().getName());
202
        xml.putProperty("rgbLine",rgbLine);
203
        xml.putProperty("rgbPolygon",rgbPolygon);
204
        xml.putProperty("rbgText",rgbText);
205
        
206
        ///////////////LINE
207
        xml.putProperty("lMaxScale",lineStyle2D.getMaxScale());
208
        xml.putProperty("lMinScale",lineStyle2D.getMinScale());
209
        if (lineStyle2D.getContour() instanceof Color){
210
                xml.putProperty("lContour",StringUtilities.color2String((Color)lineStyle2D.getContour()));
211
        }else if (lineStyle2D.getContour() instanceof GradientPaint){
212
                xml.putProperty("lTransparency",((GradientPaint)lineStyle2D.getContour()).getTransparency());
213
                xml.putProperty("lColor1",StringUtilities.color2String(((GradientPaint)lineStyle2D.getContour()).getColor1()));
214
                xml.putProperty("lColor2",StringUtilities.color2String(((GradientPaint)lineStyle2D.getContour()).getColor2()));
215
                xml.putProperty("lPoint1X",((GradientPaint)lineStyle2D.getContour()).getPoint1().getX());
216
                xml.putProperty("lPoint1Y",((GradientPaint)lineStyle2D.getContour()).getPoint1().getY());
217
                xml.putProperty("lPoint2X",((GradientPaint)lineStyle2D.getContour()).getPoint2().getX());
218
                xml.putProperty("lPoint2Y",((GradientPaint)lineStyle2D.getContour()).getPoint2().getY());
219
        }else if (lineStyle2D.getContour() instanceof TexturePaint){
220
                xml.putProperty("lTransparency",((TexturePaint)lineStyle2D.getContour()).getTransparency());
221
                xml.putProperty("lAnchorRectX",((TexturePaint)lineStyle2D.getContour()).getAnchorRect().getX());
222
                xml.putProperty("lAnchorRectY",((TexturePaint)lineStyle2D.getContour()).getAnchorRect().getY());
223
                xml.putProperty("lAnchorRectW",((TexturePaint)lineStyle2D.getContour()).getAnchorRect().getWidth());
224
                xml.putProperty("lAnchorRectH",((TexturePaint)lineStyle2D.getContour()).getAnchorRect().getHeight());
225
                //TODO falta que guardar la imagen
226
        }
227
        //TODO xml.putProperty("",lineStyle2D.getContourComposite());
228
        //TODO xml.putProperty("",lineStyle2D.getGraphicStroke());
229
        //TODO xml.putProperty("",lineStyle2D.getStroke());
230
        
231
        
232
        //////POINT
233
        xml.putProperty("pointMaxScale",pointStyle2D.getMaxScale());
234
        xml.putProperty("pointMinScale",pointStyle2D.getMinScale());
235
        
236
        ////////////POLYGON
237
        xml.putProperty("pMaxScale",polygonStyle2D.getMaxScale());
238
        xml.putProperty("pMinScale",polygonStyle2D.getMinScale());
239
        if (polygonStyle2D.getContour() instanceof Color){
240
                xml.putProperty("pContour",StringUtilities.color2String((Color)polygonStyle2D.getContour()));
241
        }else if (polygonStyle2D.getContour() instanceof GradientPaint){
242
                xml.putProperty("pContourTransparency",((GradientPaint)polygonStyle2D.getContour()).getTransparency());
243
                xml.putProperty("pContourColor1",StringUtilities.color2String(((GradientPaint)polygonStyle2D.getContour()).getColor1()));
244
                xml.putProperty("pContourColor2",StringUtilities.color2String(((GradientPaint)polygonStyle2D.getContour()).getColor2()));
245
                xml.putProperty("pContourPoint1X",((GradientPaint)polygonStyle2D.getContour()).getPoint1().getX());
246
                xml.putProperty("pContourPoint1Y",((GradientPaint)polygonStyle2D.getContour()).getPoint1().getY());
247
                xml.putProperty("pContourPoint2X",((GradientPaint)polygonStyle2D.getContour()).getPoint2().getX());
248
                xml.putProperty("pContourPoint2Y",((GradientPaint)polygonStyle2D.getContour()).getPoint2().getY());
249
        }else if (polygonStyle2D.getContour() instanceof TexturePaint){
250
                xml.putProperty("pContourTransparency",((TexturePaint)polygonStyle2D.getContour()).getTransparency());
251
                xml.putProperty("pContourAnchorRectX",((TexturePaint)polygonStyle2D.getContour()).getAnchorRect().getX());
252
                xml.putProperty("pContourAnchorRectY",((TexturePaint)polygonStyle2D.getContour()).getAnchorRect().getY());
253
                xml.putProperty("pContourAnchorRectW",((TexturePaint)polygonStyle2D.getContour()).getAnchorRect().getWidth());
254
                xml.putProperty("pContourAnchorRectH",((TexturePaint)polygonStyle2D.getContour()).getAnchorRect().getHeight());
255
                //TODO falta que guardar la imagen
256
        }
257
        if (polygonStyle2D.getFill() instanceof Color){
258
                xml.putProperty("pFill",StringUtilities.color2String((Color)polygonStyle2D.getContour()));
259
        }else if (polygonStyle2D.getContour() instanceof GradientPaint){
260
                xml.putProperty("pFillTransparency",((GradientPaint)polygonStyle2D.getContour()).getTransparency());
261
                xml.putProperty("pFillColor1",StringUtilities.color2String(((GradientPaint)polygonStyle2D.getContour()).getColor1()));
262
                xml.putProperty("pFillColor2",StringUtilities.color2String(((GradientPaint)polygonStyle2D.getContour()).getColor2()));
263
                xml.putProperty("pFillPoint1X",((GradientPaint)polygonStyle2D.getContour()).getPoint1().getX());
264
                xml.putProperty("pFillPoint1Y",((GradientPaint)polygonStyle2D.getContour()).getPoint1().getY());
265
                xml.putProperty("pFillPoint2X",((GradientPaint)polygonStyle2D.getContour()).getPoint2().getX());
266
                xml.putProperty("pFillPoint2Y",((GradientPaint)polygonStyle2D.getContour()).getPoint2().getY());
267
        }else if (polygonStyle2D.getContour() instanceof TexturePaint){
268
                xml.putProperty("pFillTransparency",((TexturePaint)polygonStyle2D.getContour()).getTransparency());
269
                xml.putProperty("pFillAnchorRectX",((TexturePaint)polygonStyle2D.getContour()).getAnchorRect().getX());
270
                xml.putProperty("pFillAnchorRectY",((TexturePaint)polygonStyle2D.getContour()).getAnchorRect().getY());
271
                xml.putProperty("pFillAnchorRectW",((TexturePaint)polygonStyle2D.getContour()).getAnchorRect().getWidth());
272
                xml.putProperty("pFillAnchorRectH",((TexturePaint)polygonStyle2D.getContour()).getAnchorRect().getHeight());
273
                //TODO falta que guardar la imagen
274
        }
275
        //TODO xml.putProperty("",polygonStyle2D.getContourComposite());
276
        //TODO xml.putProperty("",polygonStyle2D.getGraphicStroke());
277
        //TODO xml.putProperty("",polygonStyle2D.getStroke());
278
        
279
        
280
        
281
                return xml;
282
}
283
}