svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.api / src / main / java / org / gvsig / fmap / geom / type / AbstractGeometryType.java @ 40559
History | View | Annotate | Download (2.58 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 3
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | package org.gvsig.fmap.geom.type; |
25 | |||
26 | import java.util.ArrayList; |
||
27 | import java.util.List; |
||
28 | |||
29 | import org.gvsig.fmap.geom.operation.GeometryOperation; |
||
30 | |||
31 | public abstract class AbstractGeometryType implements GeometryType { |
||
32 | |||
33 | /**
|
||
34 | * Registered operations for a concrete geometry type
|
||
35 | */
|
||
36 | private List geometryOperations = new ArrayList(); |
||
37 | |||
38 | public boolean isTypeOf(GeometryType geometryType) { |
||
39 | return isTypeOf(geometryType.getType());
|
||
40 | } |
||
41 | |||
42 | public boolean isSubTypeOf(GeometryType geometryType) { |
||
43 | return isSubTypeOf(geometryType.getSubType());
|
||
44 | } |
||
45 | |||
46 | public void setGeometryOperation(int index, GeometryOperation geomOp) { |
||
47 | while (index > geometryOperations.size()) {
|
||
48 | geometryOperations.add(null);
|
||
49 | } |
||
50 | |||
51 | if (index == geometryOperations.size()) {
|
||
52 | geometryOperations.add(geomOp); |
||
53 | } else {
|
||
54 | geometryOperations.set(index, geomOp); |
||
55 | } |
||
56 | } |
||
57 | |||
58 | public GeometryOperation getGeometryOperation(int index) { |
||
59 | return (GeometryOperation) geometryOperations.get(index);
|
||
60 | } |
||
61 | |||
62 | public boolean equals(Object obj) { |
||
63 | if (obj instanceof GeometryType) { |
||
64 | GeometryType other = (GeometryType) obj; |
||
65 | return getType() == other.getType()
|
||
66 | && getSubType() == other.getSubType(); |
||
67 | } |
||
68 | return false; |
||
69 | } |
||
70 | |||
71 | protected List getGeometryOperations() { |
||
72 | return geometryOperations;
|
||
73 | } |
||
74 | |||
75 | public String toString() { |
||
76 | StringBuffer sb =
|
||
77 | new StringBuffer("[").append(getName()).append(",[") |
||
78 | .append(getGeometryOperations().toString()).append("]");
|
||
79 | |||
80 | return sb.toString();
|
||
81 | } |
||
82 | |||
83 | } |