Revision 35427

View differences:

tags/v2_0_0_Build_2027/libProjection/src-test/org/cresques/cts/AllTests.java
1
package org.cresques.cts;
2

  
3
import junit.framework.Test;
4
import junit.framework.TestSuite;
5

  
6
public class AllTests {
7

  
8
	public static Test suite() {
9
		TestSuite suite = new TestSuite("Test for org.cresques.cts");
10
		//$JUnit-BEGIN$
11

  
12
		//$JUnit-END$
13
		return suite;
14
	}
15

  
16
}
0 17

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text_de.properties
1
#Translations for language [de]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=OK
4
Aplicar=Anwenden
5
Block_Size_=
6
Cancelar=Abbrechen
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text_eu.properties
1
#Translations for language [eu]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Ados
4
Aplicar=Aplikatu
5
Block_Size_=
6
Cancelar=Utzi
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text_it.properties
1
#Translations for language [it]
2
#Tue Nov 07 12:30:01 CET 2006
3
Aceptar=Accetta
4
Aplicar=Applica
5
Block_Size_=Dimensioni blocco\:
6
Cancelar=Cancella
7
Compression_=Compressione
8
datum=Datum
9
Generate_Tfw_=Genera Tfw\:
10
Interleave_=Interlacciato\:
11
Photometric_=Fotometrica\:
12
Progressive_=Progressivo\:
13
projection=Proiezione
14
reference_system=Sistema di riferimento
15
zone=Fuso
0 16

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text.properties
1
#Translations for language [es]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Aceptar
4
Aplicar=Aplicar
5
Block_Size_=Tama\u00f1o de bloque\:
6
Cancelar=Cancelar
7
Compression_=Compresi\u00f3n\:
8
datum=Datum
9
Generate_Tfw_=Generar Tfw\:
10
Interleave_=Entrelazado\:
11
Photometric_=Fotom\u00e9trica\:
12
Progressive_=Progresivo\:
13
projection=Proyecci\u00f3n
14
reference_system=Sistema de Referencia
15
zone=Huso
0 16

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text_en.properties
1
#Translations for language [en]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Accept
4
Aplicar=Apply
5
Block_Size_=Block Size\:
6
Cancelar=Cancel
7
Compression_=Compression\:
8
datum=Datum
9
Generate_Tfw_=Generate Tfw\:
10
Interleave_=Interleave\:
11
Photometric_=Photometric\:
12
Progressive_=Progressive\:
13
projection=Projection
14
reference_system=Reference System
15
zone=Zone
0 16

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text_gl.properties
1
#Translations for language [gl]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Aceptar
4
Aplicar=Aplicar
5
Block_Size_=
6
Cancelar=Cancelar
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text_ca.properties
1
#Translations for language [ca]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Acceptar
4
Aplicar=Aplicar
5
Block_Size_=
6
Cancelar=Cancel\u00b7lar
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=Projecci\u00f3
14
reference_system=Sistema de refer\u00e8ncia
15
zone=
0 16

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text_pt.properties
1
#Translations for language [pt]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Aceitar
4
Aplicar=Aplicar
5
Block_Size_=
6
Cancelar=Cancelar
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text_cs.properties
1
#Translations for language [cs]
2
#Mon Nov 06 09:04:31 CET 2006
3
Aceptar=Budi\u017e
4
Aplicar=Pou\u017e\u00edt
5
Block_Size_=
6
Cancelar=Zru\u0161it
7
Compression_=
8
datum=Datum
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=Projekce
14
reference_system=Prostorov\u00fd referen\u010dn\u00ed syst\u00e9m
15
zone=Z\u00f3na
0 16

  
tags/v2_0_0_Build_2027/libProjection/config/org/cresques/resources/i18n/text_fr.properties
1
#Translations for language [fr]
2
#Mon Oct 30 09:38:21 CET 2006
3
Aceptar=Accepter
4
Aplicar=Appliquer
5
Block_Size_=
6
Cancelar=Annuler
7
Compression_=
8
datum=
9
Generate_Tfw_=
10
Interleave_=
11
Photometric_=
12
Progressive_=
13
projection=
14
reference_system=
15
zone=
0 16

  
tags/v2_0_0_Build_2027/libProjection/resources-test/log4j.xml
1
<?xml version="1.0" encoding="UTF-8" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
5

  
6
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
7
		<layout class="org.apache.log4j.PatternLayout">
