Revision 14169

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/gui/TableSymbolCellRenderer.java
1
/*
2
 * Created on 27-abr-2004
3
 *
4
 */
5 1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
6 2
 *
7 3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
62 58
 * @author fjp
63 59
 */
64 60
public class TableSymbolCellRenderer extends JPanel implements TableCellRenderer {
65
	Border unselectedBorder = null;
66
	Border selectedBorder = null;
67
	boolean isBordered = true;
68
	protected SymbolPreviewer preview = new SymbolPreviewer();
69

  
61
	private Border unselectedBorder = null;
62
	private Border selectedBorder = null;
63
	private boolean isBordered = true;
64
	protected SymbolPreviewer preview = new SymbolPreviewer() ;
65
	
70 66
	/**
71 67
	 * Crea un nuevo FCellRenderer.
72 68
	 *
......
76 72
		this.isBordered = isBordered;
77 73
		setOpaque(true); //MUST do this for background to show up.
78 74
	}
79

  
80
	/**
81
	 * DOCUMENT ME!
82
	 *
83
	 * @param table DOCUMENT ME!
84
	 * @param value DOCUMENT ME!
85
	 * @param isSelected DOCUMENT ME!
86
	 * @param hasFocus DOCUMENT ME!
87
	 * @param row DOCUMENT ME!
88
	 * @param column DOCUMENT ME!
89
	 *
90
	 * @return DOCUMENT ME!
91
	 */
75
	
92 76
	public Component getTableCellRendererComponent(JTable table, Object value,
93 77
		boolean isSelected, boolean hasFocus, int row, int column) {
94
		// System.out.println(value.getClass().toString());
95 78
		preview.setSymbol((ISymbol) value);
96 79

  
97
		// Color newColor = m_FSymbol.m_Color;
98
		// setBackground(newColor);
80
		
81
		if (isSelected) {
82
			preview.setBackground(table.getBackground());
83
			setBackground(table.getBackground());
84
		}
85
		
99 86
		if (isBordered) {
100 87
			if (isSelected) {
101 88
				if (selectedBorder == null) {
102 89
					selectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
103 90
							5, table.getSelectionBackground());
104 91
				}
105

  
106 92
				setBorder(selectedBorder);
107 93
			} else {
108 94
				if (unselectedBorder == null) {
109 95
					unselectedBorder = BorderFactory.createMatteBorder(2, 5, 2,
110 96
							5, table.getBackground());
111 97
				}
112

  
113 98
				setBorder(unselectedBorder);
114 99
			}
115 100
		}
116

  
117
		// setToolTipText("RGB value: " + newColor.getRed() + ", " + newColor.getGreen() + ", " + newColor.getBlue());
101
		
118 102
		return preview;
119 103
	}
104

  
105
	
106

  
120 107
}
108
	
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/legend/gui/VectorialUniqueValue.java
1
/*
2
 * Created on 30-abr-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7 1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
8 2
 *
9 3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
......
99 93
    private static Logger logger = Logger.getLogger(VectorialUniqueValue.class.getName());
100 94

  
101 95
    // private TOC m_TOC;
102
    private VectorialUniqueValueLegend m_Renderer;
96
    private VectorialUniqueValueLegend theLegend;
103 97
    private ClassifiableVectorial layer;
104 98

  
105 99
    //private boolean m_bCacheDirty = true;
106 100
    private FSymbolTable symbolTable;
107 101
    private JComboBox cmbFields;
108
    private JButton quitartodo;
109
    private JButton quitar;
102
    private JButton btnRemoveAll;
103
    private JButton btnRemove;
110 104
    private JCheckBox chbUseDefault = null;
111 105
    private VectorialUniqueValueLegend auxLegend;
112 106
	private PictureMarkerSymbol previewSymbol;
......
146 140
        btnAdd.addActionListener(this);
147 141
        pnlButtons.add(btnAdd);
148 142

  
149
        quitartodo = new JButton(PluginServices.getText(this, "Quitar_todos"));
150
        quitartodo.setActionCommand("REMOVE_ALL");
151
        quitartodo.addActionListener(this);
152
        pnlButtons.add(quitartodo);
143
        btnRemoveAll = new JButton(PluginServices.getText(this, "Quitar_todos"));
144
        btnRemoveAll.setActionCommand("REMOVE_ALL");
145
        btnRemoveAll.addActionListener(this);
146
        pnlButtons.add(btnRemoveAll);
153 147

  
154
        quitar = new JButton(PluginServices.getText(this, "Quitar"));
155
        quitar.setActionCommand("REMOVE");
156
        quitar.addActionListener(this);
157
        pnlButtons.add(quitar);
148
        btnRemove = new JButton(PluginServices.getText(this, "Quitar"));
149
        btnRemove.setActionCommand("REMOVE");
150
        btnRemove.addActionListener(this);
151
        pnlButtons.add(btnRemove);
158 152

  
159 153
        btnOpenSymbolLevelsEditor = new JButton(PluginServices.getText(this, "symbol_levels"));
160 154
        btnOpenSymbolLevelsEditor.addActionListener(this);
......
213 207
            }
214 208

  
215 209
            idField = elRs.getFieldIndexByName(fieldName);
216
            m_Renderer.setClassifyingFieldNames(new String[] {fieldName});
210
            theLegend.setClassifyingFieldNames(new String[] {fieldName});
217 211

  
218 212
            //long numReg = elRs.getRowCount();
219 213
            if (idField == -1) {
......
285 279
        	NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e);
286 280
        }
287 281

  
288
        quitartodo.setEnabled(true);
289
        quitar.setEnabled(true);
282
        btnRemoveAll.setEnabled(true);
283
        btnRemove.setEnabled(true);
290 284

  
291 285
        //m_bCacheDirty = false;
292 286
    }
......
300 294
        ISymbol theSymbol;
301 295

  
302 296
        // Borramos las anteriores listas:
303
        m_Renderer.clear();
297
        theLegend.clear();
304 298

  
305 299
        boolean bRestoValores = false; // PONERLO EN UN CHECKBOX
306 300
        int hasta;
307 301
        String fieldName = (String) cmbFields.getSelectedItem();
308
        m_Renderer.setClassifyingFieldNames(new String[] {fieldName} );
302
        theLegend.setClassifyingFieldNames(new String[] {fieldName} );
309 303

  
310 304
        if (bRestoValores) {
311 305
            hasta = symbolTable.getRowCount() - 1;
......
317 311
            clave = (Value) symbolTable.getFieldValue(row, 1);
318 312
            theSymbol = (ISymbol) symbolTable.getFieldValue(row, 0);
319 313
            theSymbol.setDescription((String) symbolTable.getFieldValue(row, 2));
320
            m_Renderer.addSymbol(clave, theSymbol);
314
            theLegend.addSymbol(clave, theSymbol);
321 315
        }
322 316

  
323 317
        if (bRestoValores) {
324 318
            theSymbol = (ISymbol) symbolTable.getFieldValue(hasta, 0);
325
            m_Renderer.setDefaultSymbol(theSymbol);
319
            theLegend.setDefaultSymbol(theSymbol);
326 320
        }
327 321
    }
328 322

  
......
352 346
        } catch (ReadDriverException e) {
353 347
        	NotificationManager.addError(PluginServices.getText(this, "recovering_recordset"), e);
354 348
        }
355

  
356
        symbolTable.removeAllItems();
357 349
    }
358 350

  
359
    /**
360
     * DOCUMENT ME!
361
     *
362
     * @param lyr DOCUMENT ME!
363
     * @param r DOCUMENT ME!
364
     */
365 351
    public void setData(FLayer layer, ILegend legend) {
366 352
    	this.layer = (ClassifiableVectorial) layer;
367 353
      	int shapeType = 0;
......
378 364

  
379 365
        fillFieldNames();
380 366

  
381
        // Si es de valor ?nico, rellenamos la tabla
382
        // y seleccionamos el campo que estamos usando
383 367
        symbolTable.removeAllItems();
384 368

  
385 369
        if (legend instanceof VectorialUniqueValueLegend) {
386
            m_Renderer = (VectorialUniqueValueLegend) legend;
387
            getChbUseDefault().setSelected(m_Renderer.isUseDefaultSymbol());
388
            cmbFields.getModel().setSelectedItem(m_Renderer.getClassifyingFieldNames()[0]);
389
            symbolTable.fillTableFromSymbolList(m_Renderer.getSymbols(),
390
            m_Renderer.getValues(), m_Renderer.getDescriptions());
370
            theLegend = (VectorialUniqueValueLegend) legend;
371
            getChbUseDefault().setSelected(theLegend.isUseDefaultSymbol());
372
            cmbFields.getModel().setSelectedItem(theLegend.getClassifyingFieldNames()[0]);
373
            symbolTable.fillTableFromSymbolList(theLegend.getSymbols(),
374
            									theLegend.getValues(),
375
            									theLegend.getDescriptions());
376
            zSort = theLegend.getZSort();
391 377
        } else {
392
            m_Renderer = new VectorialUniqueValueLegend(shapeType);
378
            theLegend = new VectorialUniqueValueLegend(shapeType);
393 379
        }
394 380
    }
