Revision 10450

View differences:

branches/simbologia/applications/appgvSIG/src/com/iver/cit/gvsig/gui/styling/SimpleFill.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1.2.3  2007-02-21 07:35:14  jaume
46
* Revision 1.1.2.4  2007-02-21 16:09:35  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.1.2.3  2007/02/21 07:35:14  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.1.2.2  2007/02/08 15:43:05  jaume
50 53
* some bug fixes in the editor and removed unnecessary imports
51 54
*
......
71 74
*/
72 75
package com.iver.cit.gvsig.gui.styling;
73 76

  
77
import java.awt.Color;
74 78
import java.awt.Dimension;
75 79
import java.awt.FlowLayout;
76 80
import java.awt.event.ActionEvent;
......
78 82
import java.util.ArrayList;
79 83

  
80 84
import javax.swing.JPanel;
85
import javax.swing.JSlider;
86
import javax.swing.event.ChangeEvent;
87
import javax.swing.event.ChangeListener;
81 88

  
82 89
import org.gvsig.gui.beans.swing.GridBagLayoutPanel;
90
import org.gvsig.gui.beans.swing.JBlank;
83 91

  
84
import sun.security.action.GetBooleanAction;
85

  
86 92
import com.iver.andami.PluginServices;
87 93
import com.iver.andami.messages.NotificationManager;
88 94
import com.iver.cit.gvsig.fmap.core.FShape;
......
91 97
import com.iver.cit.gvsig.fmap.core.symbols.SimpleFillSymbol;
92 98
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
93 99
import com.iver.cit.gvsig.project.documents.view.legend.gui.JSymbolPreviewButton;
100
import com.lowagie.tools.plugins.treeview.OutlinelistTreeNode;
94 101

  
95 102
import de.ios.framework.swing.JDecimalField;
96 103

  
97
public class SimpleFill extends AbstractTypeSymbolEditorPanel implements ActionListener {
104
public class SimpleFill extends AbstractTypeSymbolEditorPanel implements ActionListener, ChangeListener {
98 105
	private static final String NAME = PluginServices.
99 106
		getText(SimpleFill.class, "simple_fill");
100 107
	private ColorChooserPanel jccFillColor;
101 108
	private JDecimalField txtOutlineWidth;
102 109
	private ArrayList tabs = new ArrayList();
103 110
	private JSymbolPreviewButton btnOutline;
111
	private JSlider sldFillTransparency;
112
	private JSlider sldOutlineTransparency;
113
	private int outlineAlpha, fillAlpha;
104 114
	
105 115
	public SimpleFill(SymbolEditor owner) {
106 116
		super(owner);
......
119 129
		JPanel myTab = new JPanel(new FlowLayout(FlowLayout.LEADING, 5,5));
120 130
		myTab.setName(PluginServices.getText(this, "simple_fill"));
121 131
		GridBagLayoutPanel aux = new GridBagLayoutPanel();
132
		
122 133
		jccFillColor = new ColorChooserPanel();
123 134
		jccFillColor.setAlpha(255);
124

  
135
		sldFillTransparency = new JSlider();
136
		sldFillTransparency.setValue(100);
137
		aux.addComponent(PluginServices.getText(this, "fill_color"), jccFillColor);
138
		aux.addComponent(PluginServices.getText(this, "fill_opacity"), sldFillTransparency);
139
		aux.addComponent(new JBlank(30, 30));
140
		
125 141
		btnOutline = new JSymbolPreviewButton(FShape.LINE);
126 142
		btnOutline.setPreferredSize(new Dimension(100, 35));
127
		
143
		sldOutlineTransparency = new JSlider();
144
		sldOutlineTransparency.setValue(100);
128 145
		aux.addComponent(PluginServices.getText(this, "outline")+":",
129 146
				btnOutline	);
147
		aux.addComponent(PluginServices.getText(this, "transparency_opacity"), sldOutlineTransparency);
130 148
		txtOutlineWidth = new JDecimalField(25);
131 149
		// TODO restore previous outline width
132 150
		aux.addComponent(PluginServices.getText(this, "outline_width")+":",
......
135 153
		myTab.add(aux);
136 154

  
137 155
		jccFillColor.addActionListener(this);
156
		sldFillTransparency.addChangeListener(this);
138 157
		btnOutline.addActionListener(this);
139 158
		txtOutlineWidth.addActionListener(this);
159
		sldOutlineTransparency.addChangeListener(this);
140 160
		tabs.add(myTab);
141 161
	}
142 162

  
143 163
	public ISymbol getLayer() {
144 164
		SimpleFillSymbol sfs = new SimpleFillSymbol();
145
		sfs.setOutline((ILineSymbol) btnOutline.getSymbol());
146
		sfs.setFillColor(jccFillColor.getColor());
165
		ILineSymbol outline =(ILineSymbol) btnOutline.getSymbol(); 
166
		
167
		if (outline!=null) {
168
			outline.setAlpha(outlineAlpha);
169
			sfs.setOutline(outline);
170
		}
171
		
172
		Color c = jccFillColor.getColor();
173
		c = new Color(c.getRed(), c.getBlue(), c.getGreen(), fillAlpha);
174
		sfs.setFillColor(c);
147 175
		return sfs;
148 176
	}
149 177

  
......
155 183
			} else {
156 184
				sym = (SimpleFillSymbol) layer;
157 185
				jccFillColor.setColor(sym.getFillColor());
186
				sldFillTransparency.setValue((sym.getFillColor().getAlpha()/255)*100);
158 187
				btnOutline.setSymbol(sym.getOutline());
188
				ILineSymbol outline = sym.getOutline();
189
				if (outline != null) {
190
					outlineAlpha = outline.getAlpha(); 
191
					sldOutlineTransparency.setValue((outlineAlpha/255)*100);
192
				} else {
193
					sldOutlineTransparency.setValue(100);
194
				}
159 195
			}
160 196
		} catch (IndexOutOfBoundsException ioEx) {
161 197
			NotificationManager.addWarning("Symbol layer index out of bounds", ioEx);
......
174 210
	public void actionPerformed(ActionEvent e) {
175 211
		fireSymbolChangedEvent();
176 212
	}
213

  
214
	public void stateChanged(ChangeEvent e) {
215
		Object s = e.getSource();
216
		if (s.equals(sldFillTransparency)) {
217
			fillAlpha = (int) (255*(sldFillTransparency.getValue()/100.0));
218
		} else if (s.equals(sldOutlineTransparency)) {
219
			outlineAlpha = (int) (255*(sldOutlineTransparency.getValue()/100.0));
220
		}
221
		fireSymbolChangedEvent();
222
	}
177 223
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/v02/FConstant.java
147 147
	public FConstant() {
148 148
		if (NAMES == null) {
149 149
			int i = 0;
150
			NAMES = new String[9];
150
			NAMES = new String[10];
151 151
			NAMES[i++] = "Kilometros";
152 152
			NAMES[i++] = "Metros";
153 153
			NAMES[i++] = "Centimetros";
......
157 157
			NAMES[i++] = "Pies";
158 158
			NAMES[i++] = "Pulgadas";
159 159
			NAMES[i++] = "Grados";
160
			NAMES[i++] = "Coordenadas";
160 161
		}
161 162
	}
162 163
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/DotDensityFillSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.3.2.3  2007-02-16 10:54:12  jaume
46
* Revision 1.3.2.4  2007-02-21 16:09:02  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.3.2.3  2007/02/16 10:54:12  jaume
47 50
* multilayer splitted to multilayerline, multilayermarker,and  multilayerfill
48 51
*
49 52
* Revision 1.3.2.2  2007/02/15 16:23:44  jaume
......
277 280

  
278 281
	}
279 282

  
283
	
280 284
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerFillSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1.2.2  2007-02-21 07:34:09  jaume
46
* Revision 1.1.2.3  2007-02-21 16:09:02  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.1.2.2  2007/02/21 07:34:09  jaume
47 50
* labeling starts working
48 51
*
49 52
* Revision 1.1.2.1  2007/02/16 10:54:12  jaume
......
259 262
		layers = (IFillSymbol[])lst.toArray(new IFillSymbol[0]);
260 263
		return contains;
261 264
	}
