Revision 3525

View differences:

trunk/extensions/extCenterViewToPoint/build.xml
1
<project name="Generar extension en Andami" default="generate-without-source" basedir=".">
2
    <description>
3
        Instala el plugin de Centrar la Vista sobre un punto en Andami.
4
    </description>
5
  <!-- set global properties for this build -->
6
  <property name="extensions-dir" location="../Andami/gvSIG/extensiones"/>
7
  <property name="src" location="src"/>
8
  <property name="bin" location="bin"/>
9
  <property name="doc"  location="doc"/>
10
  <property name="dist"  location="dist"/>
11
  <property name="without_src"  location="without_src"/>
12
  <property name="plugin" value="com.iver.gvsig.centerviewpoint"/>
13

  
14
  <target name="init">
15
    <!-- Create the time stamp -->
16
    <tstamp/>
17
  </target>
18

  
19
  <target name="dist" depends="init"
20
	description="generate the distribution" >
21
    <!-- Remove previous distribution directory -->
22
    <delete dir="${dist}"/>
23
    <!-- Create the distribution directory structure -->
24
    <mkdir dir="${dist}"/>
25
    <mkdir dir="${dist}/src"/>
26
    <mkdir dir="${dist}/doc"/>
27
    <mkdir dir="${dist}/bin"/>
28
    <mkdir dir="${dist}/bin/com"/>
29
    <mkdir dir="${dist}/bin/com/iver"/>
30
    <mkdir dir="${dist}/bin/com/iver/gvsig"/>
31
    <mkdir dir="${dist}/bin/com/iver/gvsig/centerviewpoint"/>
32
    <mkdir dir="${dist}/bin/com/iver/gvsig/centerviewpoint/images"/>
33
    <mkdir dir="${dist}/images"/>
34
    <mkdir dir="${dist}/config"/>
35
    <!-- Copy necessary distribution files to dist dir -->
36
    <copy todir="${dist}/src">
37
      <fileset dir="${src}"/>
38
    </copy>
39
    <copy todir="${dist}/doc">
40
      <fileset dir="${doc}"/>
41
    </copy>
42
    <copy todir="${dist}/images">
43
      <fileset dir="images"/>
44
    </copy>
45
    <copy file="config/config.xml" todir="${dist}/config"/>
46
    <copy file="build.xml" todir="${dist}"/>
47
    <copy todir="${dist}">
48
    	<fileset dir="." includes="text*.properties"/>
49
    </copy>
50
    <copy todir="${dist}/bin/com/iver/gvsig/centerviewpoint">
51
    	<fileset dir="." includes="text*.properties"/>
52
    </copy>
53
    <jar jarfile="${dist}/bin/com/iver/gvsig/centerviewpoint/${plugin}.jar" basedir="${bin}"/>
54
    <copy file="config/config.xml" todir="${dist}/bin/com/iver/gvsig/centerviewtopoint"/>
55
    <copy todir="${dist}/bin/com/iver/gvsig/centerviewpoint/images">
56
      <fileset dir="images"/>
57
    </copy>
58
    <!-- Zip distribution -->
59
    <zip destfile="${dist}/gvSIGCenterViewToPointPlugin.zip"
60
         basedir="${dist}"
61
         update="true"
62
    />
63
  </target>
64

  
65
  <target name="clean" depends="dist"
66
		description="clean dist directory" >
67
    <!-- Clean the distribution directory -->
68
    <delete dir="${dist}/src"/>
69
    <delete dir="${dist}/doc"/>
70
    <delete dir="${dist}/bin"/>
71
    <delete dir="${dist}/images"/>
72
    <delete dir="${dist}/config"/>
73
  	<delete file="${dist}/build.xml"/>
74
  	<delete>
75
        <fileset dir="${dist}" includes="**/*.properties"/>
76
    </delete>
77
  </target>
78
	
79
  <target name="generate-without-source" depends="clean" description="generate the distribution without the source file" >
80
    <!-- Create the distribution directory -->
81
    <mkdir dir="${without_src}"/>
82

  
83
    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
84
    <jar jarfile="${without_src}/${plugin}.jar" basedir="${bin}"/>
85
    <copy file="config/config.xml" todir="${without_src}"/>
86
    <copy todir="${without_src}">
87
    	<fileset dir="." includes="text*.properties"/>
88
    </copy>
89
    <copy todir="${without_src}/images">
90
    	<fileset dir="images/" includes="*"/>
91
    </copy>
92
    <move todir="${extensions-dir}/${plugin}/">
93
    	<fileset dir="${without_src}" includes="**/**"/>
94
    </move>
95
  </target>
96

  
97
</project>
98

  
0 99

  
trunk/extensions/extCenterViewToPoint/text.properties
1
#text.properties
2
Centrar_la_Vista_sobre_un_punto=Centrar la Vista sobre un punto
3
Aceptar=Aceptar
0 4

  
trunk/extensions/extCenterViewToPoint/.classpath
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="src" path="src"/>
4
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5
	<classpathentry combineaccessrules="false" kind="src" path="/Andami"/>
6
	<classpathentry combineaccessrules="false" kind="src" path="/FMap 03"/>
7
	<classpathentry combineaccessrules="false" kind="src" path="/gvSIG 03Sincronizado"/>
8
	<classpathentry sourcepath="/jCMS" kind="lib" path="/FMap 03/lib/cms.jar"/>
9
	<classpathentry kind="output" path="bin"/>
10
</classpath>
0 11

  
trunk/extensions/extCenterViewToPoint/text_en.properties
1
#text_en.properties
2
Centrar_la_Vista_sobre_un_punto=Center View to point
3
Aceptar=OK
0 4

  
trunk/extensions/extCenterViewToPoint/.project
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>gvSIGCenterViewToPointPlugin</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
	</buildSpec>
14
	<natures>
15
		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
16
		<nature>org.eclipse.jdt.core.javanature</nature>
17
		<nature>org.eclipse.jem.beaninfo.BeanInfoNature</nature>
18
	</natures>
19
</projectDescription>
0 20

  
trunk/extensions/extCenterViewToPoint/config/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<libraries library-dir="."/>
4
	<depends plugin-name="com.iver.cit.gvsig"/>
