svn-gvsig-desktop / trunk / extensions / extGraph_predes / src / com / iver / cit / gvsig / fmap / core / symbols / AbstractMarkerSymbol.java @ 8458
History | View | Annotate | Download (3.56 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: AbstractMarkerSymbol.java 8458 2006-10-31 16:18:03Z jaume $
|
45 |
* $Log$
|
46 |
* Revision 1.1 2006-10-31 16:16:34 jaume
|
47 |
* *** empty log message ***
|
48 |
*
|
49 |
* Revision 1.4 2006/10/30 19:30:35 jaume
|
50 |
* *** empty log message ***
|
51 |
*
|
52 |
* Revision 1.3 2006/10/26 16:27:33 jaume
|
53 |
* support for composite marker symbols (not tested)
|
54 |
*
|
55 |
* Revision 1.2 2006/10/26 07:46:58 jaume
|
56 |
* *** empty log message ***
|
57 |
*
|
58 |
* Revision 1.1 2006/10/25 10:50:41 jaume
|
59 |
* movement of classes and gui stuff
|
60 |
*
|
61 |
* Revision 1.1 2006/10/18 07:54:06 jaume
|
62 |
* *** empty log message ***
|
63 |
*
|
64 |
*
|
65 |
*/
|
66 |
package com.iver.cit.gvsig.fmap.core.symbols; |
67 |
|
68 |
import java.awt.Point; |
69 |
import java.awt.geom.Point2D; |
70 |
import java.util.ArrayList; |
71 |
|
72 |
import com.iver.cit.gvsig.fmap.core.FShape; |
73 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
74 |
import com.iver.cit.gvsig.fmap.core.ISymbol; |
75 |
|
76 |
public abstract class AbstractMarkerSymbol implements ISymbol { |
77 |
|
78 |
protected boolean isShapeVisible = true; |
79 |
protected String desc; |
80 |
protected double rotation; |
81 |
protected Point2D offset; |
82 |
protected ISymbol[] subSymbols; // TODO maybe push it up to ISymbol |
83 |
public String getDescription() { |
84 |
return desc;
|
85 |
} |
86 |
|
87 |
public boolean isShapeVisible() { |
88 |
return isShapeVisible;
|
89 |
} |
90 |
public void setDescription(String desc) { |
91 |
this.desc = desc;
|
92 |
} |
93 |
|
94 |
|
95 |
public double getRotation() { |
96 |
return rotation;
|
97 |
} |
98 |
|
99 |
public void setRotation(double r) { |
100 |
this.rotation = r;
|
101 |
} |
102 |
public Point2D getOffset() { |
103 |
if (offset == null) { |
104 |
offset = new Point(); |
105 |
} |
106 |
return offset;
|
107 |
} |
108 |
|
109 |
public void setOffset(Point offset) { |
110 |
this.offset = offset;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* TODO maybe push it up to ISymbol
|
115 |
* @param sym
|
116 |
*/
|
117 |
public void addSymbol(ISymbol sym) { |
118 |
int capacity = 0; |
119 |
if (subSymbols != null) |
120 |
capacity = subSymbols.length; |
121 |
ArrayList lst = new ArrayList(capacity); |
122 |
for (int i = 0; i < capacity; i++) { |
123 |
lst.add(subSymbols[i]); |
124 |
} |
125 |
subSymbols = (ISymbol[])lst.toArray(new ISymbol[0]); |
126 |
} |
127 |
|
128 |
/**
|
129 |
* TODO maybe push it up to ISymbol
|
130 |
* @param sym
|
131 |
* @return true if this symbol contains the removed one
|
132 |
*/
|
133 |
public boolean removeSymbol(ISymbol sym) { |
134 |
|
135 |
int capacity = 0; |
136 |
if (subSymbols != null) |
137 |
capacity = subSymbols.length; |
138 |
ArrayList lst = new ArrayList(capacity); |
139 |
for (int i = 0; i < capacity; i++) { |
140 |
lst.add(subSymbols[i]); |
141 |
} |
142 |
boolean contains = lst.remove(sym);
|
143 |
subSymbols = (ISymbol[])lst.toArray(new ISymbol[0]); |
144 |
return contains;
|
145 |
} |
146 |
|
147 |
public boolean isSuitableFor(IGeometry geom) { |
148 |
return geom.getGeometryType() == FShape.POINT;
|
149 |
} |
150 |
} |