svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / styling / SymbolLevelsWindow.java @ 28368
History | View | Annotate | Download (21.2 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.EventObject; |
58 |
import java.util.Hashtable; |
59 |
import java.util.Iterator; |
60 |
|
61 |
import javax.swing.BorderFactory; |
62 |
import javax.swing.BoxLayout; |
63 |
import javax.swing.Icon; |
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.event.CellEditorListener; |
72 |
import javax.swing.event.ChangeEvent; |
73 |
import javax.swing.table.DefaultTableModel; |
74 |
import javax.swing.table.TableCellEditor; |
75 |
import javax.swing.table.TableColumn; |
76 |
import javax.swing.table.TableModel; |
77 |
|
78 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
79 |
import org.gvsig.gui.beans.swing.JBlank; |
80 |
import org.gvsig.gui.beans.swing.celleditors.BooleanTableCellEditor; |
81 |
import org.gvsig.gui.beans.swing.celleditors.IntegerTableCellEditor; |
82 |
import org.gvsig.gui.beans.swing.cellrenderers.BooleanTableCellRenderer; |
83 |
import org.gvsig.gui.beans.swing.cellrenderers.NumberTableCellRenderer; |
84 |
|
85 |
import com.iver.andami.PluginServices; |
86 |
import com.iver.andami.ui.mdiManager.IWindow; |
87 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
88 |
import com.iver.cit.gvsig.fmap.core.SymbologyFactory; |
89 |
import com.iver.cit.gvsig.fmap.core.symbols.IMultiLayerSymbol; |
90 |
import com.iver.cit.gvsig.fmap.core.symbols.ISymbol; |
91 |
import com.iver.cit.gvsig.fmap.core.symbols.SymbolDrawingException; |
92 |
import com.iver.cit.gvsig.fmap.rendering.ZSort; |
93 |
import com.iver.cit.gvsig.project.documents.gui.TableSymbolCellRenderer; |
94 |
|
95 |
/**
|
96 |
* Creates a panel to specify an order for the symbols of a map. This order
|
97 |
* is important when the map is going to be painted because, apart from that
|
98 |
* the waste of time can be less, the final representation of the map will
|
99 |
* depend on this order.
|
100 |
*
|
101 |
*
|
102 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
103 |
*/
|
104 |
public class SymbolLevelsWindow extends JPanel implements IWindow, ActionListener { |
105 |
private static final long serialVersionUID = 3241898997869313055L; |
106 |
private static final int DESCRIPTION_COLUMN_INDEX = 1; |
107 |
private static final int SYMBOL_COLUMN_INDEX = 0; |
108 |
private static final int MERGE_COLUMN_INDEX = 3; |
109 |
private static final int JOIN_COLUMN_INDEX = 2; |
110 |
private static final int FIRST_LEVEL_COLUMN_INDEX = 2; |
111 |
private static final String[] defaultHeaders = new String[] { |
112 |
PluginServices.getText(SymbolLevelsWindow.class, "symbol"),
|
113 |
PluginServices.getText(SymbolLevelsWindow.class, "description"),
|
114 |
PluginServices.getText(SymbolLevelsWindow.class, "join"),
|
115 |
PluginServices.getText(SymbolLevelsWindow.class, "merge"),
|
116 |
}; |
117 |
private static final int DEFAULT_VIEW = 0; |
118 |
private static final int ADVANCED_VIEW = 1; |
119 |
private static int viewMode = ADVANCED_VIEW; |
120 |
private JCheckBox chkSpecifyDrawOrder = null; |
121 |
private JPanel pnlCenter = null; |
122 |
private JScrollPane srclLevels = null; |
123 |
private JTable tblLevels = null; |
124 |
private JButton btnUp = null; |
125 |
private JButton btnDown; |
126 |
private JPanel pnlSouth = null; |
127 |
private String[] advancedHeaders; |
128 |
private JButton btnSwitchView; |
129 |
private ZSort zSort;
|
130 |
private SymbolSummary summary = new SymbolSummary(); |
131 |
|
132 |
private ActionListener action = new ActionListener() { |
133 |
public void actionPerformed(ActionEvent e) { |
134 |
String actionCommand = e.getActionCommand();
|
135 |
if ("OK".equals(actionCommand)) { |
136 |
tblLevels.editingStopped(new ChangeEvent(tblLevels)); |
137 |
applyValues(); |
138 |
} |
139 |
|
140 |
PluginServices.getMDIManager().closeWindow(SymbolLevelsWindow.this); |
141 |
|
142 |
} |
143 |
}; |
144 |
|
145 |
public WindowInfo getWindowInfo() {
|
146 |
WindowInfo wi = new WindowInfo(WindowInfo.RESIZABLE | WindowInfo.MODALDIALOG);
|
147 |
wi.setTitle(PluginServices.getText(this, "symbol_levels")); |
148 |
wi.setWidth(getWidth()+10);
|
149 |
wi.setHeight(getHeight()); |
150 |
return wi;
|
151 |
} |
152 |
/**
|
153 |
* Completes the main table of the panel with the symbols contained in the
|
154 |
* legend of the map.
|
155 |
*
|
156 |
*/
|
157 |
private void applyValues() { |
158 |
|
159 |
// update symbol order
|
160 |
TableModel model = tblLevels.getModel();
|
161 |
|
162 |
|
163 |
|
164 |
Hashtable<ISymbol, int[] > aTable = new Hashtable<ISymbol, int[]>(); |
165 |
ISymbol[] symbols = new ISymbol[model.getRowCount()]; |
166 |
for (int i = 0; i < symbols.length; i++) { |
167 |
symbols[i] = (ISymbol) model.getValueAt(i, SYMBOL_COLUMN_INDEX); |
168 |
int length = 1; |
169 |
if (symbols[i] instanceof IMultiLayerSymbol) { |
170 |
IMultiLayerSymbol mlSym = (IMultiLayerSymbol) symbols[i]; |
171 |
length = mlSym.getLayerCount(); |
172 |
} |
173 |
|
174 |
int[] symbolLevels = new int[length]; |
175 |
if (viewMode == DEFAULT_VIEW) {
|
176 |
// default view (JOIN and MERGE)
|
177 |
if (symbols[i] instanceof IMultiLayerSymbol) { |
178 |
boolean join = ((Boolean) model.getValueAt(i, JOIN_COLUMN_INDEX)).booleanValue(); |
179 |
boolean merge= ((Boolean) model.getValueAt(i, MERGE_COLUMN_INDEX)).booleanValue(); |
180 |
boolean needToJoin = true; |
181 |
if (merge && i>0) { |
182 |
int j=0; |
183 |
try {
|
184 |
int[] prevSymbolLevels = aTable.get(symbols[i-1]); |
185 |
for (j = 0; j < symbolLevels.length; j++) { |
186 |
symbolLevels[j] = prevSymbolLevels[j]; |
187 |
} |
188 |
} catch (IndexOutOfBoundsException ex) { |
189 |
/* perfect, no problem
|
190 |
* the previous symbol has different amount of layers
|
191 |
* that is ok because we just have to replicate
|
192 |
* the values of each cell
|
193 |
*/
|
194 |
for (; j < symbolLevels.length; j++) {
|
195 |
symbolLevels[j] = symbolLevels[j-1]+1; |
196 |
} |
197 |
} |
198 |
needToJoin = false;
|
199 |
} |
200 |
if (join && needToJoin) {
|
201 |
for (int j = 0; j < symbolLevels.length; j++) { |
202 |
symbolLevels[j] = zSort.getLevelCount()+j+1;
|
203 |
} |
204 |
} |
205 |
if (!join && !merge) {
|
206 |
for (int j = 0; j < symbolLevels.length; j++) { |
207 |
symbolLevels[j] = zSort.getLevelCount(); |
208 |
} |
209 |
} |
210 |
} else {
|
211 |
symbolLevels[0] = zSort.getLevelCount();
|
212 |
} |
213 |
} else {
|
214 |
// ADVANCED VIEW (user may set map levels manually)
|
215 |
for (int j = 0; j < symbolLevels.length; j++) { |
216 |
symbolLevels[j] = ((Integer) model.getValueAt(i, j+FIRST_LEVEL_COLUMN_INDEX)).intValue();
|
217 |
} |
218 |
} |
219 |
|
220 |
aTable.put(symbols[i], symbolLevels); |
221 |
} |
222 |
|
223 |
Iterator<ISymbol> it = aTable.keySet().iterator();
|
224 |
while (it.hasNext()) {
|
225 |
ISymbol sym = it.next(); |
226 |
zSort.setLevels(sym, aTable.get(sym)); |
227 |
} |
228 |
|
229 |
zSort.setUsingZSort(getChkSpecifyDrawOrder().isSelected()); |
230 |
} |
231 |
|
232 |
public SymbolLevelsWindow(ZSort zSort) {
|
233 |
super();
|
234 |
initialize(); |
235 |
setModel(zSort); |
236 |
quitaEsteMetodo(); |
237 |
tblLevels.setRowHeight(23);
|
238 |
} |
239 |
private void quitaEsteMetodo() { |
240 |
getBtnSwitchView().setEnabled(false);
|
241 |
getBtnDown().setEnabled(false);
|
242 |
getBtnUp().setEnabled(false);
|
243 |
} |
244 |
/**
|
245 |
* Sets the model
|
246 |
* @param plan ZSort
|
247 |
*/
|
248 |
|
249 |
public void setModel(ZSort plan) { |
250 |
advancedHeaders = new String[FIRST_LEVEL_COLUMN_INDEX |
251 |
+plan.getTopLevelIndexAllowed() ]; |
252 |
advancedHeaders[SYMBOL_COLUMN_INDEX] = defaultHeaders[SYMBOL_COLUMN_INDEX]; |
253 |
advancedHeaders[DESCRIPTION_COLUMN_INDEX] = defaultHeaders[DESCRIPTION_COLUMN_INDEX]; |
254 |
for (int i = 2; i < advancedHeaders.length; i++) { |
255 |
advancedHeaders[i] = String.valueOf(i-1); |
256 |
} |
257 |
this.zSort = plan;
|
258 |
getChkSpecifyDrawOrder().setSelected(plan.isUsingZSort()); |
259 |
initTableContents(getTblLevels(), plan, viewMode); |
260 |
} |
261 |
/**
|
262 |
* Initializes the table that it is showed in the panel where the user can
|
263 |
* see the different symbols of the legend and has options to specify the
|
264 |
* level for each one, merge and so on.
|
265 |
*
|
266 |
* @param table
|
267 |
* @param zSort
|
268 |
* @param mode
|
269 |
*/
|
270 |
private void initTableContents(JTable table, ZSort zSort, int mode) { |
271 |
DefaultTableModel model = new DefaultTableModel(); |
272 |
Object[][] dataVector = null; |
273 |
ISymbol[] syms = zSort.getSymbols();
|
274 |
String[] labels = zSort.getDescriptions(); |
275 |
|
276 |
if (mode == DEFAULT_VIEW) {
|
277 |
// default view (JOIN and MERGE)
|
278 |
dataVector = new Object[syms.length][syms.length]; |
279 |
for (int i = 0; i < syms.length; i++) { |
280 |
dataVector[i] = new Object[defaultHeaders.length]; |
281 |
dataVector[i][SYMBOL_COLUMN_INDEX] = syms[i]; |
282 |
dataVector[i][DESCRIPTION_COLUMN_INDEX] = labels[i]; |
283 |
if (syms[i] instanceof IMultiLayerSymbol) { |
284 |
boolean joined = true; |
285 |
int[] levels = zSort.getLevels(syms[i]); |
286 |
if(levels != null){ |
287 |
for (int j = 0; j < levels.length; j++) { |
288 |
if (joined)
|
289 |
joined = levels[j] != levels[j+1];
|
290 |
} |
291 |
} |
292 |
|
293 |
|
294 |
|
295 |
boolean merged = true; |
296 |
if (i<syms.length-1) { |
297 |
for (int j = 0; joined && j < levels.length; j++) { |
298 |
// must be joined to be merged
|
299 |
ISymbol nextSymbol = syms[i+1];
|
300 |
int[] nextLevels = zSort.getLevels(nextSymbol); |
301 |
if(nextLevels != null){ |
302 |
if (nextSymbol instanceof IMultiLayerSymbol) { |
303 |
if (j<nextLevels.length) {
|
304 |
merged = levels[j] == nextLevels[j]; |
305 |
} |
306 |
} else {
|
307 |
merged = levels[0] == nextLevels[0]; |
308 |
} |
309 |
} |
310 |
} |
311 |
if (!merged)
|
312 |
break;
|
313 |
} |
314 |
if (!joined) merged = false; |
315 |
dataVector[i][JOIN_COLUMN_INDEX] = new Boolean(joined); |
316 |
dataVector[i][MERGE_COLUMN_INDEX] = new Boolean(merged); |
317 |
} |
318 |
} |
319 |
|
320 |
model.setDataVector(dataVector, defaultHeaders); |
321 |
table.setModel(model); |
322 |
TableColumn col = table.getColumnModel().getColumn(JOIN_COLUMN_INDEX);
|
323 |
col.setCellRenderer(new BooleanTableCellRenderer(true)); |
324 |
col.setCellEditor(new BooleanTableCellEditor(table));
|
325 |
col = table.getColumnModel().getColumn(MERGE_COLUMN_INDEX); |
326 |
col.setCellRenderer(new BooleanTableCellRenderer(true)); |
327 |
col.setCellEditor(new BooleanTableCellEditor(table));
|
328 |
|
329 |
} else {
|
330 |
// advanced view (user may input the map level manually)
|
331 |
dataVector = new Object[syms.length][ |
332 |
FIRST_LEVEL_COLUMN_INDEX + /* this is the first column that
|
333 |
* contains a level for the symbol
|
334 |
*/
|
335 |
|
336 |
zSort.getTopLevelIndexAllowed() + /* according to the set of
|
337 |
* symbols this will get the
|
338 |
* max level reachable
|
339 |
*/
|
340 |
1 /* plus 1 to get a count instead of an index */]; |
341 |
for (int i = 0; i < syms.length; i++) { |
342 |
dataVector[i][SYMBOL_COLUMN_INDEX] = syms[i]; |
343 |
dataVector[i][DESCRIPTION_COLUMN_INDEX] = labels[i]; |
344 |
if (syms[i] instanceof IMultiLayerSymbol) { |
345 |
int[] levels = zSort.getLevels(syms[i]); |
346 |
|
347 |
for (int j = 0; j < levels.length; j++) { |
348 |
dataVector[i][j+FIRST_LEVEL_COLUMN_INDEX] = levels[j]; |
349 |
} |
350 |
} else {
|
351 |
dataVector[i][FIRST_LEVEL_COLUMN_INDEX] = new Integer(zSort.getLevels(syms[i])[0]); |
352 |
} |
353 |
} |
354 |
|
355 |
model.setDataVector(dataVector, advancedHeaders); |
356 |
table.setModel(model); |
357 |
for (int j = FIRST_LEVEL_COLUMN_INDEX; j < model.getColumnCount(); j++) { |
358 |
|
359 |
table.getColumnModel().getColumn(j).setCellRenderer(new NumberTableCellRenderer(true, false)); |
360 |
table.getColumnModel().getColumn(j).setCellEditor(new IntegerTableCellEditor());
|
361 |
} |
362 |
} |
363 |
|
364 |
TableSymbolCellRenderer symbolCellRenderer = new TableSymbolCellRenderer(true) { |
365 |
private static final long serialVersionUID = 5603529641148869112L; |
366 |
|
367 |
{ // Object static initialize block
|
368 |
|
369 |
preview = new SymbolPreviewer() {
|
370 |
private static final long serialVersionUID = 7262380340075167043L; |
371 |
private Icon downIcon = new Icon(){ |
372 |
public int getIconHeight() { return 7; } |
373 |
public int getIconWidth() { return 7; } |
374 |
public void paintIcon(Component c, Graphics g, int x, int y) { |
375 |
Graphics2D g2 = (Graphics2D) g; |
376 |
g2.setColor(Color.GRAY);
|
377 |
g2.translate(x + c.getWidth()-getIconWidth()*2, y + c.getHeight()-getIconHeight()*2); |
378 |
GeneralPath gp = new GeneralPath(); |
379 |
gp.moveTo(0, 0); |
380 |
gp.lineTo(getIconWidth()/2, getIconHeight()-1); |
381 |
gp.lineTo(getIconWidth()-1, 0); |
382 |
g2.fill(gp); |
383 |
g2.translate(-(x + c.getWidth()-getIconWidth()*2), -(y + c.getHeight()-getIconHeight()*2)); |
384 |
} |
385 |
}; |
386 |
@Override
|
387 |
public void paint(Graphics g) { |
388 |
super.paint(g);
|
389 |
if (getSymbol() instanceof IMultiLayerSymbol) { |
390 |
downIcon.paintIcon(this, g, 0, 0); |
391 |
} |
392 |
} |
393 |
}; |
394 |
|
395 |
} // Object static initialize block
|
396 |
}; |
397 |
TableCellEditor symbolCellEditor = new TableCellEditor(){ |
398 |
|
399 |
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { |
400 |
return null; |
401 |
} |
402 |
|
403 |
public void addCellEditorListener(CellEditorListener l) { |
404 |
} |
405 |
|
406 |
public void cancelCellEditing() { |
407 |
} |
408 |
|
409 |
public Object getCellEditorValue() { |
410 |
return null; |
411 |
} |
412 |
|
413 |
public boolean isCellEditable(EventObject anEvent) { |
414 |
return false; |
415 |
} |
416 |
|
417 |
public void removeCellEditorListener(CellEditorListener l) { |
418 |
} |
419 |
|
420 |
public boolean shouldSelectCell(EventObject anEvent) { |
421 |
return false; |
422 |
} |
423 |
|
424 |
public boolean stopCellEditing() { |
425 |
return false; |
426 |
} |
427 |
|
428 |
}; |
429 |
TableColumn col = table.getColumnModel().getColumn(SYMBOL_COLUMN_INDEX);
|
430 |
col.setCellRenderer(symbolCellRenderer); |
431 |
col.setCellEditor(symbolCellEditor); |
432 |
} |
433 |
|
434 |
private void initialize() { |
435 |
this.setLayout(new BorderLayout(15, 15)); |
436 |
this.setSize(564, 344); |
437 |
|
438 |
this.add(getChkSpecifyDrawOrder(), BorderLayout.NORTH); |
439 |
this.add(new JBlank(20, 20)); |
440 |
this.add(getPnlCenter(), BorderLayout.CENTER); |
441 |
this.add(getPnlSouth(), BorderLayout.SOUTH); |
442 |
tblLevels.addMouseListener(new MouseListener() { |
443 |
public void mouseReleased(MouseEvent e) { } |
444 |
public void mouseClicked(MouseEvent e) { } |
445 |
public void mouseEntered(MouseEvent e) { } |
446 |
public void mouseExited(MouseEvent e) { |
447 |
summary.sym = null;
|
448 |
repaint(); |
449 |
} |
450 |
|
451 |
public void mousePressed(MouseEvent e) { |
452 |
Point where = e.getPoint();
|
453 |
int whereX = where.x;
|
454 |
int whereY = where.y;
|
455 |
Rectangle bounds = tblLevels.getBounds();
|
456 |
/*
|
457 |
* calculate the right border x-position of the symbol
|
458 |
* column
|
459 |
*/
|
460 |
int rightEdge = 0; |
461 |
for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) { |
462 |
rightEdge += tblLevels.getColumnModel().getColumn(i).getWidth(); |
463 |
} |
464 |
if (whereX >= bounds.x &&
|
465 |
whereX <= rightEdge + bounds.x && |
466 |
whereY >= bounds.y && |
467 |
whereY <= bounds.height + bounds.y) { |
468 |
int rowHeight = tblLevels.getRowHeight();
|
469 |
int rowClicked = (whereY - bounds.y) / rowHeight;
|
470 |
ISymbol sym = (ISymbol) tblLevels. |
471 |
getModel(). |
472 |
getValueAt( |
473 |
rowClicked, |
474 |
SYMBOL_COLUMN_INDEX); |
475 |
if (sym instanceof IMultiLayerSymbol) { |
476 |
summary.sym = (IMultiLayerSymbol) sym; |
477 |
summary.rowIndex = rowClicked; |
478 |
} else {
|
479 |
summary.sym = null;
|
480 |
} |
481 |
repaint(); |
482 |
} |
483 |
} |
484 |
|
485 |
}); |
486 |
|
487 |
} |
488 |
|
489 |
private JCheckBox getChkSpecifyDrawOrder() { |
490 |
if (chkSpecifyDrawOrder == null) { |
491 |
chkSpecifyDrawOrder = new JCheckBox("<html><b>"+ |
492 |
PluginServices.getText(this, "draw_symbols_in_specified_order") |
493 |
+"</b></html>");
|
494 |
chkSpecifyDrawOrder.addActionListener(this);
|
495 |
} |
496 |
return chkSpecifyDrawOrder;
|
497 |
} |
498 |
|
499 |
|
500 |
private JPanel getPnlCenter() { |
501 |
if (pnlCenter == null) { |
502 |
pnlCenter = new JPanel(); |
503 |
pnlCenter.setLayout(new BorderLayout(0, 15)); |
504 |
pnlCenter.add(getSrclLevels(), BorderLayout.CENTER);
|
505 |
pnlCenter.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); |
506 |
JPanel aux = new JPanel(new FlowLayout(FlowLayout.CENTER, 15, 15)); |
507 |
JPanel pnlButtons = new JPanel(); |
508 |
pnlButtons.setLayout(new BoxLayout(pnlButtons, BoxLayout.Y_AXIS)); |
509 |
pnlButtons.add(new JBlank(1, 70)); |
510 |
pnlButtons.add(getBtnUp()); |
511 |
pnlButtons.add(new JBlank(1, 10)); |
512 |
pnlButtons.add(getBtnDown()); |
513 |
pnlButtons.setVisible(false);
|
514 |
aux.add(pnlButtons); |
515 |
pnlCenter.add(aux, BorderLayout.EAST);
|
516 |
} |
517 |
pnlCenter.setEnabled(getChkSpecifyDrawOrder().isSelected()); |
518 |
return pnlCenter;
|
519 |
} |
520 |
|
521 |
private JScrollPane getSrclLevels() { |
522 |
if (srclLevels == null) { |
523 |
srclLevels = new JScrollPane(); |
524 |
srclLevels.setViewportView(getTblLevels()); |
525 |
} |
526 |
srclLevels.setEnabled(getChkSpecifyDrawOrder().isSelected()); |
527 |
return srclLevels;
|
528 |
} |
529 |
|
530 |
|
531 |
private JTable getTblLevels() { |
532 |
if (tblLevels == null) { |
533 |
tblLevels = new JTable() { |
534 |
private static final long serialVersionUID = -1545710722048183232L; |
535 |
|
536 |
@Override
|
537 |
protected void paintComponent(Graphics g) { |
538 |
super.paintComponent(g);
|
539 |
summary.paint((Graphics2D) g);
|
540 |
} |
541 |
}; |
542 |
summary.rowHeight = tblLevels.getRowHeight(); |
543 |
} |
544 |
tblLevels.setEnabled(getChkSpecifyDrawOrder().isSelected()); |
545 |
return tblLevels;
|
546 |
} |
547 |
|
548 |
|
549 |
private JButton getBtnUp() { |
550 |
if (btnUp == null) { |
551 |
btnUp = new JButton(PluginServices.getIconTheme().get("arrow-up-icono")); |
552 |
btnUp.setActionCommand("MOVE_UP");
|
553 |
} |
554 |
return btnUp;
|
555 |
} |
556 |
|
557 |
private JButton getBtnDown() { |
558 |
if (btnDown == null) { |
559 |
btnDown = new JButton(PluginServices.getIconTheme().get("arrow-down-icono")); |
560 |
btnDown.setActionCommand("MOVE_DOWN");
|
561 |
} |
562 |
return btnDown;
|
563 |
} |
564 |
|
565 |
|
566 |
private JPanel getPnlSouth() { |
567 |
if (pnlSouth == null) { |
568 |
pnlSouth = new JPanel(new BorderLayout()); |
569 |
JPanel aux = new JPanel(); |
570 |
aux.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
571 |
aux.add(getBtnSwitchView()); |
572 |
pnlSouth.add(aux, BorderLayout.NORTH);
|
573 |
|
574 |
aux = new JPanel(); |
575 |
aux.setLayout(new FlowLayout(FlowLayout.RIGHT)); |
576 |
pnlSouth.add(new AcceptCancelPanel(action, action), BorderLayout.SOUTH); |
577 |
|
578 |
} |
579 |
return pnlSouth;
|
580 |
} |
581 |
|
582 |
private JButton getBtnSwitchView() { |
583 |
if (btnSwitchView == null) { |
584 |
btnSwitchView = new JButton( |
585 |
(viewMode != DEFAULT_VIEW) ? |
586 |
PluginServices.getText(this, "default_view"): |
587 |
PluginServices.getText(this, "advanced_view") |
588 |
); |
589 |
btnSwitchView.addActionListener(this);
|
590 |
btnSwitchView.setVisible(false);
|
591 |
} |
592 |
|
593 |
return btnSwitchView;
|
594 |
} |
595 |
|
596 |
public void actionPerformed(ActionEvent e) { |
597 |
JComponent c = (JComponent) e.getSource(); |
598 |
if (c.equals(getChkSpecifyDrawOrder())) {
|
599 |
getPnlCenter().setEnabled(getChkSpecifyDrawOrder().isSelected()); |
600 |
getSrclLevels().setEnabled(getChkSpecifyDrawOrder().isSelected()); |
601 |
TableCellEditor tce = getTblLevels().getCellEditor();
|
602 |
if (tce != null){ |
603 |
tce.stopCellEditing(); |
604 |
} |
605 |
getTblLevels().setEnabled(getChkSpecifyDrawOrder().isSelected()); |
606 |
} else if (c.equals(getBtnSwitchView())) { |
607 |
viewMode = (viewMode == ADVANCED_VIEW) ? DEFAULT_VIEW : ADVANCED_VIEW; |
608 |
initTableContents(getTblLevels(), zSort, viewMode); |
609 |
btnSwitchView.setText((viewMode != DEFAULT_VIEW) ? |
610 |
PluginServices.getText(this, "default_view"): |
611 |
PluginServices.getText(this, "advanced_view")); |
612 |
} |
613 |
} |
614 |
/**
|
615 |
* Gets the ZSort value
|
616 |
*
|
617 |
* @return zSort ZSort
|
618 |
*/
|
619 |
public ZSort getZSort() {
|
620 |
return zSort;
|
621 |
} |
622 |
|
623 |
private class SymbolSummary { |
624 |
int witdh;
|
625 |
int rowHeight = 10; |
626 |
|
627 |
int rowIndex;
|
628 |
|
629 |
IMultiLayerSymbol sym; |
630 |
|
631 |
void paint(Graphics2D g){ |
632 |
|
633 |
if (sym != null) { |
634 |
int whereY = (rowHeight*(rowIndex-1) + (int) (rowHeight/0.6)); |
635 |
int whereX = 0; |
636 |
for (int i = 0; i <= SYMBOL_COLUMN_INDEX; i++) { |
637 |
whereX += tblLevels.getColumnModel().getColumn(i).getWidth(); |
638 |
} |
639 |
whereX -= 40;
|
640 |
int width = 150; |
641 |
int height = Math.max(rowHeight*sym.getLayerCount(), rowHeight); |
642 |
Rectangle bounds = new Rectangle(whereX, whereY, width, height); |
643 |
g.setColor(new Color(255, 255, 220)); |
644 |
g.fill(bounds); |
645 |
|
646 |
g.setColor(new Color(255, 230, 20)); |
647 |
g.draw(bounds); |
648 |
|
649 |
g.setFont(new Font("Arial", Font.BOLD, 10)); |
650 |
|
651 |
for (int i = 0; i < sym.getLayerCount(); i++) { |
652 |
g.setColor(Color.black);
|
653 |
g.drawString(i+1+":", whereX+5, height + whereY - ( (i*rowHeight) + 5 )); |
654 |
Rectangle rect = new Rectangle(whereX + 20, |
655 |
height + whereY - ((i+1)*rowHeight) + 3, |
656 |
width - 20,
|
657 |
rowHeight - 6);
|
658 |
try {
|
659 |
sym.getLayer(i).drawInsideRectangle(g, null, rect, null); |
660 |
} catch (SymbolDrawingException e) {
|
661 |
if (e.getType() == SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS) {
|
662 |
try {
|
663 |
SymbologyFactory.getWarningSymbol( |
664 |
SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
665 |
"",
|
666 |
SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS).drawInsideRectangle(g, null, rect, null); |
667 |
} catch (SymbolDrawingException e1) {
|
668 |
// IMPOSSIBLE TO REACH THIS
|
669 |
} |
670 |
} else {
|
671 |
// should be unreachable code
|
672 |
throw new Error(PluginServices.getText(this, "symbol_shapetype_mismatch")); |
673 |
} |
674 |
} |
675 |
} |
676 |
|
677 |
} |
678 |
}; |
679 |
} |
680 |
|
681 |
public Object getWindowProfile() { |
682 |
return WindowInfo.DIALOG_PROFILE;
|
683 |
} |
684 |
} |