Revision 8516

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/ViewControls.java
81 81
 */
82 82
public class ViewControls extends Extension implements IPreferenceExtension{
83 83
	private static Logger logger = Logger.getLogger(ViewControls.class.getName());
84
	private static ViewPage viewPropertiesPage=new ViewPage();
84
	private static ViewPage viewPropertiesPage = new ViewPage();
85 85
	/**
86 86
	 * @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String)
87 87
	 */
......
230 230
	public boolean isEnabled() {
231 231
		com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
232 232
		.getActiveWindow();
233
		
233

  
234 234
		if (f == null) {
235 235
			return false;
236 236
		}
237
		
237

  
238 238
		if (f instanceof View) {
239 239
			View vista = (View) f;
240 240
			IProjectView model = vista.getModel();
241 241
			MapContext mapa = model.getMapContext();
242
			
242

  
243 243
			FLayers layers = mapa.getLayers();
244 244
			for (int i=0;i<layers.getLayersCount();i++) {
245 245
				if (layers.getLayer(i).isAvailable()) return true;
246 246
			}
247
			
247

  
248 248
		}
249 249
		return false;
250 250
	}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FGeometry.java
140 140
     * @see com.iver.cit.gvsig.fmap.core.IGeometry#drawInts(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.core.v02.FSymbol)
141 141
     */
142 142
    public void drawInts(Graphics2D g, ViewPort vp, ISymbol symbol) {
143
        FShape decimatedShape = FConverter.transformToInts(this, vp.getAffineTransform());
144
        symbol.draw(g, vp.getAffineTransform(), decimatedShape);
143
    	try
144
    	{
145
    		FShape decimatedShape = FConverter.transformToInts(this, vp.getAffineTransform());
146
    		symbol.draw(g, vp.getAffineTransform(), decimatedShape);
147
    	}
148
    	catch (Exception e)
149
    	{
150
    		e.printStackTrace();
151
    	}
145 152
        // FGraphicUtilities.DrawShape(g, vp.getAffineTransform(), decimatedShape, symbol);
146 153
    }
147 154

  
......
173 180
		// return shp.getBounds2D();
174 181
		return bounds2D;
175 182
	}
176
	
183

  
177 184
	public Rectangle2D reCalculateBounds2D()
178 185
	{
179 186
		return shp.getBounds2D();
......
225 232
	}
226 233

  
227 234

  
228
	
235

  
229 236
    /* (non-Javadoc)
230 237
     * @see com.iver.cit.gvsig.fmap.core.IGeometry#fastIntersects(double, double, double, double)
231 238
     */
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/ISymbol.java
89 89
	XMLEntity getXMLEntity();
90 90

  
91 91
	/**
92
	 * The description is a human-readable text used to
92 93
	 * @return description of this symbol.
93 94
	 */
94 95
	String getDescription();
95 96

  
96 97
	/**
97
	 * TODO este javadoc es poco explicactivo
98
	 * @return true if Shape must be drawn. Useful if you are labelling
98
	 * Tells whether the shape of the symbol will be drawn or not.
99
	 *
100
	 * @return <b>true</b> if Shape must be drawn. Useful if you are labelling
99 101
	 */
100 102
	boolean isShapeVisible();
101 103

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/rendering/VectorialUniqueValueLegend.java
333 333
     */
334 334
    public ISymbol getSymbol(int recordIndex) throws DriverException {
335 335
        try {
336
            Value val = dataSource.getFieldValue(recordIndex, fieldId);
336
        	 Value val = dataSource.getFieldValue(recordIndex, fieldId);
337 337
            ISymbol theSymbol = getSymbolByValue(val);
338 338

  
339 339
            //if (theSymbol != null) {
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/gvsig/gui/styling/SymbolEditor.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.6  2006-11-02 17:19:28  jaume
46
* Revision 1.7  2006-11-06 07:33:54  jaume
47
* javadoc, source style
48
*
49
* Revision 1.6  2006/11/02 17:19:28  jaume
47 50
* *** empty log message ***
48 51
*
49 52
* Revision 1.5  2006/10/31 16:16:34  jaume
......
66 69
package com.iver.cit.gvsig.gvsig.gui.styling;
67 70

  
68 71
import java.awt.BorderLayout;
72
import java.awt.Component;
69 73
import java.awt.Dimension;
70 74
import java.awt.FlowLayout;
71 75
import java.awt.event.ActionEvent;
......
116 120

  
117 121
    private AbstractTypeSymbolEditorPanel[] tabs;
118 122
	private AbstractTypeSymbolEditorPanel[] pointOptions;
123
	private SymbolLayerManager layerManager;
119 124

  
120 125

  
121 126
    public SymbolEditor(ISymbol symbol, int shapeType) {
......
280 285
    private JPanel getPnlLayers() {
281 286
        if (pnlLayers == null) {
282 287
            pnlLayers = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
283
            pnlLayers.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "layers")));
284
            pnlLayers.add(new SymbolLayerManager(this));
288
            pnlLayers.setBorder(
289
            		BorderFactory.createTitledBorder(
290
            				null, PluginServices.getText(this, "layers")));
291
            pnlLayers.add(getLayerManager());
285 292
        }
286 293
        return pnlLayers;
287 294
    }
288 295

  
289 296

  
290
    /**
297
    private SymbolLayerManager getLayerManager() {
298
    	if (layerManager == null) {
299
    		layerManager = new SymbolLayerManager(this);
300
    	}
301
    	return layerManager;
302
    }
303

  
304

  
305
	/**
291 306
     * This method initializes symbolPreview
292 307
     *
293 308
     * @return com.iver.cit.gvsig.gvsig.gui.styling.SymbolPreview
......
391 406
    	doLayout();
392 407
	}
393 408

  
394

  
395 409
	public int getSelectedLayerIndex() {
396
		// TODO de moment zero, per? en un futur s'espera que hi haja m?s d'una capa
397
		return 0;
410
		return getLayerManager().getSelectedLayerIndex();
398 411
	}
399 412

  
400
}  //  @jve:decl-index=0:visual-constraint="10,10"
413
	/**
414
	 * <p>
415
	 * Returns the type of the symbol that this panels is created for.<br>
416
	 * </p>
417
	 * <p>
418
	 * Possible values returned by this method are
419
	 *   <ol>
420
	 *     <li> <b> FShape.POINT </b>, for maker symbols </li>
421
	 *     <li> <b> FShape.POLYGON </b>, for fill symbols </li>
422
	 *     <li> <b> FShape.LINE </b>, for line symbols (not yet implemented) </li>
423
	 *     <li> <b> FShape.TEXT </b>, for text symbols (not yet implemented) </li>
424
	 *     <li> maybe some other in the future </li>
425
	 *   </ol>
426
	 * </p>
427
	 * @return
428
	 */
429
	public int getShapeType() {
430
		return shapeType;
431
	}
432
}
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/gvsig/gui/styling/SymbolLayerManager.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1  2006-11-02 17:19:28  jaume
46
* Revision 1.2  2006-11-06 07:33:54  jaume
47
* javadoc, source style
48
*
49
* Revision 1.1  2006/11/02 17:19:28  jaume
47 50
* *** empty log message ***
48 51
*
49 52
*
......
59 62
import java.awt.LayoutManager;
60 63
import java.awt.event.ActionEvent;
61 64
import java.awt.event.ActionListener;
65
import java.awt.event.MouseAdapter;
66
import java.awt.event.MouseEvent;
62 67
import java.util.ArrayList;
63 68

  
69
import javax.swing.AbstractListModel;
64 70
import javax.swing.BorderFactory;
65
import javax.swing.BoxLayout;
71
import javax.swing.DefaultListCellRenderer;
66 72
import javax.swing.ImageIcon;
67
import javax.swing.JLabel;
68 73
import javax.swing.JList;
69 74
import javax.swing.JPanel;
70
import javax.swing.JScrollBar;
71 75
import javax.swing.JScrollPane;
72
import javax.swing.ListCellRenderer;
73
import javax.swing.ListModel;
74
import javax.swing.border.Border;
75 76
import javax.swing.event.ListDataListener;
76 77
import javax.swing.event.ListSelectionEvent;
77 78
import javax.swing.event.ListSelectionListener;
78 79

  
79 80
import org.gvsig.gui.beans.swing.JButton;
80 81

  
82
import com.iver.andami.PluginServices;
83
import com.iver.cit.gvsig.fmap.core.FShape;
81 84
import com.iver.cit.gvsig.fmap.core.ISymbol;
82 85
import com.iver.cit.gvsig.fmap.core.symbols.CharacterMarkerSymbol;
83 86
import com.iver.cit.gvsig.fmap.core.symbols.SymbolFactory;
84 87
import com.iver.utiles.XMLEntity;
85 88

  
89
/**
90
 * A component linked to a SymbolEditor that shows the layers
91
 *
92
 * @author jaume
93
 *
94
 */
86 95
public class SymbolLayerManager extends JPanel implements ActionListener{
87
	private SymbolEditor owner;
88
	private JList jListLayers;
89
	private ISymbol activeLayer;
90
	private ISymbol symbol;
91
	private JButton btnAddLayer = null;
92
	private JPanel pnlButtons = null;
93
	private JButton btnRemoveLayer = null;
94
	private JButton btnMoveUpLayer = null;
95
	private JButton btnMoveDownLayer = null;
96
	private final Dimension btnDimension = new Dimension(24, 24);
97
	private JScrollPane scroll;
96
    private SymbolEditor owner;
97
    private JList jListLayers;
98
    private ISymbol activeLayer;
99
    private ISymbol symbol;
100
    private JButton btnAddLayer = null;
101
    private JPanel pnlButtons = null;
102
    private JButton btnRemoveLayer = null;
103
    private JButton btnMoveUpLayer = null;
104
    private JButton btnMoveDownLayer = null;
105
    private final Dimension btnDimension = new Dimension(24, 24);
106
    private JScrollPane scroll;
107
    private Color cellSelectedBGColor = Color.BLUE;
98 108

  
99
	public SymbolLayerManager(SymbolEditor owner) {
100
		this.owner = owner;
101
		this.symbol = owner.getSymbol();
102
		initialize();
103
	}
104 109

  
105
	private void initialize() {
110
    public SymbolLayerManager(SymbolEditor owner) {
111
        this.owner = owner;
112
        this.symbol = owner.getSymbol();
113
        initialize();
114
    }
115

  
116
    private void initialize() {
106 117
        this.setLayout(new BorderLayout());
107 118
        this.setSize(new java.awt.Dimension(155,106));
108 119
        this.add(getJScrollPane(), java.awt.BorderLayout.CENTER);
109 120
        this.add(getPnlButtons(), java.awt.BorderLayout.SOUTH);
110
	}
121
    }
111 122

  
112
	private JScrollPane getJScrollPane() {
113
		if (scroll ==  null) {
114
			scroll = new JScrollPane();
115
			scroll.setViewportView(getJListLayers());
116
			scroll.setPreferredSize(new Dimension(120, 160));
117
		}
118
		return scroll;
119
	}
123
    private JScrollPane getJScrollPane() {
124
        if (scroll ==  null) {
125
            scroll = new JScrollPane();
126
            scroll.setViewportView(getJListLayers());
127
            scroll.setPreferredSize(new Dimension(120, 160));
128
        }
129
        return scroll;
130
    }
120 131

  
121
	/**
132
    /**
122 133
     * This method initializes jList
123 134
     *
124 135
     * @return javax.swing.JList
125 136
     */
126 137
    private JList getJListLayers() {
127
    	if (jListLayers == null) {
128
    		jListLayers = new JList();
129
    		jListLayers.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
138
        if (jListLayers == null) {
139
            jListLayers = new JList();
140
            jListLayers.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
130 141
            jListLayers.setLayoutOrientation(JList.HORIZONTAL_WRAP);
131 142

  
132 143
            jListLayers.setVisibleRowCount(-1);
133 144
            jListLayers.addListSelectionListener(new ListSelectionListener() {
134
            	public void valueChanged(ListSelectionEvent e) {
135
            		setLayer((ISymbol) jListLayers.getSelectedValue());
136
            	}
145
                public void valueChanged(ListSelectionEvent e) {
146
                    setLayer((ISymbol) jListLayers.getSelectedValue());
147
                }
137 148
            });
138 149
            jListLayers.setModel(new SymbolLayerListModel(symbol));
139
            jListLayers.setCellRenderer(new ListCellRenderer() {
140
				private Color mySelectedBGColor = Color.BLUE;
150
            jListLayers.setCellRenderer(new DefaultListCellRenderer() {
141 151

  
142
				public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
143
					ISymbol sym = (ISymbol) value;
144
    				JPanel pnl = new JPanel();
145
    				LayoutManager layout = new FlowLayout(FlowLayout.LEFT, 3, 3);
146
    				pnl.setLayout(layout);
147
    				Color bgColor = (isSelected) ? mySelectedBGColor
148
							 : Color.WHITE;
149
    				pnl.setBackground(bgColor);
150
    				SymbolPreview sp = new SymbolPreview();
151
    				sp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
152
    				sp.setAlignmentX(Component.LEFT_ALIGNMENT);
153
    				sp.setPreferredSize(new Dimension(80, 30));
154
    				sp.setSize(new Dimension(80, 30));
155
    				sp.setSymbol(sym);
156
    				sp.setBackground(Color.WHITE);
157
    				pnl.add(sp);
152
                public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
153
                    return getListCell(list, value, index, isSelected, cellHasFocus);
154
                }
158 155

  
159
    				XMLEntity xml = sym.getXMLEntity();
160
    				String source;
161
    				if (xml.contains("locked"))
162
    					source = xml.getBooleanProperty("locked") ?
163
    							"images/locked.png" :
164
    							"images/unlocked.png";
165
    				 else
166
    					source = "images/unlocked.png";
156
            });
167 157

  
168
    				ImageIcon icon = new ImageIcon(getClass().
169
    						getClassLoader().getResource(source));
170
    				JButton btnLock = new JButton(icon);
171
    				btnLock.setSize(btnDimension);
172
    				btnLock.setPreferredSize(btnDimension);
173
    				btnLock.setActionCommand("LOCK");
174
    				btnLock.setBackground(bgColor);
175
    				btnLock.setAlignmentX(Component.CENTER_ALIGNMENT);
176
    				pnl.add(btnLock);
177
    				pnl.setPreferredSize(new Dimension(150,37));
178
    				return pnl;
158
            jListLayers.addMouseListener(new MouseAdapter() {
159
				public void mouseClicked(MouseEvent e) {
160
					if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
161
						SymbolSelector symSel = new SymbolSelector(activeLayer, owner.getShapeType());
162
						PluginServices.getMDIManager().addWindow(symSel);
163
						updateSymbol(symSel.getSymbol());
164
						setLayer(symSel.getSymbol());
165
					}
166

  
179 167
				}
168
            });
169
        }
170
        return jListLayers;
171
    }
180 172

  
181
            });
173
    public Component getListCell(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
174
    	ISymbol sym = (ISymbol) value;
175
        JPanel pnl = new JPanel();
176
        LayoutManager layout = new FlowLayout(FlowLayout.LEFT, 3, 3);
177
        pnl.setLayout(layout);
178
        Color bgColor = (isSelected) ? cellSelectedBGColor
179
                 : Color.WHITE;
180
        pnl.setBackground(bgColor);
181
        SymbolPreview sp = new SymbolPreview();
182
        sp.setBorder(BorderFactory.createLineBorder(Color.BLACK));
183
        sp.setAlignmentX(Component.LEFT_ALIGNMENT);
184
        sp.setPreferredSize(new Dimension(80, 30));
185
        sp.setSize(new Dimension(80, 30));
186
        sp.setSymbol(sym);
187
        sp.setBackground(Color.WHITE);
188
        pnl.add(sp);
189

  
190
        XMLEntity xml = sym.getXMLEntity();
191
        String source;
192
        if (xml.contains("locked"))
193
            source = xml.getBooleanProperty("locked") ?
194
                    "images/locked.png" :
195
                    "images/unlocked.png";
196
         else
197
            source = "images/unlocked.png";
198

  
199
        ImageIcon icon = new ImageIcon(getClass().
200
                getClassLoader().getResource(source));
201
        JButton btnLock = new JButton(icon);
202
        btnLock.setSize(btnDimension);
203
        btnLock.setPreferredSize(btnDimension);
204
        btnLock.setActionCommand("LOCK");
205
        btnLock.setBackground(bgColor);
206
        btnLock.setAlignmentX(Component.CENTER_ALIGNMENT);
207
        pnl.add(btnLock);
208
        pnl.setPreferredSize(new Dimension(150,37));
209
        return pnl;
210
    }
211

  
212
    /**
213
     * replaces current selected layer with this symbol
214
     * @param layer
215
     */
216
    private void updateSymbol(ISymbol layer) {
217
    	if (layer != null) {
218
    		int index = getJListLayers().getSelectedIndex();
219
    		XMLEntity xml = symbol.getXMLEntity();
220
    		ArrayList layers = new ArrayList() ;
221
    		for (int i = 0; i < xml.getChildrenCount(); i++) {
222
    			if (i == index) {
223
    				layers.add(layer.getXMLEntity());
224
    			} else {
225
    				layers.add(xml.getChild(i));
226
    			}
227
    		}
228
    		xml.removeAllChildren();
229
    		for (int i = 0; i < layers.size(); i++) {
230
    			xml.addChild((XMLEntity) layers.get(i));
231
    		}
232
    		symbol.setXMLEntity(xml);
233
    		owner.refresh();
234
    		getJListLayers().repaint();
182 235
    	}
183
    	return jListLayers;
184 236
    }
185 237

  
186
	private void setLayer(ISymbol symbol) {
187
		activeLayer = symbol;
188
	}
238
    private void setLayer(ISymbol symbol) {
239
    	if (symbol!=null) {
240
    		activeLayer = symbol;
189 241

  
190
	/**
191
	 * This method initializes jButton
192
	 *
193
	 * @return javax.swing.JButton
194
	 */
195
	private JButton getBtnAddLayer() {
196
		if (btnAddLayer == null) {
197
			btnAddLayer = new JButton(new ImageIcon(getClass().
198
					getClassLoader().getResource("images/add-layer.png")));
199
			btnAddLayer.setActionCommand("ADD");
200
			btnAddLayer.setSize(btnDimension);
201
			btnAddLayer.setPreferredSize(btnDimension);
202
			btnAddLayer.addActionListener(this);
203
		}
204
		return btnAddLayer;
205
	}
242
    	}
243
    }
206 244

  
207
	/**
208
	 * This method initializes pnlButtons
209
	 *
210
	 * @return javax.swing.JPanel
211
	 */
212
	private JPanel getPnlButtons() {
213
		if (pnlButtons == null) {
214
			pnlButtons = new JPanel();
215
			pnlButtons.add(getBtnAddLayer(), null);
216
			pnlButtons.add(getBtnRemoveLayer(), null);
217
			pnlButtons.add(getBtnMoveUpLayer(), null);
218
			pnlButtons.add(getBtnMoveDown(), null);
219
		}
220
		return pnlButtons;
221
	}
245
    /**
246
     * This method initializes jButton
247
     *
248
     * @return javax.swing.JButton
249
     */
250
    private JButton getBtnAddLayer() {
251
        if (btnAddLayer == null) {
252
            btnAddLayer = new JButton(new ImageIcon(getClass().
253
                    getClassLoader().getResource("images/add-layer.png")));
254
            btnAddLayer.setActionCommand("ADD");
255
            btnAddLayer.setSize(btnDimension);
256
            btnAddLayer.setPreferredSize(btnDimension);
257
            btnAddLayer.addActionListener(this);
258
        }
259
        return btnAddLayer;
260
    }
222 261

  
223
	/**
224
	 * This method initializes jButton1
225
	 *
226
	 * @return javax.swing.JButton
227
	 */
228
	private JButton getBtnRemoveLayer() {
229
		if (btnRemoveLayer == null) {
230
			btnRemoveLayer = new JButton(new ImageIcon(getClass().
231
					getClassLoader().getResource("images/delete.png")));
232
			btnRemoveLayer.setActionCommand("REMOVE");
233
			btnRemoveLayer.setSize(btnDimension);
234
			btnRemoveLayer.setPreferredSize(btnDimension);
235
			btnRemoveLayer.addActionListener(this);
236
		}
237
		return btnRemoveLayer;
238
	}
262
    /**
263
     * This method initializes pnlButtons
264
     *
265
     * @return javax.swing.JPanel
266
     */
267
    private JPanel getPnlButtons() {
268
        if (pnlButtons == null) {
269
            pnlButtons = new JPanel();
270
            pnlButtons.add(getBtnAddLayer(), null);
271
            pnlButtons.add(getBtnRemoveLayer(), null);
272
            pnlButtons.add(getBtnMoveUpLayer(), null);
273
            pnlButtons.add(getBtnMoveDown(), null);
274
        }
275
        return pnlButtons;
276
    }
239 277

  
240
	/**
241
	 * This method initializes jButton2
242
	 *
243
	 * @return javax.swing.JButton
244
	 */
245
	private JButton getBtnMoveUpLayer() {
246
		if (btnMoveUpLayer == null) {
247
			btnMoveUpLayer = new JButton(new ImageIcon(getClass().
248
					getClassLoader().getResource("images/up-arrow.png")));
249
			btnMoveUpLayer.setActionCommand("MOVE_UP");
250
			btnMoveUpLayer.setSize(btnDimension);
251
			btnMoveUpLayer.setPreferredSize(btnDimension);
252
			btnMoveUpLayer.addActionListener(this);
253
		}
254
		return btnMoveUpLayer;
255
	}
278
    /**
279
     * This method initializes jButton1
280
     *
281
     * @return javax.swing.JButton
282
     */
283
    private JButton getBtnRemoveLayer() {
284
        if (btnRemoveLayer == null) {
285
            btnRemoveLayer = new JButton(new ImageIcon(getClass().
286
                    getClassLoader().getResource("images/delete.png")));
287
            btnRemoveLayer.setActionCommand("REMOVE");
288
            btnRemoveLayer.setSize(btnDimension);
289
            btnRemoveLayer.setPreferredSize(btnDimension);
290
            btnRemoveLayer.addActionListener(this);
291
        }
292
        return btnRemoveLayer;
293
    }
256 294

  
257
	/**
258
	 * This method initializes jButton3
259
	 *
260
	 * @return javax.swing.JButton
261
	 */
262
	private JButton getBtnMoveDown() {
263
		if (btnMoveDownLayer == null) {
264
			btnMoveDownLayer = new JButton(new ImageIcon(getClass().
265
					getClassLoader().getResource("images/down-arrow.png")));
266
			btnMoveDownLayer.setActionCommand("MOVE_DOWN");
267
			btnMoveDownLayer.setSize(btnDimension);
268
			btnMoveDownLayer.setPreferredSize(btnDimension);
269
			btnMoveDownLayer.addActionListener(this);
270
		}
271
		return btnMoveDownLayer;
272
	}
295
    /**
296
     * This method initializes jButton2
297
     *
298
     * @return javax.swing.JButton
299
     */
300
    private JButton getBtnMoveUpLayer() {
301
        if (btnMoveUpLayer == null) {
302
            btnMoveUpLayer = new JButton(new ImageIcon(getClass().
303
                    getClassLoader().getResource("images/up-arrow.png")));
304
            btnMoveUpLayer.setActionCommand("MOVE_UP");
305
            btnMoveUpLayer.setSize(btnDimension);
306
            btnMoveUpLayer.setPreferredSize(btnDimension);
307
            btnMoveUpLayer.addActionListener(this);
308
        }
309
        return btnMoveUpLayer;
310
    }
