Revision 27517

View differences:

branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/IObjList.java
1
/*
2
 * Created on 21-jun-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.cresques.px;
48

  
49
import java.awt.geom.Point2D;
50
import java.util.Iterator;
51

  
52
import org.cresques.geo.Projected;
53

  
54

  
55
/**
56
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
57
 */
58
public interface IObjList extends Extent.Has, Projected {
59
    public Iterator iterator();
60

  
61
    public int size();
62

  
63
    public void add(Extent.Has obj);
64

  
65
    public void remove(Object obj);
66

  
67
    public void clear();
68

  
69
    public IObjList getAt(Point2D pt);
70

  
71
    interface vector extends IObjList {
72
        public Extent.Has get(int i);
73
    }
74
}
0 75

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/PxLine.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26
import java.awt.Color;
27
import java.awt.Graphics2D;
28
import java.awt.Stroke;
29
import java.awt.geom.AffineTransform;
30

  
31
import org.cresques.geo.ViewPortData;
32

  
33

  
34
public class PxLine extends PxObj implements IPoint, Colored {
35
    private int px = 0;
36
    private int py = 0;
37
    private int px2 = 0;
38
    private int py2 = 0;
39
    private Color pc;
40

  
41
    public PxLine(IPoint p, IPoint p2, Color color) {
42
        x(p.x());
43
        y(p.y());
44
        x2(p2.x());
45
        y2(p2.y());
46
        c(color);
47
        extent = new Extent(Math.min(x(), x2()), Math.min(y(), y2()),
48
                            Math.max(x(), x2()), Math.max(y(), y2()));
49
    }
50

  
51
    public PxLine(int x, int y, int x2, int y2, Color color) {
52
        x(x);
53
        y(y);
54
        x2(x2);
55
        y2(y2);
56
        c(color);
57
        extent = new Extent(Math.min(x(), x2()), Math.min(y(), y2()),
58
                            Math.max(x(), x2()), Math.max(y(), y2()));
59
    }
60

  
61
    public int x() {
62
        return px;
63
    }
64

  
65
    public int x(int x) {
66
        px = x;
67

  
68
        return px;
69
    }
70

  
71
    public int y() {
72
        return py;
73
    }
74

  
75
    public int y(int y) {
76
        py = y;
77

  
78
        return py;
79
    }
80

  
81
    public int x2() {
82
        return px2;
83
    }
84

  
85
    public int x2(int x) {
86
        px2 = x;
87

  
88
        return px2;
89
    }
90

  
91
    public int y2() {
92
        return py2;
93
    }
94

  
95
    public int y2(int y) {
96
        py2 = y;
97

  
98
        return py2;
99
    }
100

  
101
    public Color c() {
102
        return pc;
103
    }
104

  
105
    public Color c(Color color) {
106
        pc = color;
107

  
108
        return pc;
109
    }
110

  
111
    public void setStroke(Stroke stroke) {
112
        this.stroke = stroke;
113
    }
114

  
115
    /*        public void draw(Graphics2D g) {
116
                    draw(g, g.getTransform(), null);
117
            }
118

  
119
            public void draw(Graphics2D g, AffineTransform mat, Extent sz) {
120
    */
121
    public void draw(Graphics2D g, ViewPortData vp) {
122
        Stroke strkSave = null;
123

  
124
        if (stroke != null) {
125
            strkSave = g.getStroke();
126
            g.setStroke(stroke);
127
        }
128

  
129
        AffineTransform msave = g.getTransform();
130
        g.setTransform(vp.mat);
131
        g.setColor(c());
132
        g.drawLine(x(), y(), x2(), y2());
133

  
134
        if (strkSave != null) {
135
            g.setStroke(strkSave);
136
        }
137

  
138
        g.setTransform(msave);
139
    }
140
}
0 141

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/Drawable.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26

  
27
//import java.awt.geom.AffineTransform;
28
import java.awt.Graphics2D;
29

  
30
import org.cresques.geo.ViewPortData;
31

  
32

  
33
public interface Drawable {
34
    public void draw(Graphics2D g, ViewPortData vp);
35
}
0 36

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/PxContour.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26
import java.awt.Color;
27
import java.awt.FontMetrics;
28
import java.awt.Graphics2D;
29
import java.awt.geom.Point2D;
30
import java.util.Vector;
31

  
32
import org.cresques.cts.ICoordTrans;
33
import org.cresques.cts.IProjection;
34
import org.cresques.geo.Polygon2D;
35
import org.cresques.geo.Projected;
36
import org.cresques.geo.ViewPortData;
37
import org.cresques.geo.cover.Hoja;
38

  
39

  
40
public class PxContour extends PxObj implements Projected {
41
    final static Color colorBase = new Color(0, 64, 128, 255); //Color(255,214,132,255);
42
    final static Color fColorBase = new Color(64, 128, 192, 255); //Color(255,222,165,64);
43
    IProjection proj = null;
44
    protected String name;
45
    protected String fName;
46
    private Color fColor = fColorBase;
47
    private Color pc = colorBase;
48
    private Polygon2D polygon = null;
49

  
50
    public PxContour(Extent e, String fName, String name, IProjection proj) {
51
        this.fName = fName;
52
        this.name = name;
53
        this.proj = proj;
54

  
55
        Point2D[] v = new Point2D[4];
56
        v[0] = proj.createPoint(e.minX(), e.minY());
57
        v[1] = proj.createPoint(e.maxX(), e.minY());
58
        v[2] = proj.createPoint(e.maxX(), e.maxY());
59
        v[3] = proj.createPoint(e.minX(), e.maxY());
60
        setContour(v);
61
    }
62

  
63
    public PxContour(Hoja h) {
64
        name = h.getCode();
65
        setContour(h.getVertex());
66
    }
67

  
68
    public PxContour(Point2D[] v, String name) {
69
        this.name = name;
70
        setContour(v);
71
    }
72

  
73
    public void _PxContour(Point2D pt1, Point2D pt2, String fName, String name) {
74
        this.fName = fName;
75
        this.name = name;
76
        extent = new Extent(pt1, pt2);
77
    }
78

  
79
    public void _PxContour(Point2D[] v, String fName, String name) {
80
        this.fName = fName;
81
        this.name = name;
82
        setContour(v);
83
    }
84

  
85
    public IProjection getProjection() {
86
        return proj;
87
    }
88

  
89
    public void setProjection(IProjection p) {
90
        proj = p;
91
    }
92

  
93
    private void setContour(Point2D[] v) {
94
        extent = new Extent();
95
        polygon = new Polygon2D();
96

  
97
        for (int i = 0; i < v.length; i++) {
98
            polygon.addPoint(v[i]);
99
            extent.add(v[i]);
100
        }
101
    }
102

  
103
    /**
104
     * Vertices de un contorno.
105
     * @return
106
     */
107
    public Vector getVertex() {
108
        return polygon;
109
    }
110

  
111
    public Point2D[] getPtList() {
112
        Point2D[] v = new Point2D[polygon.size()];
113

  
114
        for (int i = 0; i < polygon.size(); i++)
115
            v[i] = (Point2D) polygon.get(i);
116

  
117
        return v;
118
    }
119

  
120
    public String getName() {
121
        return name;
122
    }
123

  
124
    public Color c() {
125
        return pc;
126
    }
127

  
128
    public Color c(Color color) {
129
        this.pc = color;
130

  
131
        return pc;
132
    }
133

  
134
    public Color fillColor() {
135
        return fColor;
136
    }
137

  
138
    public Color fillColor(Color c) {
139
        fColor = c;
140

  
141
        return fColor;
142
    }
143

  
144
    public void setColor(Color color) {
145
        pc = color;
146
    }
147

  
148
    public Color getColor() {
149
        return pc;
150
    }
151

  
152
    public void setFillColor(Color color) {
153
        fColor = color;
154
    }
155

  
156
    public Color getFillColor() {
157
        return fColor;
158
    }
159

  
160
    public void reProject(ICoordTrans rp) {
161
        Polygon2D savePol = polygon;
162

  
163
        polygon = new Polygon2D();
164
        extent = new Extent();
165

  
166
        Point2D ptDest = null;
167

  
168
        for (int i = 0; i < savePol.size(); i++) {
169
            ptDest = rp.getPDest().createPoint(0.0, 0.0);
170
            ptDest = rp.convert((Point2D) savePol.get(i), ptDest);
171
            polygon.addPoint(ptDest);
172
            extent.add(ptDest);
173
        }
174

  
175
        setProjection(rp.getPDest());
176
    }
177

  
178
    public void draw(Graphics2D g, ViewPortData vp, ICoordTrans rp) {
179
        IProjection saveProj = proj;
180
        Polygon2D savePol = polygon;
181
        Extent saveExt = extent;
182

  
183
        reProject(rp);
184
        draw(g, vp);
185

  
186
        polygon = savePol;
187
        extent = saveExt;
188
        proj = saveProj;
189
    }
190

  
191
    public void draw(Graphics2D g, ViewPortData vp) {
192
        //AffineTransform msave=g.getTransform();
193
        //g.setTransform(vp.mat);
194
        // relleno el marco si es preciso
195
        if (fColor != null) {
196
            g.setColor(fColor);
197

  
198
            if (polygon == null) {
199
                g.fillRect((int) extent.minX(), (int) extent.minY(),
200
                           (int) extent.width(), (int) extent.height());
201
            } else {
202
                polygon.fill(g, vp);
203
            }
204
        }
205

  
206
        // pinto el marco si es preciso
207
        if (pc != null) {
208
            g.setColor(pc);
209
        }
210

  
211
        if (polygon != null) {
212
            polygon.draw(g, vp);
213
        } else {
214
            g.drawRect((int) extent.minX(), (int) extent.minY(),
215
                       (int) extent.width(), (int) extent.height());
216
        }
217

  
218
        //g.setTransform(msave);
219
        // Pinto el name
220
        FontMetrics fm = g.getFontMetrics();
221
        int w = fm.stringWidth(name);
222
        int h = fm.getAscent();
223
        Point2D.Double pt = new Point2D.Double((extent.minX() +
224
                                               (extent.width() / 2.0)),
225
                                               (extent.minY() +
226
                                               (extent.height() / 2.0)));
227

  
228
        try {
229
            Point2D.Double min = new Point2D.Double(extent.minX(), extent.minY());
230
            Point2D.Double max = new Point2D.Double(extent.maxX(), extent.minY());
231
            vp.mat.transform(min, min);
232
            vp.mat.transform(max, max);
233

  
234
            if ((max.getX() - min.getX()) < w) {
235
                return;
236
            }
237

  
238
            vp.mat.transform(pt, pt);
239

  
240
            //if ((int)(pt2.getY()-pt1.getY()) >= g.getFontMetrics().getAscent())
241
            g.drawString(name, (int) pt.getX() - (w / 2),
242
                         (int) pt.getY() + (h / 2));
243
        } catch (Exception e) {
244
            e.printStackTrace();
245
        }
246
    }
247
}
0 248

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/PxPoint.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26

  
27
public class PxPoint implements IPoint {
28
    private int px = 0;
29
    private int py = 0;
30

  
31
    public PxPoint(int x, int y) {
32
        this.px = x;
33
        this.py = y;
34
    }
35

  
36
    public int x() {
37
        return px;
38
    }
39

  
40
    public int x(int x) {
41
        px = x;
42

  
43
        return px;
44
    }
45

  
46
    public int y() {
47
        return py;
48
    }
49

  
50
    public int y(int y) {
51
        py = y;
52

  
53
        return py;
54
    }
55
}
0 56

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/dxf/DxfSpline.java
26 26
import java.awt.geom.Point2D;
27 27
import java.util.Iterator;
28 28

  
29
import org.cresques.geo.Projection;
29
import org.cresques.cts.IProjection;
30 30
import org.cresques.io.DxfGroup;
31 31

  
32 32

  
......
35 35
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
36 36
 */
