svn-gvsig-desktop / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / demo / ImageFrame.java @ 263
History | View | Annotate | Download (2.33 KB)
1 |
package com.iver.cit.gvsig.fmap.demo; |
---|---|
2 |
|
3 |
import java.io.File; |
4 |
|
5 |
import javax.swing.JFrame; |
6 |
import javax.swing.JPanel; |
7 |
|
8 |
import com.iver.cit.gvsig.fmap.NewMapControl; |
9 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
10 |
import com.iver.cit.gvsig.fmap.drivers.shp.DemoSHPDriver; |
11 |
import com.iver.cit.gvsig.fmap.layers.ChildrenNotAllowedException; |
12 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
13 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
14 |
import com.iver.cit.gvsig.fmap.layers.LayerPath; |
15 |
import com.iver.cit.gvsig.fmap.layers.ProjectionMismatchException; |
16 |
import com.iver.cit.gvsig.fmap.tools.ZoomMasMapTool; |
17 |
public class ImageFrame extends JFrame { |
18 |
|
19 |
private javax.swing.JPanel jContentPane = null; |
20 |
|
21 |
/**
|
22 |
* This is the default constructor
|
23 |
*/
|
24 |
public ImageFrame() {
|
25 |
super();
|
26 |
initialize(); |
27 |
} |
28 |
/**
|
29 |
* This method initializes this
|
30 |
*
|
31 |
* @return void
|
32 |
*/
|
33 |
private void initialize() { |
34 |
this.setSize(300,200); |
35 |
this.setContentPane(getJContentPane());
|
36 |
this.setTitle("JFrame"); |
37 |
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
38 |
} |
39 |
/**
|
40 |
* This method initializes jContentPane
|
41 |
*
|
42 |
* @return javax.swing.JPanel
|
43 |
*/
|
44 |
private javax.swing.JPanel getJContentPane() {
|
45 |
if(jContentPane == null) { |
46 |
jContentPane = new javax.swing.JPanel();
|
47 |
jContentPane.setLayout(new java.awt.BorderLayout());
|
48 |
jContentPane.add(getJPanel(), java.awt.BorderLayout.CENTER); |
49 |
} |
50 |
return jContentPane;
|
51 |
} |
52 |
|
53 |
private NewMapControl jPanel = null; |
54 |
/**
|
55 |
* This method initializes jPanel
|
56 |
*
|
57 |
* @return javax.swing.JPanel
|
58 |
*/
|
59 |
private NewMapControl getJPanel() {
|
60 |
if (jPanel == null) { |
61 |
try {
|
62 |
jPanel = new NewMapControl();
|
63 |
DemoSHPDriver driver = new DemoSHPDriver();
|
64 |
FLyrVect l = LayerFactory.createLayer(driver, new File("d:/fjp/chiara/plano/vias.shp"), null); |
65 |
try {
|
66 |
jPanel.getMapContext().getLayers().addLayer(new LayerPath(), l);
|
67 |
l.getSource().start(); |
68 |
jPanel.getMapContext().getViewPort().setExtent(l.getFullExtent()); |
69 |
l.getSource().stop(); |
70 |
jPanel.addMapTool("rectangulo", new ZoomMasMapTool()); |
71 |
jPanel.addTool("zoomMas", "rectangulo"); |
72 |
jPanel.setTool("zoomMas");
|
73 |
} catch (ProjectionMismatchException e) {
|
74 |
e.printStackTrace(); |
75 |
} catch (ChildrenNotAllowedException e) {
|
76 |
e.printStackTrace(); |
77 |
} |
78 |
|
79 |
|
80 |
} catch (DriverIOException e) {
|
81 |
e.printStackTrace(); |
82 |
} |
83 |
} |
84 |
return jPanel;
|
85 |
} |
86 |
} |