Revision 14169 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SymbolLevelsWindow.java
SymbolLevelsWindow.java | ||
---|---|---|
1 |
///* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
// * |
|
3 |
// * Copyright (C) 2005 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 |
// * For more information, contact: |
|
20 |
// * |
|
21 |
// * Generalitat Valenciana |
|
22 |
// * Conselleria d'Infraestructures i Transport |
|
23 |
// * Av. Blasco Ib??ez, 50 |
|
24 |
// * 46010 VALENCIA |
|
25 |
// * SPAIN |
|
26 |
// * |
|
27 |
// * +34 963862235 |
|
28 |
// * gvsig@gva.es |
|
29 |
// * www.gvsig.gva.es |
|
30 |
// * |
|
31 |
// * or |
|
32 |
// * |
|
33 |
// * IVER T.I. S.A |
|
34 |
// * Salamanca 50 |
|
35 |
// * 46005 Valencia |
|
36 |
// * Spain |
|
37 |
// * |
|
38 |
// * +34 963163400 |
|
39 |
// * dac@iver.es |
|
40 |
// */ |
|
41 |
//package com.iver.cit.gvsig.gui.styling; |
|
42 |
// |
|
43 |
//import java.awt.BorderLayout; |
|
44 |
//import java.awt.FlowLayout; |
|
45 |
//import java.awt.event.ActionEvent; |
|
46 |
//import java.awt.event.ActionListener; |
|
47 |
//import java.util.Hashtable; |
|
48 |
//import java.util.Iterator; |
|
49 |
// |
|
50 |
//import javax.swing.BorderFactory; |
|
51 |
//import javax.swing.BoxLayout; |
|
52 |
//import javax.swing.ImageIcon; |
|
53 |
//import javax.swing.JButton; |
|
54 |
//import javax.swing.JCheckBox; |
|
55 |
//import javax.swing.JComponent; |
|
56 |
//import javax.swing.JPanel; |
|
57 |
//import javax.swing.JScrollPane; |
|
58 |
//import javax.swing.JTable; |
|
59 |
//import javax.swing.border.EtchedBorder; |
|
60 |
//import javax.swing.table.DefaultTableModel; |
|
61 |
//import javax.swing.table.TableColumn; |
|
62 |
//import javax.swing.table.TableModel; |
|
63 |
// |
|
64 |
//import org.gvsig.gui.beans.AcceptCancelPanel; |
|
65 |
//import org.gvsig.gui.beans.swing.JBlank; |
|
66 |
//import org.gvsig.gui.beans.swing.celleditors.BooleanTableCellEditor; |
|
67 |
//import org.gvsig.gui.beans.swing.celleditors.IntegerTableCellEditor; |
|
68 |
//import org.gvsig.gui.beans.swing.cellrenderers.BooleanTableCellRenderer; |
|
69 |
//import org.gvsig.gui.beans.swing.cellrenderers.NumberTableCellRenderer; |
|
70 |
// |
|
71 |
//import com.iver.andami.PluginServices; |
|
72 |
//import com.iver.andami.ui.mdiManager.IWindow; |
|
73 |
//import com.iver.andami.ui.mdiManager.WindowInfo; |
|
74 |
//import com.iver.cit.gvsig.fmap.core.symbols.IMultiLayerSymbol; |
|
75 |
//import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
|
76 |
//import com.iver.cit.gvsig.fmap.rendering.ZSort; |
|
77 |
//import com.iver.cit.gvsig.project.documents.gui.TableSymbolCellRenderer; |
|
78 |
// |
|
79 |
///** |
|
80 |
// * Creates a panel to specify an order for the symbols of a map. This order |
|
81 |
// * is important when the map is going to be painted because, apart from that |
|
82 |
// * the waste of time can be less, the final representation of the map will |
|
83 |
// * depend on this order. |
|
84 |
// * |
|
85 |
// * |
|
86 |
// * @author jaume dominguez faus - jaume.dominguez@iver.es |
|
87 |
// */ |
|
88 |
//public class SymbolLevelsWindow extends JPanel implements IWindow, ActionListener { |
|
89 |
// private static final long serialVersionUID = 3241898997869313055L; |
|
90 |
// private static final int DESCRIPTION_COLUMN_INDEX = 1; |
|
91 |
// private static final int SYMBOL_COLUMN_INDEX = 0; |
|
92 |
// private static final int MERGE_COLUMN_INDEX = 3; |
|
93 |
// private static final int JOIN_COLUMN_INDEX = 2; |
|
94 |
// private static final int FIRST_LEVEL_COLUMN_INDEX = 2; |
|
95 |
// private static final String[] defaultHeaders = new String[] { |
|
96 |
// PluginServices.getText(SymbolLevelsWindow.class, "symbol"), |
|
97 |
// PluginServices.getText(SymbolLevelsWindow.class, "description"), |
|
98 |
// PluginServices.getText(SymbolLevelsWindow.class, "join"), |
|
99 |
// PluginServices.getText(SymbolLevelsWindow.class, "merge"), |
|
100 |
// }; |
|
101 |
// private static final int DEFAULT_VIEW = 0; |
|
102 |
// private static final int ADVANCED_VIEW = 1; |
|
103 |
// private static int viewMode; |
|
104 |
// private JCheckBox chkSpecifyDrawOrder = null; |
|
105 |
// private JPanel pnlCenter = null; |
|
106 |
// private JScrollPane srclLevels = null; |
|
107 |
// private JTable tblLevels = null; |
|
108 |
// private JButton btnUp = null; |
|
109 |
// private JButton btnDown; |
|
110 |
// private JPanel pnlSouth = null; |
|
111 |
// private String[] advancedHeaders; |
|
112 |
// private JButton btnSwitchView; |
|
113 |
// private ZSort zSort; |
|
114 |
// |
|
115 |
// private ActionListener action = new ActionListener() { |
|
116 |
// public void actionPerformed(ActionEvent e) { |
|
117 |
// String actionCommand = e.getActionCommand(); |
|
118 |
// if ("OK".equals(actionCommand)) { |
|
119 |
// applyValues(); |
|
120 |
// } |
|
121 |
// |
|
122 |
// PluginServices.getMDIManager().closeWindow(SymbolLevelsWindow.this); |
|
123 |
// |
|
124 |
// } |
|
125 |
// }; |
|
126 |
// |
|
127 |
// public WindowInfo getWindowInfo() { |
|
128 |
// WindowInfo wi = new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MODALDIALOG); |
|
129 |
// wi.setTitle(PluginServices.getText(this, "symbol_levels")); |
|
130 |
// wi.setWidth(getWidth()+10); |
|
131 |
// wi.setHeight(getHeight()); |
|
132 |
// return wi; |
|
133 |
// } |
|
134 |
// /** |
|
135 |
// * Completes the main table of the panel with the symbols contained in the |
|
136 |
// * legend of the map. |
|
137 |
// * |
|
138 |
// */ |
|
139 |
// private void applyValues() { |
|
140 |
// |
|
141 |
// // update symbol order |
|
142 |
// TableModel model = tblLevels.getModel(); |
|
143 |
// |
|
144 |
// |
|
145 |
// for (int i = 0; i < model.getRowCount(); i++) { |
|
146 |
// System.out.print("["+i+"]"); |
|
147 |
// for (int j = 0; j < model.getColumnCount(); j++) { |
|
148 |
// System.out.print(j+":"+model.getValueAt(i, j)+"\t\t"); |
|
149 |
// } |
|
150 |
// System.out.println(); |
|
151 |
// } |
|
152 |
// |
|
153 |
//// if (true) return; |
|
154 |
// |
|
155 |
// Hashtable<ISymbol, int[]> aTable = new Hashtable<ISymbol, int[]>(); |
|
156 |
// ISymbol[] symbols = new ISymbol[model.getRowCount()]; |
|
157 |
// for (int i = 0; i < symbols.length; i++) { |
|
158 |
// symbols[i] = (ISymbol) model.getValueAt(i, SYMBOL_COLUMN_INDEX); |
|
159 |
// int length = 1; |
|
160 |
// if (symbols[i] instanceof IMultiLayerSymbol) { |
|
161 |
// IMultiLayerSymbol mlSym = (IMultiLayerSymbol) symbols[i]; |
|
162 |
// length = mlSym.getLayerCount(); |
|
163 |
// } |
|
164 |
// |
|
165 |
// int[] symbolLevels = new int[length]; |
|
166 |
// if (viewMode == DEFAULT_VIEW) { |
|
167 |
// // default view (JOIN and MERGE) |
|
168 |
// if (symbols[i] instanceof IMultiLayerSymbol) { |
|
169 |
// boolean join = ((Boolean) model.getValueAt(i, JOIN_COLUMN_INDEX)).booleanValue(); |
|
170 |
// boolean merge= ((Boolean) model.getValueAt(i, MERGE_COLUMN_INDEX)).booleanValue(); |
|
171 |
// boolean needToJoin = true; |
|
172 |
// if (merge && i>0) { |
|
173 |
// int j=0; |
|
174 |
// try { |
|
175 |
// int[] prevSymbolLevels = aTable.get(symbols[i-1]); |
|
176 |
// for (j = 0; j < symbolLevels.length; j++) { |
|
177 |
// symbolLevels[j] = prevSymbolLevels[j]; |
|
178 |
// } |
|
179 |
// } catch (IndexOutOfBoundsException ex) { |
|
180 |
// /* perfect, no problem |
|
181 |
// * the previous symbol has different amount of layers |
|
182 |
// * that is ok because we just have to replicate |
|
183 |
// * the values of each cell |
|
184 |
// */ |
|
185 |
// for (; j < symbolLevels.length; j++) { |
|
186 |
// symbolLevels[j] = symbolLevels[j-1]+1; |
|
187 |
// } |
|
188 |
// } |
|
189 |
// needToJoin = false; |
|
190 |
// } |
|
191 |
// if (join && needToJoin) { |
|
192 |
// for (int j = 0; j < symbolLevels.length; j++) { |
|
193 |
// symbolLevels[j] = zSort.getLevelCount()+j+1; |
|
194 |
// } |
|
195 |
// } |
|
196 |
// if (!join && !merge) { |
|
197 |
// for (int j = 0; j < symbolLevels.length; j++) { |
|
198 |
// symbolLevels[j] = zSort.getLevelCount(); |
|
199 |
// } |
|
200 |
// } |
|
201 |
// } else { |
|
202 |
// symbolLevels[0] = zSort.getLevelCount(); |
|
203 |
// } |
|
204 |
// } else { |
|
205 |
// // ADVANCED VIEW (user may set map levels manually) |
|
206 |
// for (int j = 0; j < symbolLevels.length; j++) { |
|
207 |
// symbolLevels[j] = ((Integer) model.getValueAt(i, j+FIRST_LEVEL_COLUMN_INDEX)).intValue(); |
|
208 |
// } |
|
209 |
// } |
|
210 |
// |
|
211 |
// aTable.put(symbols[i], symbolLevels); |
|
212 |
// } |
|
213 |
// |
|
214 |
// Iterator<ISymbol> it = aTable.keySet().iterator(); |
|
215 |
// while (it.hasNext()) { |
|
216 |
// ISymbol sym = it.next(); |
|
217 |
// zSort.setLevels(sym, aTable.get(sym)); |
|
218 |
// } |
|
219 |
// |
|
220 |
// zSort.setUsingZSort(getChkSpecifyDrawOrder().isSelected()); |
|
221 |
// System.err.println(zSort); |
|
222 |
// } |
|
223 |
// |
|
224 |
// /** |
|
225 |
// * This is the default constructor |
|
226 |
// */ |
|
227 |
// public SymbolLevelsWindow(ZSort zSort) { |
|
228 |
// super(); |
|
229 |
// initialize(); |
|
230 |
// setModel(zSort); |
|
231 |
// tblLevels.setRowHeight(23); |
|
232 |
// } |
|
233 |
// /** |
|
234 |
// * Sets the model |
|
235 |
// * @param plan ZSort |
|
236 |
// */ |
|
237 |
// |
|
238 |
// public void setModel(ZSort plan) { |
|
239 |
// advancedHeaders = new String[FIRST_LEVEL_COLUMN_INDEX |
|
240 |
// +plan.getTopLevelIndexAllowed() ]; |
|
241 |
// advancedHeaders[SYMBOL_COLUMN_INDEX] = defaultHeaders[SYMBOL_COLUMN_INDEX]; |
|
242 |
// advancedHeaders[DESCRIPTION_COLUMN_INDEX] = defaultHeaders[DESCRIPTION_COLUMN_INDEX]; |
|
243 |
// for (int i = 2; i < advancedHeaders.length; i++) { |
|
244 |
// advancedHeaders[i] = String.valueOf(i-1); |
|
245 |
// } |
|
246 |
// this.zSort = plan; |
|
247 |
// initTableContents(getTblLevels(), plan, viewMode); |
|
248 |
// getChkSpecifyDrawOrder().setSelected(plan.isUsingZSort()); |
|
249 |
// } |
|
250 |
// /** |
|
251 |
// * Initializes the table that it is showed in the panel where the user can |
|
252 |
// * see the different symbols of the legend and has options to specify the |
|
253 |
// * level for each one, merge and so on. |
|
254 |
// * |
|
255 |
// * @param table |
|
256 |
// * @param zSort |
|
257 |
// * @param mode |
|
258 |
// */ |
|
259 |
// private void initTableContents(JTable table, ZSort zSort, int mode) { |
|
260 |
// System.out.println(zSort); |
|
261 |
// DefaultTableModel model = new DefaultTableModel(); |
|
262 |
// Object[][] dataVector = null; |
|
263 |
// ISymbol[] syms = zSort.getSymbols(); |
|
264 |
// String[] labels = zSort.getDescriptions(); |
|
265 |
// mode = ADVANCED_VIEW; |
|
266 |
// if (mode == DEFAULT_VIEW) { |
|
267 |
// // default view (JOIN and MERGE) |
|
268 |
// dataVector = new Object[syms.length][syms.length]; |
|
269 |
// for (int i = 0; i < syms.length; i++) { |
|
270 |
// dataVector[i] = new Object[defaultHeaders.length]; |
|
271 |
// dataVector[i][SYMBOL_COLUMN_INDEX] = syms[i]; |
|
272 |
// dataVector[i][DESCRIPTION_COLUMN_INDEX] = labels[i]; |
|
273 |
// if (syms[i] instanceof IMultiLayerSymbol) { |
|
274 |
// boolean joined = true; |
|
275 |
// IMultiLayerSymbol mlSymbol = (IMultiLayerSymbol) syms[i]; |
|
276 |
// // is joined if each layer belongs to distinct level |
|
277 |
// for (int j = 0; j < mlSymbol.getLayerCount(); j++) { |
|
278 |
// if (joined) |
|
279 |
// joined = zSort.getSymbolLevel(mlSymbol.getLayer(j)) != zSort.getSymbolLevel(mlSymbol.getLayer(j+1)); |
|
280 |
// } |
|
281 |
// |
|
282 |
// |
|
283 |
// boolean merged = true; |
|
284 |
// if (i<syms.length-1) { |
|
285 |
// for (int j = 0; joined && j < mlSymbol.getLayerCount(); j++) { |
|
286 |
// // must be joined to be merged |
|
287 |
// ISymbol nextSymbol = syms[i+1]; |
|
288 |
// if (nextSymbol instanceof IMultiLayerSymbol) { |
|
289 |
// IMultiLayerSymbol nextMLSymbol = (IMultiLayerSymbol) nextSymbol; |
|
290 |
// if (j<nextMLSymbol.getLayerCount()) { |
|
291 |
// merged = zSort.getSymbolLevel(mlSymbol.getLayer(j)) == zSort.getSymbolLevel(nextMLSymbol.getLayer(j)); |
|
292 |
// } |
|
293 |
// } else { |
|
294 |
// merged = zSort.getSymbolLevel(mlSymbol.getLayer(0)) == zSort.getSymbolLevel(nextSymbol); |
|
295 |
// } |
|
296 |
// } |
|
297 |
// if (!merged) |
|
298 |
// break; |
|
299 |
// } |
|
300 |
// if (!joined) merged = false; |
|
301 |
// dataVector[i][JOIN_COLUMN_INDEX] = new Boolean(joined); |
|
302 |
// dataVector[i][MERGE_COLUMN_INDEX] = new Boolean(merged); |
|
303 |
// } |
|
304 |
// } |
|
305 |
// |
|
306 |
// model.setDataVector(dataVector, defaultHeaders); |
|
307 |
// table.setModel(model); |
|
308 |
// TableColumn col = table.getColumnModel().getColumn(JOIN_COLUMN_INDEX); |
|
309 |
// col.setCellRenderer(new BooleanTableCellRenderer(true)); |
|
310 |
// col.setCellEditor(new BooleanTableCellEditor(table)); |
|
311 |
// col = table.getColumnModel().getColumn(MERGE_COLUMN_INDEX); |
|
312 |
// col.setCellRenderer(new BooleanTableCellRenderer(true)); |
|
313 |
// col.setCellEditor(new BooleanTableCellEditor(table)); |
|
314 |
// } else { |
|
315 |
// // advanced view (user may input the map level manually) |
|
316 |
// dataVector = new Object[syms.length][ |
|
317 |
// FIRST_LEVEL_COLUMN_INDEX + /* this is the first column that |
|
318 |
// * contains a level for the symbol |
|
319 |
// */ |
|
320 |
// |
|
321 |
// zSort.getTopLevelIndexAllowed() + /* according to the set of |
|
322 |
// * symbols this will get the |
|
323 |
// * max level reachable |
|
324 |
// */ |
|
325 |
// 1 /* plus 1 to get a count instead of an index */]; |
|
326 |
// for (int i = 0; i < syms.length; i++) { |
|
327 |
// dataVector[i][SYMBOL_COLUMN_INDEX] = syms[i]; |
|
328 |
// dataVector[i][DESCRIPTION_COLUMN_INDEX] = labels[i]; |
|
329 |
// if (syms[i] instanceof IMultiLayerSymbol) { |
|
330 |
// IMultiLayerSymbol mySym = (IMultiLayerSymbol) syms[i]; |
|
331 |
// for (int j = 0; j < mySym.getLayerCount(); j++) { |
|
332 |
// dataVector[i][j+FIRST_LEVEL_COLUMN_INDEX] = new Integer(zSort.getSymbolLevel(mySym.getLayer(i))); |
|
333 |
// } |
|
334 |
// } else { |
|
335 |
// dataVector[i][FIRST_LEVEL_COLUMN_INDEX] = new Integer(zSort.getSymbolLevel(syms[i])); |
|
336 |
// } |
|
337 |
// } |
|
338 |
// |
|
339 |
// model.setDataVector(dataVector, advancedHeaders); |
|
340 |
// table.setModel(model); |
|
341 |
// for (int j = FIRST_LEVEL_COLUMN_INDEX; j < model.getColumnCount(); j++) { |
|
342 |
// |
|
343 |
// table.getColumnModel().getColumn(j).setCellRenderer(new NumberTableCellRenderer(true, false)); |
|
344 |
// table.getColumnModel().getColumn(j).setCellEditor(new IntegerTableCellEditor()); |
|
345 |
// } |
|
346 |
// } |
|
347 |
// |
|
348 |
// TableSymbolCellRenderer symbolCellRenderer = new TableSymbolCellRenderer(true); |
|
349 |
// TableColumn col = table.getColumnModel().getColumn(SYMBOL_COLUMN_INDEX); |
|
350 |
// col.setCellRenderer(symbolCellRenderer); |
|
351 |
// |
|
352 |
// |
|
353 |
// } |
|
354 |
// |
|
355 |
// /** |
|
356 |
// * This method initializes this |
|
357 |
// * |
|
358 |
// * @return void |
|
359 |
// */ |
|
360 |
// private void initialize() { |
|
361 |
// this.setLayout(new BorderLayout(15, 15)); |
|
362 |
// this.setSize(564, 344); |
|
363 |
// |
|
364 |
// this.add(getChkSpecifyDrawOrder(), BorderLayout.NORTH); |
|
365 |
// this.add(new JBlank(20, 20)); |
|
366 |
// this.add(getPnlCenter(), BorderLayout.CENTER); |
|
367 |
// this.add(getPnlSouth(), BorderLayout.SOUTH); |
|
368 |
// } |
|
369 |
// |
|
370 |
// /** |
|
371 |
// * This method initializes chkSpecifyDrawOrder |
|
372 |
// * |
|
373 |
// * @return javax.swing.JCheckBox |
|
374 |
// */ |
|
375 |
// private JCheckBox getChkSpecifyDrawOrder() { |
|
376 |
// if (chkSpecifyDrawOrder == null) { |
|
377 |
// chkSpecifyDrawOrder = new JCheckBox( |
|
378 |
// PluginServices.getText(this, "draw_symbols_in_specified_order")); |
|
379 |
// chkSpecifyDrawOrder.addActionListener(this); |
|
380 |
// } |
|
381 |
// return chkSpecifyDrawOrder; |
|
382 |
// } |
|
383 |
// |
|
384 |
// /** |
|
385 |
// * This method initializes pnlCenter |
|
386 |
// * |
|
387 |
// * @return javax.swing.JPanel |
|
388 |
// */ |
|
389 |
// private JPanel getPnlCenter() { |
|
390 |
// if (pnlCenter == null) { |
|
391 |
// pnlCenter = new JPanel(); |
|
392 |
// pnlCenter.setLayout(new BorderLayout(0, 15)); |
|
393 |
// pnlCenter.add(getSrclLevels(), BorderLayout.CENTER); |
|
394 |
// pnlCenter.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); |
|
395 |
// JPanel aux = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 15)); |
|
396 |
// JPanel pnlButtons = new JPanel(); |
|
397 |
// pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.Y_AXIS)); |
|
398 |
// pnlButtons.add(new JBlank(1, 70)); |
|
399 |
// pnlButtons.add(getBtnUp()); |
|
400 |
// pnlButtons.add(new JBlank(1, 10)); |
|
401 |
// pnlButtons.add(getBtnDown()); |
|
402 |
// aux.add(pnlButtons); |
|
403 |
// pnlCenter.add(aux, BorderLayout.EAST); |
|
404 |
// |
|
405 |
// } |
|
406 |
// return pnlCenter; |
|
407 |
// } |
|
408 |
// |
|
409 |
// /** |
|
410 |
// * This method initializes srclLevels |
|
411 |
// * |
|
412 |
// * @return javax.swing.JScrollPane |
|
413 |
// */ |
|
414 |
// private JScrollPane getSrclLevels() { |
|
415 |
// if (srclLevels == null) { |
|
416 |
// srclLevels = new JScrollPane(); |
|
417 |
// srclLevels.setViewportView(getTblLevels()); |
|
418 |
// } |
|
419 |
// return srclLevels; |
|
420 |
// } |
|
421 |
// |
|
422 |
// /** |
|
423 |
// * This method initializes tblLevels |
|
424 |
// * |
|
425 |
// * @return javax.swing.JTable |
|
426 |
// */ |
|
427 |
// private JTable getTblLevels() { |
|
428 |
// if (tblLevels == null) { |
|
429 |
// tblLevels = new JTable(); |
|
430 |
// } |
|
431 |
// return tblLevels; |
|
432 |
// } |
|
433 |
// |
|
434 |
// /** |
|
435 |
// * This method initializes btnUp |
|
436 |
// * |
|
437 |
// * @return javax.swing.JButton |
|
438 |
// */ |
|
439 |
// private JButton getBtnUp() { |
|
440 |
// if (btnUp == null) { |
|
441 |
// btnUp = new JButton(new ImageIcon(getClass(). |
|
442 |
// getClassLoader().getResource("images/up-arrow.png"))); |
|
443 |
// btnUp.setActionCommand("MOVE_UP"); |
|
444 |
// } |
|
445 |
// return btnUp; |
|
446 |
// } |
|
447 |
// /** |
|
448 |
// * This method initializes btnDown |
|
449 |
// * |
|
450 |
// * @return javax.swing.JButton |
|
451 |
// */ |
|
452 |
// private JButton getBtnDown() { |
|
453 |
// if (btnDown == null) { |
|
454 |
// btnDown = new JButton(new ImageIcon(getClass(). |
|
455 |
// getClassLoader().getResource("images/down-arrow.png"))); |
|
456 |
// btnDown.setActionCommand("MOVE_DOWN"); |
|
457 |
// } |
|
458 |
// return btnDown; |
|
459 |
// } |
|
460 |
// |
|
461 |
// /** |
|
462 |
// * This method initializes pnlSouth |
|
463 |
// * |
|
464 |
// * @return javax.swing.JPanel |
|
465 |
// */ |
|
466 |
// private JPanel getPnlSouth() { |
|
467 |
// if (pnlSouth == null) { |
|
468 |
// pnlSouth = new JPanel(new BorderLayout()); |
|
469 |
// JPanel aux = new JPanel(); |
|
470 |
// aux.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
|
471 |
// aux.add(getBtnSwitchView()); |
|
472 |
// pnlSouth.add(aux, BorderLayout.NORTH); |
|
473 |
// |
|
474 |
// aux = new JPanel(); |
|
475 |
// aux.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
|
476 |
// pnlSouth.add(new AcceptCancelPanel(action, action), BorderLayout.SOUTH); |
|
477 |
// |
|
478 |
// } |
|
479 |
// return pnlSouth; |
|
480 |
// } |
|
481 |
// /** |
|
482 |
// * Creates a JButton to change the view of the table showed in the panel. |
|
483 |
// * |
|
484 |
// * @return btnSwitchView JButton |
|
485 |
// */ |
|
486 |
// private JButton getBtnSwitchView() { |
|
487 |
// if (btnSwitchView == null) { |
|
488 |
// btnSwitchView = new JButton( |
|
489 |
// (viewMode != DEFAULT_VIEW) ? |
|
490 |
// PluginServices.getText(this, "default_view"): |
|
491 |
// PluginServices.getText(this, "advanced_view") |
|
492 |
// ); |
|
493 |
// btnSwitchView.addActionListener(this); |
|
494 |
// } |
|
495 |
// |
|
496 |
// return btnSwitchView; |
|
497 |
// } |
|
498 |
// |
|
499 |
// public void actionPerformed(ActionEvent e) { |
|
500 |
// JComponent c = (JComponent) e.getSource(); |
|
501 |
// if (c.equals(getChkSpecifyDrawOrder())) { |
|
502 |
// getPnlCenter().setEnabled(getChkSpecifyDrawOrder().isSelected()); |
|
503 |
// } else if (c.equals(getBtnSwitchView())) { |
|
504 |
// viewMode = (viewMode == ADVANCED_VIEW) ? DEFAULT_VIEW : ADVANCED_VIEW; |
|
505 |
// initTableContents(getTblLevels(), zSort, viewMode); |
|
506 |
// btnSwitchView.setText((viewMode != DEFAULT_VIEW) ? |
|
507 |
// PluginServices.getText(this, "default_view"): |
|
508 |
// PluginServices.getText(this, "advanced_view")); |
|
509 |
// } |
|
510 |
// } |
|
511 |
// /** |
|
512 |
// * Gets the ZSort value |
|
513 |
// * |
|
514 |
// * @return zSort ZSort |
|
515 |
// */ |
|
516 |
// public ZSort getZSort() { |
|
517 |
// return zSort; |
|
518 |
// } |
|
519 |
// |
|
520 |
//} // @jve:decl-index=0:visual-constraint="10,10" |
|
521 |
// |
|
522 |
// |
|
523 |
// |
|
524 |
///* |
|
525 |
// * private void applyValues() { |
|
526 |
// |
|
527 |
// // update symbol order |
|
528 |
// TableModel model = tblLevels.getModel(); |
|
529 |
// |
|
530 |
// |
|
531 |
// for (int i = 0; i < model.getRowCount(); i++) { |
|
532 |
// System.out.print("["+i+"]"); |
|
533 |
// for (int j = 0; j < model.getColumnCount(); j++) { |
|
534 |
// System.out.print(j+":"+model.getValueAt(i, j)+"\t\t"); |
|
535 |
// } |
|
536 |
// System.out.println(); |
|
537 |
// } |
|
538 |
// |
|
539 |
// ISymbol[] symbols = zSort.getSymbols(); |
|
540 |
// zSort.clear(); |
|
541 |
// for (int i = 0; i < model.getRowCount(); i++) { |
|
542 |
// symbols[i] =(ISymbol) model.getValueAt(i,0); |
|
543 |
// } |
|
544 |
// |
|
545 |
// // set the level that each symbol layer belongs to... |
|
546 |
// if (viewMode == DEFAULT_VIEW) { |
|
547 |
// // data coming from "Default view" |
|
548 |
// |
|
549 |
// //for each row in the table |
|
550 |
// // tells if the symbol bellow has merge checked |
|
551 |
// boolean mergedToPreviousSymbol = false; |
|
552 |
// for (int i = 0; i < model.getRowCount(); i++) { |
|
553 |
// ISymbol mySymbol = symbols[i]; |
|
554 |
// if (mySymbol instanceof IMultiLayerSymbol) { |
|
555 |
// // merge and join only defined for multilayer symbols |
|
556 |
// IMultiLayerSymbol mlSym = (IMultiLayerSymbol) mySymbol; |
|
557 |
// boolean joined = ((Boolean) model. |
|
558 |
// getValueAt(i, JOIN_COLUMN_INDEX)).booleanValue(); |
|
559 |
// mergedToPreviousSymbol = joined && ((Boolean) model. |
|
560 |
// getValueAt(i, MERGE_COLUMN_INDEX)).booleanValue(); |
|
561 |
// if (!mergedToPreviousSymbol) { |
|
562 |
// if (!joined) { |
|
563 |
// // They all have the same level (they are drawn at the same place at once) |
|
564 |
// int level = zSort.getLevelCount() + 1; |
|
565 |
// for (int j = 0; j < mlSym.getLayerCount(); j++) { |
|
566 |
// zSort.setLevelToSymbol(mlSym.getLayer(j), level); |
|
567 |
// } |
|
568 |
// } else { |
|
569 |
// // each layer has its own render level. |
|
570 |
// for (int j = 0; j < mlSym.getLayerCount(); j++) { |
|
571 |
// System.out.println(zSort.getLevelCount()); |
|
572 |
// zSort.setLevelToSymbol(mlSym.getLayer(j), zSort.getLevelCount() + 1); |
|
573 |
// } |
|
574 |
// } |
|
575 |
// } else { |
|
576 |
// // if the previous symbol has marked as merge |
|
577 |
// // then this will have the same rendering level |
|
578 |
// // order than the previous one. |
|
579 |
// |
|
580 |
// // NOTE: a merged symbol is automatically joined |
|
581 |
// if (i>0) { |
|
582 |
// ISymbol prevSym = symbols[i-1]; |
|
583 |
// int j = 0; |
|
584 |
// |
|
585 |
// |
|
586 |
// if (prevSym instanceof IMultiLayerSymbol) { |
|
587 |
// IMultiLayerSymbol prevMultiLayerSym = (IMultiLayerSymbol) prevSym; |
|
588 |
// for (j = 0; j < prevMultiLayerSym.getLayerCount() && |
|
589 |
// j < mlSym.getLayerCount(); j++) { |
|
590 |
// |
|
591 |
// zSort.setLevelToSymbol(mlSym.getLayer(j) |
|
592 |
// , zSort.getSymbolLevel(prevMultiLayerSym.getLayer(j))); |
|
593 |
// } |
|
594 |
// } else { |
|
595 |
// zSort.setLevelToSymbol(mlSym.getLayer(j), zSort.getSymbolLevel(prevSym)); |
|
596 |
// } |
|
597 |
// |
|
598 |
// // this for will fill up the rest of symbol's layer's level, if any.. |
|
599 |
// for (j = i+1; j < symbols.length; j++) { |
|
600 |
// zSort.setLevelToSymbol(mlSym.getLayer(j), zSort.getLevelCount() + 1); } |
|
601 |
// } |
|
602 |
// } |
|
603 |
// } else { |
|
604 |
// mergedToPreviousSymbol = false; |
|
605 |
// } |
|
606 |
// } |
|
607 |
// } else { |
|
608 |
// // data coming from "Advanced view" |
|
609 |
// for (int i = 0; i < model.getRowCount(); i++) { |
|
610 |
// ISymbol sym = (ISymbol) model.getValueAt(i, SYMBOL_COLUMN_INDEX); |
|
611 |
// |
|
612 |
// if (sym instanceof IMultiLayerSymbol) { |
|
613 |
// IMultiLayerSymbol mlSym = (IMultiLayerSymbol) sym; |
|
614 |
// for (int j = FIRST_LEVEL_COLUMN_INDEX; j < model.getColumnCount(); j++) { |
|
615 |
// if (j-FIRST_LEVEL_COLUMN_INDEX > mlSym.getLayerCount()-1) |
|
616 |
// break; |
|
617 |
// if (model.getValueAt(i,j) !=null) { |
|
618 |
// Object v = model.getValueAt(i,j); |
|
619 |
// |
|
620 |
// int level = (v instanceof String) ? |
|
621 |
// Integer.parseInt((String) v) : ((Integer)v).intValue(); |
|
622 |
// zSort.setLevelToSymbol(mlSym.getLayer(j-FIRST_LEVEL_COLUMN_INDEX), level); |
|
623 |
// } |
|
624 |
// |
|
625 |
// } |
|
626 |
// |
|
627 |
// } else { |
|
628 |
// zSort.setLevelToSymbol(sym, |
|
629 |
// ((Integer) model.getValueAt(i, FIRST_LEVEL_COLUMN_INDEX)) |
|
630 |
// .intValue()); |
|
631 |
// } |
|
632 |
// } |
|
633 |
// } |
|
634 |
// }*/ |
|
635 | 1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
636 | 2 |
* |
637 | 3 |
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana. |
Also available in: Unified diff