Statistics
| Revision:

root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / symbols / ISymbol.java @ 21535

History | View | Annotate | Download (6.29 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 com.iver.cit.gvsig.fmap.ViewPort;
49
import com.iver.cit.gvsig.fmap.core.FShape;
50
import com.iver.cit.gvsig.fmap.core.IGeometry;
51
import com.iver.cit.gvsig.fmap.core.IPrintable;
52
import com.iver.utiles.IPersistence;
53
import com.iver.utiles.XMLEntity;
54
import com.iver.utiles.swing.threads.Cancellable;
55

    
56
/**
57
 *
58
 * Interface for symbols.It is the most general one which is implemented by other
59
 * specific symbols.For this reason this interface has a method to obtain the derived
60
 * version of a common symbol(apart from others). The main purpose is to offer a set of
61
 * symbols that will be part of the FMap kernel and allow the developer to add new symbols
62
 * without changes in the initial implementation.
63
 *
64
 *
65
 * @author   jaume dominguez faus - jaume.dominguez@iver.es
66
 */
67
public interface ISymbol extends IPersistence, IPrintable {
68
        public static Color SELECTION_COLOR = Color.YELLOW;
69

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

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

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

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

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

    
147

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

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

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

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

    
178
        /**
179
         * True if this symbol is ok for the geometry. For example, a FillSymbol will
180
         * be suitable for a Polygon.
181
         * @param geom
182
         * @return
183
         */
184
        public boolean isSuitableFor(IGeometry geom);
185

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

    
198

    
199
}
200

    
201