Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_mapcontext / src / org / gvsig / fmap / mapcontext / rendering / symbols / ISymbol.java @ 28879

History | View | Annotate | Download (6.59 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 javax.print.attribute.PrintRequestAttributeSet;
49

    
50
import org.gvsig.fmap.geom.Geometry;
51
import org.gvsig.fmap.mapcontext.ViewPort;
52
import org.gvsig.tools.task.Cancellable;
53

    
54
import com.iver.utiles.IPersistence;
55
import com.iver.utiles.XMLEntity;
56
import com.iver.utiles.XMLException;
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

    
71
        public static Color SELECTION_COLOR = Color.YELLOW;
72

    
73
        /**
74
         * Returns the derived version of the symbol that will be used to draw the
75
         * feature when it is selected.
76
         * @return <b>ISymbol</b> applied to a feature when it has been selected.
77
         */
78
        public ISymbol getSymbolForSelection();
79

    
80
        /**
81
         * Used when a symbol is going to be drawn.The method to do
82
         * it will depend on the derived version of the symbol.
83
         * @param g
84
         * @param affineTransform
85
         * @param shp
86
         * @param cancel TODO
87
         */
88
        public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Cancellable cancel);
89

    
90
        /**
91
         * <p>
92
         * Returns <b>the distance between the shape's bounding box and the
93
         * symbol-that-represents-this-shape's bounding box</b> in a two-length-float
94
         * array passed as parameter.<br>
95
         * </p>
96
         * <p>
97
         * After this method returns, the float array passed will contain two values
98
         * representing <b>the amount of pixels</b> separating each of the X (first element)
99
         * and Y (second element) axes.<br>
100
         * </p>
101
         * <p>
102
         * This distance maybe dependent on:
103
         *         <ol>
104
         *                 <li>
105
         *                         <b>The ViewPort</b>: if the symbol is an instance of CartographicSupport
106
         *                         the units it uses are not pixels and the reference system is
107
         *                         CarthographicSupport.WORLD.
108
         *                 </li>
109
         *                 <li>
110
         *                         <b>The target rendering context's dpi (dots-per-inch)</b>: if the symbol
111
         *                         is an instance of CartographicSupport the units it uses are not pixels and
112
         *                         CarthographicSupport.PAPER.
113
         *                 </li>
114
         *         </ol>
115
         * <br>
116
         * </p>
117
         * <p>
118
         * And in any other case, if the unit of the symbol is pixels or the symbol is not
119
         * even an instance of CartographicSupport, the returning values are only
120
         * defined by the symbol and are not calculated.
121
         * </p>
122
         * @param ViewPort viewPort
123
         * @param Shape shp
124
         * @param int dpi
125
         * @param float[] distances, the array of floats where to store the distances in x and y axis
126
         */
127
        public void getPixExtentPlus(Geometry geom, float[] distances, ViewPort viewPort, int dpi);
128

    
129
        /**
130
         * Returns the rgb of the symbol when it is drawn like a point.
131
         *
132
         * @return rgb of the symbol.
133
         */
134
        public int getOnePointRgb();
135

    
136
        /**
137
         * Allows the symbol to be persisted during sessions.With this method, the symbol is
138
         * automatically described to be integrated as a part of the project file.Use it to
139
         * specify how do you want to write the symbol in .gvp project
140
         * @return
141
         * @throws XMLException
142
         */
143
        public XMLEntity getXMLEntity() throws XMLException;
144

    
145
        /**
146
         * Called by the factory, this method will set up the symbol and after call it, the
147
         * symbol must be fully functional and ready to be used.
148
         */
149
        public void setXMLEntity(XMLEntity xml);
150

    
151

    
152
        /**
153
         * The description is a human-readable text used to label it when show in a symbol menu or something like that.
154
         * @return   description of this symbol.
155
         * @uml.property  name="description"
156
         */
157
        public String getDescription();
158

    
159
        /**
160
         * Tells whether the shape of the symbol will be drawn or not.
161
         *
162
         * @return <b>true</b> if Shape must be drawn. Useful if you are labelling
163
         */
164
        public boolean isShapeVisible();
165

    
166
        /**
167
         * Sets the description of this symbol
168
         * @param   desc, a string with the description
169
         * @see   ISymbol.getDescription();
170
         * @uml.property  name="description"
171
         */
172
        public void setDescription(String desc);
173

    
174
        /**
175
         * The use of this method -and its mechanism- is being valorated. It probably
176
         * will be <b>deprecated</b>.
177
         * @return FSymbol constants. I think it is better to use isSuitableFor
178
         *
179
         */
180
        public int getSymbolType();
181

    
182
        /**
183
         * True if this symbol is ok for the geometry. For example, a FillSymbol will
184
         * be suitable for a Polygon.
185
         * @param geom
186
         * @return
187
         */
188
        public boolean isSuitableFor(Geometry geom);
189

    
190
        /**
191
         * Useful to render the symbol inside the TOC, or inside little
192
         * rectangles. For example, think about rendering a Label with size
193
         * in meters => You will need to specify a size in pixels.
194
         * Of course, you can also to choose to render a prepared image, etc.
195
         * @param scaleInstance
196
         * @param r
197
         * @param properties TODO
198
         * @param g2
199
         * @throws SymbolDrawingException TODO
200
         */
201
        public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r, PrintRequestAttributeSet properties) throws SymbolDrawingException;
202

    
203
}
204

    
205