Revision 1255
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.main/src/main/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your classes. |
|
2 |
|
|
3 |
This folder is added to the classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your classes. |
|
0 | 9 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.main/src/main/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.construc"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="INFO" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
|
0 | 38 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.main/src/main/java/org/gvsig/seismic/main/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.construc package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>Construc library testing and demo application.</p> |
|
11 |
|
|
12 |
</body> |
|
13 |
</html> |
|
0 | 14 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.main/src/main/java/org/gvsig/seismic/main/Main.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.seismic.main; |
|
23 |
|
|
24 |
import java.awt.BorderLayout; |
|
25 |
import java.awt.Dimension; |
|
26 |
import java.awt.event.ActionEvent; |
|
27 |
import java.awt.event.ActionListener; |
|
28 |
import java.io.File; |
|
29 |
import java.net.URL; |
|
30 |
|
|
31 |
import javax.swing.AbstractAction; |
|
32 |
import javax.swing.Action; |
|
33 |
import javax.swing.JButton; |
|
34 |
import javax.swing.JFrame; |
|
35 |
import javax.swing.JMenu; |
|
36 |
import javax.swing.JMenuBar; |
|
37 |
import javax.swing.JMenuItem; |
|
38 |
import javax.swing.JPanel; |
|
39 |
import javax.swing.JToolBar; |
|
40 |
import javax.swing.UIManager; |
|
41 |
import javax.swing.UnsupportedLookAndFeelException; |
|
42 |
import javax.swing.WindowConstants; |
|
43 |
|
|
44 |
import org.gvsig.fmap.dal.DALLocator; |
|
45 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
46 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
47 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
48 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
49 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
50 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
51 |
import org.gvsig.fmap.mapcontrol.MapControlCreationException; |
|
52 |
import org.gvsig.fmap.mapcontrol.MapControlLocator; |
|
53 |
import org.gvsig.fmap.mapcontrol.MapControlManager; |
|
54 |
import org.gvsig.fmap.mapcontrol.tools.PanListenerImpl; |
|
55 |
import org.gvsig.fmap.mapcontrol.tools.ZoomInListenerImpl; |
|
56 |
import org.gvsig.fmap.mapcontrol.tools.ZoomOutRightButtonListener; |
|
57 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
|
58 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MoveBehavior; |
|
59 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.PointBehavior; |
|
60 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.RectangleBehavior; |
|
61 |
import org.gvsig.seismic.swing.SeismicSwingLocator; |
|
62 |
import org.gvsig.seismic.swing.SeismicSwingManager; |
|
63 |
import org.gvsig.seismic.swing.gui.JSeismicWizard; |
|
64 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
|
65 |
import org.gvsig.tools.locator.LocatorException; |
|
66 |
import org.slf4j.Logger; |
|
67 |
import org.slf4j.LoggerFactory; |
|
68 |
|
|
69 |
import com.jgoodies.looks.plastic.PlasticLookAndFeel; |
|
70 |
import com.jgoodies.looks.plastic.PlasticXPLookAndFeel; |
|
71 |
|
|
72 |
/** |
|
73 |
* Main executable class for testing the Chart library. |
|
74 |
* |
|
75 |
* @author gvSIG Team |
|
76 |
* @version $Id$ |
|
77 |
*/ |
|
78 |
public class Main { |
|
79 |
|
|
80 |
private static final Logger LOG = LoggerFactory.getLogger(Main.class); |
|
81 |
|
|
82 |
private static final String SHOWINFO_TOOL_NAME = "LandRegistryViewer.infotool"; |
|
83 |
|
|
84 |
|
|
85 |
private MapControlManager mapControlManager; |
|
86 |
|
|
87 |
private MapControl mapControl; |
|
88 |
|
|
89 |
private SeismicSwingManager swingManager; |
|
90 |
|
|
91 |
private JSeismicWizard wizard; |
|
92 |
|
|
93 |
public JSeismicWizard getWizard() { |
|
94 |
return wizard; |
|
95 |
} |
|
96 |
|
|
97 |
public static void main(String args[]) throws MapControlCreationException, |
|
98 |
LocatorException, LoadLayerException, UnsupportedLookAndFeelException { |
|
99 |
new DefaultLibrariesInitializer().fullInitialize(); |
|
100 |
|
|
101 |
PlasticLookAndFeel laf = new PlasticXPLookAndFeel(); |
|
102 |
UIManager.setLookAndFeel(laf); |
|
103 |
|
|
104 |
Main main = new Main(); |
|
105 |
main.show(); |
|
106 |
} |
|
107 |
|
|
108 |
public SeismicSwingManager getSwingManager() { |
|
109 |
if(swingManager == null){ |
|
110 |
swingManager = SeismicSwingLocator.getDriverSwingManager(); |
|
111 |
} |
|
112 |
return swingManager; |
|
113 |
} |
|
114 |
|
|
115 |
@SuppressWarnings("serial") |
|
116 |
public void show() throws MapControlCreationException, LocatorException, LoadLayerException { |
|
117 |
AbstractAction exit = new AbstractAction("Exit") { |
|
118 |
public void actionPerformed(ActionEvent e) { |
|
119 |
System.exit(0); |
|
120 |
} |
|
121 |
}; |
|
122 |
|
|
123 |
JFrame frame = new JFrame("Example APP"); |
|
124 |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
|
125 |
|
|
126 |
JPanel content = new JPanel(); |
|
127 |
content.setLayout(new BorderLayout()); |
|
128 |
//Parser parser = getSwingManager().getDriverManager().createParser("UKOOA-84"); |
|
129 |
wizard = getSwingManager().createWizard(); |
|
130 |
content.add(wizard.getJComponent(), BorderLayout.CENTER); |
|
131 |
|
|
132 |
JButton accept = new JButton("Load features to view"); |
|
133 |
accept.addActionListener(new ActionListener() { |
|
134 |
public void actionPerformed(ActionEvent e) { |
|
135 |
try { |
|
136 |
if(getWizard().accept()){ |
|
137 |
createLayer(); |
|
138 |
}else{ |
|
139 |
LOG.error("[Main - accept button] ERROR: There're problems generating the data"); |
|
140 |
} |
|
141 |
} catch (MapControlCreationException e1) { |
|
142 |
// TODO Auto-generated catch block |
|
143 |
e1.printStackTrace(); |
|
144 |
} catch (LocatorException e1) { |
|
145 |
// TODO Auto-generated catch block |
|
146 |
e1.printStackTrace(); |
|
147 |
} catch (LoadLayerException e1) { |
|
148 |
// TODO Auto-generated catch block |
|
149 |
e1.printStackTrace(); |
|
150 |
} |
|
151 |
} |
|
152 |
}); |
|
153 |
content.add(accept,BorderLayout.SOUTH); |
|
154 |
|
|
155 |
frame.add(content); |
|
156 |
frame.setPreferredSize(new Dimension(510, 560)); |
|
157 |
|
|
158 |
// Display the window. |
|
159 |
frame.pack(); |
|
160 |
frame.setVisible(true); |
|
161 |
} |
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
public void createLayer() throws MapControlCreationException, LocatorException, LoadLayerException { |
|
166 |
mapControlManager = MapControlLocator.getMapControlManager(); |
|
167 |
|
|
168 |
mapControl = mapControlManager.createJMapControlPanel(); |
|
169 |
mapControl.addBehavior( |
|
170 |
"zoom", |
|
171 |
new Behavior[] { |
|
172 |
new RectangleBehavior(new ZoomInListenerImpl(mapControl)), |
|
173 |
new PointBehavior(new ZoomOutRightButtonListener(mapControl)) |
|
174 |
} |
|
175 |
); |
|
176 |
mapControl.addBehavior( |
|
177 |
"pan", |
|
178 |
new MoveBehavior( |
|
179 |
new PanListenerImpl(mapControl) |
|
180 |
) |
|
181 |
); |
|
182 |
mapControl.setTool("pan"); |
|
183 |
|
|
184 |
|
|
185 |
Action exit = new AbstractAction("Exit") { |
|
186 |
public void actionPerformed(ActionEvent e) { |
|
187 |
System.exit(0); |
|
188 |
} |
|
189 |
}; |
|
190 |
|
|
191 |
JFrame frame = new JFrame("Driver view example app"); |
|
192 |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); |
|
193 |
|
|
194 |
// Create the menu bar. |
|
195 |
JMenuBar menuBar = new JMenuBar(); |
|
196 |
|
|
197 |
// Build the menu. |
|
198 |
JMenu menuFile = new JMenu("File"); |
|
199 |
menuFile.add(new JMenuItem(exit)); |
|
200 |
|
|
201 |
menuBar.add(menuFile); |
|
202 |
|
|
203 |
JToolBar toolBar = new JToolBar(); |
|
204 |
toolBar.add( |
|
205 |
new JButton( |
|
206 |
new AbstractAction("Pan") { |
|
207 |
public void actionPerformed(ActionEvent e) { |
|
208 |
mapControl.setTool("pan"); |
|
209 |
} |
|
210 |
} |
|
211 |
) |
|
212 |
); |
|
213 |
toolBar.add( |
|
214 |
new JButton( |
|
215 |
new AbstractAction("Zoom") { |
|
216 |
public void actionPerformed(ActionEvent e) { |
|
217 |
mapControl.setTool("zoom"); |
|
218 |
} |
|
219 |
} |
|
220 |
) |
|
221 |
); |
|
222 |
toolBar.add( |
|
223 |
new JButton( |
|
224 |
new AbstractAction("Zoom all") { |
|
225 |
public void actionPerformed(ActionEvent e) { |
|
226 |
zoomAll(); |
|
227 |
} |
|
228 |
} |
|
229 |
) |
|
230 |
); |
|
231 |
|
|
232 |
toolBar.add( |
|
233 |
new JButton( |
|
234 |
new AbstractAction("Info") { |
|
235 |
public void actionPerformed(ActionEvent e) { |
|
236 |
mapControl.setTool(SHOWINFO_TOOL_NAME);; |
|
237 |
} |
|
238 |
} |
|
239 |
) |
|
240 |
); |
|
241 |
|
|
242 |
toolBar.add(new JButton(exit)); |
|
243 |
frame.setPreferredSize(new Dimension(400, 300)); |
|
244 |
frame.setJMenuBar(menuBar); |
|
245 |
frame.add(toolBar, BorderLayout.PAGE_START); |
|
246 |
frame.add(mapControl,BorderLayout.CENTER); |
|
247 |
|
|
248 |
// Display the window. |
|
249 |
frame.pack(); |
|
250 |
frame.setVisible(true); |
|
251 |
|
|
252 |
LOG.info("Providers: " + DALLocator.getDataManager().getStoreProviders().toString()); |
|
253 |
|
|
254 |
// Add the blocks layer |
|
255 |
// MapContextLocator.getMapContextManager().setDefaultVectorLegend(ISingleSymbolLegend.LEGEND_NAME); |
|
256 |
FLyrVect layer = (FLyrVect) MapContextLocator. |
|
257 |
getMapContextManager().createLayer( |
|
258 |
"test_driver", |
|
259 |
getWizard().getDriverStoreParameters() |
|
260 |
); |
|
261 |
|
|
262 |
mapControl.getMapContext().getLayers().addLayer(layer); |
|
263 |
|
|
264 |
// PropertiesOfBlockListener listener = new PropertiesOfBlockListener(); |
|
265 |
// mapControl.addBehavior(SHOWINFO_TOOL_NAME, new PointBehavior(listener)); |
|
266 |
|
|
267 |
zoomAll(); |
|
268 |
} |
|
269 |
|
|
270 |
private void zoomAll() { |
|
271 |
MapContext mapContext = mapControl.getMapContext(); |
|
272 |
Envelope all = mapContext.getLayers().getFullEnvelope(); |
|
273 |
LOG.info("Full extdents "+all.toString()); |
|
274 |
mapContext.getViewPort().setEnvelope(all); |
|
275 |
mapContext.invalidate(); |
|
276 |
} |
|
277 |
|
|
278 |
private File getResource(String pathname) { |
|
279 |
URL res = this.getClass().getClassLoader().getResource(pathname); |
|
280 |
return new File(res.getPath()); |
|
281 |
} |
|
282 |
|
|
283 |
|
|
284 |
} |
|
0 | 285 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.main/pom.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1"?> |
|
2 |
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|
3 |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> |
|
4 |
<modelVersion>4.0.0</modelVersion> |
|
5 |
<artifactId>org.gvsig.seismic.main</artifactId> |
|
6 |
<packaging>jar</packaging> |
|
7 |
<name>org.gvsig.seismic.main</name> |
|
8 |
<parent> |
|
9 |
<groupId>org.gvsig</groupId> |
|
10 |
<artifactId>org.gvsig.seismic</artifactId> |
|
11 |
<version>1.0.0-SNAPSHOT</version> |
|
12 |
</parent> |
|
13 |
|
|
14 |
|
|
15 |
<dependencies> |
|
16 |
<dependency> |
|
17 |
<groupId>org.gvsig</groupId> |
|
18 |
<artifactId>org.gvsig.seismic.lib.api</artifactId> |
|
19 |
<scope>compile</scope> |
|
20 |
</dependency> |
|
21 |
<dependency> |
|
22 |
<groupId>org.gvsig</groupId> |
|
23 |
<artifactId>org.gvsig.seismic.lib.impl</artifactId> |
|
24 |
<scope>runtime</scope> |
|
25 |
</dependency> |
|
26 |
<dependency> |
|
27 |
<groupId>org.gvsig</groupId> |
|
28 |
<artifactId>org.gvsig.seismic.swing.api</artifactId> |
|
29 |
<scope>compile</scope> |
|
30 |
</dependency> |
|
31 |
<dependency> |
|
32 |
<groupId>org.gvsig</groupId> |
|
33 |
<artifactId>org.gvsig.seismic.provider</artifactId> |
|
34 |
<scope>compile</scope> |
|
35 |
</dependency> |
|
36 |
<dependency> |
|
37 |
<groupId>org.gvsig</groupId> |
|
38 |
<artifactId>org.gvsig.seismic.swing.impl</artifactId> |
|
39 |
<scope>runtime</scope> |
|
40 |
</dependency> |
|
41 |
<dependency> |
|
42 |
<groupId>org.gvsig</groupId> |
|
43 |
<artifactId>org.gvsig.tools.lib</artifactId> |
|
44 |
<scope>compile</scope> |
|
45 |
</dependency> |
|
46 |
<dependency> |
|
47 |
<groupId>org.gvsig</groupId> |
|
48 |
<artifactId>org.gvsig.tools.dynform.api</artifactId> |
|
49 |
<scope>compile</scope> |
|
50 |
</dependency> |
|
51 |
<dependency> |
|
52 |
<groupId>org.gvsig</groupId> |
|
53 |
<artifactId>org.gvsig.tools.dynform.impl</artifactId> |
|
54 |
<scope>runtime</scope> |
|
55 |
</dependency> |
|
56 |
|
|
57 |
<dependency> |
|
58 |
<groupId>org.gvsig</groupId> |
|
59 |
<artifactId>org.gvsig.metadata.lib.basic.api</artifactId> |
|
60 |
<scope>compile</scope> |
|
61 |
</dependency> |
|
62 |
<dependency> |
|
63 |
<groupId>org.gvsig</groupId> |
|
64 |
<artifactId>org.gvsig.tools.swing.api</artifactId> |
|
65 |
<type>jar</type> |
|
66 |
<scope>compile</scope> |
|
67 |
</dependency> |
|
68 |
<dependency> |
|
69 |
<groupId>org.gvsig</groupId> |
|
70 |
<artifactId>org.gvsig.fmap.control</artifactId> |
|
71 |
<scope>compile</scope> |
|
72 |
</dependency> |
|
73 |
<dependency> |
|
74 |
<groupId>org.gvsig</groupId> |
|
75 |
<artifactId>org.gvsig.fmap.dal.api</artifactId> |
|
76 |
<scope>compile</scope> |
|
77 |
</dependency> |
|
78 |
<dependency> |
|
79 |
<groupId>org.gvsig</groupId> |
|
80 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
81 |
<scope>compile</scope> |
|
82 |
</dependency> |
|
83 |
<dependency> |
|
84 |
<groupId>org.gvsig</groupId> |
|
85 |
<artifactId>org.gvsig.fmap.geometry.api</artifactId> |
|
86 |
<scope>compile</scope> |
|
87 |
</dependency> |
|
88 |
<dependency> |
|
89 |
<groupId>org.gvsig</groupId> |
|
90 |
<artifactId>org.gvsig.fmap.mapcontext.api</artifactId> |
|
91 |
<scope>compile</scope> |
|
92 |
</dependency> |
|
93 |
|
|
94 |
|
|
95 |
<dependency> |
|
96 |
<groupId>org.gvsig</groupId> |
|
97 |
<artifactId>org.gvsig.metadata.lib.basic.impl</artifactId> |
|
98 |
<scope>runtime</scope> |
|
99 |
</dependency> |
|
100 |
<dependency> |
|
101 |
<groupId>org.gvsig</groupId> |
|
102 |
<artifactId>org.gvsig.fmap.geometry.impl</artifactId> |
|
103 |
<scope>runtime</scope> |
|
104 |
</dependency> |
|
105 |
<dependency> |
|
106 |
<groupId>org.gvsig</groupId> |
|
107 |
<artifactId>org.gvsig.fmap.geometry.operation</artifactId> |
|
108 |
<scope>runtime</scope> |
|
109 |
</dependency> |
|
110 |
<dependency> |
|
111 |
<groupId>org.gvsig</groupId> |
|
112 |
<artifactId>org.gvsig.fmap.mapcontext.impl</artifactId> |
|
113 |
<scope>runtime</scope> |
|
114 |
</dependency> |
|
115 |
<dependency> |
|
116 |
<groupId>org.gvsig</groupId> |
|
117 |
<artifactId>org.gvsig.symbology.lib.impl</artifactId> |
|
118 |
<scope>runtime</scope> |
|
119 |
</dependency> |
|
120 |
<dependency> |
|
121 |
<groupId>org.gvsig</groupId> |
|
122 |
<artifactId>org.gvsig.fmap.dal.impl</artifactId> |
|
123 |
<scope>runtime</scope> |
|
124 |
</dependency> |
|
125 |
<dependency> |
|
126 |
<groupId>org.gvsig</groupId> |
|
127 |
<artifactId>org.gvsig.fmap.dal.spi</artifactId> |
|
128 |
<scope>runtime</scope> |
|
129 |
</dependency> |
|
130 |
<dependency> |
|
131 |
<groupId>org.gvsig</groupId> |
|
132 |
<artifactId>org.gvsig.fmap.dal.file.shp</artifactId> |
|
133 |
<scope>runtime</scope> |
|
134 |
</dependency> |
|
135 |
<dependency> |
|
136 |
<groupId>org.gvsig</groupId> |
|
137 |
<artifactId>org.gvsig.fmap.dal.file.dbf</artifactId> |
|
138 |
<scope>runtime</scope> |
|
139 |
</dependency> |
|
140 |
<dependency> |
|
141 |
<groupId>org.gvsig</groupId> |
|
142 |
<artifactId>org.gvsig.fmap.dal.file.lib</artifactId> |
|
143 |
<scope>runtime</scope> |
|
144 |
</dependency> |
|
145 |
<dependency> |
|
146 |
<groupId>org.gvsig</groupId> |
|
147 |
<artifactId>org.gvsig.timesupport.lib.api</artifactId> |
|
148 |
<scope>runtime</scope> |
|
149 |
</dependency> |
|
150 |
<dependency> |
|
151 |
<groupId>org.gvsig</groupId> |
|
152 |
<artifactId>org.gvsig.timesupport.lib.impl</artifactId> |
|
153 |
<scope>runtime</scope> |
|
154 |
</dependency> |
|
155 |
<dependency> |
|
156 |
<groupId>org.gvsig</groupId> |
|
157 |
<artifactId>org.gvsig.tools.evaluator.sqljep</artifactId> |
|
158 |
<scope>runtime</scope> |
|
159 |
</dependency> |
|
160 |
<dependency> |
|
161 |
<groupId>org.gvsig</groupId> |
|
162 |
<artifactId>org.gvsig.proj.lib.proj4j</artifactId> |
|
163 |
<scope>runtime</scope> |
|
164 |
</dependency> |
|
165 |
</dependencies> |
|
166 |
</project> |
|
0 | 167 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/test/resources/README.txt | ||
---|---|---|
1 |
Put into this folder the resources needed by your test classes. |
|
2 |
|
|
3 |
This folder is added to the Tests classpath, so you can load any resources |
|
4 |
through the ClassLoader. |
|
5 |
|
|
6 |
By default, in this folder you can find an example of log4j configuration, |
|
7 |
prepared to log messages through the console, so logging works when you |
|
8 |
run your tests classes. |
|
0 | 9 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/test/resources/log4j.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="ISO-8859-1" ?> |
|
2 |
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> |
|
3 |
|
|
4 |
<!-- |
|
5 |
Log4J configuration file for unit tests execution. |
|
6 |
--> |
|
7 |
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> |
|
8 |
|
|
9 |
<!-- Appender configuration to show logging messages through the console --> |
|
10 |
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender"> |
|
11 |
<layout class="org.apache.log4j.PatternLayout"> |
|
12 |
<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n %m%n" /> |
|
13 |
</layout> |
|
14 |
</appender> |
|
15 |
|
|
16 |
<!-- |
|
17 |
Activate logging messages of DEBUG level of higher only for the |
|
18 |
org.gvsig.tools packages. |
|
19 |
You can put full classes names or packages instead, to configure |
|
20 |
logging for all the classes and subpackages of the package. |
|
21 |
--> |
|
22 |
<category name="org.gvsig.tools"> |
|
23 |
<priority value="DEBUG" /> |
|
24 |
</category> |
|
25 |
<category name="org.gvsig.chart"> |
|
26 |
<priority value="DEBUG" /> |
|
27 |
</category> |
|
28 |
|
|
29 |
<!-- |
|
30 |
By default, show only logging messages of INFO level or higher, |
|
31 |
through the previously configured CONSOLE appender. |
|
32 |
--> |
|
33 |
<root> |
|
34 |
<priority value="DEBUG" /> |
|
35 |
<appender-ref ref="CONSOLE" /> |
|
36 |
</root> |
|
37 |
</log4j:configuration> |
|
0 | 38 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/main/java/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.landregistryviewer package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p>LandRegistryViewer library API default implementation.</p> |
|
11 |
|
|
12 |
</body> |
|
13 |
</html> |
|
0 | 14 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/main/java/org/gvsig/seismic/impl/AbstractParser.java | ||
---|---|---|
1 |
package org.gvsig.seismic.impl; |
|
2 |
|
|
3 |
import java.io.BufferedReader; |
|
4 |
import java.io.File; |
|
5 |
import java.io.FileNotFoundException; |
|
6 |
import java.io.FileReader; |
|
7 |
import java.io.IOException; |
|
8 |
import java.util.ArrayList; |
|
9 |
import java.util.HashMap; |
|
10 |
import java.util.Iterator; |
|
11 |
import java.util.List; |
|
12 |
import java.util.Map; |
|
13 |
import java.util.regex.Matcher; |
|
14 |
import java.util.regex.Pattern; |
|
15 |
|
|
16 |
import javax.swing.JOptionPane; |
|
17 |
|
|
18 |
import org.cresques.cts.IProjection; |
|
19 |
import org.gvsig.fmap.crs.CRSFactory; |
|
20 |
import org.gvsig.fmap.dal.feature.EditableFeatureType; |
|
21 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
22 |
import org.gvsig.fmap.geom.DataTypes; |
|
23 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
24 |
import org.gvsig.fmap.geom.GeometryManager; |
|
25 |
import org.gvsig.seismic.Parser; |
|
26 |
import org.gvsig.seismic.SeismicManager; |
|
27 |
import org.gvsig.tools.ToolsLocator; |
|
28 |
import org.gvsig.tools.dynobject.DynObject; |
|
29 |
import org.gvsig.tools.dynobject.DynObjectManager; |
|
30 |
import org.gvsig.tools.dynobject.DynStruct; |
|
31 |
import org.slf4j.Logger; |
|
32 |
import org.slf4j.LoggerFactory; |
|
33 |
|
|
34 |
public abstract class AbstractParser implements |
|
35 |
Parser{ |
|
36 |
|
|
37 |
private static Logger logger= LoggerFactory.getLogger(AbstractParser.class); |
|
38 |
|
|
39 |
private SeismicManager manager; |
|
40 |
protected GeometryManager geomanager; |
|
41 |
|
|
42 |
protected List<String> availableExtensions = new ArrayList<String>(); |
|
43 |
protected DynObjectManager dynManager; |
|
44 |
//private List<Map<String, Object>> features; |
|
45 |
protected DynStruct dynStruct; |
|
46 |
protected File file; |
|
47 |
protected Map<String, String> metadata; |
|
48 |
private List<DynObject> data; |
|
49 |
protected EditableFeatureType featureType; |
|
50 |
|
|
51 |
protected int blankFieldCount = 1; |
|
52 |
private List<FieldDefinition> fieldDefinitions; |
|
53 |
private IProjection projection; |
|
54 |
|
|
55 |
private boolean firstErrorShown = false; |
|
56 |
|
|
57 |
private String projectid; |
|
58 |
private String projectName; |
|
59 |
private String projectYear; |
|
60 |
private String estado; |
|
61 |
|
|
62 |
protected IProjection defaultProjection; |
|
63 |
|
|
64 |
|
|
65 |
public AbstractParser(SeismicManager manager){ |
|
66 |
this.manager = manager; |
|
67 |
this.dynManager = ToolsLocator.getDynObjectManager(); |
|
68 |
this.geomanager = GeometryLocator.getGeometryManager(); |
|
69 |
//this.defaultProjection = CRSFactory.getCRS("EPSG:4326"); |
|
70 |
} |
|
71 |
|
|
72 |
public void initializeParser(){ |
|
73 |
//this.features = null; |
|
74 |
this.setData(null); |
|
75 |
// this.featureStruct = null; |
|
76 |
this.fieldDefinitions = null; |
|
77 |
|
|
78 |
this.featureType = null; |
|
79 |
this.dynStruct = null; |
|
80 |
this.metadata = null; |
|
81 |
} |
|
82 |
|
|
83 |
public boolean isFileSupported(File file) { |
|
84 |
int dot = file.getName().lastIndexOf("."); |
|
85 |
String extension = file.getName().substring(dot + 1); |
|
86 |
|
|
87 |
if( availableExtensions.contains(extension.toLowerCase())){ |
|
88 |
return true; |
|
89 |
} |
|
90 |
return false; |
|
91 |
} |
|
92 |
|
|
93 |
public void setFile(File file){ |
|
94 |
this.file = file; |
|
95 |
//this.features = null; |
|
96 |
this.setData(null); |
|
97 |
} |
|
98 |
|
|
99 |
public String[] getOrderedFieldNames() { |
|
100 |
return new String[]{}; |
|
101 |
} |
|
102 |
|
|
103 |
protected void addFieldDefinition(String nombre, int type){ |
|
104 |
getFieldDefinitions().add(new FieldDefinition(nombre, type)); |
|
105 |
} |
|
106 |
|
|
107 |
public List<FieldDefinition> getFieldDefinitions(){ |
|
108 |
if(this.fieldDefinitions == null){ |
|
109 |
this.fieldDefinitions = new ArrayList<FieldDefinition>(); |
|
110 |
initializeDefinitions(); |
|
111 |
getDataStruct(); |
|
112 |
} |
|
113 |
return this.fieldDefinitions; |
|
114 |
} |
|
115 |
|
|
116 |
protected void initializeDefinitions() { |
|
117 |
addFieldDefinition("proyecto_id", DataTypes.STRING); |
|
118 |
addFieldDefinition("proyecto", DataTypes.STRING); |
|
119 |
addFieldDefinition("Fecha", DataTypes.STRING); |
|
120 |
addFieldDefinition("Estado", DataTypes.STRING); |
|
121 |
} |
|
122 |
|
|
123 |
public int getFieldDefinitionType(String name){ |
|
124 |
for(int i=0; i<getFieldDefinitions().size(); i++){ |
|
125 |
if(getFieldDefinitions().get(i).getName().equalsIgnoreCase(name)){ |
|
126 |
return getFieldDefinitions().get(i).getType(); |
|
127 |
} |
|
128 |
} |
|
129 |
return -1; |
|
130 |
} |
|
131 |
|
|
132 |
protected void createDynObjectProjectInfo(DynObject dynObject){ |
|
133 |
if(getDataStruct().getDynField("proyecto_id") != null){ |
|
134 |
dynObject.setDynValue("proyecto_id", getProjectId()); |
|
135 |
} |
|
136 |
|
|
137 |
if(getDataStruct().getDynField("proyecto") != null){ |
|
138 |
dynObject.setDynValue("proyecto", getProjectName()); |
|
139 |
} |
|
140 |
|
|
141 |
if(getDataStruct().getDynField("Fecha") != null){ |
|
142 |
dynObject.setDynValue("Fecha", getProjectYear()); |
|
143 |
} |
|
144 |
|
|
145 |
if(getDataStruct().getDynField("Estado") != null){ |
|
146 |
dynObject.setDynValue("Estado", getEstado()); |
|
147 |
} |
|
148 |
} |
|
149 |
|
|
150 |
public String getProjectYear() { |
|
151 |
return projectYear; |
|
152 |
} |
|
153 |
|
|
154 |
public String getProjectName() { |
|
155 |
return projectName; |
|
156 |
} |
|
157 |
|
|
158 |
public String getProjectId() { |
|
159 |
return projectid; |
|
160 |
} |
|
161 |
|
|
162 |
public String getEstado() { |
|
163 |
return estado; |
|
164 |
} |
|
165 |
|
|
166 |
|
|
167 |
public String getFieldDefinitionName(String name){ |
|
168 |
for(int i=0; i<getFieldDefinitions().size(); i++){ |
|
169 |
if(getFieldDefinitions().get(i).getName().equalsIgnoreCase(name)){ |
|
170 |
return getFieldDefinitions().get(i).getName(); |
|
171 |
} |
|
172 |
} |
|
173 |
return null; |
|
174 |
} |
|
175 |
|
|
176 |
public String getFieldDefinitionName(int index){ |
|
177 |
if(index < getFieldDefinitions().size()){ |
|
178 |
return getFieldDefinitions().get(index).getName(); |
|
179 |
} |
|
180 |
return null; |
|
181 |
} |
|
182 |
|
|
183 |
public String getFieldDefinitionNewName(String name){ |
|
184 |
for(int i=0; i<getFieldDefinitions().size(); i++){ |
|
185 |
if(getFieldDefinitions().get(i).getName().equalsIgnoreCase(name)){ |
|
186 |
return getFieldDefinitions().get(i).getNewName(); |
|
187 |
} |
|
188 |
} |
|
189 |
return null; |
|
190 |
} |
|
191 |
|
|
192 |
public String getFieldDefinitionNewName(int index){ |
|
193 |
if(index < getFieldDefinitions().size()){ |
|
194 |
return getFieldDefinitions().get(index).getNewName(); |
|
195 |
} |
|
196 |
return null; |
|
197 |
} |
|
198 |
|
|
199 |
public void setFieldDefinitionNewName(String name, String newName){ |
|
200 |
for(int i=0; i<getFieldDefinitions().size(); i++){ |
|
201 |
if(getFieldDefinitions().get(i).getName().equalsIgnoreCase(name)){ |
|
202 |
getFieldDefinitions().get(i).setNewName(newName); |
|
203 |
} |
|
204 |
} |
|
205 |
} |
|
206 |
|
|
207 |
protected List<String> getFieldNames(){ |
|
208 |
Iterator it = getFieldDefinitions().iterator(); |
|
209 |
List<String> aux = new ArrayList<String>(); |
|
210 |
while(it.hasNext()){ |
|
211 |
FieldDefinition fd = (FieldDefinition) it.next(); |
|
212 |
aux.add(fd.getName()); |
|
213 |
} |
|
214 |
return aux; |
|
215 |
} |
|
216 |
|
|
217 |
protected class FieldDefinition{ |
|
218 |
private String name; |
|
219 |
private String newName; |
|
220 |
private int type; |
|
221 |
|
|
222 |
public FieldDefinition(String name, int type){ |
|
223 |
this.setName(name); |
|
224 |
this.setType(type); |
|
225 |
} |
|
226 |
|
|
227 |
public String getName() { |
|
228 |
return name; |
|
229 |
} |
|
230 |
|
|
231 |
public void setName(String name) { |
|
232 |
this.name = name; |
|
233 |
} |
|
234 |
|
|
235 |
public int getType() { |
|
236 |
return type; |
|
237 |
} |
|
238 |
|
|
239 |
public void setType(int type) { |
|
240 |
this.type = type; |
|
241 |
} |
|
242 |
|
|
243 |
public String getNewName() { |
|
244 |
if(newName == null || newName.trim().equals("")){ |
|
245 |
return name; |
|
246 |
} |
|
247 |
return newName; |
|
248 |
} |
|
249 |
|
|
250 |
public void setNewName(String newName) { |
|
251 |
this.newName = newName; |
|
252 |
} |
|
253 |
} |
|
254 |
|
|
255 |
public abstract String getName(); |
|
256 |
public abstract String getDescription(); |
|
257 |
|
|
258 |
public abstract boolean hasStartEndDelimiters(); |
|
259 |
public abstract String getStartDelimiter(); |
|
260 |
public abstract String getEndDelimiter(); |
|
261 |
|
|
262 |
public abstract boolean hasHeader(); |
|
263 |
public abstract String getHeaderToken(); |
|
264 |
public abstract boolean hasHeaderTokenRepited(); |
|
265 |
|
|
266 |
public abstract String getFieldDelimiter(); |
|
267 |
public abstract boolean hasFieldName(); |
|
268 |
public abstract String getFieldNameSeparator(); |
|
269 |
|
|
270 |
protected void preParsingProcess(){ |
|
271 |
} |
|
272 |
|
|
273 |
protected void postParsingProcess(){ |
|
274 |
} |
|
275 |
|
|
276 |
|
|
277 |
public SeismicManager getDriverManager(){ |
|
278 |
return this.manager; |
|
279 |
} |
|
280 |
|
|
281 |
public List<DynObject> parseFile(File file){ |
|
282 |
setFile(file); |
|
283 |
return updateDataContent(getDataStruct()); |
|
284 |
} |
|
285 |
|
|
286 |
public List<DynObject> parseFile(File file, DynStruct struct){ |
|
287 |
setFile(file); |
|
288 |
return updateDataContent(struct); |
|
289 |
} |
|
290 |
|
|
291 |
// protected DynStruct getFirstFeature() { |
|
292 |
// if(this.file == null) |
|
293 |
// return null; |
|
294 |
// |
|
295 |
// if(this.featureStruct == null){ |
|
296 |
// extractFeatures(file, true); |
|
297 |
// if(!getData().isEmpty()){ |
|
298 |
// postParsingProcess(getData()); |
|
299 |
// this.featureStruct = getData().get(0).getDynClass(); |
|
300 |
// } |
|
301 |
// } |
|
302 |
// |
|
303 |
// return this.featureStruct; |
|
304 |
// } |
|
305 |
// |
|
306 |
public void getFeatures(){ |
|
307 |
preParsingProcess(); |
|
308 |
extractFeatures(file, false); |
|
309 |
postParsingProcess(); |
|
310 |
} |
|
311 |
|
|
312 |
protected void extractFeatures(File file, boolean onlyFirst){ |
|
313 |
readDocument(file, onlyFirst); |
|
314 |
} |
|
315 |
|
|
316 |
public DynStruct getDataStruct(){ |
|
317 |
if(this.dynStruct == null){ |
|
318 |
if(file != null){ |
|
319 |
this.dynStruct = dynManager.createDynClass("Auxiliar", "Clase auxiliar para el parseo"); |
|
320 |
getDataStructure(); |
|
321 |
} |
|
322 |
} |
|
323 |
return this.dynStruct; |
|
324 |
} |
|
325 |
|
|
326 |
|
|
327 |
public void setDataStruct(DynStruct struct){ |
|
328 |
this.dynStruct = struct; |
|
329 |
// updateFeatureStoreDefinition(); |
|
330 |
} |
|
331 |
|
|
332 |
public FeatureStore getFeatureStore(){ |
|
333 |
return getDriverManager().getFeatureStore(); |
|
334 |
} |
|
335 |
|
|
336 |
public EditableFeatureType getFeatureType(){ |
|
337 |
return this.featureType; |
|
338 |
} |
|
339 |
|
|
340 |
|
|
341 |
protected void getDataStructure() { |
|
342 |
this.dynStruct = dynManager.createDynClass("Auxiliar", "Clase auxiliar para el parseo"); |
|
343 |
|
|
344 |
Iterator<FieldDefinition> it = getFieldDefinitions().iterator(); |
|
345 |
while(it.hasNext()){ |
|
346 |
FieldDefinition aux = (FieldDefinition)it.next(); |
|
347 |
this.dynStruct.addDynField(aux.getName()); |
|
348 |
if(getFieldDefinitionType(aux.getName())!= -1){ |
|
349 |
this.dynStruct.getDeclaredDynField(aux.getName()).setType(aux.getType()); |
|
350 |
} |
|
351 |
} |
|
352 |
} |
|
353 |
|
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
public List<DynObject> updateDataContent(){ |
|
358 |
return updateDataContent(getDataStruct()); |
|
359 |
} |
|
360 |
|
|
361 |
public List<DynObject> updateDataContent(DynStruct struct){ |
|
362 |
return updateDataContent(struct, null); |
|
363 |
} |
|
364 |
|
|
365 |
public List<DynObject> updateDataContent(DynStruct struct, List<String> fieldNames){ |
|
366 |
getFeatures(); |
|
367 |
|
|
368 |
return this.getData(); |
|
369 |
} |
|
370 |
|
|
371 |
// public List<DynObject> updateDataContent(DynStruct struct, List<String> fieldNames){ |
|
372 |
// List<DynObject> dynObjectSet = new ArrayList<DynObject>(); |
|
373 |
// |
|
374 |
// getFeatures(); |
|
375 |
// |
|
376 |
// if(struct != null){ |
|
377 |
// for(int i=struct.getDynFields().length-1;i>=0;i--){ |
|
378 |
// DynField f = struct.getDynFields()[i]; |
|
379 |
// if(f.isHidden()){ |
|
380 |
// struct.removeDynField(f.getName()); |
|
381 |
// } |
|
382 |
// } |
|
383 |
// } |
|
384 |
// Iterator itFeatures = getData().iterator(); |
|
385 |
// while(itFeatures.hasNext()){ |
|
386 |
// Map<String, Object> fields = (Map<String, Object>) itFeatures.next(); |
|
387 |
// DynObject dynObject = dynManager.createDynObject(struct); |
|
388 |
// |
|
389 |
// if(fieldNames == null && (getFieldDefinitions() == null || getFieldDefinitions().isEmpty())){ |
|
390 |
// |
|
391 |
// for(int i = 0; i<struct.getDynFields().length;i++){ |
|
392 |
// Object value = getCorrectTypeValue( |
|
393 |
// struct.getDynFields()[i].getType(), |
|
394 |
// fields.get(struct.getDynFields()[i].getName()), |
|
395 |
// struct.getDynFields()[i].getName()); |
|
396 |
// dynObject.setDynValue(struct.getDynFields()[i].getName(), value); |
|
397 |
// } |
|
398 |
// }else{ |
|
399 |
// if(fieldNames == null){ |
|
400 |
// fieldNames = getFieldNames(); |
|
401 |
// } |
|
402 |
// |
|
403 |
// String[] originalFields = new String[fields.size()]; |
|
404 |
// originalFields = fields.keySet().toArray(originalFields); |
|
405 |
// for(int i=0; i<fields.size();i++){ |
|
406 |
// if(fields.containsKey(originalFields[i])){ |
|
407 |
// String newFieldName = getFieldDefinitionNewName(originalFields[i]); |
|
408 |
// if(struct.getDynField(newFieldName) != null){ |
|
409 |
// Object value = getCorrectTypeValue( |
|
410 |
// struct.getDynField(newFieldName).getType(), |
|
411 |
// fields.get(originalFields[i]), |
|
412 |
// newFieldName); |
|
413 |
// dynObject.setDynValue( |
|
414 |
// newFieldName, |
|
415 |
// value); |
|
416 |
// } |
|
417 |
// } |
|
418 |
// } |
|
419 |
// } |
|
420 |
// dynObjectSet.add(dynObject); |
|
421 |
// } |
|
422 |
// |
|
423 |
// firstErrorShown = false; |
|
424 |
// |
|
425 |
// return dynObjectSet; |
|
426 |
// } |
|
427 |
|
|
428 |
|
|
429 |
|
|
430 |
private Object getCorrectTypeValue(int type, Object value, String name) { |
|
431 |
if(value == null){ |
|
432 |
return value; |
|
433 |
} |
|
434 |
|
|
435 |
switch(type){ |
|
436 |
case DataTypes.STRING: |
|
437 |
return value.toString(); |
|
438 |
case DataTypes.INT: |
|
439 |
int i = 0; |
|
440 |
try{ |
|
441 |
i = Integer.parseInt(value.toString()); |
|
442 |
}catch(NumberFormatException e){ |
|
443 |
if(!firstErrorShown){ |
|
444 |
JOptionPane.showMessageDialog(null, |
|
445 |
"Error converting values from '"+ name+ "'\nfield into Integer.\nPlease check if that is correct", |
|
446 |
"Parsing values error", |
|
447 |
JOptionPane.ERROR_MESSAGE); |
|
448 |
i = 0; |
|
449 |
e.printStackTrace(); |
|
450 |
firstErrorShown = true; |
|
451 |
} |
|
452 |
} |
|
453 |
return i; |
|
454 |
case DataTypes.FLOAT: |
|
455 |
float f = 0.0f; |
|
456 |
try{ |
|
457 |
f = Float.parseFloat(value.toString()); |
|
458 |
}catch(NumberFormatException e){ |
|
459 |
if(!firstErrorShown){ |
|
460 |
JOptionPane.showMessageDialog(null, |
|
461 |
"Error converting values from '"+ name+ "'\nfield into Float.\nPlease check if that is correct", |
|
462 |
"Parsing values error", |
|
463 |
JOptionPane.ERROR_MESSAGE); |
|
464 |
f = 0.0f; |
|
465 |
e.printStackTrace(); |
|
466 |
firstErrorShown = true; |
|
467 |
} |
|
468 |
} |
|
469 |
return f; |
|
470 |
case DataTypes.DOUBLE: |
|
471 |
double d = 0.0; |
|
472 |
try{ |
|
473 |
d = Double.parseDouble(value.toString()); |
|
474 |
}catch(NumberFormatException e){ |
|
475 |
if(!firstErrorShown){ |
|
476 |
JOptionPane.showMessageDialog(null, |
|
477 |
"Error converting values from '"+ name+ "'\nfield into Double.\nPlease check if that is correct", |
|
478 |
"Parsing values error", |
|
479 |
JOptionPane.ERROR_MESSAGE); |
|
480 |
d = 0.0; |
|
481 |
e.printStackTrace(); |
|
482 |
firstErrorShown = true; |
|
483 |
} |
|
484 |
} |
|
485 |
return d; |
|
486 |
case DataTypes.DATE: |
|
487 |
return value.toString(); |
|
488 |
case DataTypes.BOOLEAN: |
|
489 |
return value.toString().trim().equalsIgnoreCase("true") || value.toString().trim().equalsIgnoreCase("t") || |
|
490 |
value.toString().trim().equalsIgnoreCase("yes") || value.toString().trim().equalsIgnoreCase("y"); |
|
491 |
case DataTypes.FILE: |
|
492 |
return value.toString(); |
|
493 |
case DataTypes.GEOMETRY: |
|
494 |
return value.toString(); |
|
495 |
default: |
|
496 |
return value; |
|
497 |
} |
|
498 |
} |
|
499 |
|
|
500 |
public Map<String, String> getMetadataInfo(File file){ |
|
501 |
if(this.metadata == null){ |
|
502 |
this.file = file; |
|
503 |
readMetadata(file); |
|
504 |
} |
|
505 |
return this.metadata; |
|
506 |
} |
|
507 |
|
|
508 |
public void readMetadata(File file){ |
|
509 |
BufferedReader br = null; |
|
510 |
String text = ""; |
|
511 |
String line = ""; |
|
512 |
|
|
513 |
if(!this.hasMetadata()) |
|
514 |
return; |
|
515 |
|
|
516 |
try { |
|
517 |
br = new BufferedReader(new FileReader(file.getAbsolutePath())); |
|
518 |
boolean firstLine = true; |
|
519 |
this.metadata = new HashMap<String, String>(); |
|
520 |
while ((line = br.readLine()) != null) { |
|
521 |
Pattern delimiter = Pattern.compile("^"+ // Desde el principio de la cadena |
|
522 |
getMetadataToken()+ // Inicio contenido feature |
|
523 |
"(.*)$"); // Recoge todos los caracteres unidos al token de Metadato como separador |
|
524 |
List<String> tagValues = new ArrayList<String>(); |
|
525 |
Matcher matcher = delimiter.matcher(line); |
|
526 |
while (matcher.find()) { |
|
527 |
tagValues.add(matcher.group(1)); |
|
528 |
} |
|
529 |
|
|
530 |
if(tagValues.size()>0){ |
|
531 |
if(hasMetadataFieldName()){ |
|
532 |
for(int i=0;i<tagValues.size();i++){ |
|
533 |
String aux = tagValues.get(i); |
|
534 |
if(aux != "" && aux.length()>28){ |
|
535 |
this.metadata.put(aux.substring(0,27).trim(), aux.substring(28).trim()); |
|
536 |
String key = aux.substring(0,27).trim(); |
|
537 |
String value = aux.substring(28).trim(); |
|
538 |
if(hasProjectionData(key)){ |
|
539 |
defaultProjection = getProjectionData(value); |
|
540 |
} |
|
541 |
} |
|
542 |
} |
|
543 |
} |
|
544 |
}else{ |
|
545 |
// En el momento no coincida, ha acabado la cabecera. |
|
546 |
// No hace falta seguir leyendo |
|
547 |
br.close(); |
|
548 |
return; |
|
549 |
} |
|
550 |
} |
|
551 |
} catch (FileNotFoundException e) { |
|
552 |
e.printStackTrace(); |
|
553 |
} catch (IOException e) { |
|
554 |
e.printStackTrace(); |
|
555 |
} finally { |
|
556 |
if (br != null) { |
|
557 |
try { |
|
558 |
br.close(); |
|
559 |
} catch (IOException e) { |
|
560 |
e.printStackTrace(); |
|
561 |
} |
|
562 |
} |
|
563 |
} |
|
564 |
|
|
565 |
} |
|
566 |
|
|
567 |
protected IProjection getProjectionData(String value) { |
|
568 |
if(value.contains("58") || value.contains("21")){ |
|
569 |
defaultProjection = CRSFactory.getCRS("EPSG:24721"); |
|
570 |
} |
|
571 |
if(value.contains("63") || value.contains("20")){ |
|
572 |
defaultProjection = CRSFactory.getCRS("EPSG:24720"); |
|
573 |
} |
|
574 |
if(value.contains("69") || value.contains("19")){ |
|
575 |
defaultProjection = CRSFactory.getCRS("EPSG:24719"); |
|
576 |
} |
|
577 |
if(value.contains("75") || value.contains("18")){ |
|
578 |
defaultProjection = CRSFactory.getCRS("EPSG:24718"); |
|
579 |
} |
|
580 |
return defaultProjection; |
|
581 |
} |
|
582 |
|
|
583 |
protected boolean hasProjectionData(String key) { |
|
584 |
if(key.startsWith("H04") || |
|
585 |
key.startsWith("H19") || |
|
586 |
key.startsWith("H22")){ |
|
587 |
return true; |
|
588 |
} |
|
589 |
return false; |
|
590 |
} |
|
591 |
|
|
592 |
protected void readDocument(File file, boolean onlyFirst){ |
|
593 |
//String text = ""; |
|
594 |
String line = ""; |
|
595 |
|
|
596 |
//boolean firstLine = true; |
|
597 |
|
|
598 |
List<DynObject> objects = new ArrayList<DynObject>(); |
|
599 |
//DynStruct struct = getDataStruct(); |
|
600 |
|
|
601 |
try { |
|
602 |
BufferedReader reader = new BufferedReader(new FileReader(file)); |
|
603 |
while ((line = reader.readLine()) != null) { |
|
604 |
if(line.startsWith("EOF")) |
|
605 |
break; |
|
606 |
|
|
607 |
if(onlyFirst){ |
|
608 |
if(!this.hasMetadata() || !line.matches("^"+getMetadataToken()+"(.*)$")){ |
|
609 |
//text = line; |
|
610 |
break; |
|
611 |
} |
|
612 |
}else{ |
|
613 |
|
|
614 |
if(!this.hasMetadata() || !line.matches("^"+getMetadataToken()+"(.*)$")){ |
|
615 |
String[] fields = null; |
|
616 |
fields = line.trim().replaceAll("[ ]+", " ").split(getFieldDelimiter()); |
|
617 |
if(fields != null){ |
|
618 |
objects.add(createDynObject(fields)); |
|
619 |
} |
|
620 |
} |
|
621 |
|
|
622 |
} |
|
623 |
} |
|
624 |
reader.close(); |
|
625 |
}catch (Exception e) { |
|
626 |
e.printStackTrace(); |
|
627 |
} |
|
628 |
|
|
629 |
|
|
630 |
// |
|
631 |
// // Fase 1a: Separar las Features |
|
632 |
// String[] features = null; |
|
633 |
// if(hasStartEndDelimiters()){ |
|
634 |
// Pattern delimiter = Pattern.compile(".*"+ // Ignora lo que haya antes |
|
635 |
// getStartDelimiter()+ // Inicio contenido feature |
|
636 |
// "\\s*([^" + getEndDelimiter() + "]*)\\s*"+ // Hasta el primer final (no permite anidados) |
|
637 |
// getEndDelimiter()+ // Final de la Feauture |
|
638 |
// ".*"); // Ignora el resto |
|
639 |
// |
|
640 |
// List<String> tagValues = new ArrayList<String>(); |
|
641 |
// Matcher matcher = delimiter.matcher(text); |
|
642 |
// while (matcher.find()) { |
|
643 |
// tagValues.add(matcher.group(1)); |
|
644 |
// } |
|
645 |
// |
|
646 |
// features = new String[tagValues.size()]; |
|
647 |
// features = tagValues.toArray(features); |
|
648 |
// }else{ |
|
649 |
// features = text.split(getEndDelimiter()); |
|
650 |
// } |
|
651 |
// |
|
652 |
// // Fase 1b: Obtener los fields de cada feature |
|
653 |
// boolean firstTime = true; |
|
654 |
// for(int i=0; i<features.length; i++){ |
|
655 |
// //Map<String,Object> auxFields = new HashMap<String,Object>(); |
|
656 |
// |
|
657 |
// // Si tiene cabecera, la primera iteraci?n es la definici?n |
|
658 |
// if(hasHeader() && i==0){ |
|
659 |
// i++; |
|
660 |
// } |
|
661 |
// |
|
662 |
// String[] fields = features[i].trim().replaceAll("[ ]+", " ").split(getFieldDelimiter()); |
|
663 |
// for(int j=0; j<fields.length; j++){ |
|
664 |
// if(hasHeader()){ |
|
665 |
// String[] headerFields = features[0].split(getFieldDelimiter()); |
|
666 |
// if(headerFields.length == fields.length){ |
|
667 |
// String fieldName = headerFields[j]; |
|
668 |
// if(hasHeaderTokenRepited() && getHeaderToken() != null){ |
|
669 |
// fieldName = fieldName.replace(getHeaderToken(), ""); |
|
670 |
// } |
|
671 |
// auxFields.put(fieldName, fields[j]); |
|
672 |
// addFieldDefinition(fieldName, DataTypes.STRING); |
|
673 |
// } |
|
674 |
// }else{ |
|
675 |
// if(hasFieldName()){ |
|
676 |
// String[] aux = fields[j].split(getFieldNameSeparator()); |
|
677 |
// if(aux.length==2){ |
|
678 |
// auxFields.put(aux[0], aux[1]); |
|
679 |
// addFieldDefinition(aux[0], DataTypes.STRING); |
|
680 |
// } |
|
681 |
// }else{ |
|
682 |
// auxFields.put("blank-field-name-"+this.blankFieldCount, fields[j]); |
|
683 |
// if(firstTime){ |
|
684 |
// addFieldDefinition("blank-field-name-"+this.blankFieldCount, DataTypes.STRING); |
|
685 |
// } |
|
686 |
// this.blankFieldCount++; |
|
687 |
// } |
|
688 |
// } |
|
689 |
// } |
|
690 |
// |
|
691 |
// auxFeatures.add(auxFields); |
|
692 |
// this.blankFieldCount=1; |
|
693 |
// firstTime = false; |
|
694 |
// } |
|
695 |
|
|
696 |
|
|
697 |
this.setData(objects); |
|
698 |
|
|
699 |
} |
|
700 |
|
|
701 |
protected DynObject createDynObject(String[] fields){ |
|
702 |
DynObject dynObject = dynManager.createDynObject(getDataStruct()); |
|
703 |
for(int j=0; j<fields.length; j++){ |
|
704 |
FieldDefinition fdef = getFieldDefinitions().get(j); |
|
705 |
dynObject.setDynValue(fdef.getName(), fields[j]); |
|
706 |
} |
|
707 |
return dynObject; |
|
708 |
} |
|
709 |
|
|
710 |
public List<String> getExtensionSupported() { |
|
711 |
return availableExtensions; |
|
712 |
} |
|
713 |
|
|
714 |
public IProjection getProjection() { |
|
715 |
if(this.projection == null){ |
|
716 |
return getDefaultProjection(); |
|
717 |
} |
|
718 |
return this.projection; |
|
719 |
} |
|
720 |
|
|
721 |
public void setProjection(IProjection proj){ |
|
722 |
this.projection = proj; |
|
723 |
} |
|
724 |
|
|
725 |
|
|
726 |
protected IProjection getDefaultProjection() { |
|
727 |
return defaultProjection; |
|
728 |
} |
|
729 |
|
|
730 |
public List<DynObject> getData() { |
|
731 |
if(data == null){ |
|
732 |
data = this.parseFile(file, getDataStruct()); |
|
733 |
} |
|
734 |
return data; |
|
735 |
} |
|
736 |
|
|
737 |
public void setData(List<DynObject> data) { |
|
738 |
this.data = data; |
|
739 |
} |
|
740 |
|
|
741 |
protected String getGeographicField(String original){ |
|
742 |
return original.replace(" ", "0"); |
|
743 |
} |
|
744 |
|
|
745 |
|
|
746 |
public void setProjectId(String projectId) { |
|
747 |
this.projectid = projectId; |
|
748 |
} |
|
749 |
|
|
750 |
public void setProjectName(String projectName) { |
|
751 |
this.projectName = projectName; |
|
752 |
} |
|
753 |
|
|
754 |
public void setProjectYear(String projectYear) { |
|
755 |
this.projectYear = projectYear; |
|
756 |
} |
|
757 |
|
|
758 |
public void setEstado(String estado) { |
|
759 |
this.estado = estado; |
|
760 |
} |
|
761 |
|
|
762 |
public abstract Parser clone(); |
|
763 |
|
|
764 |
} |
|
0 | 765 |
org.gvsig.seismic/tags/org.gvsig.seismic-1.0.242/org.gvsig.seismic/org.gvsig.seismic.lib/org.gvsig.seismic.lib.impl/src/main/java/org/gvsig/seismic/impl/DefaultSeismicLibrary.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.seismic.impl; |
|
23 |
|
|
24 |
|
|
25 |
import org.gvsig.seismic.SeismicLibrary; |
|
26 |
import org.gvsig.seismic.SeismicLocator; |
|
27 |
import org.gvsig.seismic.SeismicManager; |
|
28 |
import org.gvsig.seismic.impl.parser.CADParser; |
|
29 |
import org.gvsig.seismic.impl.parser.GEOGParser; |
|
30 |
import org.gvsig.seismic.impl.parser.H19Parser; |
|
31 |
import org.gvsig.seismic.impl.parser.P190Parser; |
|
32 |
import org.gvsig.seismic.impl.parser.PTOParser; |
|
33 |
import org.gvsig.seismic.impl.parser.R06Parser; |
|
34 |
import org.gvsig.seismic.impl.parser.RPSParser; |
|
35 |
import org.gvsig.seismic.impl.parser.UKOOA84Parser; |
|
36 |
import org.gvsig.tools.library.AbstractLibrary; |
|
37 |
import org.gvsig.tools.library.LibraryException; |
|
38 |
import org.gvsig.tools.util.Caller; |
|
39 |
import org.gvsig.tools.util.impl.DefaultCaller; |
|
40 |
|
|
41 |
/** |
|
42 |
* Library for default implementation initialization and configuration. |
|
43 |
* This default implementation will be based in JFreeChart library. |
|
44 |
* |
|
45 |
* @author gvSIG team |
|
46 |
* @version $Id$ |
Also available in: Unified diff