root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / symbols / ISymbol.java @ 28367
History | View | Annotate | Download (6.4 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 com.iver.cit.gvsig.fmap.core.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 javax.print.attribute.PrintRequestAttributeSet; |
49 |
|
50 |
import com.iver.cit.gvsig.fmap.ViewPort; |
51 |
import com.iver.cit.gvsig.fmap.core.FShape; |
52 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
53 |
import com.iver.cit.gvsig.fmap.core.IPrintable; |
54 |
import com.iver.utiles.IPersistence; |
55 |
import com.iver.utiles.XMLEntity; |
56 |
import com.iver.utiles.swing.threads.Cancellable; |
57 |
|
58 |
/**
|
59 |
*
|
60 |
* Interface for symbols.It is the most general one which is implemented by other
|
61 |
* specific symbols.For this reason this interface has a method to obtain the derived
|
62 |
* version of a common symbol(apart from others). The main purpose is to offer a set of
|
63 |
* symbols that will be part of the FMap kernel and allow the developer to add new symbols
|
64 |
* without changes in the initial implementation.
|
65 |
*
|
66 |
*
|
67 |
* @author jaume dominguez faus - jaume.dominguez@iver.es
|
68 |
*/
|
69 |
public interface ISymbol extends IPersistence, IPrintable { |
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, FShape shp, 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(FShape shp, float[] distances, ViewPort viewPort, int dpi); |
127 |
|
128 |
/**
|
129 |
* Returns the rgb of the symbol when it is drawn like a point.
|
130 |
*
|
131 |
* @return rgb of the symbol.
|
132 |
*/
|
133 |
public int getOnePointRgb(); |
134 |
|
135 |
/**
|
136 |
* Allows the symbol to be persisted during sessions.With this method, the symbol is
|
137 |
* automatically described to be integrated as a part of the project file.Use it to
|
138 |
* specify how do you want to write the symbol in .gvp project
|
139 |
* @return
|
140 |
*/
|
141 |
public XMLEntity getXMLEntity();
|
142 |
|
143 |
/**
|
144 |
* Called by the factory, this method will set up the symbol and after call it, the
|
145 |
* symbol must be fully functional and ready to be used.
|
146 |
*/
|
147 |
public void setXMLEntity(XMLEntity xml); |
148 |
|
149 |
|
150 |
/**
|
151 |
* The description is a human-readable text used to label it when show in a symbol menu or something like that.
|
152 |
* @return description of this symbol.
|
153 |
* @uml.property name="description"
|
154 |
*/
|
155 |
public String getDescription(); |
156 |
|
157 |
/**
|
158 |
* Tells whether the shape of the symbol will be drawn or not.
|
159 |
*
|
160 |
* @return <b>true</b> if Shape must be drawn. Useful if you are labelling
|
161 |
*/
|
162 |
public boolean isShapeVisible(); |
163 |
|
164 |
/**
|
165 |
* Sets the description of this symbol
|
166 |
* @param desc, a string with the description
|
167 |
* @see ISymbol.getDescription();
|
168 |
* @uml.property name="description"
|
169 |
*/
|
170 |
public void setDescription(String desc); |
171 |
|
172 |
/**
|
173 |
* The use of this method -and its mechanism- is being valorated. It probably
|
174 |
* will be <b>deprecated</b>.
|
175 |
* @return FSymbol constants. I think it is better to use isSuitableFor
|
176 |
*
|
177 |
*/
|
178 |
public int getSymbolType(); |
179 |
|
180 |
/**
|
181 |
* True if this symbol is ok for the geometry. For example, a FillSymbol will
|
182 |
* be suitable for a Polygon.
|
183 |
* @param geom
|
184 |
* @return
|
185 |
*/
|
186 |
public boolean isSuitableFor(IGeometry geom); |
187 |
|
188 |
/**
|
189 |
* Useful to render the symbol inside the TOC, or inside little
|
190 |
* rectangles. For example, think about rendering a Label with size
|
191 |
* in meters => You will need to specify a size in pixels.
|
192 |
* Of course, you can also to choose to render a prepared image, etc.
|
193 |
* @param scaleInstance
|
194 |
* @param r
|
195 |
* @param properties TODO
|
196 |
* @param g2
|
197 |
* @throws SymbolDrawingException TODO
|
198 |
*/
|
199 |
public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r, PrintRequestAttributeSet properties) throws SymbolDrawingException; |
200 |
|
201 |
|
202 |
} |
203 |
|
204 |
|