Revision 360

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/FStyle2D.java
22 22
 * 
23 23
 */
24 24
public class FStyle2D {
25

  
26
	/**
25
	public static final int POINT = 1;
26
    public static final int LINE = 2;
27
    public static final int POLYGON = 4;
28
    public static final int TEXT = 8;
29
    
30
    /**
27 31
	 * RGB (incluye transparencia) que se utilizar? para la aceleraci?n gr?fica
28 32
	 */
29 33
	private int rgbPoint;
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/styling/PreviousSymbolDrawer.java
1
package com.iver.cit.gvsig.fmap.rendering.styling;
2

  
3
import com.iver.cit.gvsig.fmap.ViewPort;
4
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
5
import com.iver.cit.gvsig.fmap.core.IGeometry;
6
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
7

  
8
import java.awt.Dimension;
9
import java.awt.Graphics2D;
10
import java.awt.geom.Point2D;
11
import java.awt.geom.Rectangle2D;
12

  
13

  
14
/**
15
 * DOCUMENT ME!
16
 *
17
 * @author Vicente Caballero Navarro
18
 */
19
public class PreviousSymbolDrawer {
20
    private static IGeometry gPoint;
21
    private static IGeometry gLine;
22
    private static IGeometry gPolygon = ShapeFactory.createPoint2D(0, 0);
23
    private static IGeometry gText = ShapeFactory.createPoint2D(0, 0);
24
    FStyle2D fs2d;
25

  
26
    /**
27
     * Crea un nuevo PreviousSymbolDrawer.
28
     *
29
     * @param f DOCUMENT ME!
30
     */
31
    public PreviousSymbolDrawer(FStyle2D f) {
32
        fs2d = f;
33
        initPoint();
34
        initLine();
35
    }
36

  
37
    /**
38
     * DOCUMENT ME!
39
     *
40
     * @param g DOCUMENT ME!
41
     * @param rec DOCUMENT ME!
42
     * @param type DOCUMENT ME!
43
     */
44
    public void draw(Graphics2D g, Rectangle2D rec, int type) {
45
        boolean point = false;
46
        boolean line = false;
47
        boolean polygon = false;
48
        boolean text = false;
49
        int all = 0;
50

  
51
        if ((type % 2) > 0) { //POINT
52
            point = true;
53
            all++;
54
        }
55

  
56
        type = type / 2;
57

  
58
        if ((type % 2) > 0) { //LINE
59
            line = true;
60
            all++;
61
        }
62

  
63
        type = type / 2;
64

  
65
        if ((type % 2) > 0) { //POLYGON
66
            polygon = true;
67
            all++;
68
        }
69

  
70
        type = type / 2;
71

  
72
        if ((type % 2) > 0) { //TEXT
73
            text = true;
74
            all++;
75
        }
76

  
77
        double part = rec.getWidth() / all;
78
        Rectangle2D[] rectangles = new Rectangle2D[all];
79

  
80
        for (int i = 0; i < all; i++) {
81
            rectangles[i] = new Rectangle2D.Double(rec.getX() + (part * i),
82
                    rec.getY(), rec.getWidth() - (part * (all - i - 1)),
83
                    rec.getHeight());
84
        }
85

  
86
        int num = 0;
87

  
88
        if (point) {
89
            drawPoint(g, rectangles[num]);
90
        }
91

  
92
        if (line) {
93
            drawLine(g, rectangles[num++]);
94
        }
95

  
96
        if (polygon) {
97
            drawPolygon(g, rectangles[num++]);
98
        }
99

  
100
        if (text) {
101
            drawText(g, rectangles[num++]);
102
        }
103
    }
104

  
105
    /**
106
     * DOCUMENT ME!
107
     */
108
    private void initPoint() {
109
        gPoint = ShapeFactory.createPoint2D(0, 0);
110
    }
111

  
112
    /**
113
     * DOCUMENT ME!
114
     */
115
    private void initLine() {
116
        Point2D[] points = new Point2D.Double[4];
117
        int height = 10;
118
        int width = 10;
119
        points[0] = new Point2D.Double(0, 0 + (height / 2));
120
        points[1] = new Point2D.Double(0 + (width / 3), 0 + height);
121
        points[2] = new Point2D.Double(0 + ((2 * width) / 3), 0);
122
        points[3] = new Point2D.Double(0 + width, 0 + (height / 2));
123

  
124
        int[] parts = new int[1];
125
        parts[0] = 0;
126

  
127
        GeneralPathX gPX = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
128
                points.length);
129
        initGeneralPathX(gPX, points, parts);
130
        gLine = ShapeFactory.createPolyline2D(gPX);
131
    }
132

  
133
    /**
134
     * DOCUMENT ME!
135
     */
136
    private void initPolygon() {
137
    }
138

  
139
    /**
140
     * DOCUMENT ME!
141
     */
142
    private void initText() {
143
    }
144

  
145
    /**
146
     * DOCUMENT ME!
147
     *
148
     * @param gPX DOCUMENT ME!
149
     * @param po DOCUMENT ME!
150
     * @param pa DOCUMENT ME!
151
     */
152
    private void initGeneralPathX(GeneralPathX gPX, Point2D[] po, int[] pa) {
153
        int j = 0;
154

  
155
        for (int i = 0; i < po.length; i++) {
156
            if (i == pa[j]) {
157
                gPX.moveTo(po[i].getX(), po[i].getY());
158

  
159
                if (j < (pa.length - 1)) {
160
                    j++;
161
                }
162
            } else {
163
                gPX.lineTo(po[i].getX(), po[i].getY());
164
            }
165
        }
166
    }
167

  
168
    /**
169
     * DOCUMENT ME!
170
     *
171
     * @param g DOCUMENT ME!
172
     * @param rect DOCUMENT ME!
173
     */
174
    public void drawPoint(Graphics2D g, Rectangle2D rect) {
175
        ViewPort vp = new ViewPort();
176
        vp.setOffset(new Point2D.Double(rect.getX(), rect.getY()));
177
        vp.setImageSize(new Dimension((int) rect.getWidth(),
178
                (int) rect.getHeight()));
179
        gPoint.draw(g, vp, fs2d);
180
    }
181

  
182
    /**
183
     * DOCUMENT ME!
184
     *
185
     * @param g DOCUMENT ME!
186
     * @param rect DOCUMENT ME!
187
     */
188
    public void drawLine(Graphics2D g, Rectangle2D rect) {
189
        ViewPort vp = new ViewPort();
190
        vp.setOffset(new Point2D.Double(rect.getX(), rect.getY()));
191
        vp.setImageSize(new Dimension((int) rect.getWidth(),
192
                (int) rect.getHeight()));
193
        gLine.draw(g, vp, fs2d);
194
    }
195

  
196
    /**
197
     * DOCUMENT ME!
198
     *
199
     * @param g DOCUMENT ME!
200
     * @param rect DOCUMENT ME!
201
     */
202
    public void drawPolygon(Graphics2D g, Rectangle2D rect) {
203
    }
204

  
205
    /**
206
     * DOCUMENT ME!
207
     *
208
     * @param g DOCUMENT ME!
209
     * @param rect DOCUMENT ME!
210
     */
211
    public void drawText(Graphics2D g, Rectangle2D rect) {
212
    }
213
}
0 214

  

Also available in: Unified diff