37 37
public class DxfSpline extends DxfPolyline {
38
    
38

  
39 39
    /**
40 40
     * Constructor de DxfSpline.
41 41
     * @param proj, proyecci?n cartogr?fica en la que se encuentra el DxfSpline.
42 42
     * @param layer, capa del DXF en la que se encuentra el DxfSpline.
43 43
     */
44
    public DxfSpline(Projection proj, DxfLayer layer) {
44
    public DxfSpline(IProjection proj, DxfLayer layer) {
45 45
        super(proj, layer);
46 46
    }
47 47

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/IPoint.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26
public interface IPoint {
27
    public int x();
28

  
29
    public int x(int x);
30

  
31
    public int y();
32

  
33
    public int y(int y);
34
}
0 35

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/PxObj.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26
import java.awt.Stroke;
27

  
28

  
29
public abstract class PxObj implements Drawable, Extent.Has {
30
    public Stroke stroke = null;
31
    /**
32
     * Extent completo del raster. Este contiene las coordenadas reales tanto
33
     * para un raster rotado como sin rotar. Este extent coincide con requestExtent
34
     * cuando el raster no tiene rotaci?n. 
35
     */
36
    protected Extent extent = null;
37
    /**
38
     * Este es el extent sobre el que se ajusta una petici?n para que esta no exceda el 
39
     * extent m?ximo del raster. Para un raster sin rotar ser? igual al extent
40
     * pero para un raster rotado ser? igual al extent del raster como si no 
41
     * tuviera rotaci?n. Esto ha de ser as? ya que la rotaci?n solo se hace sobre la
42
     * vista y las peticiones han de hacerse en coordenadas de la imagen sin shearing
43
     * aplicado.
44
     */
45
    protected Extent requestExtent = null;
46

  
47
    public Extent getExtent() {
48
        return extent;
49
    }
50
}
0 51

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/PxSize.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26

  
27
public class PxSize implements ISize {
28
    private int pw = 0;
29
    private int ph = 0;
30

  
31
    public PxSize(int w, int h) {
32
        this.pw = w;
33
        this.ph = h;
34
    }
35

  
36
    public int w() {
37
        return pw;
38
    }
39

  
40
    public int w(int w) {
41
        pw = w;
42

  
43
        return pw;
44
    }
45

  
46
    public int h() {
47
        return ph;
48
    }
49

  
50
    public int h(int h) {
51
        ph = h;
52

  
53
        return ph;
54
    }
55
}
0 56

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/ISize.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26
public interface ISize {
27
    public int w();
28

  
29
    public int w(int w);
30

  
31
    public int h();
32

  
33
    public int h(int h);
34
}
0 35

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/PxRect.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26
import java.awt.Color;
27
import java.awt.Graphics2D;
28
import java.awt.geom.AffineTransform;
29

  
30
import org.cresques.geo.ViewPortData;
31

  
32

  
33
public class PxRect extends PxObj implements IPoint, ISize, Colored {
34
    private int px = 0;
35
    private int py = 0;
36
    private int pw = 0;
37
    private int ph = 0;
38
    private Color pc;
39
    private Color filColor = null;
40

  
41
    public PxRect(IPoint p, ISize s, Color color, Color fc) {
42
        x(p.x());
43
        y(p.y());
44
        w(s.w());
45
        h(s.h());
46
        c(color);
47
        fillColor(fc);
48
        extent = new Extent(x(), y(), x() + w(), y() + h());
49
    }
50

  
51
    public PxRect(int x, int y, int w, int h, Color color, Color fc) {
52
        x(x);
53
        y(y);
54
        w(w);
55
        h(h);
56
        c(color);
57
        fillColor(fc);
58
        extent = new Extent(x(), y(), x() + w(), y() + h());
59
    }
60

  
61
    public int x() {
62
        return px;
63
    }
64

  
65
    public int x(int x) {
66
        px = x;
67

  
68
        return px;
69
    }
70

  
71
    public int y() {
72
        return py;
73
    }
74

  
75
    public int y(int y) {
76
        py = y;
77

  
78
        return py;
79
    }
80

  
81
    public int w() {
82
        return pw;
83
    }
84

  
85
    public int w(int w) {
86
        pw = w;
87

  
88
        return pw;
89
    }
90

  
91
    public int h() {
92
        return ph;
93
    }
94

  
95
    public int h(int h) {
96
        ph = h;
97

  
98
        return ph;
99
    }
100

  
101
    public Color c() {
102
        return pc;
103
    }
104

  
105
    public Color c(Color color) {
106
        pc = color;
107

  
108
        return pc;
109
    }
110

  
111
    public Color fillColor() {
112
        return filColor;
113
    }
114

  
115
    public Color fillColor(Color c) {
116
        filColor = c;
117

  
118
        return filColor;
119
    }
120

  
121
    /*        public void draw(Graphics2D g) {
122
                    draw(g, g.getTransform(), null);
123
            }
124

  
125
            public void draw(Graphics2D g, AffineTransform mat, Extent sz) {
126
    */
127
    public void draw(Graphics2D g, ViewPortData vp) {
128
        AffineTransform msave = g.getTransform();
129
        g.setTransform(vp.mat);
130

  
131
        if (fillColor() != null) {
132
            g.setColor(fillColor());
133
            g.fillRect(x(), y(), w(), h());
134
        }
135

  
136
        g.setColor(c());
137
        g.drawRect(x(), y(), w(), h());
138
        g.setTransform(msave);
139
    }
140
}
0 141

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/Colored.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.px;
25

  
26
import java.awt.Color;
27

  
28

  
29
public interface Colored {
30
    public Color c();
31

  
32
    public Color c(Color c);
33
}
0 34

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/px/package.html
1
<html>
2
	<body>Pixel: Clases para dibujar.
3
</body>
4
</html>
0 5

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/geo/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/geo/Polygon2D.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.geo;
25

  
26
import java.awt.Graphics2D;
27
import java.awt.geom.GeneralPath;
28
import java.awt.geom.Point2D;
29

  
30
import java.util.Iterator;
31
import java.util.Vector;
32

  
33
import org.cresques.geo.ViewPortData;
34

  
35

  
36
/**
37
 * Clase que representa un pol?gono 2D
38
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
39
 */
40
public class Polygon2D extends Vector {
41
    GeneralPath gp = null;
42

  
43
    public Polygon2D() {
44
        super();
45
        gp = null;
46
    }
47

  
48
    /**
49
     * A?ade un vertice al po??gono
50
     * @param pt        punto 2D que representa el vertice a?adido
51
     */
52
    public void addPoint(Point2D pt) {
53
        super.add(pt);
54
    }
55

  
56
    /**
57
     * Dibuja el pol?gono
58
     * @param g        Graphics sobre el que dibuja
59
     * @param vp        ViewPort con la vista
60
     */
61
    public void draw(Graphics2D g, ViewPortData vp) {
62
        newGP(vp);
63
        g.draw(gp);
64

  
65
        //g.draw(new Line2D.Double(pt,pt0));
66
    }
67

  
68
    /**
69
     *
70
     * @param g
71
     * @param vp
72
     */
73
    public void fill(Graphics2D g, ViewPortData vp) {
74
        newGP(vp);
75
        g.fill(gp);
76
    }
77

  
78
    /**
79
     *
80
     * @param vp
81
     */
82
    private void newGP(ViewPortData vp) {
83
        //if (gp != null) return;
84
        gp = new GeneralPath();
85

  
86
        Point2D pt0 = null;
87
        Point2D pt = null;
88
        Point2D pt1 = null;
89
        Point2D.Double ptTmp = new Point2D.Double(0.0, 0.0);
90
        Iterator iter = iterator();
91

  
92
        while (iter.hasNext()) {
93
            pt1 = (Point2D) iter.next();
94
            vp.mat.transform(pt1, ptTmp);
95

  
96
            if (pt0 == null) {
97
                pt0 = ptTmp;
98
                gp.moveTo((float) ptTmp.getX(), (float) ptTmp.getY());
99
            } else {
100
                gp.lineTo((float) ptTmp.getX(), (float) ptTmp.getY());
101
            }
102
        }
103

  
104
        gp.closePath();
105
    }
106
}
0 107

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/geo/cover/package.html
1
<html>
2
	<body>Clases relacionadas con coverturas espaciales.
3
</body>
4
</html>
0 5

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/geo/cover/Hoja.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.geo.cover;
25

  
26
import org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28

  
29
import org.cresques.geo.Projected;
30
import org.cresques.px.Extent;
31

  
32

  
33
import java.awt.geom.Point2D;
34

  
35
import java.io.InputStream;
36
import java.io.OutputStream;
37

  
38
import java.util.Vector;
39

  
40

  
41
/**
42
 * @author Luis W. Sevilla <sevilla_lui@gva.es>
43
 */
44
public class Hoja implements Projected {
45
    IProjection proj;
46
    String code = null;
47
    String name = null;
48
    Extent extent = null;
49
    Point2D tl;
50
    Point2D tr;
51
    Point2D bl;
52
    Point2D br;
53

  
54
    public Hoja(IProjection proj, String code, String name) {
55
        this.proj = proj;
56
        this.code = code;
57
        this.name = name;
58
        tl = tr = bl = br = null;
59
    }
60

  
61
    public Hoja(String cod, Point2D p1, Point2D p2, Point2D p3, Point2D p4,
62
                String name) {
63
        code = cod;
64
        tl = p1;
65
        tr = p2;
66
        bl = p3;
67
        br = p4;
68

  
69
        if (name != null) {
70
            this.name = name;
71
        }
72

  
73
        setExtent();
74
    }
75

  
76
    public Hoja(String cod, Point2D[] pt, String name) {
77
        code = cod;
78
        tl = pt[0];
79
        tr = pt[1];
80
        br = pt[2];
81
        bl = pt[3];
82

  
83
        if (name != null) {
84
            this.name = name;
85
        }
86

  
87
        setExtent();
88
    }
89

  
90
    public Hoja(String cod, Vector pt, String name) {
91
        code = cod;
92
        tl = (Point2D) pt.get(0);
93
        tr = (Point2D) pt.get(1);
94
        br = (Point2D) pt.get(2);
95
        bl = (Point2D) pt.get(3);
96

  
97
        if (name != null) {
98
            this.name = name;
99
        }
100

  
101
        setExtent();
102
    }
103

  
104
    public Hoja(String cod, Hoja h, String name) {
105
        code = cod;
106
        tl = h.tl;
107
        tr = h.tr;
108
        br = h.br;
109
        bl = h.bl;
110

  
111
        if (name != null) {
112
            this.name = name;
113
        }
114

  
115
        setExtent();
116
    }
117

  
118
    public IProjection getProjection() {
119
        return proj;
120
    }
121

  
122
    public void setProjection(IProjection p) {
123
        proj = p;
124
    }
125

  
126
    public void reProject(ICoordTrans rp) {
127
        // TODO metodo reProject pendiente de implementar
128
    }
129

  
130
    public Point2D getTL() {
131
        return tl;
132
    }
133

  
134
    public void setTL(Point2D pt) {
135
        tl = pt;
136
        extent.add(pt);
137
    }
138

  
139
    public Point2D getTR() {
140
        return tr;
141
    }
142

  
143
    public void setTR(Point2D pt) {
144
        tr = pt;
145
        extent.add(pt);
146
    }
147

  
148
    public Point2D getBL() {
149
        return bl;
150
    }
151

  
152
    public void setBL(Point2D pt) {
153
        bl = pt;
154
        extent.add(pt);
155
    }
156

  
157
    public Point2D getBR() {
158
        return br;
159
    }
160

  
161
    public void setBR(Point2D pt) {
162
        br = pt;
163
        extent.add(pt);
164
    }
165

  
166
    public Extent getExtent() {
167
        return extent;
168
    }
169

  
170
    private void setExtent() {
171
        extent = new Extent(tl, br);
172
        extent.add(tr);
173
        extent.add(bl);
174
    }
175

  
176
    public String getCode() {
177
        return code;
178
    }
179

  
180
    public String getName() {
181
        return name;
182
    }
183

  
184
    public Point2D[] getVertex() {
185
        Point2D[] v = { tl, tr, br, bl };
186

  
187
        return v;
188
    }
189

  
190
    public void toXml(OutputStream os) {
191
    }
192

  
193
    public void fromXml(InputStream is) {
194
    }
195
}
0 196

  
branches/v2_0_0_prep/libraries/libDXF/src/org/cresques/geo/Point3D.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
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 2
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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.geo;
25

  
26
import java.awt.geom.Point2D;
27

  
28

  
29
/**
30
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
31
 */
32
public class Point3D extends Point2D {
33
    public double X;
34
    public double Y;
35
    public double Z;
36

  
37
    public Point3D() {
38
        setLocation(0.0, 0.0);
39
    }
40

  
41
    public Point3D(double x, double y) {
42
        setLocation(x, y);
43
    }
44

  
45
    public Point3D(double x, double y, double z) {
46
        setLocation(x, y, z);
47
    }
48

  
49
    public Point3D(Point2D pt) {
50
        setLocation(pt.getX(), pt.getY());
51
    }
52

  
53
    public Point3D(Point3D pt) {
54
        setLocation(pt.getX(), pt.getY(), pt.getZ());
55
    }
56

  
57
    public double getX() {
58
        return X;
59
    }
60

  
61
    public double getY() {
62
        return Y;
63
    }
64

  
65
    public double getZ() {
66
        return Z;
67
    }
68

  
69
    public void setLocation(double x, double y) {
70
        X = x;
71
        Y = y;
72
        Z = 0D;
73
    }
74

  
75
    public void setLocation(double x, double y, double z) {
76
        X = x;
77
        Y = y;
78
        Z = z;
79
    }
80

  
81
    public String toString() {
82
        return "(" + getX() + "," + getY() + ")";
83
    }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff