Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.mapcontext / org.gvsig.fmap.mapcontext.api / src / main / java / org / gvsig / fmap / mapcontext / rendering / symbols / ISymbol.java @ 47790

History | View | Annotate | Download (7.14 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24
package org.gvsig.fmap.mapcontext.rendering.symbols;
25

    
26
import java.awt.Color;
27
import java.awt.Graphics2D;
28
import java.awt.Rectangle;
29
import java.awt.geom.AffineTransform;
30
import org.gvsig.fmap.dal.feature.Feature;
31
import org.gvsig.fmap.geom.Geometry;
32
import org.gvsig.fmap.mapcontext.MapContext;
33
import org.gvsig.tools.lang.Cloneable;
34
import org.gvsig.tools.persistence.Persistent;
35
import org.gvsig.tools.task.Cancellable;
36

    
37

    
38
/**
39
 *
40
 * Interface for symbols.It is the most general one which is implemented by other
41
 * specific symbols.For this reason this interface has a method to obtain the derived
42
 * version of a common symbol(apart from others). The main purpose is to offer a set of
43
 * symbols that will be part of the FMap kernel and allow the developer to add new symbols
44
 * without changes in the initial implementation.
45
 *
46
 *
47
 * @author   jaume dominguez faus - jaume.dominguez@iver.es
48
 */
49
public interface ISymbol extends Persistent, IPrintable, Cloneable {
50

    
51
        public static Color SELECTION_COLOR = MapContext.DEFAULT_SELECTION_COLOR;
52

    
53
        /**
54
         * Returns the derived version of the symbol that will be used to draw the
55
         * feature when it is selected.
56
         * @return <b>ISymbol</b> applied to a feature when it has been selected.
57
         */
58
        public ISymbol getSymbolForSelection();
59
        
60
    public ISymbol getSymbolForSelection(Color selectionColor);
61

    
62
        /**
63
         * Used when a symbol is going to be drawn.The method to do
64
         * it will depend on the derived version of the symbol.
65
         * @param g
66
         * @param affineTransform
67
         * @param shp
68
         * @param cancel TODO
69
         */
70
        public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Feature f, Cancellable cancel);
71

    
72
//        /**
73
//         * <p>
74
//         * Returns <b>the distance between the shape's bounding box and the
75
//         * symbol-that-represents-this-shape's bounding box</b> in a two-length-float
76
//         * array passed as parameter.<br>
77
//         * </p>
78
//         * <p>
79
//         * After this method returns, the float array passed will contain two values
80
//         * representing <b>the amount of pixels</b> separating each of the X (first element)
81
//         * and Y (second element) axes.<br>
82
//         * </p>
83
//         * <p>
84
//         * This distance maybe dependent on:
85
//         *         <ol>
86
//         *                 <li>
87
//         *                         <b>The ViewPort</b>: if the symbol is an instance of CartographicSupport
88
//         *                         the units it uses are not pixels and the reference system is
89
//         *                         CarthographicSupport.WORLD.
90
//         *                 </li>
91
//         *                 <li>
92
//         *                         <b>The target rendering context's dpi (dots-per-inch)</b>: if the symbol
93
//         *                         is an instance of CartographicSupport the units it uses are not pixels and
94
//         *                         CarthographicSupport.PAPER.
95
//         *                 </li>
96
//         *         </ol>
97
//         * <br>
98
//         * </p>
99
//         * <p>
100
//         * And in any other case, if the unit of the symbol is pixels or the symbol is not
101
//         * even an instance of CartographicSupport, the returning values are only
102
//         * defined by the symbol and are not calculated.
103
//         * </p>
104
//         * @param ViewPort viewPort
105
//         * @param Shape shp
106
//         * @param int dpi
107
//         * @param float[] distances, the array of floats where to store the distances in x and y axis
108
//         */
109
//        public void getPixExtentPlus(Geometry geom, float[] distances, ViewPort viewPort, int dpi);
110
        
111
        
112
//        /**
113
//         * Informs that the geometry will be represented with that symbol in just one pixel or dot
114
//         * 
115
//         * 
116
//         * 
117
//         * @param geom
118
//         * @param positionOfDotOrPixel (out) filled with pixel or dot location
119
//         * @param viewPort
120
//         * @param dpi
121
//         * @return
122
//         */
123
//        public boolean isOneDotOrPixel(Geometry geom, double[] positionOfDotOrPixel,
124
//                        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

    
135

    
136

    
137
        /**
138
         * The description is a human-readable text used to label it when show in a symbol menu or something like that.
139
         * @return   description of this symbol.
140
         * @uml.property  name="description"
141
         */
142
        public String getDescription();
143

    
144
        /**
145
         * Tells whether the shape of the symbol will be drawn or not.
146
         *
147
         * @return <b>true</b> if Shape must be drawn. Useful if you are labelling
148
         */
149
        public boolean isShapeVisible();
150

    
151
        /**
152
         * Sets the description of this symbol
153
         * @param   desc, a string with the description
154
         * @see   ISymbol.getDescription();
155
         * @uml.property  name="description"
156
         */
157
        public void setDescription(String desc);
158

    
159
        /**
160
         * The use of this method -and its mechanism- is being valorated. It probably
161
         * will be <b>deprecated</b>.
162
         * @return FSymbol constants. I think it is better to use isSuitableFor
163
         *
164
         */
165
        public int getSymbolType();
166

    
167
        /**
168
         * True if this symbol is ok for the geometry. For example, a FillSymbol will
169
         * be suitable for a Polygon.
170
         * @param geom
171
         * @return
172
         */
173
        public boolean isSuitableFor(Geometry geom);
174

    
175
        /**
176
         * Useful to render the symbol inside the TOC, or inside little
177
         * rectangles. For example, think about rendering a Label with size
178
         * in meters => You will need to specify a size in pixels.
179
         * Of course, you can also to choose to render a prepared image, etc.
180
         * @param scaleInstance
181
         * @param r
182
         * @param g2
183
         * @throws SymbolDrawingException TODO
184
         */
185
        public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r) throws SymbolDrawingException;
186
        
187
        /**
188
         * Returns the {@link Color} to use to render the symbol.
189
         * @param 
190
         * @return  the {@link Color} to use to render the symbol
191
         */
192
        public Color getColor();
193
        
194
        /**
195
         * Sets the {@link Color} to use to render the symbol.
196
         * @param color to render the symbol
197
         */
198
        public void setColor(Color color);
199
        
200
    /**
201
     * Set the id ob the symbol (the basename of file).
202
     * This attribute is not persistent.
203
     *
204
     * @param id
205
     */
206
    public void setID(String id);
207

    
208
    /**
209
     * Get the id ob the symbol (the basename of file).This attribute is not persistent.
210
     * @return
211
     */
212
    public String getID();
213
    
214
    public Feature getFeature();
215
    
216
    public void setFeature(Feature feature);
217
    
218
    public void draw(Graphics2D g, AffineTransform affineTransform, Geometry geom, Feature f, Cancellable cancel, Rectangle r);
219
        
220
}