svn-gvsig-desktop / branches / v2_0_0_prep / libraries / org.gvsig.symbology / org.gvsig.symbology.main / src / main / java / org / gvsig / symbology / main / Main.java @ 34291
History | View | Annotate | Download (3.85 KB)
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.symbology.main; |
23 |
|
24 |
import java.awt.BorderLayout; |
25 |
import java.awt.Dimension; |
26 |
import java.awt.event.ActionEvent; |
27 |
|
28 |
import javax.swing.AbstractAction; |
29 |
import javax.swing.Action; |
30 |
import javax.swing.JButton; |
31 |
import javax.swing.JFrame; |
32 |
import javax.swing.JMenu; |
33 |
import javax.swing.JMenuBar; |
34 |
import javax.swing.JMenuItem; |
35 |
import javax.swing.JToolBar; |
36 |
import javax.swing.WindowConstants; |
37 |
|
38 |
import org.gvsig.symbology.SymbologyLocator; |
39 |
import org.gvsig.symbology.SymbologyManager; |
40 |
import org.gvsig.symbology.swing.SymbologySwingLocator; |
41 |
import org.gvsig.symbology.swing.SymbologySwingManager; |
42 |
import org.gvsig.tools.library.impl.DefaultLibrariesInitializer; |
43 |
import org.slf4j.Logger; |
44 |
import org.slf4j.LoggerFactory; |
45 |
|
46 |
/**
|
47 |
* Main executable class for testing the Symbology library.
|
48 |
*
|
49 |
* @author gvSIG Team
|
50 |
* @version $Id$
|
51 |
*/
|
52 |
public class Main { |
53 |
|
54 |
private static final Logger LOG = LoggerFactory.getLogger(Main.class); |
55 |
|
56 |
private SymbologyManager manager;
|
57 |
private SymbologySwingManager swingManager;
|
58 |
|
59 |
public static void main(String args[]) { |
60 |
new DefaultLibrariesInitializer().fullInitialize();
|
61 |
Main main = new Main();
|
62 |
main.show(); |
63 |
} |
64 |
|
65 |
@SuppressWarnings("serial") |
66 |
public void show() { |
67 |
manager = SymbologyLocator.getSymbologyManager(); |
68 |
swingManager = SymbologySwingLocator.getSwingManager(); |
69 |
|
70 |
Action showCookie = new AbstractAction("Get a Symbology") { |
71 |
|
72 |
public void actionPerformed(ActionEvent e) { |
73 |
showSymbology(manager); |
74 |
} |
75 |
}; |
76 |
|
77 |
Action exit = new AbstractAction("Exit") { |
78 |
|
79 |
public void actionPerformed(ActionEvent e) { |
80 |
System.exit(0); |
81 |
} |
82 |
}; |
83 |
|
84 |
JFrame frame = new JFrame("Symbology example app"); |
85 |
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
86 |
|
87 |
// Create the menu bar.
|
88 |
JMenuBar menuBar = new JMenuBar(); |
89 |
|
90 |
// Build the menu.
|
91 |
JMenu menuFile = new JMenu("File"); |
92 |
menuFile.add(new JMenuItem(showCookie)); |
93 |
menuFile.add(new JMenuItem(exit)); |
94 |
|
95 |
menuBar.add(menuFile); |
96 |
|
97 |
JToolBar toolBar = new JToolBar(); |
98 |
toolBar.add(new JButton(showCookie)); |
99 |
toolBar.add(new JButton(exit)); |
100 |
|
101 |
frame.setPreferredSize(new Dimension(200, 100)); |
102 |
frame.setJMenuBar(menuBar); |
103 |
frame.add(toolBar, BorderLayout.PAGE_START);
|
104 |
|
105 |
// Display the window.
|
106 |
frame.pack(); |
107 |
frame.setVisible(true);
|
108 |
} |
109 |
|
110 |
public void showSymbology(SymbologyManager manager) { |
111 |
// try {
|
112 |
// SymbologyService service =
|
113 |
// (SymbologyService) manager.getSymbologyService();
|
114 |
// JSymbologyServicePanel panel =
|
115 |
// swingManager.createSymbology(service);
|
116 |
// swingManager.getWindowManager().showWindow(panel, "Symbology",
|
117 |
// SymbologyWindowManager.MODE_WINDOW);
|
118 |
//
|
119 |
// } catch (ServiceException e) {
|
120 |
// LOG.error("Error showing a Symbology", e);
|
121 |
// }
|
122 |
} |
123 |
|
124 |
} |