gvsig-raster / org.gvsig.raster.wmts / trunk / org.gvsig.raster.wmts / org.gvsig.raster.wmts.swing / org.gvsig.raster.wmts.swing.impl / src / main / java / org / gvsig / raster / wmts / swing / impl / panel / layer / LayersSelectedPanel.java @ 2613
History | View | Annotate | Download (5.11 KB)
1 | 2607 | nbrodin | /* 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.raster.wmts.swing.impl.panel.layer; |
||
23 | |||
24 | import java.awt.Dimension; |
||
25 | import java.awt.GridBagConstraints; |
||
26 | import java.awt.GridBagLayout; |
||
27 | |||
28 | import javax.swing.ImageIcon; |
||
29 | import javax.swing.JButton; |
||
30 | import javax.swing.JPanel; |
||
31 | import javax.swing.JScrollPane; |
||
32 | |||
33 | import org.gvsig.andami.IconThemeHelper; |
||
34 | import org.gvsig.gui.beans.controls.dnd.JDnDListModel; |
||
35 | 2613 | nbrodin | import org.gvsig.i18n.Messages; |
36 | 2607 | nbrodin | |
37 | /**
|
||
38 | * Layer list panel
|
||
39 | *
|
||
40 | * @author Nacho Brodin (nachobrodin@gmail.com)
|
||
41 | */
|
||
42 | public class LayersSelectedPanel extends JPanel { |
||
43 | private static final long serialVersionUID = 1L; |
||
44 | private JButton btnUp = null; |
||
45 | private JButton btnDown = null; |
||
46 | private LayerList lstSelectedLayers = null; |
||
47 | private JPanel jPanelControlLayers = null; |
||
48 | private JScrollPane jScrollPanel = null; |
||
49 | private String pathToImagesForTest = "/src/main/resources/images/"; |
||
50 | |||
51 | public LayersSelectedPanel() {
|
||
52 | init(); |
||
53 | } |
||
54 | |||
55 | public void init() { |
||
56 | setLayout(new GridBagLayout()); |
||
57 | |||
58 | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
||
59 | //gridBagConstraints1.fill = GridBagConstraints.BOTH;
|
||
60 | gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
|
||
61 | gridBagConstraints1.weightx = 1.0;
|
||
62 | //gridBagConstraints1.weighty = 1.0;
|
||
63 | gridBagConstraints1.insets = new java.awt.Insets(2, 0, 2, 0); |
||
64 | add(getJScrollPane(), gridBagConstraints1); |
||
65 | |||
66 | //Esto solo si es una lista
|
||
67 | |||
68 | /*gridBagConstraints1.fill = GridBagConstraints.VERTICAL;
|
||
69 | gridBagConstraints1.gridx = 1;
|
||
70 | gridBagConstraints1.weightx = 0.0;
|
||
71 | add(getJPanelControlLayers(), gridBagConstraints1);*/
|
||
72 | } |
||
73 | |||
74 | /**
|
||
75 | * This method initializes jScrollPane5
|
||
76 | *
|
||
77 | * @return ScrollPane
|
||
78 | */
|
||
79 | private JScrollPane getJScrollPane() { |
||
80 | if (jScrollPanel == null) { |
||
81 | jScrollPanel = new JScrollPane(); |
||
82 | jScrollPanel.setViewportView(getLstSelectedLayers()); |
||
83 | jScrollPanel.setPreferredSize(new java.awt.Dimension(205, 32)); |
||
84 | } |
||
85 | return jScrollPanel;
|
||
86 | } |
||
87 | |||
88 | /**
|
||
89 | * This method initializes lstSelectedLayers
|
||
90 | * @return List
|
||
91 | */
|
||
92 | public LayerList getLstSelectedLayers() {
|
||
93 | if (lstSelectedLayers == null) { |
||
94 | lstSelectedLayers = new LayerList();
|
||
95 | lstSelectedLayers.setModel(new JDnDListModel());
|
||
96 | lstSelectedLayers.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
||
97 | } |
||
98 | return lstSelectedLayers;
|
||
99 | } |
||
100 | |||
101 | /**
|
||
102 | * This method initializes jPanel2
|
||
103 | * @return Panel
|
||
104 | */
|
||
105 | @SuppressWarnings("unused") |
||
106 | private JPanel getJPanelControlLayers() { |
||
107 | if (jPanelControlLayers == null) { |
||
108 | jPanelControlLayers = new JPanel(); |
||
109 | jPanelControlLayers.setLayout(new GridBagLayout()); |
||
110 | |||
111 | GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
||
112 | gridBagConstraints1.fill = GridBagConstraints.VERTICAL;
|
||
113 | gridBagConstraints1.anchor = GridBagConstraints.CENTER;
|
||
114 | gridBagConstraints1.weighty = 0.0;
|
||
115 | gridBagConstraints1.insets = new java.awt.Insets(2, 2, 2, 2); |
||
116 | |||
117 | jPanelControlLayers.add(getBtnUp(), gridBagConstraints1); |
||
118 | |||
119 | gridBagConstraints1.gridy = 1;
|
||
120 | jPanelControlLayers.add(getBtnDown(), gridBagConstraints1); |
||
121 | } |
||
122 | return jPanelControlLayers;
|
||
123 | } |
||
124 | |||
125 | /**
|
||
126 | * This method initializes btnUp
|
||
127 | * @return Button
|
||
128 | */
|
||
129 | public JButton getBtnUp() { |
||
130 | if (btnUp == null) { |
||
131 | btnUp = new JButton(); |
||
132 | btnUp.setPreferredSize(new Dimension(30, 30)); |
||
133 | 2613 | nbrodin | btnUp.setToolTipText(Messages.getText("move_layer_up"));
|
134 | 2607 | nbrodin | btnUp.setIcon(loadIcon("aplication-preferences-uparrow"));
|
135 | } |
||
136 | return btnUp;
|
||
137 | } |
||
138 | |||
139 | /**
|
||
140 | * This method initializes btnDown
|
||
141 | * @return Button
|
||
142 | */
|
||
143 | public JButton getBtnDown() { |
||
144 | if (btnDown == null) { |
||
145 | btnDown = new JButton(); |
||
146 | btnDown.setPreferredSize(new Dimension(30, 30)); |
||
147 | 2613 | nbrodin | btnDown.setToolTipText(Messages.getText("move_layer_down"));
|
148 | 2607 | nbrodin | btnDown.setIcon(loadIcon("aplication-preferences-downarrow"));
|
149 | } |
||
150 | return btnDown;
|
||
151 | } |
||
152 | |||
153 | private ImageIcon loadIcon(String iconName) { |
||
154 | ImageIcon icon = null; |
||
155 | try {
|
||
156 | icon = IconThemeHelper.getImageIcon(iconName); |
||
157 | } catch(NullPointerException e) {} |
||
158 | if(icon == null) |
||
159 | icon = new ImageIcon(System.getProperty("user.dir") + pathToImagesForTest + iconName + ".png", ""); |
||
160 | if(icon == null) |
||
161 | icon = new ImageIcon(System.getProperty("user.dir") + pathToImagesForTest + iconName + ".gif", ""); |
||
162 | return icon;
|
||
163 | } |
||
164 | |||
165 | } |