273 311

  
274
	public void actionPerformed(ActionEvent e) {
275
		String command = e.getActionCommand();
276
		XMLEntity xml = symbol.getXMLEntity();
277
		int index = getJListLayers().getSelectedIndex();
278
		if (command.equals("ADD")) {
279
			xml.addChild(new CharacterMarkerSymbol(new Font("Arial", Font.PLAIN, 10), (int) 'a', Color.BLACK).getXMLEntity());
280
			index = xml.getChildrenCount()-1;
281
		} else if (command.equals("REMOVE")) {
282
			xml.removeChild(getJListLayers().getSelectedIndex());
283
		} else if (command.equals("MOVE_UP")) {
284
			if (index>0) {
285
				ArrayList layers = new ArrayList();
286
				for (int i = 0; i < xml.getChildrenCount(); i++) {
287
					if (i == index)
288
						layers.add(i-1, xml.getChild(i));
289
					else
290
						layers.add(xml.getChild(i));
291
				}
292
				xml.removeAllChildren();
293
				for (int i = 0; i < layers.size(); i++) {
294
					xml.addChild((XMLEntity) layers.get(i));
295
				}
296
				index --;
297
			}
298
		} else if (command.equals("MOVE_DOWN")) {
299
			if (index < xml.getChildrenCount()-1) {
300
				ArrayList layers = new ArrayList();
301
				for (int i = 0; i < xml.getChildrenCount(); i++) {
302
					if (i == index) {
303
						layers.add(i, xml.getChild(i+1));
304
						layers.add(i+1, xml.getChild(i));
305
						i++;
306
					}
307
					else
308
						layers.add(xml.getChild(i));
309
				}
310
				xml.removeAllChildren();
311
				for (int i = 0; i < layers.size(); i++) {
312
					xml.addChild((XMLEntity) layers.get(i));
313
				}
314
				index++;
315
			}
316
		} else if (command.equals("LOCK")) {
317
			XMLEntity layerXML = xml.getChild(index);
318
			boolean locked = !xml.contains("locked") || !xml.getBooleanProperty("locked");
319
			layerXML.putProperty("locked", locked);
320
		}
321
		getJListLayers().setSelectedIndex(index);
322
		symbol.setXMLEntity(xml);
323
		owner.refresh();
324
//		getJListLayers().setSelectedIndex(index);
325
	}
312
    /**
313
     * This method initializes jButton3
314
     *
315
     * @return javax.swing.JButton
316
     */
317
    private JButton getBtnMoveDown() {
318
        if (btnMoveDownLayer == null) {
319
            btnMoveDownLayer = new JButton(new ImageIcon(getClass().
320
                    getClassLoader().getResource("images/down-arrow.png")));
321
            btnMoveDownLayer.setActionCommand("MOVE_DOWN");
322
            btnMoveDownLayer.setSize(btnDimension);
323
            btnMoveDownLayer.setPreferredSize(btnDimension);
324
            btnMoveDownLayer.addActionListener(this);
325
        }
326
        return btnMoveDownLayer;
327
    }
326 328

  
327
	public int getSelectedLayerIndex() {
328
		/*int i = getJListLayers().getSelectedIndex();
329
		if (i==-1 && symbol.getXMLEntity().getChildrenCount()==0)
330
			i = 0;
331
		return i;*/
332
		return getJListLayers().getSelectedIndex();
333
	}
329
    public void actionPerformed(ActionEvent e) {
330
        String command = e.getActionCommand();
331
        XMLEntity xml = symbol.getXMLEntity();
332
        int index = getJListLayers().getSelectedIndex();
333
        if (command.equals("ADD")) {
334
            xml.addChild(new CharacterMarkerSymbol(new Font("Arial", Font.PLAIN, 10), (int) 'a', Color.BLACK).getXMLEntity());
335
            index = xml.getChildrenCount()-1;
336
        } else if (command.equals("REMOVE")) {
337
        	try {
338
        		xml.removeChild(getJListLayers().getSelectedIndex());
339
        	} catch (Exception ex) {
340
        		// Index out of bounds or so, we don't care
341
        	}
342
        } else if (command.equals("MOVE_UP")) {
343
            if (index>0) {
344
                ArrayList layers = new ArrayList();
345
                for (int i = 0; i < xml.getChildrenCount(); i++) {
346
                    if (i == index)
347
                        layers.add(i-1, xml.getChild(i));
348
                    else
349
                        layers.add(xml.getChild(i));
350
                }
351
                xml.removeAllChildren();
352
                for (int i = 0; i < layers.size(); i++) {
353
                    xml.addChild((XMLEntity) layers.get(i));
354
                }
355
                index --;
356
            }
357
        } else if (command.equals("MOVE_DOWN")) {
358
            if (index < xml.getChildrenCount()-1) {
359
                ArrayList layers = new ArrayList();
360
                for (int i = 0; i < xml.getChildrenCount(); i++) {
361
                    if (i == index) {
362
                        layers.add(i, xml.getChild(i+1));
363
                        layers.add(i+1, xml.getChild(i));
364
                        i++;
365
                    }
366
                    else
367
                        layers.add(xml.getChild(i));
368
                }
369
                xml.removeAllChildren();
370
                for (int i = 0; i < layers.size(); i++) {
371
                    xml.addChild((XMLEntity) layers.get(i));
372
                }
373
                index++;
374
            }
375
        } else if (command.equals("LOCK")) {
376
            try {
377
                XMLEntity layerXML = xml.getChild(index);
378
                boolean locked = !xml.contains("locked") || !xml.getBooleanProperty("locked");
379
                layerXML.putProperty("locked", locked);
380
            } catch (Exception ex) {
381
                // Index out of bounds or so, we don't care
382
            }
383
        }
384
        symbol.setXMLEntity(xml);
385
        getJListLayers().setSelectedIndex(index);
386
        owner.refresh();
387
        getJListLayers().repaint();
388
    }
389

  
390
    public int getSelectedLayerIndex() {
391
        /*int i = getJListLayers().getSelectedIndex();
392
        if (i==-1 && symbol.getXMLEntity().getChildrenCount()==0)
393
            i = 0;
394
        return i;*/
395
        return getJListLayers().getSelectedIndex();
396
    }
334 397
}
335 398

  
336
class SymbolLayerListModel implements ListModel {
399
class SymbolLayerListModel extends AbstractListModel {
337 400

  
338
	private ISymbol symbol;
401
    private ISymbol symbol;
339 402

  
340
	public SymbolLayerListModel(ISymbol symbol) {
341
		this.symbol = symbol;
342
	}
403
    public SymbolLayerListModel(ISymbol symbol) {
404
        this.symbol = symbol;
405
    }
343 406

  
344
	public int getSize() {
345
		return symbol.getXMLEntity().getChildrenCount();
346
	}
407
    public int getSize() {
408
        return symbol.getXMLEntity().getChildrenCount();
409
    }
347 410

  
348
	public Object getElementAt(int index) {
349
		XMLEntity xml = symbol.getXMLEntity();
350
		return SymbolFactory.createFromXML(xml.getChild(index));
351
	}
411
    public Object getElementAt(int index) {
412
        XMLEntity xml = symbol.getXMLEntity();
413
        return SymbolFactory.createFromXML(xml.getChild(index));
414
    }
352 415

  
353
	public void addListDataListener(ListDataListener l) {
354
		// TODO Auto-generated method stub
355
	}
416
    public void addListDataListener(ListDataListener l) {
417
        throw new Error("List data listeners not yet supported for LayerManager");
418
    }
356 419

  
357
	public void removeListDataListener(ListDataListener l) {
358
		// TODO Auto-generated method stub
420
    public void removeListDataListener(ListDataListener l) {
421
        throw new Error("List data listeners not yet supported for LayerManager");
422
    }
359 423

  
360
	}
361

  
362 424
}
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/gvsig/gui/styling/SymbolSelectorListModel.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.4  2006-11-02 17:19:28  jaume
46
* Revision 1.5  2006-11-06 07:33:54  jaume
47
* javadoc, source style
48
*
49
* Revision 1.4  2006/11/02 17:19:28  jaume
47 50
* *** empty log message ***
48 51
*
49 52
* Revision 1.3  2006/10/30 19:30:35  jaume
......
79 82
import org.exolab.castor.xml.MarshalException;
80 83
import org.exolab.castor.xml.ValidationException;
81 84

  
85
import com.iver.andami.messages.NotificationManager;
82 86
import com.iver.cit.gvsig.fmap.core.ISymbol;
83 87
import com.iver.cit.gvsig.fmap.core.symbols.SymbolFactory;
84 88
import com.iver.utiles.XMLEntity;
......
142 146
					xml = new XMLEntity((XmlTag) XmlTag.unmarshal(new FileReader(ff[i])));
143 147
					add(SymbolFactory.createFromXML(xml));
144 148
				} catch (MarshalException e) {
145
					// TODO Auto-generated catch block
146
					e.printStackTrace();
149
					NotificationManager.
150
						addWarning("Error in file ["+ff[i].getAbsolutePath()+"]. " +
151
								"File corrupted! Skiping it...", e);
147 152
				} catch (ValidationException e) {
148
					// TODO Auto-generated catch block
149
					e.printStackTrace();
153
					NotificationManager.
154
						addWarning("Error validating symbol file ["+ff[i].getAbsolutePath()+"].", e);
150 155
				} catch (FileNotFoundException e) {
151
					// TODO Auto-generated catch block
152
					e.printStackTrace();
156
					// unreachable code, but anyway...
157
					NotificationManager.
158
						addWarning("File not found: "+ ff[i].getAbsolutePath(), e);
153 159
				}
154 160

  
155 161
			}
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/gvsig/gui/styling/SymbolSelector.java
234 234
    				}
235 235

  
236 236
    				public void addTreeModelListener(TreeModelListener l) {
237
    					// TODO Auto-generated method stub
237
    					// TODO Necessite?
238 238

  
239 239
    				}
240 240

  
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/fmap/core/symbols/SymbolFactory.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1  2006-10-30 19:30:35  jaume
46
* Revision 1.2  2006-11-06 07:33:54  jaume
47
* javadoc, source style
48
*
49
* Revision 1.1  2006/10/30 19:30:35  jaume
47 50
* *** empty log message ***
48 51
*
49 52
*
50 53
*/
51 54
package com.iver.cit.gvsig.fmap.core.symbols;
52 55

  
56
import com.iver.andami.messages.NotificationManager;
53 57
import com.iver.cit.gvsig.fmap.core.ISymbol;
58
import com.iver.utiles.NotExistInXMLEntity;
54 59
import com.iver.utiles.XMLEntity;
55 60

  
61
/**
62
 * Factory for obtaining ISymbols of any kind from several sources like.
63
 * <ol>
64
 * 	<li>
65
 * 		<b>XMLEntity's</b> that, at least, contains a full class name
66
 * 			string property that defines which class handles such symbol.
67
 *  </li>
68
 * </ol>
69
 *
70
 * @author jaume dominguez faus - jaume.dominguez@iver.es
71
 */
56 72
public class SymbolFactory {
73
	/**
74
	 * Factory that allows to create ISymbol from an ISymbol xml
75
	 * descriptor. A barely specific XMLEntity object
76
	 */
77
	public static ISymbol createFromXML(XMLEntity xml) {
78
		String className = null;
79
		try {
80
			className = xml.getStringProperty("className");
81
		} catch (NotExistInXMLEntity e) {
82
			NotificationManager.
83
				addError("Symbol class name not set.\n" +
84
						" Maybe you forgot to add the" +
85
						" putProperty(\"className\", yourClassName)" +
86
						" call in the getXMLEntity method of your symbol", e);
87
		}
57 88

  
58
	public static ISymbol createFromXML(XMLEntity xml) {
59
		Class clazz;
89
		Class clazz = null;
60 90
		ISymbol sym = null;
61 91

  
62 92
		try {
63
			clazz = Class.forName(xml.getStringProperty("className"));
93
			clazz = Class.forName(className);
64 94
			sym = (ISymbol) clazz.newInstance();
65 95
			sym.setXMLEntity(xml);
66 96
		} catch (InstantiationException e) {
67
			// TODO Auto-generated catch block
68
			e.printStackTrace();
97
			NotificationManager.
98
				addError("Trying to instantiate an interface" +
99
						" or abstract class + "+className, e);
69 100
		} catch (IllegalAccessException e) {
70
			// TODO Auto-generated catch block
71
			e.printStackTrace();
101
			NotificationManager.addError(null, e);
72 102
		} catch (ClassNotFoundException e) {
73
			// TODO Auto-generated catch block
74
			e.printStackTrace();
103
			NotificationManager.addError("No class called " + className +
104
					" was found.\nCheck the following.\n" +
105
					"\t- The fullname of the class you're looking " +
106
						"for matches the value in the className " +
107
						"property of the XMLEntity ("+className+").\n" +
108
					"\t- The jar file containing your symbol class is in" +
109
						"the application classpath", e);
75 110
		}
76 111
		return sym;
77 112
	}
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/fmap/core/symbols/MarkerFillSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2  2006-10-31 16:16:34  jaume
46
* Revision 1.3  2006-11-06 07:33:54  jaume
47
* javadoc, source style
48
*
49
* Revision 1.2  2006/10/31 16:16:34  jaume
47 50
* *** empty log message ***
48 51
*
49 52
* Revision 1.1  2006/10/30 19:30:35  jaume
......
57 60
import java.awt.Graphics2D;
58 61
import java.awt.Rectangle;
59 62
import java.awt.Shape;
63
import java.awt.TexturePaint;
60 64
import java.awt.geom.AffineTransform;
61 65
import java.awt.geom.Point2D;
62 66
import java.util.ArrayList;
......
74 78
	private double xSeparation = 20;
75 79
	private double ySeparation = 20;
76 80
	private Dimension markerSize = new Dimension(7,7);
81
	private TexturePaint texture;
77 82

  
78 83
	public boolean isGrid() {
79 84
		return grid;
......
106 111
	public void setRotation(double rotation) {
107 112
		this.rotation = rotation;
108 113
	}
109

  
114
	
110 115
	public double getXOffset() {
111 116
		return xOffset;
112 117
	}
trunk/extensions/extGraph_predes/src/com/iver/cit/gvsig/fmap/core/symbols/AbstractFillSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2  2006-10-31 16:16:34  jaume
46
* Revision 1.3  2006-11-06 07:33:54  jaume
47
* javadoc, source style
48
*
49
* Revision 1.2  2006/10/31 16:16:34  jaume
47 50
* *** empty log message ***
48 51
*
49 52
* Revision 1.1  2006/10/30 19:30:35  jaume
......
61 64

  
62 65
public abstract class AbstractFillSymbol implements ISymbol {
63 66
	Color color;
64
	Color outline; // aix? canviar? a AbsrtactLineSymbol quan existisca
67
	Color outline; // TODO aix? canviar? a AbsrtactLineSymbol quan existisca
65 68
	protected boolean isShapeVisible;
66 69
	protected String desc;
67 70
	protected ISymbol[] layers;

Also available in: Unified diff