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