8
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
9
		</layout>
10
	</appender>
11

  
12
	<category name="org.gvsig.tools">
13
		<priority value="DEBUG" />
14
	</category>
15
	<category name="org.cresques">
16
		<priority value="DEBUG" /> 
17
	</category>
18
	<category name="org.gvsig.fmap.crs">
19
		<priority value="DEBUG" /> 
20
	</category>
21

  
22
	<root>
23
		<priority value="INFO" />
24
		<appender-ref ref="CONSOLE" />
25
	</root>
26
</log4j:configuration>
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/geo/ViewPortData.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.Dimension;
27
import java.awt.geom.AffineTransform;
28
import java.awt.geom.Point2D;
29
import java.text.DecimalFormat;
30

  
31
import org.cresques.cts.ICoordTrans;
32
import org.cresques.cts.IProjection;
33
import org.cresques.px.Extent;
34

  
35

  
36
/**
37
 * Datos de vista sobre las capas.
38
 *
39
 * Mantiene un conjunto de datos necesarios, que describen el modo de
40
 * ver las capas actual.
41
 *
42
 * cmartinez: Esta clase no deber?a formar parte de una API, pero
43
 * se deja hasta que se aborde el refactoring de libProjection.
44
 *
45
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
46
 */
47
public class ViewPortData implements Projected {
48
    /**
49
     * Tipo de proyecci?n de la vista.
50
     */
51
    IProjection proj = null;
52

  
53
    /**
54
     * Sistema de coordenadas de la vista.
55
     */
56
    IProjection cs = null;
57

  
58
    /**
59
     * Amplitud de la vista, en coordenadas proyectadas.
60
     */
61
    Extent extent = null;
62

  
63
    /**
64
     * Tama?o de la vista, en coordenadas de dispositivo.
65
     */
66
    Dimension size = null;
67

  
68
    /**
69
     * Transformaci?n af?n usada en la vista actual.
70
     */
71
    public AffineTransform mat = null;
72

  
73
    /**
74
     * Resoluci?n (Puntos por pulgada) de la vista actual.
75
     * Se necesita para los c?lculos de escala geogr?fica.
76
     */
77
    int dpi = java.awt.Toolkit.getDefaultToolkit().getScreenResolution();
78

  
79
    public ViewPortData() {
80
    }
81

  
82
    public ViewPortData(IProjection proj, Extent extent, Dimension size) {
83
        this.proj = proj;
84
        this.extent = extent;
85
        this.size = size;
86
        mat = new AffineTransform();
87
        mat.scale(1.0, -1.0);
88
    }
89

  
90
    public IProjection getProjection() {
91
        return proj;
92
    }
93

  
94
    public void setProjection(IProjection proj) {
95
        this.proj = proj;
96
    }
97

  
98
    public void reProject(ICoordTrans rp) {
99
        // TODO metodo reProject pendiente de implementar
100
    }
101

  
102
    public void setCoordSys(IProjection cs) {
103
        this.cs = cs;
104
    }
105

  
106
    //public void setCoordTrans(ICoordTrans ct) { this.ct = ct; }
107
    public AffineTransform getMat() {
108
        return mat;
109
    }
110

  
111
    public void setMat(AffineTransform mat) {
112
        this.mat = mat;
113
    }
114

  
115
    public Object clone() {
116
        ViewPortData vp = new ViewPortData();
117

  
118
        if (mat != null) {
119
            vp.mat = new AffineTransform(mat);
120
        }
121

  
122
        if (extent != null) {
123
            vp.extent = new Extent(extent);
124
        }
125

  
126
        vp.proj = proj;
127
        vp.size = size;
128
        vp.dpi = dpi;
129

  
130
        return vp;
131
    }
132

  
133
    public double getWidth() {
134
        return size.width;
135
    }
136

  
137
    public double getHeight() {
138
        return size.height;
139
    }
140

  
141
    /**
142
     *
143
     */
144
    public Dimension getSize() {
145
        return size;
146
    }
147

  
148
    public void setSize(double w, double h) {
149
        setSize(new Dimension((int) w, (int) h));
150
    }
151

  
152
    public void setSize(Dimension sz) {
153
        size = sz;
154
        reExtent();
155
    }
156

  
157
    public Extent getExtent() {
158
        return extent;
159
    }
160

  
161
    public void setExtent(Dimension sz) {
162
        Point2D.Double pt0 = new Point2D.Double(0, 0);
163
        Point2D.Double ptSz = new Point2D.Double(sz.width, sz.height);
164

  
165
        try {
166
            mat.inverseTransform(pt0, pt0);
167
            mat.inverseTransform(ptSz, ptSz);
168
        } catch (Exception e) {
169
            e.printStackTrace();
170
        }
171

  
172
        extent = new Extent(pt0, ptSz);
173
    }
174

  
175
    public void reExtent() {
176
        setExtent(size);
177
    }
178

  
179
    public void setDPI(int dpi) {
180
        this.dpi = dpi;
181
    }
182

  
183
    public int getDPI() {
184
        return this.dpi;
185
    }
186

  
187
    /**
188
     * zoom a un marco.
189
     *
190
     * @param extent
191
     */
192
    public void zoom(Extent extent) {
193
        double[] scale = extent.getScale(getWidth(), getHeight());
194
        double escala = Math.min(scale[0], scale[1]);
195

  
196
        mat.setToIdentity();
197
        mat.scale(escala, -escala);
198
        mat.translate(-extent.minX(), -extent.maxY());
199
        this.extent = extent;
200
        reExtent();
201
    }
202

  
203
    /**
204
     * zoom centrado en un punto.
205
     *
206
     * @param zoom
207
     * @param pt
208
     */
209
    public void zoom(double zoom, Point2D pt) {
210
        zoom(zoom, zoom, pt);
211
    }
212

  
213
    public void zoom(double zx, double zy, Point2D pt) {
214
        centerAt(pt);
215
        mat.scale(zx, zy);
216
        centerAt(pt);
217
        reExtent();
218
    }
219

  
220
    /**
221
     * Zoom a una escala (geogr?fica);
222
     *
223
     * @param scale
224
     */
225
    public void zoomToGeoScale(double scale) {
226
        double actual = getGeoScale();
227
        double f = actual / scale;
228
        zoomToCenter(f);
229
    }
230

  
231
    /**
232
     * Zoom a una escala (geogr?fica);
233
     *
234
     * @param scale
235
     */
236
    public void zoomToCenter(double f) {
237
        Point2D.Double ptCenter = new Point2D.Double(getWidth() / 2.0,
238
                                                     getHeight() / 2.0);
239

  
240
        try {
241
            mat.inverseTransform(ptCenter, ptCenter);
242
        } catch (Exception e) {
243
            e.printStackTrace();
244
        }
245

  
246
        zoom(f, ptCenter);
247
    }
248

  
249
    /**
250
     * Centrar en un punto.
251
     *
252
     * @param pt
253
     */
254
    public void centerAt(Point2D pt) {
255
        Point2D.Double ptCenter = new Point2D.Double(getWidth() / 2.0,
256
                                                     getHeight() / 2.0);
257

  
258
        try {
259
            mat.inverseTransform(ptCenter, ptCenter);
260
            mat.translate(ptCenter.x - pt.getX(), ptCenter.y - pt.getY());
261
        } catch (Exception e) {
262
            e.printStackTrace();
263
        }
264

  
265
        reExtent();
266
    }
267

  
268
    /**
269
     * Desplaza la vista actual.
270
     *
271
     * @param pt
272
     */
273
    public void pan(Point2D ptIni, Point2D ptFin) {
274
        mat.translate(ptFin.getX() - ptIni.getX(), ptFin.getY() - ptIni.getY());
275
        reExtent();
276
    }
277

  
278
    public Point2D getCenter() {
279
        Point2D.Double ptCenter = new Point2D.Double(getWidth() / 2.0,
280
                                                     getHeight() / 2.0);
281

  
282
        try {
283
            mat.inverseTransform(ptCenter, ptCenter);
284
        } catch (Exception e) {
285
            e.printStackTrace();
286
        }
287

  
288
        return ptCenter;
289
    }
290

  
291
    /**
292
     * Escala Geogr?fica.
293
     *
294
     * @param dpi resolucion en puntos por pulgada
295
     */
296
    public double getGeoScale() {
297
        /* // TODO Actulizarlo para Geotools2
298
        double scale = 0.0;
299
        if (proj.getClass() == UtmZone.class) { // UTM;
300
                scale = (extent.maxX()-extent.minX())*        // metros
301
                        (dpi / 2.54 * 100.0)/                                // px / metro
302
                        getWidth();                                                        // pixels
303
        } else if (proj.getClass() == Geodetic.class) { // Geodetic
304
                scale = (extent.maxX()-extent.minX())*                // grados
305
                        // 1852.0 metros x minuto de meridiano
306
                        (dpi / 2.54 * 100.0 * 1852.0 * 60.0)/        // px / metro
307
                        getWidth();                                                                // pixels
308
        } else if (proj.getClass() == Mercator.class) { // Mercator
309
                Projection prj = Geodetic.getProjection((Ellipsoid) proj.getDatum());
310
                GeoPoint pt1 = (GeoPoint) prj.createPoint(1.0,0.0);
311
                GeoPoint pt2 = (GeoPoint) prj.createPoint(2.0,0.0);
312
                ProjPoint ppt1 = (ProjPoint) proj.createPoint(0.0, 0.0);
313
                ProjPoint ppt2 = (ProjPoint) proj.createPoint(0.0, 0.0);
314
                ((Mercator) proj).fromGeo(pt1, ppt1);
315
                ((Mercator) proj).fromGeo(pt2, ppt2);
316
                //scale = ppt2.getX()-ppt1.getX();
317
                scale =  ((extent.maxX()-extent.minX())/ (ppt2.getX()-ppt1.getX()) ) *
318
                //scale = ((extent.maxX()-extent.minX())/ getWidth());// *
319
                        (dpi / 2.54 * 100.0 * 1852.0 * 60.0) /
320
                        getWidth();
321
        } */
322
        return proj.getScale(extent.minX(), extent.maxX(), getWidth(), dpi);
323
    }
324

  
325
    public String getGeoScaleAsString(String fmt) {
326
        DecimalFormat format = new DecimalFormat(fmt);
327

  
328
        return "1:" + format.format(getGeoScale());
329
    }
330
}
0 331

  
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/geo/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/geo/cover/.cvsignore
1
*.dfPackage
2
*.wmf
0 3

  
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/geo/package.html
1
<html>
2
	<body>Pixel: Clases base relacionadas con geometria.
