root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / SymbolLevelsWindow.java @ 14169
History | View | Annotate | Download (19.3 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.Color; |
45 |
import java.awt.Component; |
46 |
import java.awt.FlowLayout; |
47 |
import java.awt.Font; |
48 |
import java.awt.Graphics; |
49 |
import java.awt.Graphics2D; |
50 |
import java.awt.Point; |
51 |
import java.awt.Rectangle; |
52 |
import java.awt.event.ActionEvent; |
53 |
import java.awt.event.ActionListener; |
54 |
import java.awt.event.MouseEvent; |
55 |
import java.awt.event.MouseListener; |
56 |
import java.awt.geom.GeneralPath; |
57 |
import java.util.Hashtable; |
58 |
import java.util.Iterator; |
59 |
|
60 |
import javax.swing.BorderFactory; |
61 |
import javax.swing.BoxLayout; |
62 |
import javax.swing.Icon; |
63 |
import javax.swing.ImageIcon; |
64 |
import javax.swing.JButton; |
65 |
import javax.swing.JCheckBox; |
66 |
import javax.swing.JComponent; |
67 |
import javax.swing.JPanel; |
68 |
import javax.swing.JScrollPane; |
69 |
import javax.swing.JTable; |
70 |
import javax.swing.border.EtchedBorder; |
71 |
import javax.swing.table.DefaultTableModel; |
72 |
import javax.swing.table.TableColumn; |
73 |
import javax.swing.table.TableModel; |
74 |
|
75 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
76 |
import org.gvsig.gui.beans.swing.JBlank; |
77 |
import org.gvsig.gui.beans.swing.celleditors.BooleanTableCellEditor; |
78 |
import org.gvsig.gui.beans.swing.celleditors.IntegerTableCellEditor; |
79 |
import org.gvsig.gui.beans.swing.cellrenderers.BooleanTableCellRenderer; |
80 |
import org.gvsig.gui.beans.swing.cellrenderers.NumberTableCellRenderer; |
81 |
|
82 |
import com.iver.andami.PluginServices; |
83 |
import com.iver.andami.ui.mdiManager.IWindow; |
84 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
85 |
import com.iver.cit.gvsig.fmap.core.symbols.IMultiLayerSymbol; |
86 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
87 |
import com.iver.cit.gvsig.fmap.rendering.ZSort; |
88 |
import com.iver.cit.gvsig.project.documents.gui.TableSymbolCellRenderer; |
89 |
|
90 |
/**
|
91 |
* Creates a panel to specify an order for the symbols of a map. This order
|
92 |
* is important when the map is going to be painted because, apart from that
|
93 |
* the waste of time can be less, the final representation of the map will
|
94 |
* depend on this order.
|
95 |
*
|
96 |
*
|
97 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
98 |
*/
|
99 |
public class SymbolLevelsWindow extends JPanel implements IWindow, ActionListener { |
100 |
private static final long serialVersionUID = 3241898997869313055L; |
101 |
private static final int DESCRIPTION_COLUMN_INDEX = 1; |
102 |
private static final int SYMBOL_COLUMN_INDEX = 0; |
103 |
private static final int MERGE_COLUMN_INDEX = 3; |
104 |
private static final int JOIN_COLUMN_INDEX = 2; |
105 |
private static final int FIRST_LEVEL_COLUMN_INDEX = 2; |
106 |
private static final String[] defaultHeaders = new String[] { |
107 |
PluginServices.getText(SymbolLevelsWindow.class, "symbol"),
|
108 |
PluginServices.getText(SymbolLevelsWindow.class, "description"),
|
109 |
PluginServices.getText(SymbolLevelsWindow.class, "join"),
|
110 |
PluginServices.getText(SymbolLevelsWindow.class, "merge"),
|
111 |
}; |
112 |
private static final int DEFAULT_VIEW = 0; |
113 |
private static final int ADVANCED_VIEW = 1; |
114 |
private static int viewMode = ADVANCED_VIEW; |
115 |
private JCheckBox chkSpecifyDrawOrder = null; |
116 |
private JPanel pnlCenter = null; |
117 |
private JScrollPane srclLevels = null; |
118 |
private JTable tblLevels = null; |
119 |
private JButton btnUp = null; |
120 |
private JButton btnDown; |
121 |
private JPanel pnlSouth = null; |
122 |
private String[] advancedHeaders; |
123 |
private JButton btnSwitchView; |
124 |
private ZSort zSort;
|
125 |
private SymbolSummary summary = new SymbolSummary(); |
126 |
|
127 |
private ActionListener action = new ActionListener() { |
128 |
public void actionPerformed(ActionEvent e) { |
129 |
String actionCommand = e.getActionCommand();
|
130 |
if ("OK".equals(actionCommand)) { |
131 |
applyValues(); |
132 |
} |
133 |
|
134 |
PluginServices.getMDIManager().closeWindow(SymbolLevelsWindow.this); |
135 |
|
136 |
} |
137 |
}; |
138 |
|
139 |
public WindowInfo getWindowInfo() {
|
140 |
WindowInfo wi = new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MODALDIALOG);
|
141 |
wi.setTitle(PluginServices.getText(this, "symbol_levels")); |
142 |
wi.setWidth(getWidth()+10);
|
143 |
wi.setHeight(getHeight()); |
144 |
return wi;
|
145 |
} |
146 |
|
147 |
/**
|
148 |
* Completes the main table of the panel with the symbols contained in the
|
149 |
* legend of the map.
|
150 |
*
|
151 |
*/
|
152 |
private void applyValues() { |
153 |
|
154 |
// update symbol order
|
155 |
TableModel model = tblLevels.getModel();
|
156 |
|
157 |
|
158 |
|
159 |
Hashtable<ISymbol, int[] > aTable = new Hashtable<ISymbol, int[]>(); |
160 |
ISymbol[] symbols = new ISymbol[model.getRowCount()]; |
161 |
for (int i = 0; i < symbols.length; i++) { |
162 |
symbols[i] = (ISymbol) model.getValueAt(i, SYMBOL_COLUMN_INDEX); |
163 |
int length = 1; |
164 |
if (symbols[i] instanceof IMultiLayerSymbol) { |
165 |
IMultiLayerSymbol mlSym = (IMultiLayerSymbol) symbols[i]; |
166 |
length = mlSym.getLayerCount(); |
167 |
} |
168 |
|
169 |
int[] symbolLevels = new int[length]; |
170 |
if (viewMode == DEFAULT_VIEW) {
|
171 |
// default view (JOIN and MERGE)
|
172 |
if (symbols[i] instanceof IMultiLayerSymbol) { |
173 |
boolean join = ((Boolean) model.getValueAt(i, JOIN_COLUMN_INDEX)).booleanValue(); |
174 |
boolean merge= ((Boolean) model.getValueAt(i, MERGE_COLUMN_INDEX)).booleanValue(); |
175 |
boolean needToJoin = true; |
176 |
if (merge && i>0) { |
177 |
int j=0; |
178 |
try {
|
179 |
int[] prevSymbolLevels = aTable.get(symbols[i-1]); |
180 |
for (j = 0; j < symbolLevels.length; j++) { |
181 |
symbolLevels[j] = prevSymbolLevels[j]; |
182 |
} |
183 |
} catch (IndexOutOfBoundsException ex) { |
184 |
/* perfect, no problem
|
185 |
* the previous symbol has different amount of layers
|
186 |
* that is ok because we just have to replicate
|
187 |
* the values of each cell
|
188 |
*/
|
189 |
for (; j < symbolLevels.length; j++) {
|
190 |
symbolLevels[j] = symbolLevels[j-1]+1; |
191 |
} |
192 |
} |
193 |
needToJoin = false;
|
194 |
} |
195 |
if (join && needToJoin) {
|
196 |
for (int j = 0; j < symbolLevels.length; j++) { |
197 |
symbolLevels[j] = zSort.getLevelCount()+j+1;
|
198 |
} |
199 |
} |
200 |
if (!join && !merge) {
|
201 |
for (int j = 0; j < symbolLevels.length; j++) { |
202 |
symbolLevels[j] = zSort.getLevelCount(); |
203 |
} |
204 |
} |
205 |
} else {
|
206 |
symbolLevels[0] = zSort.getLevelCount();
|
207 |
} |
208 |
} else {
|
209 |
// ADVANCED VIEW (user may set map levels manually)
|
210 |
for (int j = 0; j < symbolLevels.length; j++) { |
211 |
symbolLevels[j] = ((Integer) model.getValueAt(i, j+FIRST_LEVEL_COLUMN_INDEX)).intValue();
|
212 |
} |
213 |
} |
214 |
|
215 |
aTable.put(symbols[i], symbolLevels); |
216 |
} |
217 |
|
218 |
Iterator<ISymbol> it = aTable.keySet().iterator();
|
219 |
while (it.hasNext()) {
|
220 |
ISymbol sym = it.next(); |
221 |
zSort.setLevels(sym, aTable.get(sym)); |
222 |
} |
223 |
|
224 |
zSort.setUsingZSort(getChkSpecifyDrawOrder().isSelected()); |
225 |
} |
226 |
|
227 |
public SymbolLevelsWindow(ZSort zSort) {
|
228 |
super();
|
229 |
initialize(); |
230 |
setModel(zSort); |
231 |
tblLevels.setRowHeight(23);
|
232 |
} |
233 |
|
234 |
/**
|
235 |
* Sets the model
|
236 |
* @param plan ZSort
|
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 |
/**
|
252 |
* Initializes the table that it is showed in the panel where the user can
|
253 |
* see the different symbols of the legend and has options to specify the
|
254 |
* level for each one, merge and so on.
|
255 |
*
|
256 |
* @param table
|
257 |
* @param zSort
|
258 |
* @param mode
|
259 |
*/
|
260 |
private void initTableContents(JTable table, ZSort zSort, int mode) { |
261 |
DefaultTableModel model = new DefaultTableModel(); |
262 |
Object[][] dataVector = null; |
263 |
ISymbol[] syms = zSort.getSymbols();
|
264 |
String[] labels = zSort.getDescriptions(); |
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(j))); |
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 |
private static final long serialVersionUID = 5603529641148869112L; |
350 |
|
351 |
{ // Object static initialize block
|
352 |
|
353 |
preview = new SymbolPreviewer() {
|
354 |
private static final long serialVersionUID = 7262380340075167043L; |
355 |
private Icon downIcon = new Icon(){ |
356 |
public int getIconHeight() { return 7; } |
357 |
public int getIconWidth() { return 7; } |
358 |
public void paintIcon(Component c, Graphics g, int x, int y) { |
359 |
Graphics2D g2 = (Graphics2D) g; |
360 |
g2.setColor(Color.GRAY);
|
361 |
g2.translate(x + c.getWidth()-getIconWidth()*2, y + c.getHeight()-getIconHeight()*2); |
362 |
GeneralPath gp = new GeneralPath(); |
363 |
gp.moveTo(0, 0); |
364 |
gp.lineTo(getIconWidth()/2, getIconHeight()-1); |
365 |
gp.lineTo(getIconWidth()-1, 0); |
366 |
g2.fill(gp); |
367 |
g2.translate(-(x + c.getWidth()-getIconWidth()*2), -(y + c.getHeight()-getIconHeight()*2)); |
368 |
} |
369 |
}; |
370 |
@Override
|
371 |
public void paint(Graphics g) { |
372 |
super.paint(g);
|
373 |
if (getSymbol() instanceof IMultiLayerSymbol) { |
374 |
downIcon.paintIcon(this, g, 0, 0); |
375 |
} |
376 |
} |
377 |
}; |
378 |
|
379 |
} // Object static initialize block
|
380 |
}; |
381 |
TableColumn col = table.getColumnModel().getColumn(SYMBOL_COLUMN_INDEX);
|
382 |
col.setCellRenderer(symbolCellRenderer); |
383 |
} |
384 |
|
385 |
private void initialize() { |
386 |
this.setLayout(new BorderLayout(15, 15)); |
387 |
this.setSize(564, 344); |
388 |
|
389 |
this.add(getChkSpecifyDrawOrder(), BorderLayout.NORTH); |
390 |
this.add(new JBlank(20, 20)); |
391 |
this.add(getPnlCenter(), BorderLayout.CENTER); |
392 |
this.add(getPnlSouth(), BorderLayout.SOUTH); |
393 |
tblLevels.addMouseListener(new MouseListener() { |
394 |
public void mouseReleased(MouseEvent e) { } |
395 |
public void mouseClicked(MouseEvent e) { } |
396 |
public void mouseEntered(MouseEvent e) { } |
397 |
public void mouseExited(MouseEvent e) { |
398 |
summary.sym = null;
|
399 |
repaint(); |
400 |
} |
401 |
|
402 |
public void mousePressed(MouseEvent e) { |
403 |
Point where = e.getPoint();
|
404 |
int whereX = where.x;
|
405 |
int whereY = where.y;
|
406 |
Rectangle bounds = tblLevels.getBounds();
|
407 |
/*
|
408 |
* calculate the right border x-position of the symbol
|
409 |
* column
|
410 |
*/
|
411 |
int rightEdge = 0; |
412 |
for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) { |
413 |
rightEdge += tblLevels.getColumnModel().getColumn(i).getWidth(); |
414 |
} |
415 |
if (whereX >= bounds.x &&
|
416 |
whereX <= rightEdge + bounds.x && |
417 |
whereY >= bounds.y && |
418 |
whereY <= bounds.height + bounds.y) { |
419 |
int rowHeight = tblLevels.getRowHeight();
|
420 |
int rowClicked = (whereY - bounds.y) / rowHeight;
|
421 |
ISymbol sym = (ISymbol) tblLevels. |
422 |
getModel(). |
423 |
getValueAt( |
424 |
rowClicked, |
425 |
SYMBOL_COLUMN_INDEX); |
426 |
if (sym instanceof IMultiLayerSymbol) { |
427 |
summary.sym = (IMultiLayerSymbol) sym; |
428 |
summary.rowIndex = rowClicked; |
429 |
} else {
|
430 |
summary.sym = null;
|
431 |
} |
432 |
repaint(); |
433 |
} |
434 |
} |
435 |
|
436 |
}); |
437 |
|
438 |
} |
439 |
|
440 |
private JCheckBox getChkSpecifyDrawOrder() { |
441 |
if (chkSpecifyDrawOrder == null) { |
442 |
chkSpecifyDrawOrder = new JCheckBox( |
443 |
PluginServices.getText(this, "draw_symbols_in_specified_order")); |
444 |
chkSpecifyDrawOrder.addActionListener(this);
|
445 |
} |
446 |
return chkSpecifyDrawOrder;
|
447 |
} |
448 |
|
449 |
|
450 |
private JPanel getPnlCenter() { |
451 |
if (pnlCenter == null) { |
452 |
pnlCenter = new JPanel(); |
453 |
pnlCenter.setLayout(new BorderLayout(0, 15)); |
454 |
pnlCenter.add(getSrclLevels(), BorderLayout.CENTER);
|
455 |
pnlCenter.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); |
456 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 15)); |
457 |
JPanel pnlButtons = new JPanel(); |
458 |
pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.Y_AXIS)); |
459 |
pnlButtons.add(new JBlank(1, 70)); |
460 |
pnlButtons.add(getBtnUp()); |
461 |
pnlButtons.add(new JBlank(1, 10)); |
462 |
pnlButtons.add(getBtnDown()); |
463 |
aux.add(pnlButtons); |
464 |
pnlCenter.add(aux, BorderLayout.EAST);
|
465 |
|
466 |
} |
467 |
return pnlCenter;
|
468 |
} |
469 |
|
470 |
private JScrollPane getSrclLevels() { |
471 |
if (srclLevels == null) { |
472 |
srclLevels = new JScrollPane(); |
473 |
srclLevels.setViewportView(getTblLevels()); |
474 |
} |
475 |
return srclLevels;
|
476 |
} |
477 |
|
478 |
|
479 |
private JTable getTblLevels() { |
480 |
if (tblLevels == null) { |
481 |
tblLevels = new JTable() { |
482 |
private static final long serialVersionUID = -1545710722048183232L; |
483 |
|
484 |
@Override
|
485 |
protected void paintComponent(Graphics g) { |
486 |
super.paintComponent(g);
|
487 |
summary.paint((Graphics2D) g);
|
488 |
} |
489 |
}; |
490 |
summary.rowHeight = tblLevels.getRowHeight(); |
491 |
} |
492 |
return tblLevels;
|
493 |
} |
494 |
|
495 |
|
496 |
private JButton getBtnUp() { |
497 |
if (btnUp == null) { |
498 |
btnUp = new JButton(new ImageIcon(getClass(). |
499 |
getClassLoader().getResource("images/up-arrow.png")));
|
500 |
btnUp.setActionCommand("MOVE_UP");
|
501 |
} |
502 |
return btnUp;
|
503 |
} |
504 |
|
505 |
private JButton getBtnDown() { |
506 |
if (btnDown == null) { |
507 |
btnDown = new JButton(new ImageIcon(getClass(). |
508 |
getClassLoader().getResource("images/down-arrow.png")));
|
509 |
btnDown.setActionCommand("MOVE_DOWN");
|
510 |
} |
511 |
return btnDown;
|
512 |
} |
513 |
|
514 |
|
515 |
private JPanel getPnlSouth() { |
516 |
if (pnlSouth == null) { |
517 |
pnlSouth = new JPanel(new BorderLayout()); |
518 |
JPanel aux = new JPanel(); |
519 |
aux.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
520 |
aux.add(getBtnSwitchView()); |
521 |
pnlSouth.add(aux, BorderLayout.NORTH);
|
522 |
|
523 |
aux = new JPanel(); |
524 |
aux.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
525 |
pnlSouth.add(new AcceptCancelPanel(action, action), BorderLayout.SOUTH); |
526 |
|
527 |
} |
528 |
return pnlSouth;
|
529 |
} |
530 |
|
531 |
private JButton getBtnSwitchView() { |
532 |
if (btnSwitchView == null) { |
533 |
btnSwitchView = new JButton( |
534 |
(viewMode != DEFAULT_VIEW) ? |
535 |
PluginServices.getText(this, "default_view"): |
536 |
PluginServices.getText(this, "advanced_view") |
537 |
); |
538 |
btnSwitchView.addActionListener(this);
|
539 |
} |
540 |
|
541 |
return btnSwitchView;
|
542 |
} |
543 |
|
544 |
public void actionPerformed(ActionEvent e) { |
545 |
JComponent c = (JComponent) e.getSource(); |
546 |
if (c.equals(getChkSpecifyDrawOrder())) {
|
547 |
getPnlCenter().setEnabled(getChkSpecifyDrawOrder().isSelected()); |
548 |
} else if (c.equals(getBtnSwitchView())) { |
549 |
viewMode = (viewMode == ADVANCED_VIEW) ? DEFAULT_VIEW : ADVANCED_VIEW; |
550 |
initTableContents(getTblLevels(), zSort, viewMode); |
551 |
btnSwitchView.setText((viewMode != DEFAULT_VIEW) ? |
552 |
PluginServices.getText(this, "default_view"): |
553 |
PluginServices.getText(this, "advanced_view")); |
554 |
} |
555 |
} |
556 |
/**
|
557 |
* Gets the ZSort value
|
558 |
*
|
559 |
* @return zSort ZSort
|
560 |
*/
|
561 |
public ZSort getZSort() {
|
562 |
return zSort;
|
563 |
} |
564 |
|
565 |
private class SymbolSummary { |
566 |
int witdh;
|
567 |
int rowHeight = 10; |
568 |
|
569 |
int rowIndex;
|
570 |
|
571 |
IMultiLayerSymbol sym; |
572 |
|
573 |
void paint(Graphics2D g){ |
574 |
|
575 |
if (sym != null) { |
576 |
int whereY = (rowHeight*(rowIndex-1) + (int) (rowHeight/0.6)); |
577 |
int whereX = 0; |
578 |
for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) { |
579 |
whereX += tblLevels.getColumnModel().getColumn(i).getWidth(); |
580 |
} |
581 |
whereX -= 40;
|
582 |
int width = 150; |
583 |
int height = Math.max(rowHeight*sym.getLayerCount(), rowHeight); |
584 |
Rectangle bounds = new Rectangle(whereX, whereY, width, height); |
585 |
g.setColor(new Color(255, 255, 220)); |
586 |
g.fill(bounds); |
587 |
|
588 |
g.setColor(new Color(255, 230, 20)); |
589 |
g.draw(bounds); |
590 |
|
591 |
g.setFont(new Font("Arial", Font.BOLD, 10)); |
592 |
for (int i = 0; i < sym.getLayerCount(); i++) { |
593 |
g.setColor(Color.black);
|
594 |
g.drawString(i+1+":", whereX+5, height + whereY - ( (i*rowHeight) + 5 )); |
595 |
sym.getLayer(i).drawInsideRectangle(g, |
596 |
null,
|
597 |
new Rectangle(whereX + 20, |
598 |
height + whereY - ((i+1)*rowHeight) + 3, |
599 |
width - 20,
|
600 |
rowHeight - 6));
|
601 |
} |
602 |
|
603 |
} |
604 |
}; |
605 |
} |
606 |
} |