Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / rendering / symbols / ISymbol.java @ 30011

History | View | Annotate | Download (7.3 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.geom.Geometry;
50
import org.gvsig.fmap.mapcontext.ViewPort;
51
import org.gvsig.tools.task.Cancellable;
52
import org.gvsig.tools.lang.Cloneable;
53
import org.gvsig.utils.IPersistence;
54
import org.gvsig.utils.XMLEntity;
55
import org.gvsig.utils.XMLException;
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 IPersistence, 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, 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
         * Allows the symbol to be persisted during sessions.With this method, the symbol is
152
         * automatically described to be integrated as a part of the project file.Use it to
153
         * specify how do you want to write the symbol in .gvp project
154
         * @return
155
         * @throws XMLException
156
         */
157
        public XMLEntity getXMLEntity() throws XMLException;
158

    
159
        /**
160
         * Called by the factory, this method will set up the symbol and after call it, the
161
         * symbol must be fully functional and ready to be used.
162
         */
163
        public void setXMLEntity(XMLEntity xml);
164

    
165

    
166
        /**
167
         * The description is a human-readable text used to label it when show in a symbol menu or something like that.
168
         * @return   description of this symbol.
169
         * @uml.property  name="description"
170
         */
171
        public String getDescription();
172

    
173
        /**
174
         * Tells whether the shape of the symbol will be drawn or not.
175
         *
176
         * @return <b>true</b> if Shape must be drawn. Useful if you are labelling
177
         */
178
        public boolean isShapeVisible();
179

    
180
        /**
181
         * Sets the description of this symbol
182
         * @param   desc, a string with the description
183
         * @see   ISymbol.getDescription();
184
         * @uml.property  name="description"
185
         */
186
        public void setDescription(String desc);
187

    
188
        /**
189
         * The use of this method -and its mechanism- is being valorated. It probably
190
         * will be <b>deprecated</b>.
191
         * @return FSymbol constants. I think it is better to use isSuitableFor
192
         *
193
         */
194
        public int getSymbolType();
195

    
196
        /**
197
         * True if this symbol is ok for the geometry. For example, a FillSymbol will
198
         * be suitable for a Polygon.
199
         * @param geom
200
         * @return
201
         */
202
        public boolean isSuitableFor(Geometry geom);
203

    
204
        /**
205
         * Useful to render the symbol inside the TOC, or inside little
206
         * rectangles. For example, think about rendering a Label with size
207
         * in meters => You will need to specify a size in pixels.
208
         * Of course, you can also to choose to render a prepared image, etc.
209
         * @param scaleInstance
210
         * @param r
211
         * @param properties TODO
212
         * @param g2
213
         * @throws SymbolDrawingException TODO
214
         */
215
        public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r, PrintAttributes properties) throws SymbolDrawingException;
216
        
217
        /**
218
         * Returns the {@link Color} to use to render the symbol.
219
         * @param 
220
         * @return  the {@link Color} to use to render the symbol
221
         */
222
        public Color getColor();
223
        
224
        /**
225
         * Sets the {@link Color} to use to render the symbol.
226
         * @param color to render the symbol
227
         */
228
        public void setColor(Color color);
229
}