3
</body>
4
</html>
0 5

  
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/geo/Projected.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 org.cresques.cts.ICoordTrans;
27
import org.cresques.cts.IProjection;
28

  
29

  
30
/**
31
 * <p><code>Projected</code> should be implement by all objects that can be re-projected.</p>
32
 *
33
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>*
34
 */
35
public interface Projected {
36
	/**
37
	 * <p>Returns the current projection.<p>
38
	 * 
39
	 * @return current projection
40
	 * 
41
	 * @see #reProject(ICoordTrans)
42
	 */
43
    public IProjection getProjection();
44

  
45
    /**
46
     * <p>Changes projection of the graphical information of this object.</p>
47
     * 
48
     * @param ct transformation coordinates for obtaining the new projection
49
     * 
50
     * @see #getProjection()
51
     */
52
    public void reProject(ICoordTrans ct);
53
}
0 54

  
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/CRSFactoryNotRegisteredException.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

  
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}   {Create a base Locator implementation}
26
 */
27
package org.cresques;
28

  
29
import org.gvsig.tools.exception.BaseRuntimeException;
30

  
31
/**
32
 * Exception for errors related to the initialization of a Library.
33
 * 
34
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
35
 */
36
public class CRSFactoryNotRegisteredException extends BaseRuntimeException {
37

  
38
	private static final long serialVersionUID = 7354573543115812224L;
39

  
40
	private static final String KEY = "_CRSFactoryNotRegisteredException";
41

  
42
    private static final String MESSAGE = "An instance of ICRSFactory has not " +
43
    		"been registered in the CRSFactory";
44

  
45
    public CRSFactoryNotRegisteredException() {
46
        super(MESSAGE, KEY, serialVersionUID);
47
    }
48
}
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/ui/package.html
1
<html>
2
	<body>User Interface: Clases para interface de usuario.