265

  
266
	public int getFillAlpha() {
267
		// will compute the acumulated opacity
268
		double myAlpha = 0;
269
		for (int i = 0; i < layers.length; i++) {
270
			double layerAlpha = layers[i].getFillAlpha()/255D;
271
			myAlpha += (1-myAlpha)*layerAlpha;
272
		}
273
		int result = (int) Math.round(myAlpha * 255); 
274
		return (result>255) ? 255 : result;
275
	}
262 276
	
263 277
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/MultiLayerLineSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1.2.2  2007-02-21 07:34:09  jaume
46
* Revision 1.1.2.3  2007-02-21 16:09:02  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.1.2.2  2007/02/21 07:34:09  jaume
47 50
* labeling starts working
48 51
*
49 52
* Revision 1.1.2.1  2007/02/16 10:54:12  jaume
......
270 273
		return contains;
271 274
	}
272 275

  
276
	public int getAlpha() {
277
		// will compute the acumulated opacity
278
		double myAlpha = 0;
279
		for (int i = 0; i < layers.length; i++) {
280
			double layerAlpha = layers[i].getAlpha()/255D;
281
			myAlpha += (1-myAlpha)*layerAlpha;
282
		}
283
		int result = (int) Math.round(myAlpha * 255); 
284
		return (result>255) ? 255 : result;
285
	}
273 286
	
287
	public void setAlpha(int outlineAlpha) {
288
		// first, get the biggest alpha in the layers and the index if such layer
289
		int maxAlpha = Integer.MIN_VALUE;
290
		int maxAlphaLayerIndex = 0;
291
		for (int i = 0; i < layers.length; i++) {
292
			if (layers[i].getAlpha() > maxAlpha) {
293
				maxAlpha = layers[i].getAlpha();
294
				maxAlphaLayerIndex = i;
295
			}
296
		}
297
		
298
		// now, max alpha takes the value of the desired alpha and the rest
299
		// will take a scaled (to biggest alpha) alpha value
300
		for (int i = 0; i < layers.length; i++) {
301
			if (i!=maxAlphaLayerIndex) {
302
				double scaledAlpha = (double) layers[i].getAlpha()/maxAlpha;
303
				layers[i].setAlpha((int) (outlineAlpha*scaledAlpha));
304
			} else {
305
				layers[i].setAlpha(outlineAlpha);
306
			}
307
		}
308
		
309
	}
310
	
311
	
274 312
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/IFillSymbol.java
43 43
 *
44 44
 * $Id$
45 45
 * $Log$
46
 * Revision 1.1.2.1  2007-02-16 10:54:12  jaume
46
 * Revision 1.1.2.2  2007-02-21 16:09:02  jaume
47
 * *** empty log message ***
48
 *
49
 * Revision 1.1.2.1  2007/02/16 10:54:12  jaume
47 50
 * multilayer splitted to multilayerline, multilayermarker,and  multilayerfill
48 51
 *
49 52
 *
......
84 87
	 */
85 88
	public abstract ILineSymbol getOutline();
86 89

  
90
	public abstract int getFillAlpha();
91
	
87 92
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/ILineSymbol.java
43 43
 *
44 44
 * $Id$
45 45
 * $Log$
46
 * Revision 1.1.2.4  2007-02-15 16:23:44  jaume
46
 * Revision 1.1.2.5  2007-02-21 16:09:02  jaume
47 47
 * *** empty log message ***
48 48
 *
49
 * Revision 1.1.2.4  2007/02/15 16:23:44  jaume
50
 * *** empty log message ***
51
 *
49 52
 * Revision 1.1.2.3  2007/02/14 15:53:35  jaume
50 53
 * *** empty log message ***
51 54
 *
......
102 105
	 */
103 106
	public abstract double getWidth();
104 107

  
108
	public abstract int getAlpha();
109

  
110
	public abstract void setAlpha(int outlineAlpha);
105 111
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/AbstractFillSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.3.2.1  2007-02-16 10:54:12  jaume
46
* Revision 1.3.2.2  2007-02-21 16:09:02  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.3.2.1  2007/02/16 10:54:12  jaume
47 50
* multilayer splitted to multilayerline, multilayermarker,and  multilayerfill
48 51
*
49 52
* Revision 1.3  2007/01/24 17:58:22  jaume
......
121 124
	public ILineSymbol getOutline() {
122 125
		return outline;
123 126
	}
127
	
128
	public int getFillAlpha() {
129
		return color.getAlpha();
130
	}
124 131
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/symbols/AbstractLineSymbol.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2.2.2  2007-02-15 16:23:44  jaume
46
* Revision 1.2.2.3  2007-02-21 16:09:02  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.2.2.2  2007/02/15 16:23:44  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.2.2.1  2007/02/09 07:47:04  jaume
50 53
* Isymbol moved
51 54
*
......
145 148
	public void setLineStyle(ILineStyle lineStyle) {
146 149
		this.lineStyle = lineStyle;
147 150
	}
151
	
152
	public int getAlpha() {
153
		return color.getAlpha();
154
	}
155
	
156
	public void setAlpha(int outlineAlpha) {
157
		color = new Color(color.getRed(), color.getGreen(), color.getBlue(), outlineAlpha);
158
	}
148 159

  
149 160
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/MapContext.java
88 88
 */
89 89
public class MapContext implements Projected {
90 90
	public static final double[] CHANGEM = { 1000, 1, 0.01, 0.001, 1609.344,
91
			0.9144, 0.3048, 0.0254 };
91
			0.9144, 0.3048, 0.0254, 1/8.983152841195214E-6 };
92 92

  
93 93
	public static final double[] CHANGE = { 100000, 100, 1, 0.1, 160934.4,
94
			91.44, 30.48, 2.54 };
94
			91.44, 30.48, 2.54, 1/8.983152841195214E-4 };
95 95

  
96 96
	public static final int EQUALS = 0;
97 97

  
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/MemoryDriver.java
47 47
package com.iver.cit.gvsig.fmap.drivers;
48 48

  
49 49
import java.awt.geom.Rectangle2D;
50
import java.io.File;
51 50
import java.io.IOException;
52 51
import java.sql.Types;
53 52
import java.util.ArrayList;
......
58 57
import com.hardcode.gdbms.engine.data.DataSourceFactory;
59 58
import com.hardcode.gdbms.engine.data.driver.DriverException;
60 59
import com.hardcode.gdbms.engine.data.driver.ObjectDriver;
60
import com.hardcode.gdbms.engine.values.StringValue;
61 61
import com.hardcode.gdbms.engine.values.Value;
62 62
import com.iver.cit.gvsig.fmap.core.FShape;
63 63
import com.iver.cit.gvsig.fmap.core.IGeometry;
......
79 79
	private Rectangle2D fullExtent;
80 80
	private int m_Position;
81 81
	private DefaultTableModel m_TableModel = new DefaultTableModel();
82

  
82
	private int[] fieldWidth=null;
83
	
83 84
	/**
84 85
	 * Devuelve el modelo de la tabla.
85 86
	 *
......
103 104
		Rectangle2D boundsShp = geom.getBounds();
104 105
		memShapeInfo.addShapeInfo(boundsShp, geom.getGeometryType());
105 106
		arrayGeometries.add(geom);
107
		if (fieldWidth==null) {
108
			initializeFieldWidth(row);
109
		}
110
		actualizeFieldWidth(row);
106 111
		m_TableModel.addRow(row);
107 112

  
108 113
		try {
......
120 125
		m_Position++;
121 126
	}
122 127

  
123
	
128

  
124 129
	/**
125 130
	 * M?todo de conveniencia, para poder a?adir directamente un shape
126 131
	 * o una IGeometry. (Arriba est? el de a?adir una IGeometry.
......
132 137
			return; // No a?adimos nada
133 138
		}
134 139
		IGeometry geom = ShapeFactory.createGeometry(shp);
135
		
140

  
136 141
		addGeometry(geom, row);
137 142
	}
138 143

  
......
203 208
	/**
204 209
	 * @see com.hardcode.gdbms.engine.data.ReadDriver#getFieldType(int)
205 210
	 */
206
	
211

  
207 212
/*
208 213
 * azabala, bug 666
209 214
 * Habra que estudiar como hacer, porque si una fila tiene el primer valor
210 215
 * (o todos) a NullValue, devolvera como tipo de dato Types.NULL.
211 216
 * Quizas, habra que hacer que los MemoryDriver tb tengan un ITableDefinition.
212
 * 
217
 *
213 218
 * DxfMemoryDriver no obstante si que tiene informacion sobre el esquema, asi
214 219
 * que debera sobreescribir este metodo para salvar el bug
215 220
 * (metodo getTableDefinition)
216
 * 
217
 * 
218
 * 
219
 * 
221
 *
222
 *
223
 *
224
 *
220 225
 */
221 226
	public int getFieldType(int i) throws DriverException {
222 227
	    // TODO: Revisar esto. Por ejemplo, el long
......
232 237
        }
233 238
        else
234 239
        {
235
            // TODO: ESTO CREO QUE NO TIENE SENTIDO. SIEMPRE DEVUELVE Object.class, lo dice en 
240
            // TODO: ESTO CREO QUE NO TIENE SENTIDO. SIEMPRE DEVUELVE Object.class, lo dice en
236 241
            // la documentaci?n. Creo que habr?a que quitarlo.
237 242
    	    if (m_TableModel.getColumnClass(i) == String.class)
238 243
    	        return Types.VARCHAR;
......
248 253
    	        return Types.BIT;
249 254
    	    if (m_TableModel.getColumnClass(i) == Date.class)
250 255
    	        return Types.DATE;
251
        }	    
256
        }
252 257
	    return Types.VARCHAR;
253 258
	    // return m_TableModel.getColumnClass(i);
254 259
//	    throw new DriverException("Tipo no soportado: " + m_TableModel.getColumnClass(i).getName());
......
281 286
	public long getRowCount() throws DriverException {
282 287
		return arrayGeometries.size();
283 288
	}
284
    
289

  
285 290
    /* (non-Javadoc)
286 291
     * @see com.hardcode.gdbms.engine.data.driver.GDBMSDriver#setDataSourceFactory(com.hardcode.gdbms.engine.data.DataSourceFactory)
287 292
     */
......
299 304
		m_Position = 0;
300 305

  
301 306
    }
302
    
303
    public int getFieldWidth(int fieldId)
304
    {
305
    	// TODO
306
    	return 30;
307
    private void initializeFieldWidth(Object[] row) {
308
    	fieldWidth=new int[row.length];
309
		for (int i=0;i<row.length;i++) {
310
			fieldWidth[i]=((Value)row[i]).getWidth();
311
		}
307 312
    }
308
    
313
    /**
314
     * Actualize the width fields with StringValue.
315
     * @param row
316
     */
317
    private void actualizeFieldWidth(Object[] row) {
318
    	for (int i=0;i<row.length;i++) {
319
			if (row[i] instanceof StringValue) {
320
				int width=((StringValue)row[i]).getWidth();
321
				if (fieldWidth[i]<width) {
322
					fieldWidth[i]=width;
323
				}
324
			}
325
		}
326
    }
327
    public int getFieldWidth(int fieldId){
328
    	if (fieldWidth==null)
329
    		return 1;
330
    	return fieldWidth[fieldId];
331
    }
309 332

  
333

  
310 334
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/FieldDescription.java
53 53
 */
54 54
public class FieldDescription {
55 55

  
56
	public String toString() {
57
		return getFieldAlias();
58
	}
59

  
56 60
	public static int stringToType(String strType) {
57 61
		int type = -1;
58 62
		if (strType.equals("String"))
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dbf/DbaseFile.java
170 170

  
171 171
	/**
172 172
	 * DOCUMENT ME!
173
	 * 
173
	 *
174 174
	 * @return DOCUMENT ME!
175 175
	 */
176 176
	public int getFieldCount() {
......
179 179

  
180 180
	/**
181 181
	 * DOCUMENT ME!
182
	 * 
182
	 *
183 183
	 * @param rowIndex
184 184
	 *            DOCUMENT ME!
185 185
	 * @param fieldId
186 186
	 *            DOCUMENT ME!
187
	 * 
187
	 *
188 188
	 * @return DOCUMENT ME!
189 189
	 */
190 190
	public boolean getBooleanFieldValue(int rowIndex, int fieldId) {
......
207 207

  
208 208
	/**
209 209
	 * DOCUMENT ME!
210
	 * 
210
	 *
211 211
	 * @param rowIndex
212 212
	 *            DOCUMENT ME!
213 213
	 * @param fieldId
214 214
	 *            DOCUMENT ME!
215
	 * 
215
	 *
216 216
	 * @return DOCUMENT ME!
217 217
	 * @throws UnsupportedEncodingException
218 218
	 */
......
256 256
//		raf.writeBytes(str);
257 257
		aux.flip();
258 258
		int numBytesWritten = channel.write(aux, recordOffset + fieldOffset);
259
		channel.force(true);
260
		
259
		//channel.force(true);
261 260

  
261

  
262 262
	}
263 263

  
264 264

  
265 265
	/**
266 266
	 * Retrieve the name of the given column.
267
	 * 
267
	 *
268 268
	 * @param inIndex
269 269
	 *            DOCUMENT ME!
270
	 * 
270
	 *
271 271
	 * @return DOCUMENT ME!
272 272
	 */
273 273
	public String getFieldName(int inIndex) {
......
276 276

  
277 277
	/**
278 278
	 * Retrieve the type of the given column.
279
	 * 
279
	 *
280 280
	 * @param inIndex
281 281
	 *            DOCUMENT ME!
282
	 * 
282
	 *
283 283
	 * @return DOCUMENT ME!
284 284
	 */
285 285
	public char getFieldType(int inIndex) {
......
288 288

  
289 289
	/**
290 290
	 * Retrieve the length of the given column.
291
	 * 
291
	 *
292 292
	 * @param inIndex
293 293
	 *            DOCUMENT ME!
294
	 * 
294
	 *
295 295
	 * @return DOCUMENT ME!
296 296
	 */
297 297
	public int getFieldLength(int inIndex) {
......
300 300

  
301 301
	/*
302 302
	 * Retrieve the value of the given column as string.
303
	 * 
303
	 *
304 304
	 * @param idField DOCUMENT ME! @param idRecord DOCUMENT ME!
305
	 * 
305
	 *
306 306
	 * @return DOCUMENT ME!
307
	 * 
307
	 *
308 308
	 * public Object getFieldValue(int idField, long idRecord) throws
309 309
	 * IOException { Object[] tmpReg = getRecord(idRecord); return
310 310
	 * tmpReg[idField]; }
311 311
	 */
312 312
	/*
313 313
	 * DOCUMENT ME!
314
	 * 
314
	 *
315 315
	 * @param idField DOCUMENT ME! @param idRecord DOCUMENT ME!
316
	 * 
316
	 *
317 317
	 * @return DOCUMENT ME!
318
	 * 
318
	 *
319 319
	 * public double getFieldValueAsDouble(int idField, int idRecord) throws
320 320
	 * IOException { Object[] tmpReg = getRecord(idRecord); return (double)
321 321
	 * Double.parseDouble(tmpReg[idField].toString()); }
......
323 323

  
324 324
	/**
325 325
	 * Retrieve the location of the decimal point.
326
	 * 
326
	 *
327 327
	 * @param inIndex
328 328
	 *            DOCUMENT ME!
329
	 * 
329
	 *
330 330
	 * @return DOCUMENT ME!
331 331
	 */
332 332
	public int getFieldDecimalLength(int inIndex) {
......
335 335

  
336 336
	/**
337 337
	 * read the DBF file into memory.
338
	 * 
338
	 *
339 339
	 * @param file
340 340
	 *            DOCUMENT ME!
341
	 * 
341
	 *
342 342
	 * @throws IOException
343 343
	 *             DOCUMENT ME!
344 344
	 */
......
420 420

  
421 421
	/**
422 422
	 * Removes all data from the dataset
423
	 * 
423
	 *
424 424
	 * @throws IOException
425 425
	 *             DOCUMENT ME!
426 426
	 */
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dbf/DBFDriver.java
75 75
                fieldTypes[i] = dbf.getFieldType(i);
76 76
            }
77 77
    		int aux = (int)(Math.random() * 1000);
78
    		fTemp = new File(tempDirectoryPath + "/tmpDbf" + aux + ".dbf");            
78
    		fTemp = new File(tempDirectoryPath + "/tmpDbf" + aux + ".dbf");
79 79
    		dbfWriter.setFile(fTemp);
80 80
        } catch (DriverException e) {
81 81
            throw new IOException(e.getMessage());
......
394 394

  
395 395
	public ITableDefinition getTableDefinition() {
396 396
		tableDef = new TableDefinition();
397
		int numFields; 
397
		int numFields;
398 398
		try {
399 399
			numFields = getFieldCount();
400 400
			FieldDescription[] fieldsDescrip = new FieldDescription[numFields];
......
415 415
				// TODO: ?DEFAULTVALUE?
416 416
				// fieldsDescrip[i].setDefaultValue(get)
417 417
			}
418
	
418

  
419 419
			tableDef.setFieldsDesc(fieldsDescrip);
420 420
			return tableDef;
421 421
		} catch (DriverException e) {
......
443 443
		// TODO: DEVOLVER FALSE SI NO HA HABIDO CAMBIOS EN LOS CAMPOS.
444 444
		return true;
445 445
	}
446

  
446
	public void setFieldValue(int rowIndex, int fieldId, Object obj)
447
	throws IOException {
448
		dbf.setFieldValue(rowIndex,fieldId,obj);
449
	}
447 450
}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/IEditableSource.java
187 187

  
188 188
	public ITableDefinition getTableDefinition() throws DriverLoadException, com.hardcode.gdbms.engine.data.driver.DriverException;
189 189

  
190
	public void validateRow(IRow row) throws EditionException;
191
	
190
	public void validateRow(IRow row, int sourceType) throws EditionException;
191

  
192 192
	/**
193 193
	 *  Use it to add, remove or rename fields. If null, you cannot modifiy the table structure
194 194
	 *  (for example, with dxf files, dgn files, etc).
195 195
	 *  The changes will be applied when stopEditing() is called.
196 196
	 */
197 197
	public IFieldManager getFieldManager();
198
	
198

  
199 199
	public void saveEdits(IWriter writer, int sourceType) throws EditionException;
200
	
200

  
201 201
	/**
202 202
	 * @return
203 203
	 */
204 204
	public Driver getOriginalDriver();
205
	
205

  
206 206
	/**
207 207
	 * Please, use this if you need support for defaultValues.
208 208
	 * Don't user getRecordset().getFieldsDescription()!!.
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/AnnotationEditableAdapter.java
194 194
		int posAnteriorInExpansionFile = -1;
195 195
		Integer integer = new Integer(calculatedIndex);
196 196

  
197
		System.err.println("Modifica una Row en la posici?n: "
198
				+ calculatedIndex);
197
//		System.err.println("Modifica una Row en la posici?n: "
198
//				+ calculatedIndex);
199 199
		// Si la geometr?a no ha sido modificada
200 200
		if (!relations.containsKey(integer)) {
201 201
			FLabel label=(FLabel)getLabel(calculatedIndex,true).clone();
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/rules/RulePolygon.java
42 42

  
43 43
import com.iver.cit.gvsig.fmap.core.FCircle2D;
44 44
import com.iver.cit.gvsig.fmap.core.FEllipse2D;
45
import com.iver.cit.gvsig.fmap.core.FGeometry;
46 45
import com.iver.cit.gvsig.fmap.core.FPolyline2D;
47
import com.iver.cit.gvsig.fmap.core.FShape;
48 46
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
49 47
import com.iver.cit.gvsig.fmap.core.IFeature;
50 48
import com.iver.cit.gvsig.fmap.core.IGeometry;
51 49
import com.iver.cit.gvsig.fmap.core.IRow;
52 50
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
53 51
import com.iver.cit.gvsig.fmap.core.v02.FConverter;
54
import com.vividsolutions.jts.geom.Geometry;
52
import com.iver.cit.gvsig.fmap.edition.EditionEvent;
55 53

  
56 54
/**
57 55
 * @author fjp
......
61 59
 */
62 60
public class RulePolygon extends AbstractRule {
63 61

  
64
    public boolean validate(IRow row) {
65
        IFeature feat = (IFeature) row;
62
    public boolean validate(IRow row,int sourceType) {
63
        if (sourceType==EditionEvent.ALPHANUMERIC)
64
        	return true;
65
    	IFeature feat = (IFeature) row;
66 66
        IGeometry geom = feat.getGeometry();
67 67
        if ((geom.getInternalShape() instanceof FCircle2D)
68 68
        		|| (geom.getInternalShape() instanceof FEllipse2D)) {
......
70 70
        }
71 71
        GeneralPathX gp = new GeneralPathX();
72 72
        gp.append(geom.getPathIterator(null, FConverter.FLATNESS), true);
73
        
73

  
74 74
        if (gp.isClosed())
75 75
        {
76
        	boolean bCCW =gp.isCCW(); 
76
        	boolean bCCW =gp.isCCW();
77 77
        	System.out.println("Counter ClockWise  = " + bCCW);
78 78
        	if (bCCW)
79 79
        	{
......
82 82
//            	IGeometry aux = ShapeFactory.createPolygon2D(gp);
83 83
//            	Geometry jtsGeom = aux.toJTSGeometry();
84 84
//            	geom = FConverter.jts_to_igeometry(jtsGeom);
85
        		
85

  
86 86
        		geom = ShapeFactory.createPolygon2D(gp);
87
        	}	
87
        	}
88 88
        	else
89 89
        	{
90 90
        		geom = ShapeFactory.createPolygon2D((FPolyline2D)geom.getInternalShape());
91 91
        	}
92 92
//        	IGeometry aux = ShapeFactory.createPolygon2D(gp);
93
//        	
94
        	Geometry jtsGeom = geom.toJTSGeometry();
95
        	System.err.println(jtsGeom.toText());
96
//        	
93
//
94
//        	Geometry jtsGeom = geom.toJTSGeometry();
95
//        	System.err.println(jtsGeom.toText());
96
//
97 97
//        	geom = FConverter.jts_to_igeometry(jtsGeom);
98
        	
98

  
99 99
            // gp.ensureOrientation(false); // Poligono exterior.
100
        	
100

  
101 101
//        	Area area = new Area(geom);
102 102
//            GeneralPathX gp2 = new GeneralPathX();
103
//            gp2.append(area.getPathIterator(null), true);        	
103
//            gp2.append(area.getPathIterator(null), true);
104 104
//            geom = ShapeFactory.createPolygon2D(gp2);
105
            
105

  
106 106
            feat.setGeometry(geom);
107 107
            return true;
108 108
        }
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/rules/IRule.java
51 51
	String getName();
52 52
	String getDescription();
53 53
	int getPriority();
54
	boolean validate(IRow row);
54
	boolean validate(IRow row,int sourceType);
55 55

  
56 56
}
57 57

  
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/IWriter.java
17 17
	void process(IRowEdited row) throws EditionException;
18 18

  
19 19
	void postProcess() throws EditionException;
20

  
20
	
21
	/**
22
	 * A developer can use this Properties for his own purposes. For example, to
23
	 * let his extension know something about one writer. 
24
	 * <br>
25
	 * We can found for example:
26
	 * <br>
27
	 * <b>FieldNameMaxLength<b>: Maximum length of field name (Null or 0 --> unlimited).
28
	 * 
29
	 * @param capability
30
	 * @return A message describing the capability. Null if not supported.
31
	 */
21 32
	public String getCapability(String capability);
33
	
22 34
	/**
23 35
	 * @param capabilities The capabilities to set.
24 36
	 */
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java
143 143

  
144 144
	protected boolean isFullExtentDirty = false;
145 145

  
146
	private ArrayList fieldEvents=new ArrayList();
147
	private ArrayList rowEvents=new ArrayList();
148

  
146 149
	/**
147 150
	 * Crea un nuevo EditableAdapter.
148 151
	 */
......
354 357
			{
355 358
				for (int i = 0; i < rowCount; i++) {
356 359
					IRowEdited rowEdited = getRow(i);
357
	
360

  
358 361
					if (rowEdited != null) {
359 362
						writer.process(rowEdited);
360 363
					}
......
500 503
			throws DriverIOException, IOException {
501 504

  
502 505
		try {
503
			validateRow(row);
506
			validateRow(row,sourceType);
504 507
		} catch (EditionException e) {
505 508
			e.printStackTrace();
506 509
			throw new IOException(e.getMessage());
......
580 583
			throws IOException, DriverIOException {
581 584

  
582 585
		try {
583
			validateRow(row);
586
			validateRow(row,sourceType);
584 587
		} catch (EditionException e) {
585 588
			e.printStackTrace();
586 589
			throw new IOException(e.getMessage());
......
628 631
		commands.setDescription(description);
629 632
		cr.pushCommand(commands);
630 633
		complex = false;
634
		for (int j = 0; j < editionListeners.size(); j++) {
635
			for (int i = 0; i < fieldEvents.size(); i++) {
636
				IEditionListener listener = (IEditionListener) editionListeners
637
					.get(j);
638
				listener.afterFieldEditEvent((AfterFieldEditEvent)fieldEvents.get(i));
639
			}
640
			for (int i = 0; i < rowEvents.size(); i++) {
641
				IEditionListener listener = (IEditionListener) editionListeners
642
						.get(j);
643
				listener.afterRowEditEvent(null,(AfterRowEditEvent)rowEvents.get(i));
644
			}
645
		}
646
		fieldEvents.clear();
647
		rowEvents.clear();
631 648
	}
632 649

  
633 650
	/**
......
678 695
			relations.put(new Integer(geometryIndex), new Integer(
679 696
					previousExpansionFileIndex));
680 697
		}
681
		fireAfterModifyRow(geometryIndex, sourceType);
698
		//fireAfterModifyRow(geometryIndex, sourceType);
682 699
	}
683 700

  
684 701
	/**
......
735 752

  
736 753
		int pos = -1;
737 754
		Integer integer = new Integer(index);
738
		System.err.println("Modifica una Row en la posici?n: " + index);
755
//		System.err.println("Modifica una Row en la posici?n: " + index);
739 756
		// Si la geometr?a no ha sido modificada
740 757
		if (!relations.containsKey(integer)) {
741 758
			int expansionIndex = expansionFile.addRow(feat,
......
760 777
			relations.put(integer, new Integer(num));
761 778
		}
762 779
		isFullExtentDirty = true;
763
		fireAfterModifyRow(index, sourceType);
780
		//fireAfterModifyRow(index, sourceType);
764 781
		return pos;
765 782
	}
766 783

  
......
874 891
			return ods;
875 892
		}
876 893
	}
877
	
894

  
878 895
	/**
879 896
	 * Return always the original recordset (even when is editing,
880 897
	 * nor the getRecorset() method)
881
	 * 
898
	 *
882 899
	 * */
883 900
	public SelectableDataSource getOriginalRecordset(){
884 901
		return ods;
......
1175 1192
	protected void fireAfterRemoveRow(int index, int sourceType) {
1176 1193
		AfterRowEditEvent event = new AfterRowEditEvent(this, index,
1177 1194
				EditionEvent.CHANGE_TYPE_DELETE, sourceType);
1195
		if (complex){
1196
			rowEvents.add(event);
1197
			return;
1198
		}
1178 1199
		for (int i = 0; i < editionListeners.size(); i++) {
1179 1200
			IEditionListener listener = (IEditionListener) editionListeners
1180 1201
					.get(i);
......
1200 1221
	protected void fireAfterRowAdded(IRow feat,int calculatedIndex, int sourceType) {
1201 1222
		AfterRowEditEvent event = new AfterRowEditEvent(this, calculatedIndex,
1202 1223
				EditionEvent.CHANGE_TYPE_ADD, sourceType);
1224
		if (complex){
1225
			rowEvents.add(event);
1226
			return;
1227
		}
1203 1228
		for (int i = 0; i < editionListeners.size(); i++) {
1204 1229
			IEditionListener listener = (IEditionListener) editionListeners
1205 1230
					.get(i);
......
1210 1235
	protected void fireAfterFieldAdded(FieldDescription field) {
1211 1236
		AfterFieldEditEvent event = new AfterFieldEditEvent(this,field,
1212 1237
				EditionEvent.CHANGE_TYPE_ADD);
1238
		if (complex) {
1239
			fieldEvents.add(event);
1240
			return;
1241
		}
1213 1242
		for (int i = 0; i < editionListeners.size(); i++) {
1214 1243
			IEditionListener listener = (IEditionListener) editionListeners
1215 1244
					.get(i);
1216 1245
			listener.afterFieldEditEvent(event);
1246

  
1217 1247
		}
1218 1248
	}
1219 1249

  
1220 1250
	protected void fireAfterFieldRemoved(FieldDescription field) {
1221 1251
		AfterFieldEditEvent event = new AfterFieldEditEvent(this,field,
1222 1252
				EditionEvent.CHANGE_TYPE_DELETE);
1253
		if (complex) {
1254
			fieldEvents.add(event);
1255
			return;
1256
		}
1223 1257
		for (int i = 0; i < editionListeners.size(); i++) {
1224 1258
			IEditionListener listener = (IEditionListener) editionListeners
1225 1259
					.get(i);
......
1230 1264
	protected void fireAfterFieldModified(FieldDescription field) {
1231 1265
		AfterFieldEditEvent event = new AfterFieldEditEvent(this,field,
1232 1266
				EditionEvent.CHANGE_TYPE_MODIFY);
1267
		if (complex) {
1268
			fieldEvents.add(event);
1269
			return;
1270
		}
1233 1271
		for (int i = 0; i < editionListeners.size(); i++) {
1234 1272
			IEditionListener listener = (IEditionListener) editionListeners
1235 1273
					.get(i);
......
1301 1339
	protected void fireAfterModifyRow(int index, int sourceType) {
1302 1340
		AfterRowEditEvent event = new AfterRowEditEvent(this, index,
1303 1341
				EditionEvent.CHANGE_TYPE_MODIFY, sourceType);
1342
		if (complex){
1343
			rowEvents.add(event);
1344
			return;
1345
		}
1304 1346
		for (int i = 0; i < editionListeners.size(); i++) {
1305 1347
			IEditionListener listener = (IEditionListener) editionListeners
1306 1348
					.get(i);
......
1373 1415
	 * contenga el nombre de la tabla (y por tanto requiere
1374 1416
	 * DBLayerDefinition-en realidad hace falta DBTableDefinition)
1375 1417
	 * TODO REVISAR LA ARQUITECTURA DE ESTO
1376
	 * 
1418
	 *
1377 1419
	 * */
1378 1420
	public ITableDefinition getTableDefinition() throws DriverLoadException,
1379 1421
			DriverException {
......
1386 1428
		}else{
1387 1429
			AlphanumericDBDriver dbDriver = (AlphanumericDBDriver)originalDriver;
1388 1430
			return dbDriver.getTableDefinition();
1389
			
1431

  
1390 1432
		}
1391
		
1392
		
1433

  
1434

  
1393 1435
	}
1394 1436

  
1395
	public void validateRow(IRow row) throws EditionException {
1437
	public void validateRow(IRow row,int sourceType) throws EditionException {
1396 1438
		for (int i = 0; i < rules.size(); i++) {
1397 1439
			IRule rule = (IRule) rules.get(i);
1398
			boolean bAux = rule.validate(row);
1440
			boolean bAux = rule.validate(row,sourceType);
1399 1441
			if (bAux == false) {
1400 1442
				EditionException ex = new EditionException(
1401 1443
						"NOT follow the rule: " + rule.getDescription());
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/shp/ShpWriter.java
27 27
import com.iver.cit.gvsig.fmap.layers.FLayer;
28 28
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
29 29
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
30
import com.iver.utiles.xmlEntity.generate.Property;
30 31

  
31 32
/**
32 33
 * @author   jaume dominguez faus - jaume.dominguez@iver.es
......
66 67
											};
67 68
	private Charset charset = Charset.forName("ISO-8859-1");
68 69

  
70
	public ShpWriter() {
71
		super();
72
		this.capabilities.setProperty("FieldNameMaxLength","10");
73
	}
69 74
	public void setFile(File f)
70 75
	{
71 76
		shpPath = f.getAbsolutePath();
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/dbf/DbfWriter.java
47 47
	 * @uml.associationEnd  multiplicity="(0 -1)"
48 48
	 */
49 49
	private FieldDescription[] originalFields;
50
	
51
	public DbfWriter() {
52
		super();
53
		this.capabilities.setProperty("FieldNameMaxLength","10");
54
	}
50 55

  
51 56
	public void setFile(File f) {
52 57
		String strFichDbf = f.getAbsolutePath().replaceAll("\\.shp", ".dbf");
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/StatusLayerRaster.java
193 193
		//en el orden correcto
194 194
		if(layer instanceof FLyrRaster){
195 195
			if(files.size()!=0){
196
				((FLyrRaster)layer).delFile(layer.getSource().getFiles()[0].getName());
196
				((FLyrRaster)layer).delFile((String)files.get(0));
197 197
				for(int i=0;i<files.size();i++)
198 198
					((FLyrRaster)layer).addFiles((String)files.get(i));
199 199
			}
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/RasterOperations.java
80 80
	 *
81 81
	 * @return RasterAdapter.
82 82
	 */
83
	public RasterAdapter getSource() ;
83
	//public RasterAdapter getSource() ;
84 84
		
85 85
	/**
86 86
	 * Inserta el RasterAdapter.
87 87
	 * @param ra   RasterAdapter.
88 88
	 * @uml.property  name="source"
89 89
	 */
90
	public void setSource(RasterAdapter ra) ;
90
	//public void setSource(RasterAdapter ra) ;
91 91
	
92 92
	/**
93 93
	 * Asigna la posici?n en la que se ha hecho click al mostrar
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLayers.java
418 418
    		*/
419 419
    			LayerDrawEvent beforeEvent = new LayerDrawEvent(lyr, g, viewPort, LayerDrawEvent.LAYER_BEFORE_DRAW);
420 420
    			fmap.fireLayerDrawingEvent(beforeEvent);
421
        		if ((lyr.isDirty()) && (lyr.isCachingDrawnLayers() == false))
421
        		if ((lyr.isDirty()) || (lyr.isCachingDrawnLayers() == false))
422 422
        			bNeedRecalculateCache = true;
423 423

  
424 424
    			if (lyr.isVisible()) {
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/tools/geo/Geo.java
13 13
    public static double SqKm = 707632.4; /* Square km per spherical degree. */
14 14
    public static double SqM = 707632400000.0; /* Square M per spherical degree. */
15 15

  
16
    double hav(double X)/*  Haversine function: hav(x)= (1-cos(x))/2.  */
17
     {
16
    public static double getDecimalDegrees(double m) {
17
    	///(m*180)/ (6378137.0 * Math.PI)
18
    	return (m*8.983152841195214E-6);
19
    }
20

  
21
    /*  Haversine function: hav(x)= (1-cos(x))/2.  */
22
    private static double hav(double X){
18 23
        return (1.0 - Math.cos(X)) / 2.0;
19 24
    }
20 25

  
21 26
    /*  Returns the area of a spherical polygon in spherical degrees,
22 27
    given the latitudes and longitudes in Lat and Lon, respectively.
23 28
    The N data points have indices which range from 0 to N-1. */
24
    public double sphericalPolyArea(double[] lat, double[] lon, int n) {
29
    public static double sphericalPolyArea(double[] lat, double[] lon, int n) {
25 30
        int j;
26 31
        int k;
27 32
        double lam1;
branches/simbologia/libraries/libFMap/src/com/iver/cit/gvsig/fmap/tools/AreaListenerImpl.java
201 201
			lon[K]= xs[K].doubleValue()/Geo.Degree;
202 202
			lat[K]= ys[K].doubleValue()/Geo.Degree;
203 203
		}
204
		Geo geoC=new Geo();
205
		return (geoC.sphericalPolyArea(lat,lon,xs.length-1)*Geo.SqM);///1.29132441;//Esto es una constante para ajustar el resultado, que por alg?n motivo no es correcto.
204
		return (Geo.sphericalPolyArea(lat,lon,xs.length-1)*Geo.SqM);///1.29132441;//Esto es una constante para ajustar el resultado, que por alg?n motivo no es correcto.
206 205
	}
207 206
	/**
208 207
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()

Also available in: Unified diff