5
		<resourceBundle name="text"/>
6
	<extensions>
7
		<extension class-name="com.iver.gvsig.centerviewtopoint.CenterViewToPointExtension"
8
			description="CenterViewToPoint 0.1RC1  Extensi?n que permite hacer zooms en funci?n de un par de coordenadas introducidas por el usuario."
9
			active="true">
10
			<menu text="Vista/Centrar_la_Vista_sobre_un_punto" tooltip="Centrar_la_Vista_sobre_un_punto" 
11
				action-command="CENTERVIEWTOPOINT" 
12
				icon="images/centerviewtopoint.png" />
13
			<tool-bar name="com.iver.cit.gvsig.Herramientas">
14
				<action-tool icon="images/centerviewtopoint.png"
15
					action-command="CENTERVIEWTOPOINT" tooltip="Centrar_la_Vista_sobre_un_punto"
16
					enable-text="deber?a de estar activada" last="true"/>
17
			</tool-bar>
18
		</extension>
19
	</extensions>
20
</plugin-config>
0 21

  
trunk/extensions/extCenterViewToPoint/doc/install.txt
1
Plugin de Centrado de la Vista sobre un punto para gvSIG. Instrucciones de instalaci?n
2

  
3
- Copiar el contenido de la carpeta bin/ en:
4
  gvSIG/extensiones/
5

  
0 6

  
trunk/extensions/extCenterViewToPoint/doc/version_history.txt
1
Center View to point Plugin for gvSIG. Version history
2

  
3
This document lists the Change History of release versions of the Center View to point
4
Plugin for gvSIG
5

  
6

  
7
Version 0.1
8
Release Date: 16-11-2005
9

  
10
- Baseline version
11

  
0 12

  
trunk/extensions/extCenterViewToPoint/doc/gpl.txt
1
		    GNU GENERAL PUBLIC LICENSE
2
		       Version 2, June 1991
3

  
4
 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6
 Everyone is permitted to copy and distribute verbatim copies
7
 of this license document, but changing it is not allowed.
8

  
9
			    Preamble
10

  
11
  The licenses for most software are designed to take away your
12
freedom to share and change it.  By contrast, the GNU General Public
13
License is intended to guarantee your freedom to share and change free
14
software--to make sure the software is free for all its users.  This
15
General Public License applies to most of the Free Software
16
Foundation's software and to any other program whose authors commit to
17
using it.  (Some other Free Software Foundation software is covered by
18
the GNU Library General Public License instead.)  You can apply it to
19
your programs, too.
20

  
21
  When we speak of free software, we are referring to freedom, not
22
price.  Our General Public Licenses are designed to make sure that you
23
have the freedom to distribute copies of free software (and charge for
24
this service if you wish), that you receive source code or can get it
25
if you want it, that you can change the software or use pieces of it
26
in new free programs; and that you know you can do these things.
27

  
28
  To protect your rights, we need to make restrictions that forbid
29
anyone to deny you these rights or to ask you to surrender the rights.
30
These restrictions translate to certain responsibilities for you if you
31
distribute copies of the software, or if you modify it.
32

  
33
  For example, if you distribute copies of such a program, whether
34
gratis or for a fee, you must give the recipients all the rights that
35
you have.  You must make sure that they, too, receive or can get the
36
source code.  And you must show them these terms so they know their
37
rights.
38

  
39
  We protect your rights with two steps: (1) copyright the software, and
40
(2) offer you this license which gives you legal permission to copy,
41
distribute and/or modify the software.
42

  
43
  Also, for each author's protection and ours, we want to make certain
44
that everyone understands that there is no warranty for this free
45
software.  If the software is modified by someone else and passed on, we
46
want its recipients to know that what they have is not the original, so
47
that any problems introduced by others will not reflect on the original
48
authors' reputations.
49

  
50
  Finally, any free program is threatened constantly by software
51
patents.  We wish to avoid the danger that redistributors of a free
52
program will individually obtain patent licenses, in effect making the
53
program proprietary.  To prevent this, we have made it clear that any
54
patent must be licensed for everyone's free use or not licensed at all.
55

  
56
  The precise terms and conditions for copying, distribution and
57
modification follow.
58

59
		    GNU GENERAL PUBLIC LICENSE
60
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61

  
62
  0. This License applies to any program or other work which contains
63
a notice placed by the copyright holder saying it may be distributed
64
under the terms of this General Public License.  The "Program", below,
65
refers to any such program or work, and a "work based on the Program"
66
means either the Program or any derivative work under copyright law:
67
that is to say, a work containing the Program or a portion of it,
68
either verbatim or with modifications and/or translated into another
69
language.  (Hereinafter, translation is included without limitation in
70
the term "modification".)  Each licensee is addressed as "you".
71

  
72
Activities other than copying, distribution and modification are not
73
covered by this License; they are outside its scope.  The act of
74
running the Program is not restricted, and the output from the Program
75
is covered only if its contents constitute a work based on the
76
Program (independent of having been made by running the Program).
77
Whether that is true depends on what the Program does.
78

  
79
  1. You may copy and distribute verbatim copies of the Program's
80
source code as you receive it, in any medium, provided that you
81
conspicuously and appropriately publish on each copy an appropriate
82
copyright notice and disclaimer of warranty; keep intact all the
83
notices that refer to this License and to the absence of any warranty;
84
and give any other recipients of the Program a copy of this License
85
along with the Program.
86

  
87
You may charge a fee for the physical act of transferring a copy, and
88
you may at your option offer warranty protection in exchange for a fee.
89

  
90
  2. You may modify your copy or copies of the Program or any portion
91
of it, thus forming a work based on the Program, and copy and
92
distribute such modifications or work under the terms of Section 1
93
above, provided that you also meet all of these conditions:
94

  
95
    a) You must cause the modified files to carry prominent notices
96
    stating that you changed the files and the date of any change.
97

  
98
    b) You must cause any work that you distribute or publish, that in
99
    whole or in part contains or is derived from the Program or any
100
    part thereof, to be licensed as a whole at no charge to all third