3
</body>
4
</html>
0 5

  
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/ui/DefaultDialogPanel.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.ui;
25

  
26
import java.awt.FlowLayout;
27
import java.awt.GridBagConstraints;
28
import java.awt.GridBagLayout;
29
import java.awt.event.ComponentEvent;
30
import java.awt.event.ComponentListener;
31

  
32
import javax.swing.JButton;
33
import javax.swing.JPanel;
34

  
35
import org.cresques.Messages;
36

  
37

  
38
/**
39
 * @author Luis W. Sevilla (sevilla_lui@gva.es)
40
 */
41
public class DefaultDialogPanel extends JPanel implements ComponentListener{
42
    final private static long serialVersionUID = -3370601314380922368L;
43
    protected JPanel contentPane = null;
44
    private JPanel tabPane = null;
45
    protected JPanel buttonPane = null;
46
    private JButton acceptButton = null;
47
    private JButton cancelButton = null;
48
    private JButton applyButton = null;
49
    private int flag = 0;
50
    protected int cWidth = 0, difWidth = 0;
51
    protected int cHeight = 0, difHeight = 0;
52
	protected JPanel pButton = null;
53

  
54
    /**
55
     * Constructor
56
     * @param init
57
     */
58
    public DefaultDialogPanel(boolean init){
59
    	if(init)
60
    		initialize();
61
    }
62

  
63
    /**
64
     * Constructor
65
     */
66
    public DefaultDialogPanel() {
67
        super();
68
        this.initialize();
69
    }
70

  
71
    /**
72
     * This method initializes this
73
     *
74
     * @return void
75
     */
76
    public void initialize() {
77
        //setBounds(0,0,321,230);
78
        //javax.swing.BoxLayout(jContentPane, javax.swing.BoxLayout.Y_AXIS);
79
        //jContentPane.setLayout(new java.awt.GridLayout(2,1));
80
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
81
        gridBagConstraints11.gridx = 0;
82
        gridBagConstraints11.insets = new java.awt.Insets(4,0,0,0);
83
        gridBagConstraints11.gridy = 1;
84
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
85
        gridBagConstraints.insets = new java.awt.Insets(5,0,2,0);
86
        gridBagConstraints.gridy = 0;
87
        gridBagConstraints.gridx = 0;
88
        setLayout(new GridBagLayout());
89
        setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
90

  
91
        //jContentPane.setSize(30, 24);
92
        this.setPreferredSize(new java.awt.Dimension(320, 165));
93
        this.add(getTabPanel(), gridBagConstraints);
94
        this.add(getPButton(), gridBagConstraints11);
95
        this.addComponentListener(this);
96

  
97
    }
98

  
99
    /**
100
     * Obtiene el panel general
101
     * @return
102
     */
103
    protected JPanel getContentPanel() {
104
        if (contentPane == null) {
105
            contentPane = new JPanel();
106
            contentPane.setLayout(new GridBagLayout());
107
            contentPane.setBounds(6, 200, 310, 125);
108
            contentPane.setPreferredSize(new java.awt.Dimension(310, 100));
109
        }
110

  
111
        return contentPane;
112
    }
113

  
114
    public JPanel getTabPanel() {
115
        if (tabPane == null) {
116
            GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
117
            gridBagConstraints2.insets = new java.awt.Insets(5,0,0,0);
118
            gridBagConstraints2.gridy = 0;
119
            gridBagConstraints2.gridx = 0;
120
            tabPane = new JPanel();
121
            tabPane.setLayout(new GridBagLayout());
122

  
123

  
124
            //tabPane.setBounds(6, 7, 309, 189);
125
            tabPane.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.SoftBevelBorder.RAISED));
126
            tabPane.add(getContentPanel(), gridBagConstraints2);
127
        }
128

  
129
        return tabPane;
130
    }
131

  
132
    /**
133
	 * This method initializes jPanel
134
	 *
135
	 * @return javax.swing.JPanel
136
	 */
137
	private JPanel getPButton() {
138
		if (pButton == null) {
139
			FlowLayout flowLayout1 = new FlowLayout();
140
			flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
141
			flowLayout1.setHgap(0);
142
			flowLayout1.setVgap(0);
143
			pButton = new JPanel();
144
			pButton.setPreferredSize(new java.awt.Dimension(320,25));
145
			pButton.setLayout(flowLayout1);
146
			pButton.add(getButtonPanel(), null);
147
		}
148
		return pButton;
149
	}
150

  
151

  
152
    /**
153
     * Obtiene el panel que contiene los botones de Aceptar, Cancelar y Aplicar
154
     * @return
155
     */
156
    protected JPanel getButtonPanel() {
157
        if (buttonPane == null) {
158
            GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
159
            gridBagConstraints4.gridx = 2;
160
            gridBagConstraints4.insets = new java.awt.Insets(0,3,0,0);
161
            gridBagConstraints4.gridy = 0;
162
            GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
163
            gridBagConstraints3.gridx = 1;
164
            gridBagConstraints3.insets = new java.awt.Insets(0,3,0,3);
165
            gridBagConstraints3.gridy = 0;
166
            GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
167
            gridBagConstraints1.insets = new java.awt.Insets(0,0,0,3);
168
            gridBagConstraints1.gridy = 0;
169
            gridBagConstraints1.gridx = 0;
170
            buttonPane = new JPanel();
171
            buttonPane.setLayout(new GridBagLayout());
172
            buttonPane.add(getAcceptButton(), gridBagConstraints1);
173
            buttonPane.add(getCancelButton(), gridBagConstraints3);
174
            buttonPane.add(getApplyButton(), gridBagConstraints4);
175
        }
176

  
177
        return buttonPane;
178
    }
