Statistics
| Revision:

root / trunk / extensions / extGraph_predes / src / com / iver / cit / gvsig / fmap / core / symbols / AbstractMarker.java @ 8432

History | View | Annotate | Download (3.48 KB)

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

    
42
/* CVS MESSAGES:
43
*
44
* $Id: AbstractMarker.java 8432 2006-10-30 19:30:35Z jaume $
45
* $Log$
46
* Revision 1.4  2006-10-30 19:30:35  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.3  2006/10/26 16:27:33  jaume
50
* support for composite marker symbols (not tested)
51
*
52
* Revision 1.2  2006/10/26 07:46:58  jaume
53
* *** empty log message ***
54
*
55
* Revision 1.1  2006/10/25 10:50:41  jaume
56
* movement of classes and gui stuff
57
*
58
* Revision 1.1  2006/10/18 07:54:06  jaume
59
* *** empty log message ***
60
*
61
*
62
*/
63
package com.iver.cit.gvsig.fmap.core.symbols;
64

    
65
import java.awt.Point;
66
import java.awt.geom.Point2D;
67
import java.util.ArrayList;
68

    
69
import com.iver.cit.gvsig.fmap.core.FShape;
70
import com.iver.cit.gvsig.fmap.core.IGeometry;
71
import com.iver.cit.gvsig.fmap.core.ISymbol;
72

    
73
public abstract class AbstractMarker implements ISymbol {
74

    
75
        protected boolean isShapeVisible = true;
76
        protected String desc;
77
        protected double rotation;
78
        protected Point2D offset;
79
        protected ISymbol[] subSymbols; // TODO maybe push it up to ISymbol
80
        public String getDescription() {
81
                return desc;
82
        }
83
        
84
        public boolean isShapeVisible() {
85
                return isShapeVisible;
86
        }
87
        public void setDescription(String desc) {
88
                this.desc = desc;
89
        }
90

    
91

    
92
        public double getRotation() {
93
                return rotation;
94
        }
95

    
96
        public void setRotation(double r) {
97
                this.rotation = r;
98
        }
99
        public Point2D getOffset() {
100
                if (offset == null) {
101
                        offset = new Point();
102
                }
103
                return offset;
104
        }
105

    
106
        public void setOffset(Point offset) {
107
                this.offset = offset;
108
        }
109

    
110
        /**
111
         * TODO maybe push it up to ISymbol
112
         * @param sym
113
         */
114
        public void addSymbol(ISymbol sym) {
115
                int capacity = 0;
116
                if (subSymbols != null)
117
                        capacity = subSymbols.length;
118
                ArrayList lst = new ArrayList(capacity);
119
                for (int i = 0; i < capacity; i++) {
120
                        lst.add(subSymbols[i]);
121
                }
122
                subSymbols = (ISymbol[])lst.toArray(new ISymbol[0]);
123
        }
124

    
125
        /**
126
         * TODO maybe push it up to ISymbol
127
         * @param sym
128
         * @return true if this symbol contains the removed one
129
         */
130
        public boolean removeSymbol(ISymbol sym) {
131

    
132
                int capacity = 0;
133
                if (subSymbols != null)
134
                        capacity = subSymbols.length;
135
                ArrayList lst = new ArrayList(capacity);
136
                for (int i = 0; i < capacity; i++) {
137
                        lst.add(subSymbols[i]);
138
                }
139
                boolean contains = lst.remove(sym);
140
                subSymbols = (ISymbol[])lst.toArray(new ISymbol[0]);
141
                return contains;
142
        }
143

    
144
        public boolean isSuitableFor(IGeometry geom) {
145
                return geom.getGeometryType() == FShape.POINT;
146
        }
147
}