101
    parties under the terms of this License.
102

  
103
    c) If the modified program normally reads commands interactively
104
    when run, you must cause it, when started running for such
105
    interactive use in the most ordinary way, to print or display an
106
    announcement including an appropriate copyright notice and a
107
    notice that there is no warranty (or else, saying that you provide
108
    a warranty) and that users may redistribute the program under
109
    these conditions, and telling the user how to view a copy of this
110
    License.  (Exception: if the Program itself is interactive but
111
    does not normally print such an announcement, your work based on
112
    the Program is not required to print an announcement.)
113

114
These requirements apply to the modified work as a whole.  If
115
identifiable sections of that work are not derived from the Program,
116
and can be reasonably considered independent and separate works in
117
themselves, then this License, and its terms, do not apply to those
118
sections when you distribute them as separate works.  But when you
119
distribute the same sections as part of a whole which is a work based
120
on the Program, the distribution of the whole must be on the terms of
121
this License, whose permissions for other licensees extend to the
122
entire whole, and thus to each and every part regardless of who wrote it.
123

  
124
Thus, it is not the intent of this section to claim rights or contest
125
your rights to work written entirely by you; rather, the intent is to
126
exercise the right to control the distribution of derivative or
127
collective works based on the Program.
128

  
129
In addition, mere aggregation of another work not based on the Program
130
with the Program (or with a work based on the Program) on a volume of
131
a storage or distribution medium does not bring the other work under
132
the scope of this License.
133

  
134
  3. You may copy and distribute the Program (or a work based on it,
135
under Section 2) in object code or executable form under the terms of
136
Sections 1 and 2 above provided that you also do one of the following:
137

  
138
    a) Accompany it with the complete corresponding machine-readable
139
    source code, which must be distributed under the terms of Sections
140
    1 and 2 above on a medium customarily used for software interchange; or,
141

  
142
    b) Accompany it with a written offer, valid for at least three
143
    years, to give any third party, for a charge no more than your
144
    cost of physically performing source distribution, a complete
145
    machine-readable copy of the corresponding source code, to be
146
    distributed under the terms of Sections 1 and 2 above on a medium
147
    customarily used for software interchange; or,
148

  
149
    c) Accompany it with the information you received as to the offer
150
    to distribute corresponding source code.  (This alternative is
151
    allowed only for noncommercial distribution and only if you
152
    received the program in object code or executable form with such
153
    an offer, in accord with Subsection b above.)
154

  
155
The source code for a work means the preferred form of the work for
156
making modifications to it.  For an executable work, complete source
157
code means all the source code for all modules it contains, plus any
158
associated interface definition files, plus the scripts used to
159
control compilation and installation of the executable.  However, as a
160
special exception, the source code distributed need not include
161
anything that is normally distributed (in either source or binary
162
form) with the major components (compiler, kernel, and so on) of the
163
operating system on which the executable runs, unless that component
164
itself accompanies the executable.
165

  
166
If distribution of executable or object code is made by offering
167
access to copy from a designated place, then offering equivalent
168
access to copy the source code from the same place counts as
169
distribution of the source code, even though third parties are not
170
compelled to copy the source along with the object code.
171

172
  4. You may not copy, modify, sublicense, or distribute the Program
173
except as expressly provided under this License.  Any attempt
174
otherwise to copy, modify, sublicense or distribute the Program is
175
void, and will automatically terminate your rights under this License.
176
However, parties who have received copies, or rights, from you under
177
this License will not have their licenses terminated so long as such
178
parties remain in full compliance.
179

  
180
  5. You are not required to accept this License, since you have not
181
signed it.  However, nothing else grants you permission to modify or
182
distribute the Program or its derivative works.  These actions are
183
prohibited by law if you do not accept this License.  Therefore, by
184
modifying or distributing the Program (or any work based on the
185
Program), you indicate your acceptance of this License to do so, and
186
all its terms and conditions for copying, distributing or modifying
187
the Program or works based on it.
188

  
189
  6. Each time you redistribute the Program (or any work based on the
190
Program), the recipient automatically receives a license from the
191
original licensor to copy, distribute or modify the Program subject to
192
these terms and conditions.  You may not impose any further
193
restrictions on the recipients' exercise of the rights granted herein.
194
You are not responsible for enforcing compliance by third parties to
195
this License.
196

  
197
  7. If, as a consequence of a court judgment or allegation of patent
198
infringement or for any other reason (not limited to patent issues),
199
conditions are imposed on you (whether by court order, agreement or
200
otherwise) that contradict the conditions of this License, they do not
201
excuse you from the conditions of this License.  If you cannot
202
distribute so as to satisfy simultaneously your obligations under this
203
License and any other pertinent obligations, then as a consequence you
204
may not distribute the Program at all.  For example, if a patent
205
license would not permit royalty-free redistribution of the Program by
206
all those who receive copies directly or indirectly through you, then
207
the only way you could satisfy both it and this License would be to
208
refrain entirely from distribution of the Program.
209

  
210
If any portion of this section is held invalid or unenforceable under
211
any particular circumstance, the balance of the section is intended to
212
apply and the section as a whole is intended to apply in other
213
circumstances.
214

  
215
It is not the purpose of this section to induce you to infringe any
216
patents or other property right claims or to contest validity of any
217
such claims; this section has the sole purpose of protecting the
218
integrity of the free software distribution system, which is
219
implemented by public license practices.  Many people have made
220
generous contributions to the wide range of software distributed
221
through that system in reliance on consistent application of that
222
system; it is up to the author/donor to decide if he or she is willing
223
to distribute software through any other system and a licensee cannot
224
impose that choice.
225

  
226
This section is intended to make thoroughly clear what is believed to
227
be a consequence of the rest of this License.
228

229
  8. If the distribution and/or use of the Program is restricted in
230
certain countries either by patents or by copyrighted interfaces, the
231
original copyright holder who places the Program under this License
232
may add an explicit geographical distribution limitation excluding
233
those countries, so that distribution is permitted only in or among
234
countries not thus excluded.  In such case, this License incorporates
235
the limitation as if written in the body of this License.
236

  
237
  9. The Free Software Foundation may publish revised and/or new versions