179

  
180
    /**
181
     * This method initializes Accept button
182
     *
183
     * @return javax.swing.JButton
184
     */
185
    public JButton getAcceptButton() {
186
        if (acceptButton == null) {
187
            acceptButton = new JButton("Aceptar");
188
            acceptButton.setText(Messages.getText("Aceptar"));
189
        }
190

  
191
        return acceptButton;
192
    }
193

  
194
    /**
195
     * This method initializes Cancel Button
196
     *
197
     * @return javax.swing.JButton
198
     */
199
    public JButton getCancelButton() {
200
        if (cancelButton == null) {
201
            cancelButton = new JButton("Cancelar");
202
            cancelButton.setText(Messages.getText("Cancelar"));
203
        }
204

  
205
        return cancelButton;
206
    }
207

  
208
    /**
209
     * This method initializes Apply Button
210
     *
211
     * @return javax.swing.JButton
212
     */
213
    public JButton getApplyButton() {
214
        if (applyButton == null) {
215
            applyButton = new JButton(Messages.getText("Aplicar"));
216
        }
217

  
218
        return applyButton;
219
    }
220

  
221
	public void componentHidden(ComponentEvent e) {
222
		// TODO Auto-generated method stub
223

  
224
	}
225

  
226
	public void componentMoved(ComponentEvent e) {
227
		// TODO Auto-generated method stub
228

  
229
	}
