Revision 38596 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/type/impl/DefaultGeometryType.java

View differences:

DefaultGeometryType.java
28 28
package org.gvsig.fmap.geom.type.impl;
29 29

  
30 30
import java.lang.reflect.Constructor;
31
import java.util.ArrayList;
32
import java.util.List;
33 31

  
34 32
import org.gvsig.fmap.geom.Geometry;
35 33
import org.gvsig.fmap.geom.GeometryManager;
36 34
import org.gvsig.fmap.geom.exception.CreateGeometryException;
37
import org.gvsig.fmap.geom.operation.GeometryOperation;
35
import org.gvsig.fmap.geom.type.AbstractGeometryType;
38 36
import org.gvsig.fmap.geom.type.GeometryType;
39 37

  
40 38
/**
41 39
 * @author <a href="mailto:jpiera@gvsig.org">Jorge Piera</a>
42 40
 */
43
public class DefaultGeometryType implements GeometryType {
44
	/** 
45
	 * The geometry identifier
46
	 */
47
	private int id;
41
public class DefaultGeometryType extends AbstractGeometryType {
48 42
	
49 43
	/** 
50 44
	 * Geometry type name
......
68 62
	 */
69 63
	private int subType;	
70 64
		
71
	/** 
72
	 * Registered operations for a concrete geometry type
73
	 */
74
	private List geometryOperations = new ArrayList();
75
	
76 65
	/**
77 66
	 * Super types of a geometry. e.g: the super type of an
78 67
	 * arc is a curve, the super type of a circle is a surface...
......
114 103
     * @param superSubTypes
115 104
     * The superSubtypes of the geometry type      
116 105
     */
117
    public DefaultGeometryType(Class geomClass, String name, int id, int type, int subType, 
106
    public DefaultGeometryType(Class geomClass, String name, int type, int subType, 
118 107
        int[] superTypes, int[] superSubTypes) {
119 108
        this.geometryClass = geomClass;
120 109
        if (name == null) {
......
122 111
        } else {
123 112
            this.name = name;
124 113
        }
125
        this.id = id;       
126 114
        this.type = type;   
127 115
        this.subType = subType;
128 116
        this.superTypes = superTypes;
......
155 143
	 * @param type
156 144
	 * The geometry abstract type			
157 145
	 */
158
	public DefaultGeometryType(Class geomClass, String name, int id, int type, int subType) {
159
		this(geomClass, name, id, type, subType, new int[0], new int[0]);
146
	public DefaultGeometryType(Class geomClass, String name, int type, int subType) {
147
		this(geomClass, name, type, subType, new int[0], new int[0]);
160 148
	}
161 149
	
162 150
	/**
......
175 163
		} 
176 164
	}
177 165
	
178
	/**
179
	 * Guardamos una referencia a una instancia de la operación en el índice que se pasa como parámetro.
180
	 * Si el índice ya está ocupado se sobrescribe.
181
	 * 
182
	 * @param index
183
	 * @param geomOp
184
	 */
185
	public void setGeometryOperation(int index, GeometryOperation geomOp) {
186
		
187
		while (index > geometryOperations.size()) {
188
			geometryOperations.add(null);
189
		}
190
		
191
		if (index == geometryOperations.size()) {
192
			geometryOperations.add(geomOp);
193
		} else {				
194
			geometryOperations.set(index, geomOp);
195
		}
196
	}
197
	
198
	public GeometryOperation getGeometryOperation(int index) {
199
		return (GeometryOperation) geometryOperations.get(index);
200
	}
201
	
202 166
	public Class getGeometryClass() {
203 167
		return geometryClass;
204 168
	}
205 169
	
206
	public String toString() {
207
		StringBuffer sb = new StringBuffer("[")
208
		.append(geometryClass.getName())
209
		.append(",[")
210
		.append(geometryOperations.toString())
211
		.append("]");
212
		
213
		return sb.toString();
214
	}
215
	
216
	public int getId() {
217
		return id;
218
	}
219

  
220 170
	public String getName() {
221 171
		return name;
222 172
	}
......
253 203
        return false;
254 204
    }
255 205

  
256
    public boolean isTypeOf(GeometryType geometryType) {
257
        return isTypeOf(geometryType.getType());
258
    }
259

  
260
    public boolean isSubTypeOf(GeometryType geometryType) {
261
        return isSubTypeOf(geometryType.getSubType());
262
    }
263

  
264
    public boolean equals(Object obj) {
265
        if (obj instanceof GeometryType) {
266
            GeometryType other = (GeometryType) obj;
267
            return type == other.getType() && subType == other.getSubType();
268
        }
269
        return false;
270
    }
271 206
}
272 207

  

Also available in: Unified diff