root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / SymbolLevelsWindow.java @ 13928
History | View | Annotate | Download (20 KB)
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 |
DefaultTableModel model = new DefaultTableModel(); |
261 |
Object[][] dataVector = null; |
262 |
ISymbol[] syms = zSort.getSymbols();
|
263 |
String[] labels = zSort.getDescriptions(); |
264 |
System.out.println(zSort);
|
265 |
|
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 |
* This method initializes this
|
355 |
*
|
356 |
* @return void
|
357 |
*/
|
358 |
private void initialize() { |
359 |
this.setLayout(new BorderLayout(15, 15)); |
360 |
this.setSize(564, 344); |
361 |
|
362 |
this.add(getChkSpecifyDrawOrder(), BorderLayout.NORTH); |
363 |
this.add(new JBlank(20, 20)); |
364 |
this.add(getPnlCenter(), BorderLayout.CENTER); |
365 |
this.add(getPnlSouth(), BorderLayout.SOUTH); |
366 |
} |
367 |
|
368 |
/**
|
369 |
* This method initializes chkSpecifyDrawOrder
|
370 |
*
|
371 |
* @return javax.swing.JCheckBox
|
372 |
*/
|
373 |
private JCheckBox getChkSpecifyDrawOrder() { |
374 |
if (chkSpecifyDrawOrder == null) { |
375 |
chkSpecifyDrawOrder = new JCheckBox( |
376 |
PluginServices.getText(this, "draw_symbols_in_specified_order")); |
377 |
chkSpecifyDrawOrder.addActionListener(this);
|
378 |
} |
379 |
return chkSpecifyDrawOrder;
|
380 |
} |
381 |
|
382 |
/**
|
383 |
* This method initializes pnlCenter
|
384 |
*
|
385 |
* @return javax.swing.JPanel
|
386 |
*/
|
387 |
private JPanel getPnlCenter() { |
388 |
if (pnlCenter == null) { |
389 |
pnlCenter = new JPanel(); |
390 |
pnlCenter.setLayout(new BorderLayout(0, 15)); |
391 |
pnlCenter.add(getSrclLevels(), BorderLayout.CENTER);
|
392 |
pnlCenter.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); |
393 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 15)); |
394 |
JPanel pnlButtons = new JPanel(); |
395 |
pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.Y_AXIS)); |
396 |
pnlButtons.add(new JBlank(1, 70)); |
397 |
pnlButtons.add(getBtnUp()); |
398 |
pnlButtons.add(new JBlank(1, 10)); |
399 |
pnlButtons.add(getBtnDown()); |
400 |
aux.add(pnlButtons); |
401 |
pnlCenter.add(aux, BorderLayout.EAST);
|
402 |
|
403 |
} |
404 |
return pnlCenter;
|
405 |
} |
406 |
|
407 |
/**
|
408 |
* This method initializes srclLevels
|
409 |
*
|
410 |
* @return javax.swing.JScrollPane
|
411 |
*/
|
412 |
private JScrollPane getSrclLevels() { |
413 |
if (srclLevels == null) { |
414 |
srclLevels = new JScrollPane(); |
415 |
srclLevels.setViewportView(getTblLevels()); |
416 |
} |
417 |
return srclLevels;
|
418 |
} |
419 |
|
420 |
/**
|
421 |
* This method initializes tblLevels
|
422 |
*
|
423 |
* @return javax.swing.JTable
|
424 |
*/
|
425 |
private JTable getTblLevels() { |
426 |
if (tblLevels == null) { |
427 |
tblLevels = new JTable(); |
428 |
} |
429 |
return tblLevels;
|
430 |
} |
431 |
|
432 |
/**
|
433 |
* This method initializes btnUp
|
434 |
*
|
435 |
* @return javax.swing.JButton
|
436 |
*/
|
437 |
private JButton getBtnUp() { |
438 |
if (btnUp == null) { |
439 |
btnUp = new JButton(new ImageIcon(getClass(). |
440 |
getClassLoader().getResource("images/up-arrow.png")));
|
441 |
btnUp.setActionCommand("MOVE_UP");
|
442 |
} |
443 |
return btnUp;
|
444 |
} |
445 |
/**
|
446 |
* This method initializes btnDown
|
447 |
*
|
448 |
* @return javax.swing.JButton
|
449 |
*/
|
450 |
private JButton getBtnDown() { |
451 |
if (btnDown == null) { |
452 |
btnDown = new JButton(new ImageIcon(getClass(). |
453 |
getClassLoader().getResource("images/down-arrow.png")));
|
454 |
btnDown.setActionCommand("MOVE_DOWN");
|
455 |
} |
456 |
return btnDown;
|
457 |
} |
458 |
|
459 |
/**
|
460 |
* This method initializes pnlSouth
|
461 |
*
|
462 |
* @return javax.swing.JPanel
|
463 |
*/
|
464 |
private JPanel getPnlSouth() { |
465 |
if (pnlSouth == null) { |
466 |
pnlSouth = new JPanel(new BorderLayout()); |
467 |
JPanel aux = new JPanel(); |
468 |
aux.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
469 |
aux.add(getBtnSwitchView()); |
470 |
pnlSouth.add(aux, BorderLayout.NORTH);
|
471 |
|
472 |
aux = new JPanel(); |
473 |
aux.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
474 |
pnlSouth.add(new AcceptCancelPanel(action, action), BorderLayout.SOUTH); |
475 |
|
476 |
} |
477 |
return pnlSouth;
|
478 |
} |
479 |
/**
|
480 |
* Creates a JButton to change the view of the table showed in the panel.
|
481 |
*
|
482 |
* @return btnSwitchView JButton
|
483 |
*/
|
484 |
private JButton getBtnSwitchView() { |
485 |
if (btnSwitchView == null) { |
486 |
btnSwitchView = new JButton( |
487 |
(viewMode != DEFAULT_VIEW) ? |
488 |
PluginServices.getText(this, "default_view"): |
489 |
PluginServices.getText(this, "advanced_view") |
490 |
); |
491 |
btnSwitchView.addActionListener(this);
|
492 |
} |
493 |
|
494 |
return btnSwitchView;
|
495 |
} |
496 |
|
497 |
public void actionPerformed(ActionEvent e) { |
498 |
JComponent c = (JComponent) e.getSource(); |
499 |
if (c.equals(getChkSpecifyDrawOrder())) {
|
500 |
getPnlCenter().setEnabled(getChkSpecifyDrawOrder().isSelected()); |
501 |
} else if (c.equals(getBtnSwitchView())) { |
502 |
viewMode = (viewMode == ADVANCED_VIEW) ? DEFAULT_VIEW : ADVANCED_VIEW; |
503 |
initTableContents(getTblLevels(), zSort, viewMode); |
504 |
btnSwitchView.setText((viewMode != DEFAULT_VIEW) ? |
505 |
PluginServices.getText(this, "default_view"): |
506 |
PluginServices.getText(this, "advanced_view")); |
507 |
} |
508 |
} |
509 |
/**
|
510 |
* Gets the ZSort value
|
511 |
*
|
512 |
* @return zSort ZSort
|
513 |
*/
|
514 |
public ZSort getZSort() {
|
515 |
return zSort;
|
516 |
} |
517 |
|
518 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
519 |
|
520 |
|
521 |
|
522 |
/*
|
523 |
* private void applyValues() {
|
524 |
|
525 |
// update symbol order
|
526 |
TableModel model = tblLevels.getModel();
|
527 |
|
528 |
|
529 |
for (int i = 0; i < model.getRowCount(); i++) {
|
530 |
System.out.print("["+i+"]");
|
531 |
for (int j = 0; j < model.getColumnCount(); j++) {
|
532 |
System.out.print(j+":"+model.getValueAt(i, j)+"\t\t");
|
533 |
}
|
534 |
System.out.println();
|
535 |
}
|
536 |
|
537 |
ISymbol[] symbols = zSort.getSymbols();
|
538 |
zSort.clear();
|
539 |
for (int i = 0; i < model.getRowCount(); i++) {
|
540 |
symbols[i] =(ISymbol) model.getValueAt(i,0);
|
541 |
}
|
542 |
|
543 |
// set the level that each symbol layer belongs to...
|
544 |
if (viewMode == DEFAULT_VIEW) {
|
545 |
// data coming from "Default view"
|
546 |
|
547 |
//for each row in the table
|
548 |
// tells if the symbol bellow has merge checked
|
549 |
boolean mergedToPreviousSymbol = false;
|
550 |
for (int i = 0; i < model.getRowCount(); i++) {
|
551 |
ISymbol mySymbol = symbols[i];
|
552 |
if (mySymbol instanceof IMultiLayerSymbol) {
|
553 |
// merge and join only defined for multilayer symbols
|
554 |
IMultiLayerSymbol mlSym = (IMultiLayerSymbol) mySymbol;
|
555 |
boolean joined = ((Boolean) model.
|
556 |
getValueAt(i, JOIN_COLUMN_INDEX)).booleanValue();
|
557 |
mergedToPreviousSymbol = joined && ((Boolean) model.
|
558 |
getValueAt(i, MERGE_COLUMN_INDEX)).booleanValue();
|
559 |
if (!mergedToPreviousSymbol) {
|
560 |
if (!joined) {
|
561 |
// They all have the same level (they are drawn at the same place at once)
|
562 |
int level = zSort.getLevelCount() + 1;
|
563 |
for (int j = 0; j < mlSym.getLayerCount(); j++) {
|
564 |
zSort.setLevelToSymbol(mlSym.getLayer(j), level);
|
565 |
}
|
566 |
} else {
|
567 |
// each layer has its own render level.
|
568 |
for (int j = 0; j < mlSym.getLayerCount(); j++) {
|
569 |
System.out.println(zSort.getLevelCount());
|
570 |
zSort.setLevelToSymbol(mlSym.getLayer(j), zSort.getLevelCount() + 1);
|
571 |
}
|
572 |
}
|
573 |
} else {
|
574 |
// if the previous symbol has marked as merge
|
575 |
// then this will have the same rendering level
|
576 |
// order than the previous one.
|
577 |
|
578 |
// NOTE: a merged symbol is automatically joined
|
579 |
if (i>0) {
|
580 |
ISymbol prevSym = symbols[i-1];
|
581 |
int j = 0;
|
582 |
|
583 |
|
584 |
if (prevSym instanceof IMultiLayerSymbol) {
|
585 |
IMultiLayerSymbol prevMultiLayerSym = (IMultiLayerSymbol) prevSym;
|
586 |
for (j = 0; j < prevMultiLayerSym.getLayerCount() &&
|
587 |
j < mlSym.getLayerCount(); j++) {
|
588 |
|
589 |
zSort.setLevelToSymbol(mlSym.getLayer(j)
|
590 |
, zSort.getSymbolLevel(prevMultiLayerSym.getLayer(j)));
|
591 |
}
|
592 |
} else {
|
593 |
zSort.setLevelToSymbol(mlSym.getLayer(j), zSort.getSymbolLevel(prevSym));
|
594 |
}
|
595 |
|
596 |
// this for will fill up the rest of symbol's layer's level, if any..
|
597 |
for (j = i+1; j < symbols.length; j++) {
|
598 |
zSort.setLevelToSymbol(mlSym.getLayer(j), zSort.getLevelCount() + 1); }
|
599 |
}
|
600 |
}
|
601 |
} else {
|
602 |
mergedToPreviousSymbol = false;
|
603 |
}
|
604 |
}
|
605 |
} else {
|
606 |
// data coming from "Advanced view"
|
607 |
for (int i = 0; i < model.getRowCount(); i++) {
|
608 |
ISymbol sym = (ISymbol) model.getValueAt(i, SYMBOL_COLUMN_INDEX);
|
609 |
|
610 |
if (sym instanceof IMultiLayerSymbol) {
|
611 |
IMultiLayerSymbol mlSym = (IMultiLayerSymbol) sym;
|
612 |
for (int j = FIRST_LEVEL_COLUMN_INDEX; j < model.getColumnCount(); j++) {
|
613 |
if (j-FIRST_LEVEL_COLUMN_INDEX > mlSym.getLayerCount()-1)
|
614 |
break;
|
615 |
if (model.getValueAt(i,j) !=null) {
|
616 |
Object v = model.getValueAt(i,j);
|
617 |
|
618 |
int level = (v instanceof String) ?
|
619 |
Integer.parseInt((String) v) : ((Integer)v).intValue();
|
620 |
zSort.setLevelToSymbol(mlSym.getLayer(j-FIRST_LEVEL_COLUMN_INDEX), level);
|
621 |
}
|
622 |
|
623 |
}
|
624 |
|
625 |
} else {
|
626 |
zSort.setLevelToSymbol(sym,
|
627 |
((Integer) model.getValueAt(i, FIRST_LEVEL_COLUMN_INDEX))
|
628 |
.intValue());
|
629 |
}
|
630 |
}
|
631 |
}
|
632 |
}*/
|