230

  
231
	public void componentResized(ComponentEvent e) {
232
		if(e.getSource() == this)
233
			this.resizeWindow();
234
	}
235

  
236
	public void resizeWindow(){
237
		if (flag == 0){
238
			cWidth = this.getSize().width;
239
			cHeight = this.getSize().height;
240
			flag++;
241
		}
242

  
243
		int nWidth = getWidth();
244
		int nHeight = getHeight();
245
		difWidth = nWidth - cWidth;
246
		difHeight = nHeight - cHeight;
247
		this.tabPane.setSize(this.tabPane.getSize().width + difWidth, this.tabPane.getSize().height + difHeight);
248
		this.tabPane.setLocation(this.tabPane.getLocation().x - difWidth/2, this.tabPane.getLocation().y - difHeight/2);
249

  
250
		this.contentPane.setSize(this.contentPane.getSize().width + difWidth, this.contentPane.getSize().height + difHeight);
251
		//this.pButton.setSize(this.getPButton().getWidth() + difWidth/2, 25);
252
		//this.buttonPane.setLocation(this.buttonPane.getLocation().x + difWidth/2, this.buttonPane.getLocation().y + difHeight/2);
253
		this.pButton.setLocation(this.pButton.getLocation().x + difWidth/2, this.pButton.getLocation().y + difHeight/2);
254

  
255
	}
256

  
257
	public void componentShown(ComponentEvent e) {
258
		// TODO Auto-generated method stub
259

  
260
	}
261

  
262

  
263
}  //  @jve:decl-index=0:visual-constraint="12,13"
0 264

  
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/ui/cts/CSSelectionDialogPanel.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.ui.cts;
25

  
26
import javax.swing.JPanel;
27

  
28
import org.cresques.Messages;
29
import org.cresques.impl.cts.ProjectionPool;
30
import org.cresques.ui.DefaultDialogPanel;
31

  
32

  
33
/**
34
 * Dialogo para abrir fichero.
35
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
36
 */
37
public class CSSelectionDialogPanel extends DefaultDialogPanel {
38
    final private static long serialVersionUID = -3370601314380922368L;
39

  
40
    public CSSelectionDialogPanel() {
41
        super();
42
        init();
43
    }
44

  
45
    /**
46
     * This method initializes this
47
     *
48
     * @return void
49
     */
50
    private void init() {
51
        this.setBounds(0, 0, 350, 260);
52
    }
53

  
54
    public CSSelectionPanel getProjPanel() {
55
        return (CSSelectionPanel) getContentPanel();
56
    }
57

  
58
    protected JPanel getContentPanel() {
59
        if (contentPane == null) {
60
        	contentPane = new CSSelectionPanel(Messages.getText("reference_system"));
61
        	contentPane.setBounds(14, 12, 280, 163);
62

  
63
            ((CSSelectionPanel) contentPane).setProjection(new ProjectionPool().get("EPSG:32619"));
64
        }
65

  
66
        return contentPane;
67
    }
68
}
0 69

  
tags/v2_0_0_Build_2027/libProjection/src/org/cresques/ui/cts/CSSelectionPanel.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.ui.cts;
25

  
26
import javax.swing.JLabel;
27
import javax.swing.JPanel;
28

  
29
import org.cresques.Messages;
30
import org.cresques.cts.IProjection;
31
import org.cresques.ui.LoadableComboBox;
32

  
33

  
34
//import es.gva.cit.geoexplorer.ui.LoadableComboBox;
35

  
36
/**
37
 * Panel de edici?n de Sistemas de referencia
38
 * @author "Luis W. Sevilla" <sevilla_lui@gva.es>
39
 */
