root / tags / v2_0_0_Build_2058 / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / rendering / symbols / ISymbol.java @ 39247
History | View | Annotate | Download (6.76 KB)
1 |
/* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 |
package org.gvsig.fmap.mapcontext.rendering.symbols; |
42 |
|
43 |
import java.awt.Color; |
44 |
import java.awt.Graphics2D; |
45 |
import java.awt.Rectangle; |
46 |
import java.awt.geom.AffineTransform; |
47 |
|
48 |
import org.gvsig.compat.print.PrintAttributes; |
49 |
import org.gvsig.fmap.dal.feature.Feature; |
50 |
import org.gvsig.fmap.geom.Geometry; |
51 |
import org.gvsig.fmap.mapcontext.ViewPort; |
52 |
import org.gvsig.tools.persistence.Persistent; |
53 |
import org.gvsig.tools.task.Cancellable; |
54 |
import org.gvsig.tools.lang.Cloneable; |
55 |
|
56 |
|
57 |
/**
|
58 |
*
|
59 |
* Interface for symbols.It is the most general one which is implemented by other
|
60 |
* specific symbols.For this reason this interface has a method to obtain the derived
|
61 |
* version of a common symbol(apart from others). The main purpose is to offer a set of
|
62 |
* symbols that will be part of the FMap kernel and allow the developer to add new symbols
|
63 |
* without changes in the initial implementation.
|
64 |
*
|
65 |
*
|
66 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
67 |
*/
|
68 |
public interface ISymbol extends Persistent, IPrintable, Cloneable { |
69 |
|
70 |
public static Color SELECTION_COLOR = Color.YELLOW; |
71 |
|
72 |
/**
|
73 |
* Returns the derived version of the symbol that will be used to draw the
|
74 |
* feature when it is selected.
|
75 |
* @return <b>ISymbol</b> applied to a feature when it has been selected.
|
76 |
*/
|
77 |
public ISymbol getSymbolForSelection();
|
78 |
|
79 |
/**
|
80 |
* Used when a symbol is going to be drawn.The method to do
|
81 |
* it will depend on the derived version of the symbol.
|
82 |
* @param g
|
83 |
* @param affineTransform
|
84 |
* @param shp
|
85 |
* @param cancel TODO
|
86 |
*/
|
87 |
public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Feature f, Cancellable cancel); |
88 |
|
89 |
/**
|
90 |
* <p>
|
91 |
* Returns <b>the distance between the shape's bounding box and the
|
92 |
* symbol-that-represents-this-shape's bounding box</b> in a two-length-float
|
93 |
* array passed as parameter.<br>
|
94 |
* </p>
|
95 |
* <p>
|
96 |
* After this method returns, the float array passed will contain two values
|
97 |
* representing <b>the amount of pixels</b> separating each of the X (first element)
|
98 |
* and Y (second element) axes.<br>
|
99 |
* </p>
|
100 |
* <p>
|
101 |
* This distance maybe dependent on:
|
102 |
* <ol>
|
103 |
* <li>
|
104 |
* <b>The ViewPort</b>: if the symbol is an instance of CartographicSupport
|
105 |
* the units it uses are not pixels and the reference system is
|
106 |
* CarthographicSupport.WORLD.
|
107 |
* </li>
|
108 |
* <li>
|
109 |
* <b>The target rendering context's dpi (dots-per-inch)</b>: if the symbol
|
110 |
* is an instance of CartographicSupport the units it uses are not pixels and
|
111 |
* CarthographicSupport.PAPER.
|
112 |
* </li>
|
113 |
* </ol>
|
114 |
* <br>
|
115 |
* </p>
|
116 |
* <p>
|
117 |
* And in any other case, if the unit of the symbol is pixels or the symbol is not
|
118 |
* even an instance of CartographicSupport, the returning values are only
|
119 |
* defined by the symbol and are not calculated.
|
120 |
* </p>
|
121 |
* @param ViewPort viewPort
|
122 |
* @param Shape shp
|
123 |
* @param int dpi
|
124 |
* @param float[] distances, the array of floats where to store the distances in x and y axis
|
125 |
*/
|
126 |
public void getPixExtentPlus(Geometry geom, float[] distances, ViewPort viewPort, int dpi); |
127 |
|
128 |
|
129 |
/**
|
130 |
* Informs that the geometry will be represented with that symbol in just one pixel or dot
|
131 |
*
|
132 |
*
|
133 |
*
|
134 |
* @param geom
|
135 |
* @param positionOfDotOrPixel (out) filled with pixel or dot location
|
136 |
* @param viewPort
|
137 |
* @param dpi
|
138 |
* @return
|
139 |
*/
|
140 |
public boolean isOneDotOrPixel(Geometry geom, double[] positionOfDotOrPixel, |
141 |
ViewPort viewPort, int dpi);
|
142 |
|
143 |
/**
|
144 |
* Returns the rgb of the symbol when it is drawn like a point.
|
145 |
*
|
146 |
* @return rgb of the symbol.
|
147 |
*/
|
148 |
public int getOnePointRgb(); |
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
/**
|
155 |
* The description is a human-readable text used to label it when show in a symbol menu or something like that.
|
156 |
* @return description of this symbol.
|
157 |
* @uml.property name="description"
|
158 |
*/
|
159 |
public String getDescription(); |
160 |
|
161 |
/**
|
162 |
* Tells whether the shape of the symbol will be drawn or not.
|
163 |
*
|
164 |
* @return <b>true</b> if Shape must be drawn. Useful if you are labelling
|
165 |
*/
|
166 |
public boolean isShapeVisible(); |
167 |
|
168 |
/**
|
169 |
* Sets the description of this symbol
|
170 |
* @param desc, a string with the description
|
171 |
* @see ISymbol.getDescription();
|
172 |
* @uml.property name="description"
|
173 |
*/
|
174 |
public void setDescription(String desc); |
175 |
|
176 |
/**
|
177 |
* The use of this method -and its mechanism- is being valorated. It probably
|
178 |
* will be <b>deprecated</b>.
|
179 |
* @return FSymbol constants. I think it is better to use isSuitableFor
|
180 |
*
|
181 |
*/
|
182 |
public int getSymbolType(); |
183 |
|
184 |
/**
|
185 |
* True if this symbol is ok for the geometry. For example, a FillSymbol will
|
186 |
* be suitable for a Polygon.
|
187 |
* @param geom
|
188 |
* @return
|
189 |
*/
|
190 |
public boolean isSuitableFor(Geometry geom); |
191 |
|
192 |
/**
|
193 |
* Useful to render the symbol inside the TOC, or inside little
|
194 |
* rectangles. For example, think about rendering a Label with size
|
195 |
* in meters => You will need to specify a size in pixels.
|
196 |
* Of course, you can also to choose to render a prepared image, etc.
|
197 |
* @param scaleInstance
|
198 |
* @param r
|
199 |
* @param properties TODO
|
200 |
* @param g2
|
201 |
* @throws SymbolDrawingException TODO
|
202 |
*/
|
203 |
public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r, PrintAttributes properties) throws SymbolDrawingException; |
204 |
|
205 |
/**
|
206 |
* Returns the {@link Color} to use to render the symbol.
|
207 |
* @param
|
208 |
* @return the {@link Color} to use to render the symbol
|
209 |
*/
|
210 |
public Color getColor(); |
211 |
|
212 |
/**
|
213 |
* Sets the {@link Color} to use to render the symbol.
|
214 |
* @param color to render the symbol
|
215 |
*/
|
216 |
public void setColor(Color color); |
217 |
} |