238
of the General Public License from time to time.  Such new versions will
239
be similar in spirit to the present version, but may differ in detail to
240
address new problems or concerns.
241

  
242
Each version is given a distinguishing version number.  If the Program
243
specifies a version number of this License which applies to it and "any
244
later version", you have the option of following the terms and conditions
245
either of that version or of any later version published by the Free
246
Software Foundation.  If the Program does not specify a version number of
247
this License, you may choose any version ever published by the Free Software
248
Foundation.
249

  
250
  10. If you wish to incorporate parts of the Program into other free
251
programs whose distribution conditions are different, write to the author
252
to ask for permission.  For software which is copyrighted by the Free
253
Software Foundation, write to the Free Software Foundation; we sometimes
254
make exceptions for this.  Our decision will be guided by the two goals
255
of preserving the free status of all derivatives of our free software and
256
of promoting the sharing and reuse of software generally.
257

  
258
			    NO WARRANTY
259

  
260
  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
REPAIR OR CORRECTION.
269

  
270
  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
POSSIBILITY OF SUCH DAMAGES.
279

  
280
		     END OF TERMS AND CONDITIONS
281

282
	    How to Apply These Terms to Your New Programs
283

  
284
  If you develop a new program, and you want it to be of the greatest
285
possible use to the public, the best way to achieve this is to make it
286
free software which everyone can redistribute and change under these terms.
287

  
288
  To do so, attach the following notices to the program.  It is safest
289
to attach them to the start of each source file to most effectively
290
convey the exclusion of warranty; and each file should have at least
291
the "copyright" line and a pointer to where the full notice is found.
292

  
293
    <one line to give the program's name and a brief idea of what it does.>
294
    Copyright (C) <year>  <name of author>
295

  
296
    This program is free software; you can redistribute it and/or modify
297
    it under the terms of the GNU General Public License as published by
298
    the Free Software Foundation; either version 2 of the License, or
299
    (at your option) any later version.
300

  
301
    This program is distributed in the hope that it will be useful,
302
    but WITHOUT ANY WARRANTY; without even the implied warranty of
303
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
304
    GNU General Public License for more details.
305

  
306
    You should have received a copy of the GNU General Public License
307
    along with this program; if not, write to the Free Software
308
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
309

  
310

  
311
Also add information on how to contact you by electronic and paper mail.
312

  
313
If the program is interactive, make it output a short notice like this
314
when it starts in an interactive mode:
315

  
316
    Gnomovision version 69, Copyright (C) year name of author
317
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318
    This is free software, and you are welcome to redistribute it
319
    under certain conditions; type `show c' for details.
320

  
321
The hypothetical commands `show w' and `show c' should show the appropriate
322
parts of the General Public License.  Of course, the commands you use may
323
be called something other than `show w' and `show c'; they could even be
324
mouse-clicks or menu items--whatever suits your program.
325

  
326
You should also get your employer (if you work as a programmer) or your
327
school, if any, to sign a "copyright disclaimer" for the program, if
328
necessary.  Here is a sample; alter the names:
329

  
330
  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331
  `Gnomovision' (which makes passes at compilers) written by James Hacker.
332

  
333
  <signature of Ty Coon>, 1 April 1989
334
  Ty Coon, President of Vice
335

  
336
This General Public License does not permit incorporating your program into
337
proprietary programs.  If your program is a subroutine library, you may
338
consider it more useful to permit linking proprietary applications with the
339
library.  If this is what you want to do, use the GNU Library General
340
Public License instead of this License.
0 341

  
trunk/extensions/extCenterViewToPoint/src/com/iver/gvsig/centerviewpoint/CenterViewToPointExtension.java
1
/*
2
 * Created on 22-jun-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.gvsig.centerviewpoint;
45

  
46
import java.awt.Color;
47

  
48
import com.iver.andami.PluginServices;
49
import com.iver.andami.plugins.Extension;
50
import com.iver.cit.gvsig.fmap.FMap;
51
import com.iver.cit.gvsig.gui.View;
52
import com.iver.cit.gvsig.project.ProjectView;
53
import com.iver.gvsig.centerviewtopoint.gui.InputCoordinatesPanel;
54

  
55
/**
56
 * The CenterViewToPointExtension class allows to center the View over a
57
 * concrete point given by its coordinates.
58
 * 
59
 * @author jmorell
60
 */
61
public class CenterViewToPointExtension implements Extension {
62
	private View vista;
63
	public static Color COLOR=Color.red;
64
    /* (non-Javadoc)
65
     * @see com.iver.andami.plugins.Extension#inicializar()
66
     */
67
    public void inicializar() {
68
        // TODO Auto-generated method stub
69

  
70
    }
71

  
72
    /* (non-Javadoc)
73
     * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
74
     */
75
    public void execute(String actionCommand) {
76
		vista = (View)PluginServices.getMDIManager().getActiveView();
77
        FMap mapContext = vista.getModel().getMapContext();
78
        InputCoordinatesPanel dataSelectionPanel = new InputCoordinatesPanel(mapContext);
79
        //dataSelectionPanel.setColor(color);
80
		PluginServices.getMDIManager().addView(dataSelectionPanel);
81
    }
82

  
83
    public View getView(){
84
    	return vista;
85
    }
86
    /* (non-Javadoc)
87
     * @see com.iver.andami.plugins.Extension#isEnabled()
88
     */
89
    public boolean isEnabled() {
90
        return true;
91
    }
92

  
93
    /* (non-Javadoc)
94
     * @see com.iver.andami.plugins.Extension#isVisible()
95
     */
96
    public boolean isVisible() {
97
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
98
		 .getActiveView();
99
		if (f == null) {
100
		    return false;
101
		}
102
		if (f.getClass() == View.class) {
103
		    View vista = (View) f;
104
		    ProjectView model = vista.getModel();
105
		    FMap mapa = model.getMapContext();
106
            if (mapa.getLayers().getLayersCount() > 0) {
107
                return true;
108
            } else {
109
                return false;
110
            }
111
		} else {
112
		    return false;
113
		}
114
    }
115

  
116
}
0 117

  
trunk/extensions/extCenterViewToPoint/src/com/iver/gvsig/centerviewtopoint/gui/InputCoordinatesPanel.java
1
/*
2
 * Created on 08-nov-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.gvsig.centerviewtopoint.gui;
45

  
46
import java.awt.Color;
47
import java.awt.Component;
48
import java.awt.event.MouseEvent;
49
import java.awt.geom.Point2D;
50
import java.awt.geom.Rectangle2D;
51

  
52
import javax.swing.JDialog;
53
import javax.swing.JOptionPane;
54
import javax.swing.JPanel;
55
import javax.swing.JLabel;
56
import javax.swing.JTextField;
57
import javax.swing.JButton;
58

  
59
import org.cresques.cts.IProjection;
60

  
61
import com.iver.andami.PluginServices;
62
import com.iver.andami.ui.mdiManager.View;
63
import com.iver.andami.ui.mdiManager.ViewInfo;
64
import com.iver.cit.gvsig.fmap.FMap;
65
import com.iver.cit.gvsig.fmap.MapControl;
66
import com.iver.cit.gvsig.fmap.core.IGeometry;
67
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
68
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
69
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
70
import com.iver.cit.gvsig.fmap.layers.GraphicLayer;
71
import com.iver.cit.gvsig.fmap.rendering.FGraphic;
72
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
73
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
74
import com.iver.cit.gvsig.gui.Panels.ColorChooserPanel;
75
import com.iver.cit.gvsig.gui.toolListeners.InfoListener;
76
import com.iver.gvsig.centerviewpoint.CenterViewToPointExtension;
77

  
78
/**
79
 * The InputCoordinatesPanel class creates a JPanel where the
80
 * user can input the coordinates of the point of reference
81
 * for center the View.
82
 * 
83
 * @author jmorell
84
 */
85
public class InputCoordinatesPanel extends JPanel implements View {
86
    private static final long serialVersionUID = 1L;
87
    private JLabel labelX = null;
88
    private JTextField textX = null;
89
    private JLabel labelY = null;
90
    private JTextField textY = null;
91
    private JButton buttonSearch = null;
92
    private MapControl mapControl;
93
    private ViewInfo viewInfo = null;
94
    private String firstCoordinate;
95
    private String secondCoordinate;
96
    private Point2D center;
97
    private GraphicLayer lyr;
98
    private ColorChooserPanel colorPanel;
99
	/**
100
     * This is the default constructor
101
     */
102
    public InputCoordinatesPanel(FMap mapContext) {
103
        super();
104
        this.mapControl = new MapControl();
105
        mapControl.setMapContext(mapContext);
106
        lyr=mapControl.getMapContext().getGraphicsLayer();
107
        initializeCoordinates();
108
        initialize();
109
    }
110
    
111
    private void initializeCoordinates() {
112
        IProjection proj = mapControl.getProjection();
113
        String projName = proj.getAbrev();
114
        if (projName.equals("EPSG:23030") || projName.equals("EPSG:27492") || projName.equals("EPSG:42101") || projName.equals("EPSG:42304")) {
115
            firstCoordinate = "X";
116
            secondCoordinate = "Y";
117
        } else if (projName.equals("EPSG:4230") || projName.equals("EPSG:4326")) {
118
            firstCoordinate = "Lon";
119
            secondCoordinate = "Lat";
120
        } else {
121
            System.out.println("Proyecci?n: " + projName);
122
            System.out.println("Proyecci?n no soportada.");
123
        }
124
    }
125

  
126
    private void zoomToCoordinates() throws Exception {
127
       try{
128
    	Rectangle2D oldExtent = mapControl.getViewPort().getAdjustedExtent();
129
        double oldCenterX = oldExtent.getCenterX();
130
        double oldCenterY = oldExtent.getCenterY();
131
        double centerX = (new Double((String)textX.getText())).doubleValue();
132
        double centerY = (new Double((String)textY.getText())).doubleValue();
133
        center=new Point2D.Double(centerX,centerY);
134
        double movX = centerX-oldCenterX;
135
        double movY = centerY-oldCenterY;
136
        double upperLeftCornerX = oldExtent.getMinX()+movX;
137
        double upperLeftCornerY = oldExtent.getMinY()+movY;
138
        double width = oldExtent.getWidth();
139
        double height = oldExtent.getHeight();
140
        Rectangle2D extent = new Rectangle2D.Double(upperLeftCornerX, upperLeftCornerY, width, height);
141
        mapControl.getViewPort().setExtent(extent);
142
       }catch (NumberFormatException e) {
143
    	   throw new Exception();
144
       }
145
	
146
    }
147

  
148
    /**
149
     * This method initializes this
150
     * 
151
     * @return void
152
     */
153
    private void initialize() {
154
        labelY = new JLabel();
155
        labelY.setBounds(10, 35, 28, 20);
156
        labelY.setText(secondCoordinate + ":");
157
        labelX = new JLabel();
158
        labelX.setBounds(10, 10, 28, 20);
159
        labelX.setText(firstCoordinate + ":");
160
        this.setLayout(null);
161
        this.setSize(212, 122);
162
        this.add(labelX, null);
163
        this.add(getTextX(), null);
164
        this.add(labelY, null);
165
        this.add(getTextY(), null);
166
        this.add(getColorPanel());
167
        this.add(getButtonSearch(), null);
168
    }
169

  
170
    /**
171
     * This method initializes textX	
172
     * 	
173
     * @return javax.swing.JTextField	
174
     */    
175
    private JTextField getTextX() {
176
    	if (textX == null) {
177
    		textX = new JTextField();
178
    		textX.setBounds(40, 10, 132, 20);
179
    		textX.addActionListener(new java.awt.event.ActionListener() { 
180
    			public void actionPerformed(java.awt.event.ActionEvent e) {    
181
    				textX.transferFocus();
182
    			}
183
    		});
184
    	}
185
    	return textX;
186
    }
187

  
188
    /**
189
     * This method initializes textY	
190
     * 	
191
     * @return javax.swing.JTextField	
192
     */    
193
    private JTextField getTextY() {
194
    	if (textY == null) {
195
    		textY = new JTextField();
196
    		textY.setBounds(40, 35, 132, 20);
197
    		textY.addActionListener(new java.awt.event.ActionListener() { 
198
    			public void actionPerformed(java.awt.event.ActionEvent e) {    
199
    				textY.transferFocus();
200
    			}
201
    		});
202
    	}
203
    	return textY;
204
    }
205

  
206
    /**
207
     * This method initializes buttonSearch	
208
     * 	
209
     * @return javax.swing.JButton	
210
     */    
211
    private JButton getButtonSearch() {
212
    	if (buttonSearch == null) {
213
    		buttonSearch = new JButton();
214
    		buttonSearch.setBounds(88, 91, 84, 20);
215
    		buttonSearch.addActionListener(new java.awt.event.ActionListener() { 
216
    			public void actionPerformed(java.awt.event.ActionEvent e) {    
217
    				try{
218
    				zoomToCoordinates();
219
    				}catch (Exception e1) {
220
    					JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"Formato de n?mero incorrecto."));
221
    					return;
222
    				}
223
    				// y sale.
224
                    if (PluginServices.getMainFrame() == null)
225
                        ((JDialog) (getParent().getParent().getParent().getParent())).dispose();
226
                    else
227
                        PluginServices.getMDIManager().closeView(InputCoordinatesPanel.this);
228
                    
229
                    openInfo();
230
                    drawPoint(((ColorChooserPanel)getColorPanel()).getColor());
231
    			}
232
    		});
233
    		buttonSearch.setText(PluginServices.getText(this,"Aceptar"));
234
    	}
235
    	return buttonSearch;
236
    }
237

  
238
    /* (non-Javadoc)
239
     * @see com.iver.andami.ui.mdiManager.View#getViewInfo()
240
     */
241
    public ViewInfo getViewInfo() {
242
        // TODO Auto-generated method stub
243
        if (viewInfo == null) {
244
            viewInfo=new ViewInfo(ViewInfo.MODALDIALOG);
245
            viewInfo.setTitle(PluginServices.getText(this,"Centrar_la_Vista_sobre_un_punto"));
246
        }
247
        return viewInfo;
248
    }
249
    private void openInfo(){
250
    	InfoListener infoListener=new InfoListener(mapControl);
251
    	MouseEvent e=new MouseEvent((Component)(((CenterViewToPointExtension)PluginServices.getExtension(CenterViewToPointExtension.class)).getView()),MouseEvent.BUTTON1,MouseEvent.ACTION_EVENT_MASK,MouseEvent.MOUSE_CLICKED,500,400,1,true);
252
    	Point2D centerPixels=mapControl.getViewPort().fromMapPoint(center.getX(),center.getY());
253
    	PointEvent pe=new PointEvent(centerPixels,e);
254
    	try {
255
			infoListener.point(pe);
256
		} catch (BehaviorException e1) {
257
			// TODO Auto-generated catch block
258
			e1.printStackTrace();
259
		}
260
		if (mapControl.getMapContext().getLayers().getActives().length==0){
261
			JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(),PluginServices.getText(this,"No hay ning?n tema seleccionado.")+" \n"+
262
					PluginServices.getText(this,"Debe seleccionar los temas de los que quiera obtener informaci?n."));
263
		}
264
    }
265
    private void drawPoint(Color color){
266
    	CenterViewToPointExtension.COLOR=color;
267
    	lyr.clearAllGraphics();
268
    	FSymbol theSymbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT,color);           
269
        int idSymbol = lyr.addSymbol(theSymbol);
270
        IGeometry geom = ShapeFactory.createPoint2D(center.getX(),center.getY());
271
        FGraphic theGraphic = new FGraphic(geom, idSymbol);
272
        lyr.addGraphic(theGraphic);
273
        mapControl.drawGraphics();
274

  
275
    }
276
   
277

  
278
	/**
279
	 * This method initializes jPanel	
280
	 * 	
281
	 * @return javax.swing.JPanel	
282
	 */
283
	private JPanel getColorPanel() {
284
		if (colorPanel==null){
285
		 	colorPanel=new ColorChooserPanel();
286
		 	colorPanel.setAlpha(250);
287
		 	colorPanel.setColor(CenterViewToPointExtension.COLOR);
288
		 	colorPanel.setBounds(new java.awt.Rectangle(40,59,98,24));
289
		}
290
		 	return colorPanel;
291
	}
292
}  //  @jve:decl-index=0:visual-constraint="103,18"
0 293

  
trunk/extensions/extAddEventTheme/src/com/iver/gvsig/addeventtheme/gui/AddEventThemePanel.java
1
/*
2
 * Created on 09-nov-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.gvsig.addeventtheme.gui;
45

  
46
import java.util.ArrayList;
47

  
48
import javax.swing.JPanel;
49

  
50
import com.hardcode.gdbms.engine.data.DataSource;
51
import com.iver.andami.PluginServices;
52
import com.iver.andami.ui.mdiManager.View;
53
import com.iver.andami.ui.mdiManager.ViewInfo;
54
import com.iver.cit.gvsig.fmap.DriverException;
55
import com.iver.cit.gvsig.fmap.FMap;
56
import com.iver.cit.gvsig.fmap.layers.FLayer;
57
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
58
import com.iver.cit.gvsig.project.ProjectTable;
59
import com.iver.gvsig.addeventtheme.AddEventThemeDriver;
60

  
61
import javax.swing.DefaultComboBoxModel;
62
import javax.swing.JDialog;
63
import javax.swing.JLabel;
64
import javax.swing.JComboBox;
65
import javax.swing.JButton;
66

  
67
import org.cresques.cts.IProjection;
68

  
69
/**
70
 * The AddEventThemePanel class creates a JPanel where the
71
 * user can input the name of the gvSIG Table from that the
72
 * plugin will create the new point Layer, and the fields
73
 * corresponding with the point coordinates.
74
 * 
75
 * @author jmorell
76
 */
77
public class AddEventThemePanel extends JPanel implements View {
78
    private static final long serialVersionUID = 1L;
79
    private ViewInfo viewInfo = null;
80
    private JLabel tableLabel = null;
81
    private JLabel xLabel = null;
82
    private JLabel yLabel = null;
83
    private JComboBox tableComboBox = null;
84
    private JComboBox xComboBox = null;
85
    private JComboBox yComboBox = null;
86
    private JButton okButton = null;
87
    private FMap mapContext;
88
    private ArrayList tableList;
89
    private String firstCoordinate;
90
    private String secondCoordinate;
91

  
92
    /**
93
     * This is the default constructor
94
     */
95
    public AddEventThemePanel(FMap mapContext, ArrayList tableList) {
96
        super();
97
        this.mapContext = mapContext;
98
        this.tableList = tableList;
99
        initializeCoordinates();
100
        initialize();
101
    }
102

  
103
    private void initializeCoordinates() {
104
        IProjection proj = mapContext.getProjection();
105
        String projName = proj.getAbrev();
106
        if (projName.equals("EPSG:23030") || projName.equals("EPSG:27492") || projName.equals("EPSG:42101") || projName.equals("EPSG:42304")) {
107
            firstCoordinate = "X";
108
            secondCoordinate = "Y";
109
        } else if (projName.equals("EPSG:4230") || projName.equals("EPSG:4326")) {
110
            firstCoordinate = "Lon";
111
            secondCoordinate = "Lat";
112
        } else {
113
            System.out.println("Proyecci?n: " + projName);
114
            System.out.println("Proyecci?n no soportada.");
115
        }
116
    }
117

  
118
    /**
119
     * This method initializes this
120
     * 
121
     * @return void
122
     */
123
    private void initialize() {
124
        yLabel = new JLabel();
125
        yLabel.setBounds(6, 68, 36, 24);
126
        yLabel.setText(secondCoordinate + ":");
127
        xLabel = new JLabel();
128
        xLabel.setBounds(6, 37, 36, 24);
129
        xLabel.setText(firstCoordinate + ":");
130
        tableLabel = new JLabel();
131
        tableLabel.setBounds(6, 6, 36, 24);
132
        tableLabel.setText(PluginServices.getText(this,"Tabla") + ":");
133
        this.setLayout(null);
134
        this.setSize(221, 131);
135
        this.add(tableLabel, null);
136
        this.add(xLabel, null);
137
        this.add(yLabel, null);
138
        this.add(getTableComboBox(), null);
139
        this.add(getXComboBox(), null);
140
        this.add(getYComboBox(), null);
141
        this.add(getOkButton(), null);
142
    }
143

  
144
    private String[] getTableNames() {
145
        String[] tableNames = new String[tableList.size()];
146
        for (int i=0;i<tableList.size();i++) {
147
            tableNames[i] = ((ProjectTable)tableList.get(i)).getName();
148
        }
149
        return tableNames;
150
    }
151
    private String[] getFieldNames() {
152
        String tableName = (String)tableComboBox.getSelectedItem();
153
        ProjectTable projectTable = getProjectTable(tableName);
154
        DataSource ds;
155
        String[] fieldNames = null;
156
        try {
157
            ds = projectTable.getModelo();
158
            fieldNames = new String[ds.getFieldCount()];
159
            for (int i = 0; i < ds.getFieldCount(); i++) {
160
                fieldNames[i] = ds.getFieldName(i);
161
            }
162
        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
163
            // TODO Auto-generated catch block
164
            e.printStackTrace();
165
        }
166
        return fieldNames;
167
    }
168
    
169
    private ProjectTable getProjectTable(String tableName) {
170
        ProjectTable projectTable = null;
171
        for (int i=0;i<tableList.size();i++) {
172
            if (((ProjectTable)tableList.get(i)).getName().equals(tableName)) {
173
                projectTable = (ProjectTable)tableList.get(i);
174
                break;
175
            }
176
        }
177
        return projectTable;
178
    }
179
    
180
    private void createNewLayerFromDataSource() {
181
        String tableName = (String)tableComboBox.getSelectedItem();
182
        ProjectTable projectTable = getProjectTable(tableName);
183
        DataSource ds = projectTable.getModelo();
184
        int xFieldIndex = 0;
185
        int yFieldIndex = 0;
186
        try {
187
            xFieldIndex = ds.getFieldIndexByName(getXFieldName());
188
            yFieldIndex = ds.getFieldIndexByName(getYFieldName());
189
        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e1) {
190
            // TODO Auto-generated catch block
191
            e1.printStackTrace();
192
        }
193
        AddEventThemeDriver addEventThemeDriver = new AddEventThemeDriver();
194
        addEventThemeDriver.setData(ds, xFieldIndex, yFieldIndex);
195
        FLayer capa = null;
196
        try {
197
            capa = LayerFactory.createLayer(tableName, addEventThemeDriver, mapContext.getProjection());
198
        } catch (DriverException e) {
199
            // TODO Auto-generated catch block
200
            e.printStackTrace();
201
        }
202
        mapContext.getLayers().addLayer(capa);
203
    }
204
    
205
    private String getXFieldName() {
206
        return ((String)xComboBox.getSelectedItem());
207
    }
208

  
209
    private String getYFieldName() {
210
        return ((String)yComboBox.getSelectedItem());
211
    }
212
    
213
    /* (non-Javadoc)
214
     * @see com.iver.andami.ui.mdiManager.View#getViewInfo()
215
     */
216
    public ViewInfo getViewInfo() {
217
        // TODO Auto-generated method stub
218
        if (viewInfo == null) {
219
            viewInfo=new ViewInfo(ViewInfo.MODALDIALOG);
220
            viewInfo.setTitle(PluginServices.getText(this,"Anadir_tema_de_eventos"));
221
        }
222
        return viewInfo;
223
    }
224

  
225
    /**
226
     * This method initializes tableComboBox	
227
     * 	
228
     * @return javax.swing.JComboBox	
229
     */    
230
    private JComboBox getTableComboBox() {
231
    	if (tableComboBox == null) {
232
    		tableComboBox = new JComboBox();
233
            DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getTableNames());
234
            tableComboBox.setModel(defaultModel);
235
    		tableComboBox.setBounds(43, 6, 161, 24);
236
    		tableComboBox.addItemListener(new java.awt.event.ItemListener() { 
237
    			public void itemStateChanged(java.awt.event.ItemEvent e) {    
238
    				System.out.println("itemStateChanged()"); // TODO Auto-generated Event stub itemStateChanged()
239
                    // Cambiar el estado del xComboBox
240
                    DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getFieldNames());
241
                    xComboBox.setModel(defaultModel);
242
                    // Cambiar el estado del yComboBox
243
                    defaultModel = new DefaultComboBoxModel(getFieldNames());
244
                    yComboBox.setModel(defaultModel);
245
    			}
246
    		});
247
    	}
248
    	return tableComboBox;
249
    }
250

  
251
    /**
252
     * This method initializes xComboBox	
253
     * 	
254
     * @return javax.swing.JComboBox	
255
     */    
256
    private JComboBox getXComboBox() {
257
    	if (xComboBox == null) {
258
    		xComboBox = new JComboBox();
259
            DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getFieldNames());
260
            xComboBox.setModel(defaultModel);
261
    		xComboBox.setBounds(43, 37, 161, 24);
262
    	}
263
    	return xComboBox;
264
    }
265

  
266
    /**
267
     * This method initializes yComboBox	
268
     * 	
269
     * @return javax.swing.JComboBox	
270
     */    
271
    private JComboBox getYComboBox() {
272
    	if (yComboBox == null) {
273
    		yComboBox = new JComboBox();
274
            DefaultComboBoxModel defaultModel = new DefaultComboBoxModel(getFieldNames());
275
            yComboBox.setModel(defaultModel);
276
    		yComboBox.setBounds(43, 68, 161, 24);
277
    	}
278
    	return yComboBox;
279
    }
280

  
281
    /**
282
     * This method initializes okButton	
283
     * 	
284
     * @return javax.swing.JButton	
285
     */    
286
    private JButton getOkButton() {
287
    	if (okButton == null) {
288
    		okButton = new JButton();
289
    		okButton.setBounds(104, 100, 100, 24);
290
    		okButton.addActionListener(new java.awt.event.ActionListener() { 
291
    			public void actionPerformed(java.awt.event.ActionEvent e) {    
292
    				System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
293
                    createNewLayerFromDataSource();
294
                    // y sale.
295
                    if (PluginServices.getMainFrame() == null)
296
                        ((JDialog) (getParent().getParent().getParent().getParent())).dispose();
297
                    else
298
                        PluginServices.getMDIManager().closeView(AddEventThemePanel.this);
299
    			}
300
    		});
301
    		okButton.setText(PluginServices.getText(this,"Aceptar"));
302
    	}
303
    	return okButton;
304
    }
305
}  //  @jve:decl-index=0:visual-constraint="10,10"
0 306

  
trunk/extensions/extAddEventTheme/src/com/iver/gvsig/addeventtheme/AddEventThemeDriver.java
1
/*
2
 * Created on 10-nov-2005
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
package com.iver.gvsig.addeventtheme;
45

  
46
import java.awt.geom.Rectangle2D;
47
import java.io.IOException;
48

  
49
import com.hardcode.driverManager.DriverLoadException;
50
import com.hardcode.gdbms.engine.data.DataSource;
51
import com.hardcode.gdbms.engine.data.DataSourceFactory;
52
import com.hardcode.gdbms.engine.data.NoSuchTableException;
53
import com.hardcode.gdbms.engine.data.driver.DriverException;
54
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
55
import com.hardcode.gdbms.engine.data.edition.DataWare;
56
import com.hardcode.gdbms.engine.values.StringValue;
57
import com.hardcode.gdbms.engine.values.Value;
58
import com.iver.cit.gvsig.fmap.core.FGeometry;
59
import com.iver.cit.gvsig.fmap.core.FPoint2D;
60
import com.iver.cit.gvsig.fmap.core.FShape;
61
import com.iver.cit.gvsig.fmap.core.IGeometry;
62
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
63
import com.iver.cit.gvsig.fmap.drivers.DriverAttributes;
64
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
65
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
66
import com.iver.utiles.IPersistance;
67
import com.iver.utiles.XMLEntity;
68

  
69
/**
70
 * The class AddEventThemeDriver allows to create a new FLayer from a
71
 * gvSIG DataSource.
72
 * 
73
 * @author jmorell
74
 */
75
public class AddEventThemeDriver implements VectorialDriver, ObjectDriver, IPersistance {
76
    private Rectangle2D fullExtent = null;
77
    private DataSource ds;
78
    private int xFieldIndex;
79
    private int yFieldIndex;
80

  
81
    /**
82
     * Initializes this.
83
     * @param ds
84
     * @param xFieldIndex
85
     * @param yFieldIndex
86
     */
87
    public void setData(DataSource ds, int xFieldIndex, int yFieldIndex) {
88
        this.ds = ds;
89
        this.xFieldIndex = xFieldIndex;
90
        this.yFieldIndex = yFieldIndex;
91
    }
92
    
93
    public int getShapeType() {
94
        return FShape.POINT;
95
    }
96

  
97
    public int getShapeCount() throws IOException {
98
        try {
99
            return (int) ds.getRowCount();
100
        } catch (DriverException e) {
101
            // TODO Auto-generated catch block
102
            e.printStackTrace();
103
        }
104
        return 0;
105
    }
106

  
107
    public DriverAttributes getDriverAttributes() {
108
        // TODO Auto-generated method stub
109
        return null;
110
    }
111

  
112
    public Rectangle2D getFullExtent() throws IOException {
113
        if (fullExtent == null) {
114
            try {
115
                for (int i=0;i<ds.getRowCount();i++) {
116
                    double x = (new Double(((Value)ds.getFieldValue((int)i, xFieldIndex)).toString())).doubleValue();
117
                    double y = (new Double(((Value)ds.getFieldValue((int)i, yFieldIndex)).toString())).doubleValue();
118
                    FGeometry geometry = ShapeFactory.createGeometry(new FPoint2D(x, y));
119
                    Rectangle2D rect = geometry.getBounds2D();
120
                    if (fullExtent == null) {
121
                        fullExtent = rect;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff