Revision 980

View differences:

org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2
  <modelVersion>4.0.0</modelVersion>
3
  <parent>
4
    <groupId>org.gvsig</groupId>
5
    <artifactId>org.gvsig.lrs</artifactId>
6
    <version>1.0.179</version>
7
  </parent>
8
  <artifactId>org.gvsig.lrs.app</artifactId>
9
  <packaging>pom</packaging>
10
  <name>${project.artifactId}</name>
11
  <modules>
12
    <module>org.gvsig.lrs.app.mainplugin</module>
13
  </modules>
14

  
15
</project>
org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/buildNumber.properties
1
#Mon Oct 09 23:12:32 CEST 2023
2
buildNumber=182
0 3

  
org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/src/main/resources-plugin/plugin-persistence.def
1
<?xml version="1.0"?>
2
<!--
3
Definitions of plugin persistence org.gvsig.lrs.app.mainplugin
4
 -->
5
<definitions>
6
  <version>1.0.0</version>
7
  <classes>
8
    <class name="org.gvsig.lrs.app.mainplugin">
9
      <extends>
10
      	<class name="JLrsCalculateMLastUsedValues"/>
11
      </extends>
12
      <description>Persistence of the LRS plugin</description>
13
      <fields>
14
      </fields>
15
    </class>
16
  </classes>
17
</definitions>  
org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/src/main/resources-plugin/i18n/text.properties
1
#text.properties
2

  
3
error_creating_panel=Error creando el panel
4

  
5
# CREATE ROUTE
6
length=Longitud
7
one_field=Un campo
8
two_fields=Dos campos
9
up_left=Arriba izquierda
10
down_left=Abajo izquierda
11
up_right=Arriba derecha
12
down_right=Abajo derecha
13
create_routes=Crear rutas
14
source=Origen
15
m-coordinate-selector=Selecciona geometrias para calcular su coordenada M
16
calculate-m-routes=Calcular coordenada M
17
id_route_field=Campo de identificadores de rutas
18
pk_selected=Campos con los valores de la coordenada M en los extremos
19
pk_inicial=Valor inicial
20
pk_final=Valor final
21
output_file=Archivo de salida
22
measure_source=Origen de mediciones
23
from_measure_field=Campo desde o longitud
24
to_measure_field=Campo hasta
25
coordinates_priority=Prioridad de coordenadas
26
measure_factor=Factor de medici\u00f3n
27
measure_offset=Compensaci\u00f3n de medici\u00f3n
28
ignore_spatial_gaps=Ignorar huecos espaciales
29
_Browser=Navegador
30
_Accept=Aceptar
31
_Cancel=Cancelar
32
_Close=Cerrar
33
linear_reference_system=Ref. lineal
34
progress=Progreso
35
error_getting_parameters=Error obteniendo los par\u00e1metros del algoritmo
36
need_to_select_a_route_identifier_field=Es necesario seleccionar un campo de identificadores de rutas
37
paratemeters=Parametros
38
_LrsNeededParameterException=Falta alguno de los par\u00e1metros necesarios.
39
need_to_fill_the_target_path=Es necesario rellenar la ruta al archivo de salida
40
need_to_select_a_length_measure_field=Es necesario seleccionar un campo para las medidas
41
need_to_select_a_from_measure_field=Es necesario seleccionar un campo para las medidas o desde el que comenzarlas
42
need_to_select_a_to_measure_field=Es necesario seleccionar un campo hasta el que terminar las medidas
43
file_already_exists_do_you_want_overwrite_it=El archivo ya existe \u00bfDesea sobrescribirlo?
44
grouping_features=Agrupando elementos
45
at_least_one_layer_needed=Es necesaria al menos una capa
46
impossible_to_find_needed_layer=No se ha podido encontrar la capa necesaria
47
error_creating_outputStore=Error creando el almac\u00e9n de salida
48
load_layer_question=\u00bfLe gustar\u00eda cargar la capa generada?
49
load_layer_question_title=\u00bfCargar Capa?
50

  
51
#CALIBRATE ROUTE
52
calibrate_point_layer=Capa de puntos de calibraci\u00f3n
53
id_calibration_point_route_field=Identificador de ruta en la capa de puntos
54
measures_field=Campo de medidas
55
measure_calc_method=M\u00e9todo de c\u00e1lculo de mediciones
56
search_radius=Radio de b\u00fasqueda
57
interpolate_between_calibration_points=Interpolar entre puntos de calibraci\u00f3n
58
units=Unidades
59
extrapolate_before_calibration_points=Extrapolar antes de puntos de calibraci\u00f3n
60
extrapolate_after_calibration_points=Extrapolar despu\u00e9s de puntos de calibraci\u00f3n
61
include_all=Incluir todos los elementos en la capa de salida
62
distance=Distancia
63
measures=Medidas
64
calibrate_routes=Calibrar rutas
65
two_or_more_layers_are_needed=Son necesarias dos o mas capas
66
impossible_to_find_needed_layers=No fue posible encontrar las capas necesarias
67
error_getting_selected_item_from_cmbInputLayer=Error obteniendo el valor seleccionado del origen
68
error_getting_selected_item_from_cmbIdRouteField=Error obteniendo el valor seleccionado del identificador de rutas
69
need_to_select_a_source_layer=Es necesario seleccionar un campo para el origen
70
error_getting_selected_item_from_cmbCalibratePointLayer=Error obteniendo la capa de puntos de calibraci\u00f3n
71
need_to_select_a_calibrate_point_layer=Es necesario seleccionar un campo para la capa de puntos de calibraci\u00f3n
72
error_getting_selected_item_from_cmbCalibrationPointIdRouteField=Error obteniendo el valor seleccionado del identificador de rutas de la capa de calibraci\u00f3n
73
need_to_select_a_route_identifier_calibration_point_field=Es necesario seleccionar un campo para el identificador de rutas de la capa de calibraci\u00f3n
74
error_getting_selected_item_from_cmbFromMeasureField=Error obteniendo el valor seleccionado del campo desde
75
need_to_select_a_from_Measure_field=Es necesario seleccionar un valor desde
76
calibrating_features=Calibrando elementos
77
kilometer=kil\u00f3metro
78
meter=metro
79
centimeter=cent\u00edmetro
80
millimeter=mil\u00edmetro
81
mile=milla
82
yards=yardas
83
feet=pies
84
inch=pulgada
85

  
86
#EDIT ROUTE
87
a_layer_is_needed=Es necesaria una capa
88
an_editing_layer_is_needed=Es necesaria una capa editable
89
impossible_to_find_needed_layer=No fue posible encontrar una capa necesaria
90
edit_route_calibration=Editar calibraci\u00f3n de ruta
91
error_getting_table_info=Error obteniendo la tabla de informaci\u00f3n
92

  
93
minimum=M\u00ednimo
94
maximum=M\u00e1ximo
95
_Invert=Invertir
96
_Apply=Aplicar
97
a_selectedIdRoute_is_needed=Es necesario un identificador de ruta seleccionado
98
route_not_contained=El identificador de ruta no esta contenido en la capa en edici\u00f3n
99

  
100
warnings_in_edit_route=Se han encontrado las siguientes advertencias en la tabla de edici\u00f3n:
101
accept_warnings_question=\u00bfEsta seguro de que desea continuar guardando estos datos?
102
warnings_dialog=Di\u00e1logo de Advertencias Encontradas
103
more_warnings_found=...y {0} advertencias mas encontradas
104
warn_Not_data_found_in_table=La tabla de edici\u00f3n no tiene datos
105
warn_Not_enough_data_found_in_table=La tabla de edici\u00f3n no tiene datos suficientes
106
warn_Negative_value_at_row=Un dato negativo ha sido encontrado en la fila {0}
107
warn_Out_of_sequence_value_at_row=El valor en la fila {0} esta fuera de secuencia
108
warn_Repeated_value_at_row=Valores repetidos en las filas {0} y {1}
109

  
110

  
111
#GENERATE DYNAMIC SEGMENTATION
112
generate_dynamic_segmentation=Generar segmentaci\u00f3n din\u00e1mica
113
table=Tabla de Valores
114
table_id_route_field=Identificador de ruta en la tabla de valores
115
landmark_field=Hito
116
final_landmark_field=Hito final
117
value_field=Valor
118
a_table_is_needed=Es necesaria una tabla
119
error_getting_selected_item_from_cmbTable=Error obteniendo el valor seleccionando de la tabla
120
need_to_select_a_table=Es necesario seleccionar un campo para el valor de la tabla
121
error_getting_selected_item_from_cmbTableIdRouteField=Error obteniendo el valor seleccionando el identificador de ruta de la tabla
122
error_getting_selected_item_from_cmbLandmarkField=Error obteniendo el valor seleccionando del hito
123
need_to_select_a_landmark_field=Es necesario seleccionar un campo para el valor del hito
124
error_getting_selected_item_from_cmbFinalLandmarkField=Error obteniendo el valor seleccionando del hito final
125
error_getting_selected_item_from_cmbValueField=Error obteniendo el valor seleccionando del campo de valor
126
need_to_select_a_value_field=Es necesario seleccionar un campo para el valor
127

  
128
#SHOW MEASURES
129
at_least_a_line_needed=Al menos una l\u00ednea es necesaria
130
show_measures=Mostrar medidas
131
wiper_measures=Limpiar medidas
132

  
133
_Data_units=Unidades de los datos
134
_m=m
135
_Km=Km
136
_Unknown_slash_other=Desconocida / otras
137
_Units_of_measure_of_the_M_coordinate_of_the_layer=Unidades de medida de la coordenada M de la capa
138

  
139
_Stretch_{0}=Tramo {0}
140

  
141
_Recalculate_proportionally=Recalcular proporcionalmente
142
_Recalibrate=Recalibrar
org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
1
#text_en.properties
2

  
3
error_creating_panel=Error creating panel
4

  
5
# CREATE ROUTE
6
length=Length
7
one_field=One field
8
two_fields=Two fields
9
up_left=Up left
10
down_left=Down left
11
up_right=Up right
12
down_right=Down right
13
create_routes=Create Routes
14
source=Source
15
id_route_field=Route identifier field
16
m-coordinate-selector=Select the geometries to calculate the M coodinate
17
calculate-m-routes=Calculate M coordinate
18
pk_selected=Fields to get the M coordinate values
19
pk_inicial=Initial value
20
pk_final=End value
21
output_file=Output file
22
measure_source=Measure source
23
from_measure_field=From-measure or length field
24
to_measure_field=To-measure field
25
coordinates_priority=Coordinate priority
26
measure_factor=Measure factor
27
measure_offset=Measure offset
28
ignore_spatial_gaps=Ignore spatial gaps
29
_Browser=Browser
30
_Accept=Ok
31
_Cancel=Cancel
32
_Close=Close
33
linear_reference_system=Linear ref.
34
progress=Progress
35
error_getting_parameters=Error getting algorithm parameters
36
need_to_select_a route_identifier_field=You need to select a route identifier field
37
paratemeters=Parameters
38
_LrsNeededParameterException=One or more of required parameters are empty
39
need_to_fill_the_target_path=You need to fill the target file path
40
need_to_select_a_length_measure_field=You need to select a length measure field
41
need_to_select_a_from_measure_field=You need to select a from measure field
42
need_to_select_a_to_measure_field=You need to select a to measure field
43
file_already_exists_do_you_want_overwrite_it=File already exists. Do you want overwrite it?
44
grouping_features=Grouping features
45
at_least_one_layer_needed=At least one layer is needed
46
impossible_to_find_needed_layer=Impossible to find needed layer
47
error_creating_outputStore=Error creating output store
48
load_layer_question=Would you like to load the generated layer?
49
load_layer_question_title=Load Layer?
50

  
51
#CALIBRATE ROUTE
52
calibrate_point_layer=Calibration points layer
53
id_calibration_point_route_field=Route identifier in calibration points layer
54
measures_field=Measures field
55
measure_calc_method=Measure calculations method
56
search_radius=Search radius
57
interpolate_between_calibration_points=Interpolate between calibration points
58
units=Units
59
extrapolate_before_calibration_points=Extrapolate before calibration points
60
extrapolate_after_calibration_points=Extrapolate after calibration points
61
include_all=Include all elements in output layer
62
distance=Distance
63
measures=Measures
64
calibrate_routes=Calibrate routes
65
two_or_more_layers_are_needed=Two or more layers are needed
66
impossible_to_find_needed_layers=Impossible to find needed layers
67
error_getting_selected_item_from_cmbInputLayer=Error getting selected item from source layer
68
error_getting_selected_item_from_cmbIdRouteField=Error getting selected item from route identifier field
69
need_to_select_a_source_layer=You need to select a source layer
70
error_getting_selected_item_from_cmbCalibratePointLayer=Error getting selected item from calibration points layer
71
need_to_select_a_calibrate_point_layer=You need to select a calibration points layer
72
error_getting_selected_item_from_cmbCalibrationPointIdRouteField=Error getting selected item from route identifier in calibration points layer
73
need_to_select_a_route_identifier_calibration_point_field=You need to select a route identifier field from calibration points layer
74
error_getting_selected_item_from_cmbFromMeasureField=Error getting selected item from From-measure field
75
need_to_select_a_from_Measure_field=You need to select a From-measure field
76
calibrating_features=Calibrating features
77
kilometer=kilometer
78
meter=meter
79
centimeter=centimeter
80
millimeter=millimeter
81
mile=mile
82
yards=yards
83
feet=feet
84
inch=inch
85

  
86
#EDIT ROUTE
87
a_layer_is_needed=A layer is needed
88
an_editing_layer_is_needed=An editing layer is needed
89
impossible_to_find_needed_layer=Impossible to find a correct layer
90
edit_route_calibration=Edit route calibration
91

  
92
minimum=Minimum
93
maximum=Maximum
94
_Invert=Invert
95
_Apply=Apply
96
a_selectedIdRoute_is_needed=A selected route identifier is needed
97
route_not_contained=Selected id route is not contained in editing layer
98
error_getting_table_info=Error getting table info
99

  
100
warnings_in_edit_route=Have been found the following warnings in the data table:
101
accept_warnings_question=Are you sure you want to continue saving this data?
102
warnings_dialog=Warnings Found Dialog
103
more_warnings_found=...and {0} more warnings found
104
warn_Not_data_found_in_table=The editing table has not data
105
warn_Not_enough_data_found_in_table=The editing table has not enough data
106
warn_Negative_value_at_row=A negative value has been found at row {0}
107
warn_Out_of_sequence_value_at_row=Value at row {0} is out of sequence
108
warn_Repeated_value_at_row=Repeated values in rows {0} and {1}
109

  
110

  
111
#GENERATE DYNAMIC SEGMENTATION
112
generate_dynamic_segmentation=Generate dynamic segmentation
113
table=Value table
114
table_id_route_field=Route identifier in value table
115
landmark_field=Landmark
116
final_landmark_field=Final Landmark
117
value_field=Value
118
a_table_is_needed=A table is needed
119
error_getting_selected_item_from_cmbTable=Error getting selected item from table
120
need_to_select_a_table=You need to select a table
121
error_getting_selected_item_from_cmbTableIdRouteField=Error getting selected item from route identifier in value table
122
error_getting_selected_item_from_cmbLandmarkField=Error getting selected item from landmark field
123
need_to_select_a_landmark_field=You need to select a landmark field
124
error_getting_selected_item_from_cmbFinalLandmarkField=Error getting selected item from final landmark field
125
error_getting_selected_item_from_cmbValueField=Error getting selected item from value field
126
need_to_select_a_value_field=You need to select a value field
127

  
128
#SHOW MEASURES
129
at_least_a_line_needed=At least a line is needed
130
show_measures=Show Measures
131
wiper_measures=Clean measures
132

  
133
_Data_units=Data units
134
_m=m
135
_Km=Km
136
_Unknown_slash_other=Unknown / other
137
_Units_of_measure_of_the_M_coordinate_of_the_layer=Units of measure of the M coordinate of the layer
138

  
139
_Stretch_{0}=Stretch {0}
140

  
141
_Recalculate_proportionally=Recalculate proportionally
142
_Recalibrate=Recalibrate
0 143

  
org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/src/main/resources-plugin/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG
3
  Association. This program is free software; you can redistribute it and/or modify
4
  it under the terms of the GNU General Public License as published by the Free Software
5
  Foundation; either version 3 of the License, or (at your option) any later version.
6
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
7
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
8
  PURPOSE. See the GNU General Public License for more details. You should have received
9
  a copy of the GNU General Public License along with this program; if not, write to
10
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
11
  USA. For any additional information, do not hesitate to contact us at info AT gvsig.com,
12
  or visit our website www.gvsig.com. -->
13
<plugin-config>
14
  <depends plugin-name="org.gvsig.app.mainplugin" />
15
  <depends plugin-name="org.gvsig.app.document.table.app.mainplugin" />
16
  <depends plugin-name="org.gvsig.shp.app.mainplugin" />
17
  <resourceBundle name="text" />
18
  <libraries library-dir="lib" />
19
  <extensions>
20
    <extension class-name="org.gvsig.lrs.app.createroute.CreateRouteExtension"
21
      description="" active="true" priority="1">
22

  
23
      <action name="create-routes" label="create_routes" tooltip="create_routes"
24
        position="900700100" action-command="create-routes" icon="pk_red"
25
        accelerator="" />
26

  
27
      <menu text="tools/linear_reference_system/create_routes" name="create-routes" />
28

  
29
      <tool-bar name="linear_reference_system" position="900700100">
30
        <action-tool name="create-routes" />
31
      </tool-bar>
32

  
33
    </extension>
34
    <extension class-name="org.gvsig.lrs.app.calibrateroute.CalibrateRouteExtension"
35
      description="" active="true" priority="1">
36

  
37
      <action name="calibrate-routes" label="calibrate_routes" tooltip="calibrate_routes"
38
        position="900700200" action-command="calibrate-routes" icon="pk_blue"
39
        accelerator="" />
40

  
41
      <menu text="tools/linear_reference_system/calibrate_routes" name="calibrate-routes" />
42

  
43
      <tool-bar name="linear_reference_system" position="900700200">
44
        <action-tool name="calibrate-routes" />
45
      </tool-bar>
46
      
47
      
48
    </extension>
49
    <extension class-name="org.gvsig.lrs.app.calibrateroute.MeasureCalculatorRouteExtension"
50
      description="" active="true" priority="2">
51
      
52
      <action name="calculate-m-routes" label="calculate-m-routes" tooltip="calculate-m-routes"
53
        position="900700300" action-command="calculate-m-routes" icon="pk_m"
54
        accelerator="" />
55

  
56
      <menu text="tools/linear_reference_system/calculate-m-routes" name="calculate-m-routes" />
57

  
58
      <tool-bar name="linear_reference_system" position="900700300">
59
        <action-tool name="calculate-m-routes" />
60
      </tool-bar>
61

  
62
    </extension>
63

  
64
    <extension class-name="org.gvsig.lrs.app.editroutecalibration.EditRouteCalibrationExtension"
65
      description="" active="true" priority="1">
66
      <action name="edit-route-calibration" label="edit_route_calibration" tooltip="edit_route_calibration"
67
        position="900700400" action-command="edit-route-calibration" icon="pk_cian"
68
        accelerator="" />
69
      <menu text="tools/linear_reference_system/edit_route_calibration" name="edit-route-calibration" />
70
      <tool-bar name="linear_reference_system" position="900700400">
71
        <action-tool name="edit-route-calibration" />
72
      </tool-bar>
73
    </extension>
74

  
75
    <extension class-name="org.gvsig.lrs.app.generatedynamicsegmentation.GenerateDynamicSegmentationExtension"
76
      description="" active="true" priority="1">
77
      <action name="generate-dynamic-segmentation" label="generate_dynamic_segmentation" tooltip="generate_dynamic_segmentation"
78
        position="900700500" action-command="generate-dynamic-segmentation" icon="pk_yellow"
79
        accelerator="" />
80
      <menu text="tools/linear_reference_system/generate_dynamic_segmentation" name="generate-dynamic-segmentation" />
81
      <tool-bar name="linear_reference_system" position="900700500">
82
        <action-tool name="generate-dynamic-segmentation" />
83
      </tool-bar>
84
    </extension>
85

  
86
    <extension class-name="org.gvsig.lrs.app.showmeasures.ShowMeasuresExtension"
87
      description="" active="true" priority="1">
88
      <action name="show-measures" label="show_measures" tooltip="show_measures"
89
        position="900700600" action-command="show-measures" icon="pk_green"
90
        accelerator="" />
91
      <menu text="tools/linear_reference_system/show_measures" name="show-measures" />
92
      <tool-bar name="linear_reference_system" position="900700600">
93
        <action-tool name="show-measures" />
94
      </tool-bar>
95
    </extension>
96

  
97
    <extension class-name="org.gvsig.lrs.app.showmeasures.WiperMeasuresExtension"
98
      description="" active="true" priority="1">
99
      <action name="wiper-measures" label="wiper_measures" tooltip="wiper_measures"
100
        position="900700700" action-command="wiper-measures" icon="wiper"
101
        accelerator="" />
102
      <menu text="tools/linear_reference_system/wiper_measures" name="wiper-measures" />
103
      <tool-bar name="linear_reference_system" position="900700700">
104
        <action-tool name="wiper-measures" />
105
      </tool-bar>
106
    </extension>
107

  
108
  </extensions>
109
</plugin-config>
org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml
1
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG
2
  Association. This program is free software; you can redistribute it and/or modify
3
  it under the terms of the GNU General Public License as published by the Free Software
4
  Foundation; either version 3 of the License, or (at your option) any later version.
5
  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
6
  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
7
  PURPOSE. See the GNU General Public License for more details. You should have received
8
  a copy of the GNU General Public License along with this program; if not, write to
9
  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
10
  USA. For any additional information, do not hesitate to contact us at info AT gvsig.com,
11
  or visit our website www.gvsig.com. -->
12
<assembly>
13
  <id>gvsig-plugin-package</id>
14
  <formats>
15
    <format>zip</format>
16
  </formats>
17
  <baseDirectory>${project.artifactId}</baseDirectory>
18
  <includeBaseDirectory>true</includeBaseDirectory>
19
  <files>
20
    <file>
21
      <source>target/${project.artifactId}-${project.version}.jar</source>
22
      <outputDirectory>lib</outputDirectory>
23
    </file>
24
    <file>
25
      <source>target/package.info</source>
26
    </file>
27
  </files>
28

  
29
  <fileSets>
30
    <fileSet>
31
      <directory>src/main/resources-plugin</directory>
32
      <outputDirectory>.</outputDirectory>
33
    </fileSet>
34
  </fileSets>
35

  
36

  
37
  <dependencySets>
38
    <dependencySet>
39
      <useProjectArtifact>false</useProjectArtifact>
40
      <useTransitiveDependencies>false</useTransitiveDependencies>
41
      <outputDirectory>lib</outputDirectory>
42
      <includes>
43
        <include>org.gvsig:org.gvsig.lrs.lib.api</include>
44
        <include>org.gvsig:org.gvsig.lrs.lib.impl</include>
45
        <include>org.gvsig:org.gvsig.lrs.swing.api</include>
46
        <include>org.gvsig:org.gvsig.lrs.swing.impl</include>
47
      </includes>
48
    </dependencySet>
49
  </dependencySets>
50

  
51
</assembly>
52

  
0 53

  
org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/src/main/java/org/gvsig/lrs/app/editroutecalibration/EditRouteCalibrationExtension.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.lrs.app.editroutecalibration;
24

  
25
import java.awt.Component;
26
import java.awt.event.ActionEvent;
27
import java.awt.event.ActionListener;
28
import java.awt.event.ComponentEvent;
29
import java.awt.event.ComponentListener;
30
import java.text.MessageFormat;
31
import java.util.List;
32
import java.util.Map;
33
import javax.swing.JOptionPane;
34
import org.apache.commons.lang3.StringUtils;
35
import org.gvsig.andami.IconThemeHelper;
36
import org.gvsig.andami.plugins.Extension;
37
import org.gvsig.app.ApplicationLocator;
38
import org.gvsig.app.ApplicationManager;
39
import org.gvsig.app.project.documents.view.ViewDocument;
40
import org.gvsig.app.project.documents.view.gui.IView;
41
import org.gvsig.fmap.dal.exception.DataException;
42
import org.gvsig.fmap.dal.feature.EditableFeature;
43
import org.gvsig.fmap.dal.feature.Feature;
44
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
45
import org.gvsig.fmap.dal.feature.FeatureReference;
46
import org.gvsig.fmap.dal.feature.FeatureStore;
47
import org.gvsig.fmap.geom.Geometry;
48
import org.gvsig.fmap.geom.aggregate.MultiLine;
49
import org.gvsig.fmap.geom.primitive.Line;
50
import org.gvsig.fmap.mapcontext.MapContext;
51
import org.gvsig.fmap.mapcontext.layers.FLayer;
52
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
53
import org.gvsig.lrs.lib.api.LrsEditRouteCalibrationAlgorithmParams;
54
import org.gvsig.lrs.lib.api.LrsEditRouteCalibrationSelectIdRouteAlgorithmParams;
55
import org.gvsig.lrs.lib.api.exceptions.LrsGettingParametersException;
56
import org.gvsig.lrs.lib.api.exceptions.LrsNeededParameterException;
57
import org.gvsig.lrs.swing.api.JLrsAlgorithmParams;
58
import org.gvsig.lrs.swing.api.LrsAlgorithmsSwingLocator;
59
import org.gvsig.lrs.swing.api.LrsAlgorithmsSwingManager;
60
import org.gvsig.lrs.swing.impl.JLrsEditRouteCalibrationController;
61
import org.gvsig.lrs.swing.impl.JLrsEditRouteCalibrationSelectIdRouteController;
62
import org.gvsig.lrs.swing.impl.JLrsUtils;
63
import org.gvsig.tools.ToolsLocator;
64
import org.gvsig.tools.i18n.I18nManager;
65
import org.gvsig.tools.swing.api.ToolsSwingLocator;
66
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
67
import org.slf4j.Logger;
68
import org.slf4j.LoggerFactory;
69

  
70

  
71
/**
72
 * @author dmartinez
73
 *
74
 */
75
public class EditRouteCalibrationExtension extends Extension implements ComponentListener {
76

  
77
    private static final Logger logger = LoggerFactory.getLogger(EditRouteCalibrationExtension.class);
78

  
79
    private JLrsEditRouteCalibrationSelectIdRouteController panelSelectId;
80

  
81
    private JLrsEditRouteCalibrationController panelController;
82

  
83
    @Override
84
    public void execute(String actionCommand) {
85
        if (StringUtils.equalsIgnoreCase(actionCommand, "edit-route-calibration")) {
86
            IView view = getActiveView();
87
            final FLyrVect activeLayer;
88
            if (view!=null){
89
                activeLayer = getActiveLayer(view);
90
            }else{
91
                activeLayer = null;
92
            }
93

  
94
            final MapContext mapContext = view.getMapControl().getMapContext();
95

  
96
            final WindowManager winManager = ToolsSwingLocator.getWindowManager();
97

  
98
            final LrsAlgorithmsSwingManager manager = LrsAlgorithmsSwingLocator.getLrsAlgorithmsSwingManager();
99

  
100
            final I18nManager i18nManager = ToolsLocator.getI18nManager();
101

  
102
            try {
103
                panelSelectId = (JLrsEditRouteCalibrationSelectIdRouteController)manager.createJLrsEditRouteCalibrationSelectIdRouteAlgorithmParameters(activeLayer, null);
104
                panelSelectId.addComponentListener(this);
105
            } catch (LrsNeededParameterException e2) {
106
                logger.error("Error creating panel", e2);
107
                JOptionPane.showMessageDialog(
108
                    null,
109
                    new StringBuilder().append(i18nManager.getTranslation("error_creating_panel"))
110
                        .append(":").append(e2.getLocalizedMessage()),
111
                    i18nManager.getTranslation("error"), JOptionPane.ERROR_MESSAGE);
112
                return;
113
            }
114
            panelSelectId.setVisibleAceptCancel(true);
115
            panelSelectId.addActionListener((ActionEvent e) -> {
116
                JLrsAlgorithmParams panel = (JLrsAlgorithmParams) e.getSource();
117
                if (panel.isCanceled()) {
118
                    return;
119
                }
120
                LrsEditRouteCalibrationSelectIdRouteAlgorithmParams params = null;
121
                try {
122
                    params = (LrsEditRouteCalibrationSelectIdRouteAlgorithmParams)panel.getParams();
123
                } catch (LrsGettingParametersException e1) {
124
                    logger.error("Error getting parameters", e1);
125
                    JOptionPane.showMessageDialog(
126
                            null,
127
                            new StringBuilder().append(i18nManager.getTranslation("error_getting_parameters"))
128
                                    .append(":").append(e1.getLocalizedMessage()),
129
                            i18nManager.getTranslation("error"), JOptionPane.ERROR_MESSAGE);
130
                    return;
131
                } catch (LrsNeededParameterException e1) {
132
                    logger.warn("Error getting parameters", e1);
133
                    JOptionPane.showMessageDialog(
134
                            null,
135
                            i18nManager.getTranslation(e1.getMessage()),
136
                            i18nManager.getTranslation("warning"), JOptionPane.WARNING_MESSAGE);
137
                    return;
138
                }   try {
139
                    panelController = (JLrsEditRouteCalibrationController)manager.createJLrsEditRouteCalibrationAlgorithmParameters(activeLayer, mapContext, params.getIdRouteField(), null);
140
                    panelController.addComponentListener(EditRouteCalibrationExtension.this);
141
                } catch (Exception e2) {
142
                    logger.error("Error creating panel", e2);
143
                    JOptionPane.showMessageDialog(
144
                            null,
145
                            new StringBuilder().append(i18nManager.getTranslation("error_creating_panel"))
146
                                    .append(":").append(e2.getLocalizedMessage()),
147
                            i18nManager.getTranslation("error"), JOptionPane.ERROR_MESSAGE);
148
                    return;
149
                }   
150
                panelController.setVisibleAceptCancel(true);
151
                panelController.addActionListener((ActionEvent e1) -> {
152
                    JLrsEditRouteCalibrationController panel1 = (JLrsEditRouteCalibrationController) e1.getSource();
153
                    if (panel1.isCanceled()) {
154
                        return;
155
                    }
156
                    if (panel1.hasWarnings()) {
157
                        boolean acceptedWarnings = showWarnings(panel1.getWarnings());
158
                        if (acceptedWarnings) {
159
                            panel1.close();
160
                        } else {
161
                            return;
162
                        }
163
                    }
164
                    final LrsEditRouteCalibrationAlgorithmParams params1;
165
                    try {
166
                        params1 = (LrsEditRouteCalibrationAlgorithmParams) panel1.getParams();
167
                    } catch (LrsGettingParametersException e2) {
168
                        logger.error("Error getting parameters", e2);
169
                        JOptionPane.showMessageDialog(null, new StringBuilder().append(i18nManager.getTranslation("error_getting_parameters"))
170
                                .append(":").append(e2.getLocalizedMessage()), i18nManager.getTranslation("error"), JOptionPane.ERROR_MESSAGE);
171
                        return;
172
                    } catch (LrsNeededParameterException e3) {
173
                        logger.warn("Error getting parameters", e3);
174
                        JOptionPane.showMessageDialog(null, i18nManager.getTranslation(e3.getMessage()), i18nManager.getTranslation("warning"), JOptionPane.WARNING_MESSAGE);
175
                        return;
176
                    }
177
                    if (params1 != null) {
178
                        saveLayer(activeLayer, params1);
179
                    }
180
                    panel1.close();
181
                });
182
                winManager.showWindow(panelController.asJComponent(), i18nManager.getTranslation("edit_route_calibration"),
183
                        WindowManager.MODE.WINDOW);
184
            });
185
            winManager.showWindow(panelSelectId.asJComponent(), i18nManager.getTranslation("edit_route_calibration"),
186
                WindowManager.MODE.WINDOW);
187
        }
188
    }
189

  
190
    public void initialize() {
191
        registerIcons();
192
    }
193

  
194
    public boolean isEnabled() {
195
        IView view = getActiveView();
196
        if (view!=null){
197
            FLyrVect activeLayer = getActiveLayer(view);
198
            if (panelSelectId == null && panelController == null && activeLayer!=null && activeLayer.isEditing()){
199
                return JLrsUtils.isMlayerWithNonGeomField(activeLayer);
200
            }
201
        }
202
        return false;
203
    }
204

  
205
    public boolean isVisible() {
206
        ApplicationManager application = ApplicationLocator.getManager();
207

  
208
        return application.getActiveComponent(ViewDocument.class) != null;
209
    }
210

  
211
    private void registerIcons() {
212
        IconThemeHelper.registerIcon("lrs", "pk_cian", this);
213
    }
214

  
215

  
216
    private IView getActiveView() {
217
        ApplicationManager application = ApplicationLocator.getManager();
218
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
219
        return view;
220
    }
221

  
222
    private FLyrVect getActiveLayer(IView vista) {
223
        if (vista != null) {
224
            ViewDocument viewDocument = vista.getViewDocument();
225
            FLayer[] actives =
226
                viewDocument.getMapContext().getLayers().getActives();
227

  
228
            if ((actives.length == 1) && (actives[0] instanceof FLyrVect)) {
229
                return (FLyrVect) actives[0];
230
            }
231
        }
232
        return null;
233
    }
234

  
235
    private boolean showWarnings(List<String> warnings){
236
        final int MAXWARNINGSSHOWED=15;
237

  
238
        final I18nManager i18nManager = ToolsLocator.getI18nManager();
239
        logger.debug("Warnings found accepting edit route panel");
240
        StringBuilder messageBuilder= new StringBuilder().append(i18nManager.getTranslation("warnings_in_edit_route"));
241
        String newLine=System.getProperty("line.separator");
242
        messageBuilder.append(newLine);
243
        for (int i=0;(i<=MAXWARNINGSSHOWED&&i<warnings.size());i++){
244
            if(i<MAXWARNINGSSHOWED){
245
                String warning=warnings.get(i);
246
                messageBuilder.append(newLine);
247
                messageBuilder.append(warning);
248
            }
249
            if (i==MAXWARNINGSSHOWED&&warnings.size()>MAXWARNINGSSHOWED){
250
                messageBuilder.append(newLine);
251
                int warningsNotShowed=warnings.size()-MAXWARNINGSSHOWED;
252
                messageBuilder.append(MessageFormat.format(
253
                    i18nManager.getTranslation("more_warnings_found"), warningsNotShowed));
254
            }
255
        }
256
        messageBuilder.append(newLine);
257
        messageBuilder.append(newLine).append(i18nManager.getTranslation("accept_warnings_question"));
258
        int result =JOptionPane.showConfirmDialog(
259
            null,
260
            messageBuilder,
261
            i18nManager.getTranslation("warnings_dialog"), JOptionPane.YES_NO_OPTION);
262
        return (result==JOptionPane.YES_OPTION);
263
    }
264

  
265
    private void saveLayer(FLyrVect activeLayer,LrsEditRouteCalibrationAlgorithmParams params){
266
        FeatureAttributeDescriptor fieldRoute=params.getIdRouteField();
267
        String routeName=params.getSelectedRouteName();
268
        Map<FeatureReference, List<Double>> modifiedMCoordinates = params.getModifiedMCoordinates();
269
        
270

  
271
        FeatureStore featureStore=activeLayer.getFeatureStore();
272
        if (!featureStore.isEditing()){
273
            throw new IllegalArgumentException();
274
        }
275
        try {
276
            for (Map.Entry<FeatureReference, List<Double>> entry : modifiedMCoordinates.entrySet()) {
277
                FeatureReference fref = entry.getKey();
278
                List<Double> mCoordinates = entry.getValue();
279
                Feature f = fref.getFeature();
280
                Geometry geom = f.getDefaultGeometry().cloneGeometry();
281
                int k = 0;
282
                if (geom.getGeometryType().isTypeOf(Geometry.TYPES.LINE)) {
283
                    Line line = (Line) geom;
284
                    for (int i = 0; i < line.getNumVertices(); i++) {
285
                        line.setCoordinateAt(i, line.getDimension() - 1, mCoordinates.get(k++));
286
                    }
287
                } else if (geom.getGeometryType().isTypeOf(Geometry.TYPES.MULTILINE)) {
288
                    MultiLine multiline = (MultiLine) geom;
289
                    for (int i = 0; i < multiline.getPrimitivesNumber(); i++) {
290
                        Line line = (Line) multiline.getPrimitiveAt(i);
291
                        for (int j = 0; j < line.getNumVertices(); j++) {
292
                            line.setCoordinateAt(j, line.getDimension() - 1, mCoordinates.get(k++));
293
                        }
294
                    }
295
                }
296
                EditableFeature ef = f.getEditable();
297
                ef.setDefaultGeometry(geom);
298
                featureStore.update(ef);
299
            }
300

  
301
        } catch (DataException e) {
302
            logger.error("Error saving modified layer",e);
303
        }
304
    }
305

  
306
    @Override
307
    public void componentResized(ComponentEvent e) {
308
        // TODO Auto-generated method stub
309

  
310
    }
311

  
312
    @Override
313
    public void componentMoved(ComponentEvent e) {
314
        // TODO Auto-generated method stub
315

  
316
    }
317

  
318
    @Override
319
    public void componentShown(ComponentEvent e) {
320
        // TODO Auto-generated method stub
321

  
322
    }
323

  
324
    @Override
325
    public void componentHidden(ComponentEvent e) {
326
        Component component = e.getComponent();
327
        if (component == panelSelectId) {
328
            panelSelectId = null;
329
        } else if (component == panelController) {
330
            panelController = null;
331
        } else {
332
            if (panelSelectId != null && panelSelectId.getParent() == component) {
333
                panelSelectId = null;
334
            } else if (panelController != null && panelController.getParent() == component) {
335
                panelController.close();
336
                panelController = null;
337

  
338
            }
339
        }
340
    }
341
}
org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/src/main/java/org/gvsig/lrs/app/generatedynamicsegmentation/GenerateDynamicSegmentationExtension.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.lrs.app.generatedynamicsegmentation;
24

  
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27
import java.util.ArrayList;
28
import java.util.List;
29

  
30
import javax.swing.JOptionPane;
31

  
32
import org.apache.commons.lang3.StringUtils;
33
import org.slf4j.Logger;
34
import org.slf4j.LoggerFactory;
35

  
36
import org.gvsig.andami.IconThemeHelper;
37
import org.gvsig.andami.plugins.Extension;
38
import org.gvsig.app.ApplicationLocator;
39
import org.gvsig.app.ApplicationManager;
40
import org.gvsig.app.project.documents.Document;
41
import org.gvsig.app.project.documents.table.TableDocument;
42
import org.gvsig.app.project.documents.table.TableManager;
43
import org.gvsig.app.project.documents.view.ViewDocument;
44
import org.gvsig.app.project.documents.view.gui.IView;
45
import org.gvsig.fmap.dal.feature.FeatureStore;
46
import org.gvsig.fmap.dal.store.shp.SHPNewStoreParameters;
47
import org.gvsig.fmap.mapcontext.MapContextLocator;
48
import org.gvsig.fmap.mapcontext.MapContextManager;
49
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
50
import org.gvsig.fmap.mapcontext.layers.FLayers;
51
import org.gvsig.fmap.mapcontext.layers.operations.LayerCollection;
52
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
53
import org.gvsig.lrs.lib.api.LrsAlgorithm;
54
import org.gvsig.lrs.lib.api.LrsAlgorithmsLocator;
55
import org.gvsig.lrs.lib.api.LrsAlgorithmsManager;
56
import org.gvsig.lrs.lib.api.LrsGenerateDynamicSegmentationAlgorithmParams;
57
import org.gvsig.lrs.lib.api.exceptions.LrsGettingParametersException;
58
import org.gvsig.lrs.lib.api.exceptions.LrsNeededParameterException;
59
import org.gvsig.lrs.swing.api.JLrsAlgorithmParams;
60
import org.gvsig.lrs.swing.api.JLrsProgressDialog;
61
import org.gvsig.lrs.swing.api.LrsAlgorithmsSwingLocator;
62
import org.gvsig.lrs.swing.api.LrsAlgorithmsSwingManager;
63
import org.gvsig.lrs.swing.impl.JLrsGenerateDynamicSegmentationParamsController;
64
import org.gvsig.lrs.swing.impl.JLrsUtils;
65
import org.gvsig.tools.ToolsLocator;
66
import org.gvsig.tools.i18n.I18nManager;
67
import org.gvsig.tools.swing.api.ToolsSwingLocator;
68
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
69
import org.gvsig.tools.task.SimpleTaskStatus;
70

  
71

  
72
/**
73
 * @author dmartinez
74
 *
75
 */
76
public class GenerateDynamicSegmentationExtension extends Extension {
77

  
78
    private static final Logger logger = LoggerFactory.getLogger(GenerateDynamicSegmentationExtension.class);
79

  
80
    /* (non-Javadoc)
81
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
82
     */
83
    public void execute(String actionCommand) {
84
        if (StringUtils.equalsIgnoreCase(actionCommand, "generate-dynamic-segmentation")) {
85
            IView view = getActiveView();
86
            FLayers layers = view.getMapControl().getMapContext().getLayers();
87
            List<FeatureStore> tables=getTables();
88

  
89

  
90
            final WindowManager winManager = ToolsSwingLocator.getWindowManager();
91

  
92
            final LrsAlgorithmsSwingManager manager = LrsAlgorithmsSwingLocator.getLrsAlgorithmsSwingManager();
93

  
94
            final I18nManager i18nManager = ToolsLocator.getI18nManager();
95

  
96
            JLrsGenerateDynamicSegmentationParamsController panel;
97
            try {
98
                panel = (JLrsGenerateDynamicSegmentationParamsController)manager.createJLrsGenerateDynamicSegmentationAlgorithmParameters(layers,tables, null);
99
            } catch (LrsNeededParameterException e2) {
100
                logger.error("Error creating panel", e2);
101
                JOptionPane.showMessageDialog(
102
                    null,
103
                    new StringBuilder().append(i18nManager.getTranslation("error_creating_panel"))
104
                        .append(":").append(e2.getLocalizedMessage()),
105
                    i18nManager.getTranslation("error"), JOptionPane.ERROR_MESSAGE);
106
                return;
107
            }
108
            panel.setVisibleAceptCancel(true);
109
            panel.addActionListener(new ActionListener() {
110

  
111
                public void actionPerformed(ActionEvent e) {
112
                    JLrsAlgorithmParams panel = (JLrsAlgorithmParams) e.getSource();
113
                    if (panel.isCanceled()) {
114
                        return;
115
                    }
116
                    LrsGenerateDynamicSegmentationAlgorithmParams params = null;
117
                    try {
118
                        params = (LrsGenerateDynamicSegmentationAlgorithmParams)panel.getParams();
119
                    } catch (LrsGettingParametersException e1) {
120
                        logger.error("Error getting parameters", e1);
121
                        JOptionPane.showMessageDialog(
122
                            null,
123
                            new StringBuilder().append(i18nManager.getTranslation("error_getting_parameters"))
124
                                .append(":").append(e1.getLocalizedMessage()),
125
                            i18nManager.getTranslation("error"), JOptionPane.ERROR_MESSAGE);
126
                        return;
127
                    } catch (LrsNeededParameterException e1) {
128
                        logger.warn("Error getting parameters", e1);
129
                        JOptionPane.showMessageDialog(
130
                            null,
131
                            i18nManager.getTranslation(e1.getMessage()),
132
                            i18nManager.getTranslation("warning"), JOptionPane.WARNING_MESSAGE);
133
                        return;
134
                    }
135

  
136
                    LrsAlgorithmsManager algorithmsManager = LrsAlgorithmsLocator.getLrsAlgorithmsManager();
137
                    final LrsAlgorithm algorithm = algorithmsManager.createLrsAlgorithm(params);
138
                    final SHPNewStoreParameters shpParams=(SHPNewStoreParameters)params.getNewFeatureStoreParameters();
139

  
140
                    final SimpleTaskStatus taskStatus =
141
                        ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus(i18nManager.getTranslation("progress"));
142

  
143
                    final JLrsProgressDialog progressDialog = manager.createJLrsProgressDialog(taskStatus);
144

  
145
                    winManager.showWindow(progressDialog.asJComponent(), i18nManager.getTranslation("generate_dynamic_segmentation"),
146
                        WindowManager.MODE.WINDOW);
147

  
148
                    Thread task = new Thread(new Runnable() {
149

  
150
                        public void run() {
151
                            try {
152
                                algorithm.execute(taskStatus);
153
                                int resultLoadLayer =JOptionPane.showConfirmDialog(
154
                                    null,
155
                                    i18nManager.getTranslation("load_layer_question"),
156
                                    i18nManager.getTranslation("load_layer_question_title"), JOptionPane.YES_NO_OPTION);
157
                                if (resultLoadLayer==JOptionPane.YES_OPTION){
158
                                    loadLayer(shpParams);
159
                                }
160

  
161
                            } catch (Exception e) {
162
                                logger.error("Error generating dynamic segmentation ", e);
163
                                String message = e.getMessage();
164
                                if (e.getCause() != null) {
165
                                    message = e.getCause().getMessage();
166
                                }
167
                                JOptionPane.showMessageDialog(
168
                                    progressDialog.asJComponent(),
169
                                    message,
170
                                    i18nManager.getTranslation("generate_dynamic_segmentation"),
171
                                    JOptionPane.ERROR_MESSAGE
172
                                );
173
                            }
174
                        }
175
                    });
176
                    task.start();
177

  
178
                }
179
            });
180
            winManager.showWindow(panel.asJComponent(), i18nManager.getTranslation("generate_dynamic_segmentation"),
181
                WindowManager.MODE.WINDOW);
182
        }
183
    }
184

  
185
    /* (non-Javadoc)
186
     * @see org.gvsig.andami.plugins.IExtension#initialize()
187
     */
188
    public void initialize() {
189
        registerIcons();
190
    }
191

  
192
    /* (non-Javadoc)
193
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
194
     */
195
    public boolean isEnabled() {
196
        IView view = getActiveView();
197
        if (view!=null){
198
            ViewDocument viewDocument = view.getViewDocument();
199
            LayerCollection layers = viewDocument.getMapContext().getLayers();
200
            if (JLrsUtils.validateMLayerWithNonGeomField(layers)){
201
                List<FeatureStore> tables=getTables();
202
                if (tables!=null&&tables.size()>0){
203
                    return JLrsUtils.validateStoreWithFieldsAndOneNumeric(tables);
204
                }
205
            }
206
        }
207
        return false;
208
    }
209

  
210
    /* (non-Javadoc)
211
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
212
     */
213
    public boolean isVisible() {
214
        ApplicationManager application = ApplicationLocator.getManager();
215

  
216
        return application.getActiveComponent(ViewDocument.class) != null;
217
    }
218

  
219
    private void registerIcons() {
220
        IconThemeHelper.registerIcon("lrs", "pk_yellow", this);
221
    }
222

  
223
    private List<FeatureStore> getTables(){
224
        ApplicationManager application = ApplicationLocator.getManager();
225
        List<Document> documents=application.getCurrentProject().getDocuments(TableManager.TYPENAME);
226
        List<FeatureStore> tables=new ArrayList<FeatureStore>();
227
        if (documents!=null){
228
            for (int i = 0; i < documents.size(); i++) {
229
                TableDocument tableDocument=(TableDocument)documents.get(i);
230
                tables.add(tableDocument.getStore());
231
            }
232
        }
233
        return tables;
234
    }
235

  
236
    private IView getActiveView() {
237
        ApplicationManager application = ApplicationLocator.getManager();
238
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
239
        return view;
240
    }
241

  
242
    private void loadLayer(SHPNewStoreParameters shpParams){
243
        if (shpParams!=null ){
244
            String name=shpParams.getFile().getName();
245
            if (name.contains(".shp")){
246
                name=name.substring(0,name.lastIndexOf(".shp"));
247
            }
248
            MapContextManager mapContextManager =MapContextLocator.getMapContextManager();
249

  
250
            FLyrVect newLayer=null;
251
            try {
252
                newLayer = (FLyrVect) mapContextManager.createLayer(name,shpParams);
253
            } catch (LoadLayerException e) {
254
                logger.warn("Couldn't load layer",e);
255
            }
256
            getActiveView().getMapControl().getMapContext().getLayers().addLayer(newLayer);
257
        }
258
    }
259

  
260
}
org.gvsig.lrs/tags/org.gvsig.lrs-1.0.179/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/src/main/java/org/gvsig/lrs/app/createroute/CreateRouteExtension.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.lrs.app.createroute;
24

  
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27

  
28
import javax.swing.JOptionPane;
29

  
30
import org.apache.commons.lang3.StringUtils;
31
import org.bouncycastle.util.Store;
32
import org.cresques.cts.IProjection;
33
import org.gvsig.andami.IconThemeHelper;
34
import org.gvsig.andami.plugins.Extension;
35
import org.gvsig.app.ApplicationLocator;
36
import org.gvsig.app.ApplicationManager;
37
import org.gvsig.app.project.documents.view.ViewDocument;
38
import org.gvsig.app.project.documents.view.gui.IView;
39
import org.gvsig.fmap.dal.DALLocator;
40
import org.gvsig.fmap.dal.DataManager;
41
import org.gvsig.fmap.dal.DataStore;
42
import org.gvsig.fmap.dal.DataStoreParameters;
43
import org.gvsig.fmap.dal.exception.InitializeException;
44
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException;
45
import org.gvsig.fmap.dal.exception.ReadException;
46
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
47
import org.gvsig.fmap.dal.feature.FeatureStore;
48
import org.gvsig.fmap.dal.store.shp.SHPNewStoreParameters;
49
import org.gvsig.fmap.geom.Geometry;
50
import org.gvsig.fmap.geom.type.GeometryType;
51
import org.gvsig.fmap.mapcontext.MapContextLocator;
52
import org.gvsig.fmap.mapcontext.MapContextManager;
53
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException;
54
import org.gvsig.fmap.mapcontext.layers.FLayer;
55
import org.gvsig.fmap.mapcontext.layers.FLayers;
56
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
57
import org.gvsig.lrs.lib.api.LrsAlgorithm;
58
import org.gvsig.lrs.lib.api.LrsAlgorithmsLocator;
59
import org.gvsig.lrs.lib.api.LrsAlgorithmsManager;
60
import org.gvsig.lrs.lib.api.LrsCreateRouteAlgorithmParams;
61
import org.gvsig.lrs.lib.api.exceptions.LrsGettingParametersException;
62
import org.gvsig.lrs.lib.api.exceptions.LrsNeededParameterException;
63
import org.gvsig.lrs.swing.api.JLrsAlgorithmParams;
64
import org.gvsig.lrs.swing.api.JLrsProgressDialog;
65
import org.gvsig.lrs.swing.api.LrsAlgorithmsSwingLocator;
66
import org.gvsig.lrs.swing.api.LrsAlgorithmsSwingManager;
67
import org.gvsig.lrs.swing.impl.JLrsCreateRouteParamsController;
68
import org.gvsig.lrs.swing.impl.JLrsUtils;
69
import org.gvsig.tools.ToolsLocator;
70
import org.gvsig.tools.i18n.I18nManager;
71
import org.gvsig.tools.swing.api.ToolsSwingLocator;
72
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
73
import org.gvsig.tools.task.SimpleTaskStatus;
74
import org.slf4j.Logger;
75
import org.slf4j.LoggerFactory;
76

  
77

  
78
/**
79
 * @author fdiaz
80
 *
81
 */
82
public class CreateRouteExtension extends Extension {
83

  
84
    private static final Logger logger = LoggerFactory.getLogger(CreateRouteExtension.class);
85

  
86
    /* (non-Javadoc)
87
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
88
     */
89
    public void execute(String actionCommand) {
90
        if (StringUtils.equalsIgnoreCase(actionCommand, "create-routes")) {
91
            IView view = getActiveView();
92
            FLayers layers = view.getMapControl().getMapContext().getLayers();
93

  
94
            final WindowManager winManager = ToolsSwingLocator.getWindowManager();
95

  
96
            final LrsAlgorithmsSwingManager manager = LrsAlgorithmsSwingLocator.getLrsAlgorithmsSwingManager();
97

  
98
            final I18nManager i18nManager = ToolsLocator.getI18nManager();
99

  
100
            JLrsCreateRouteParamsController panel;
101
            try {
102
                panel = (JLrsCreateRouteParamsController)manager.createJLrsCreateRouteAlgorithmParameters(layers, null);
103
            } catch (LrsNeededParameterException e2) {
104
                logger.error("Error creating panel", e2);
105
                JOptionPane.showMessageDialog(
106
                    null,
107
                    new StringBuilder().append(i18nManager.getTranslation("error_creating_panel"))
108
                        .append(":").append(e2.getLocalizedMessage()),
109
                    i18nManager.getTranslation("error"), JOptionPane.ERROR_MESSAGE);
110
                return;
111
            }
112
            panel.setVisibleAceptCancel(true);
113
            panel.addActionListener(new ActionListener() {
114

  
115
                public void actionPerformed(ActionEvent e) {
116
                    JLrsAlgorithmParams panel = (JLrsAlgorithmParams) e.getSource();
117
                    if (panel.isCanceled()) {
118
                        return;
119
                    }
120
                    LrsCreateRouteAlgorithmParams params = null;
121
                    try {
122
                        params = (LrsCreateRouteAlgorithmParams)panel.getParams();
123
                    } catch (LrsGettingParametersException e1) {
124
                        logger.error("Error getting parameters", e1);
125
                        JOptionPane.showMessageDialog(
126
                            null,
127
                            new StringBuilder().append(i18nManager.getTranslation("error_getting_parameters"))
128
                                .append(":").append(e1.getLocalizedMessage()),
129
                            i18nManager.getTranslation("error"), JOptionPane.ERROR_MESSAGE);
130
                        return;
131
                    } catch (LrsNeededParameterException e1) {
132
                        logger.warn("Error getting parameters", e1);
133
                        JOptionPane.showMessageDialog(
134
                            null,
135
                            i18nManager.getTranslation(e1.getMessage()),
136
                            i18nManager.getTranslation("warning"), JOptionPane.WARNING_MESSAGE);
137
                        return;
138
                    }
139
                    LrsAlgorithmsManager algorithmsManager = LrsAlgorithmsLocator.getLrsAlgorithmsManager();
140
                    final LrsAlgorithm algorithm = algorithmsManager.createLrsAlgorithm(params);
141
                    final SHPNewStoreParameters shpParams=(SHPNewStoreParameters)params.getNewFeatureStoreParameters();
142

  
143
                    final SimpleTaskStatus taskStatus =
144
                        ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus(i18nManager.getTranslation("progress"));
145

  
146
                    final JLrsProgressDialog progressDialog = manager.createJLrsProgressDialog(taskStatus);
147

  
148
                    winManager.showWindow(progressDialog.asJComponent(), i18nManager.getTranslation("create_routes"),
149
                        WindowManager.MODE.WINDOW);
150

  
151
                    Thread task = new Thread(new Runnable() {
152

  
153
                        public void run() {
154
                            try {
155
                                algorithm.execute(taskStatus);
156
                                int resultLoadLayer =JOptionPane.showConfirmDialog(
157
                                    null,
158
                                    i18nManager.getTranslation("load_layer_question"),
159
                                    i18nManager.getTranslation("load_layer_question_title"), JOptionPane.YES_NO_OPTION);
160
                                if (resultLoadLayer==JOptionPane.YES_OPTION){
161
                                    loadLayer(shpParams);
162
                                }
163
                            } catch (Exception e) {
164
                                logger.error("Error creating routes", e);
165
                                String message = e.getMessage();
166
                                if (e.getCause() != null) {
167
                                    message = e.getCause().getMessage();
168
                                }
169
                                JOptionPane.showMessageDialog(
170
                                    progressDialog.asJComponent(),
171
                                    message,
172
                                    i18nManager.getTranslation("create_routes"),
173
                                    JOptionPane.ERROR_MESSAGE
174
                                );
175
                            }
176
                        }
177
                    });
178
                    task.start();
179
                }
180
            });
181
            winManager.showWindow(panel.asJComponent(), i18nManager.getTranslation("create_routes"),
182
                WindowManager.MODE.WINDOW);
183
        }
184
    }
185

  
186
    /* (non-Javadoc)
187
     * @see org.gvsig.andami.plugins.IExtension#initialize()
188
     */
189
    public void initialize() {
190
        registerIcons();
191
    }
192

  
193
    /* (non-Javadoc)
194
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
195
     */
196
    public boolean isEnabled() {
197
        IView view = getActiveView();
198
        if (view!=null){
199
            FLayers layers = view.getMapControl().getMapContext().getLayers();
200
            return JLrsUtils.validateOneCurveLyrOneNonGeomField(layers);
201
        }else return false;
202

  
203
    }
204

  
205
    /* (non-Javadoc)
206
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
207
     */
208
    public boolean isVisible() {
209
        ApplicationManager application = ApplicationLocator.getManager();
210

  
211
        return application.getActiveComponent(ViewDocument.class) != null;
212
    }
213

  
214
    private void registerIcons() {
215
        IconThemeHelper.registerIcon("lrs", "pk_red", this);
216
        IconThemeHelper.registerIcon("lrs", "pk_m", this);
217
    }
218

  
219

  
220
    private IView getActiveView() {
221
        ApplicationManager application = ApplicationLocator.getManager();
222
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
223
        return view;
224
    }
225

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

Also available in: Unified diff