40
public class CSSelectionPanel extends JPanel {
41
    final private static long serialVersionUID = -3370601314380922368L;
42
    private LoadableComboBox datumComboBox = null;
43
    private LoadableComboBox projComboBox = null;
44
    private LoadableComboBox huseComboBox = null;
45
    private JLabel jLabel = null;
46
    private JLabel jLabel1 = null;
47
    private JLabel jLabel2 = null;
48
    private String tit;
49
    private CSSelectionModel model;
50

  
51
    /**
52
     * Constructor de la clase.
53
     */
54
    public CSSelectionPanel(String tit) {
55
        super();
56

  
57
        if (tit == null) {
58
            //tit = "Sistema de referencia";
59
            //TODO: add com.iver.andami.PluginServices to this project
60
            //change all the labels from fix text got from the internationalitation
61
            tit = Messages.getText("reference_system");
62
            if (tit == null) tit="Reference System";
63
        }
64

  
65
        this.tit = tit;
66
        setModel(new CSSelectionModel());
67
        initialize();
68
    }
69

  
70
    /**
71
     * Inicializa el panel.
72
     * @return javax.swing.JPanel
73
     */
74
    private void initialize() {
75
        setPreferredSize(new java.awt.Dimension(295, 170));
76
        setLayout(null);
77

  
78
        /*javax.swing.border.Border border = javax.swing.BorderFactory.createCompoundBorder(
79
        javax.swing. BorderFactory.createTitledBorder("Sistema de coordenadas"),
80
        javax.swing.BorderFactory.createEmptyBorder(5,5,5,5)); */
81
        setBorder(javax.swing.BorderFactory.createCompoundBorder(null,
82
                                                                 javax.swing.BorderFactory.createTitledBorder(null,
83
                                                                		 										Messages.getText("reference_system"),
84
                                                                                                              javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
85
                                                                                                              javax.swing.border.TitledBorder.DEFAULT_POSITION,
86
                                                                                                              null,
87
                                                                                                              null)));
88

  
89
        jLabel = new JLabel();
90
        jLabel.setBounds(15, 15, 77, 23);
91
        jLabel.setText(Messages.getText("datum") + ":");
92
        add(jLabel, null);
93
        add(getDatumComboBox(), null);
94

  
95
        jLabel1 = new JLabel();
96
        jLabel1.setBounds(15, 60, 77, 23);
97
        jLabel1.setText(Messages.getText("projection") + ":");
98
        add(jLabel1, null);
99
        add(getProjComboBox(), null);
100

  
101
        jLabel2 = new JLabel();
102
        jLabel2.setBounds(15, 105, 77, 23);
103
        jLabel2.setText(Messages.getText("zone") + ":");
104
        add(jLabel2, null);
105
        add(getHuseComboBox(), null);
106

  
107
        setHuseComboBoxEnabled(false);
108
    }
109

  
110
    public void setModel(CSSelectionModel model) {
111
        this.model = model;
112

  
113
        getHuseComboBox().loadData(model.getZoneList());
114
        getDatumComboBox().loadData(model.getDatumList());
115
        getProjComboBox().loadData(model.getProjectionList());
116
    }
117

  
118
    private void setHuseComboBoxEnabled(boolean enabled) {
119
        if (jLabel2 != null) {
120
            jLabel2.setEnabled(enabled);
121
        }
122

  
123
        getHuseComboBox().setEnabled(enabled);
124
    }
125

  
126
    private void setDatumComboBoxEnabled(boolean enabled) {
127
        if (jLabel != null) {
128
            jLabel.setEnabled(enabled);
129
        }
130

  
131
        getDatumComboBox().setEnabled(enabled);
132
    }
133

  
134
    public void setProjection(IProjection proj) {
135
        model.setProjection(proj);
136

  
137
        setDatumComboBoxEnabled(true);
138
        getDatumComboBox().setSelectedIndex(model.getSelectedDatum());
139
 
140
        getProjComboBox().removeAllItems();
141
        getProjComboBox().loadData(model.getProjectionList());
142

  
143
        model.setProjection(proj);
144
        getProjComboBox().setSelectedIndex(model.getSelectedProj());
145
        model.setProjection(proj);
146
        
147
        if (model.getSelectedZone() >= 0) {
148
            setHuseComboBoxEnabled(true);
149
            getHuseComboBox().removeAllItems();
150
            getHuseComboBox().loadData(model.getZoneList());
151

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff