svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / colortable / ui / ColorTablePanel.java @ 12416
History | View | Annotate | Download (6.55 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*/
|
19 |
package org.gvsig.rastertools.colortable.ui; |
20 |
|
21 |
import java.awt.BorderLayout; |
22 |
import java.awt.Dimension; |
23 |
|
24 |
import javax.swing.JPanel; |
25 |
import javax.swing.JScrollPane; |
26 |
import javax.swing.JTabbedPane; |
27 |
|
28 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
29 |
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel; |
30 |
import org.gvsig.gui.beans.graphic.listview.ListViewComponent; |
31 |
import org.gvsig.gui.beans.graphic.listview.ListViewItem; |
32 |
import org.gvsig.gui.beans.graphic.listview.RampPainter; |
33 |
import org.gvsig.gui.beans.imagenavigator.ImageNavigator; |
34 |
import org.gvsig.rastertools.colortable.ColorTableListener; |
35 |
import org.gvsig.rastertools.colortable.panels.ColorTInterpolated; |
36 |
import org.gvsig.rastertools.colortable.panels.ColorTTable; |
37 |
|
38 |
import com.iver.andami.PluginServices; |
39 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
40 |
/**
|
41 |
* ColorTablePanel es el panel donde se gestionara todo el comportamiento de las
|
42 |
* tablas de color.
|
43 |
*
|
44 |
* @version 26/06/2007
|
45 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
46 |
*/
|
47 |
public class ColorTablePanel extends DefaultButtonsPanel { |
48 |
private static final long serialVersionUID = 6028780107787443656L; |
49 |
|
50 |
private ImageNavigator imageNavigator = null; |
51 |
private ColorTableListener colorTableListener = null; |
52 |
private JTabbedPane jTabbedPane1 = null; |
53 |
private JPanel jPreview = null; |
54 |
private ColorTTable colorTTable = null; |
55 |
private ColorTInterpolated colorTInterpolated = null; |
56 |
private ListViewComponent listViewComponent = null; |
57 |
|
58 |
/**
|
59 |
* Construir un nuevo ColorTablePanel
|
60 |
*/
|
61 |
public ColorTablePanel() {
|
62 |
super(ButtonsPanel.BUTTONS_NONE);
|
63 |
getButtonsPanel().addSave(); |
64 |
getButtonsPanel().addButton("Guardar como", ButtonsPanel.BUTTON_LAST + 1); |
65 |
getButtonsPanel().addButton("Guardar como predeterminado", ButtonsPanel.BUTTON_LAST + 2); |
66 |
getButtonsPanel().addAccept(); |
67 |
getButtonsPanel().addApply(); |
68 |
getButtonsPanel().addCancel(); |
69 |
initialize(); |
70 |
} |
71 |
|
72 |
private void initialize() { |
73 |
setLayout(new BorderLayout(8, 8)); |
74 |
|
75 |
add(getJTabbedPane(), BorderLayout.CENTER);
|
76 |
add(getPPreview(), BorderLayout.EAST);
|
77 |
} |
78 |
|
79 |
private JTabbedPane getJTabbedPane() { |
80 |
if (jTabbedPane1 == null) { |
81 |
jTabbedPane1 = new javax.swing.JTabbedPane();
|
82 |
|
83 |
jTabbedPane1.addTab("Tabla", getColorTTable());
|
84 |
jTabbedPane1.addTab("Rampa", getColorTInterpolated());
|
85 |
|
86 |
} |
87 |
return jTabbedPane1;
|
88 |
} |
89 |
|
90 |
private ColorTTable getColorTTable() {
|
91 |
if (colorTTable == null) { |
92 |
colorTTable = new ColorTTable();
|
93 |
} |
94 |
return colorTTable;
|
95 |
} |
96 |
|
97 |
private ColorTInterpolated getColorTInterpolated() {
|
98 |
if (colorTInterpolated == null) { |
99 |
colorTInterpolated = new ColorTInterpolated();
|
100 |
} |
101 |
return colorTInterpolated;
|
102 |
} |
103 |
|
104 |
/**
|
105 |
* Devuelve el componente para la vista previa
|
106 |
* @return
|
107 |
*/
|
108 |
private ImageNavigator getImageNavigator() {
|
109 |
if (imageNavigator == null) { |
110 |
imageNavigator = new ImageNavigator(getColorTableListener());
|
111 |
imageNavigator.setFocusable(true);
|
112 |
imageNavigator.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
|
113 |
} |
114 |
return imageNavigator;
|
115 |
} |
116 |
|
117 |
/**
|
118 |
* Devuelve el panel donde estar? el widget de preview
|
119 |
* @return
|
120 |
*/
|
121 |
private JPanel getPPreview() { |
122 |
if (jPreview == null) { |
123 |
jPreview = new JPanel(); |
124 |
JPanel jsubpanel = new JPanel(); |
125 |
JPanel jsubpanel2 = new JPanel(); |
126 |
jsubpanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "vista_previa"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
127 |
jsubpanel.setLayout(new BorderLayout()); |
128 |
jsubpanel2.setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
129 |
jsubpanel2.setLayout(new BorderLayout()); |
130 |
|
131 |
jsubpanel.setPreferredSize(new Dimension(192, 192)); |
132 |
jsubpanel.setMinimumSize(new Dimension(192, 192)); |
133 |
jsubpanel.setMaximumSize(new Dimension(192, 192)); |
134 |
|
135 |
jsubpanel2.add(getImageNavigator(), BorderLayout.CENTER);
|
136 |
jsubpanel.add(jsubpanel2, BorderLayout.CENTER);
|
137 |
|
138 |
jPreview.setLayout(new BorderLayout(8, 8)); |
139 |
jPreview.add(jsubpanel, BorderLayout.NORTH);
|
140 |
|
141 |
JPanel jsubpanel3 = new JPanel(); |
142 |
JPanel jsubpanel4 = new JPanel(); |
143 |
jsubpanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "libreria"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
144 |
jsubpanel3.setLayout(new BorderLayout()); |
145 |
jsubpanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(8, 8, 8, 8)); |
146 |
jsubpanel4.setLayout(new BorderLayout()); |
147 |
|
148 |
JScrollPane jScrollPane = new JScrollPane(); |
149 |
jScrollPane.setViewportView(getListViewComponent()); |
150 |
|
151 |
for (int i=0; i<7; i++) { |
152 |
ListViewItem item = new ListViewItem(new RampPainter(), "Prueba " + i); |
153 |
getListViewComponent().addItem(item); |
154 |
} |
155 |
|
156 |
jsubpanel4.add(jScrollPane, BorderLayout.CENTER);
|
157 |
jsubpanel3.add(jsubpanel4, BorderLayout.CENTER);
|
158 |
|
159 |
jsubpanel3.setPreferredSize(new Dimension(192, 192)); |
160 |
jsubpanel3.setMinimumSize(new Dimension(192, 192)); |
161 |
jsubpanel3.setMaximumSize(new Dimension(192, 192)); |
162 |
|
163 |
jPreview.add(jsubpanel3, BorderLayout.CENTER);
|
164 |
} |
165 |
return jPreview;
|
166 |
} |
167 |
|
168 |
/**
|
169 |
* Obtener el componente que hara la carga pesada de los listeners
|
170 |
* @return
|
171 |
*/
|
172 |
private ColorTableListener getColorTableListener() {
|
173 |
if (colorTableListener == null) { |
174 |
colorTableListener = new ColorTableListener();
|
175 |
} |
176 |
return colorTableListener;
|
177 |
} |
178 |
|
179 |
/**
|
180 |
* Especificar el layer para el recorte
|
181 |
* @param layer
|
182 |
*/
|
183 |
public void setLayer(FLayer layer) { |
184 |
} |
185 |
|
186 |
/**
|
187 |
* Especificar el layer para el recorte
|
188 |
* @param layer
|
189 |
*/
|
190 |
public FLayer getLayer() {
|
191 |
return null; |
192 |
} |
193 |
|
194 |
public ListViewComponent getListViewComponent() {
|
195 |
if (listViewComponent == null) { |
196 |
listViewComponent = new ListViewComponent();
|
197 |
} |
198 |
return listViewComponent;
|
199 |
} |
200 |
} |