395 381

  
......
400 386
        fillSymbolListFromTable();
401 387

  
402 388
        if (auxLegend != null) {
403
            m_Renderer.setDefaultSymbol(auxLegend.getDefaultSymbol());
404
            m_Renderer.useDefaultSymbol(chbUseDefault.isSelected());
389
            theLegend.setDefaultSymbol(auxLegend.getDefaultSymbol());
390
            theLegend.useDefaultSymbol(chbUseDefault.isSelected());
405 391
        }
406

  
407
        m_Renderer.setZSort(zSort);
408
        return m_Renderer;
392
        theLegend.setZSort(zSort);
393
        
394
        return theLegend;
409 395
    }
410 396

  
411
    /**
412
     * This method initializes chbUseDefault
413
     *
414
     * @return javax.swing.JCheckBox
415
     */
416 397
    private JCheckBox getChbUseDefault() {
417 398
        if (chbUseDefault == null) {
418 399
            chbUseDefault = new JCheckBox();
419 400
            chbUseDefault.setSelected(true);
420 401
            chbUseDefault.addActionListener(new java.awt.event.ActionListener() {
421 402
            	public void actionPerformed(java.awt.event.ActionEvent e) {
422
            		if (auxLegend==null)auxLegend=m_Renderer;
403
            		if (auxLegend==null)auxLegend=theLegend;
423 404
            		if (chbUseDefault.isSelected()) {
424 405
            			addDefault();
425 406
            		} else {
......
463 444
    		System.out.println("Nombre del campo: " + fieldName);
464 445
    		symbolTable.removeAllItems();
465 446

  
466
    		if (m_Renderer.getClassifyingFieldNames()!=null && fieldName != m_Renderer.getClassifyingFieldNames()[0]) {
447
    		if (theLegend.getClassifyingFieldNames()!=null && fieldName != theLegend.getClassifyingFieldNames()[0]) {
467 448
    			//m_bCacheDirty = true;
468
    			m_Renderer.setClassifyingFieldNames(new String[] {fieldName});
449
    			theLegend.setClassifyingFieldNames(new String[] {fieldName});
469 450
    		}
470 451
    	}
471 452

  
......
497 478

  
498 479
    	if (e.getActionCommand() == "OPEN_SYMBOL_LEVEL_EDITOR") {
499 480

  
500
			if (m_Renderer != null) {
501
				ZSort myZSort = m_Renderer.getZSort();
481
			if (theLegend != null) {
482
				ZSort myZSort = ((VectorialUniqueValueLegend) getLegend()).getZSort();
502 483
				if (myZSort == null) {
503
						myZSort = new ZSort(m_Renderer);
484
						myZSort = new ZSort(theLegend);
504 485
				}
505 486
				SymbolLevelsWindow sl = new SymbolLevelsWindow(myZSort);
506 487
				PluginServices.getMDIManager().addWindow(sl);
507 488
				zSort = sl.getZSort();
489
				if (auxLegend != null)
490
					auxLegend.setZSort(zSort);
508 491
			}
509 492

  
510 493
    	}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SymbolPreviewer.java
42 42
/* CVS MESSAGES:
43 43
 *
44 44
 * $Id$
45
 * $Log$
46
 * Revision 1.6  2007-08-16 06:54:35  jvidal
45
 * $Log: SymbolPreviewer.java,v $
46
 * Revision 1.6  2007/08/16 06:54:35  jvidal
47 47
 * javadoc updated
48 48
 *
49 49
 * Revision 1.5  2007/08/07 11:41:15  jvidal
......
178 178
			g2.drawString(noneSelected,	 (r.x*scale) - (hGap/2), r.height/2+vGap*scale);
179 179
		}
180 180
	}
181
	
181 182
	/**
182 183
	 * Sets the EditorTool for the pane.
183 184
	 *
184 185
	 * @param l,EditorTool
185 186
	 */
186

  
187
	public void setEditorTool(EditorTool l) {
187
	public void setEditorTool(EditorTool tool) {
188 188
		MouseListener[] ml = getMouseListeners();
189 189
		for (int i = 0; i < ml.length; i++) {
190 190
			super.removeMouseListener(ml[i]);
......
194 194
			super.removeMouseMotionListener(mml[i]);
195 195
		}
196 196

  
197
		if (l!= null) {
198
			super.addMouseListener(l);
199
			setCursor(l.getCursor());
200
			super.addMouseMotionListener(l);
197
		if (tool!= null) {
198
			super.addMouseListener(tool);
199
			setCursor(tool.getCursor());
200
			super.addMouseMotionListener(tool);
201 201
		}
202 202
	}
203 203

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/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