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 @ 40559
History | View | Annotate | Download (6.48 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
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 | 40559 | jjdelcerro | * as published by the Free Software Foundation; either version 3
|
9 | 40435 | jjdelcerro | * 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 | 40559 | jjdelcerro | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | * MA 02110-1301, USA.
|
||
20 | 40435 | jjdelcerro | *
|
21 | 40559 | jjdelcerro | * For any additional information, do not hesitate to contact us
|
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | 40435 | jjdelcerro | */
|
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 | |||
31 | import org.gvsig.compat.print.PrintAttributes; |
||
32 | import org.gvsig.fmap.dal.feature.Feature; |
||
33 | import org.gvsig.fmap.geom.Geometry; |
||
34 | import org.gvsig.fmap.mapcontext.ViewPort; |
||
35 | import org.gvsig.tools.persistence.Persistent; |
||
36 | import org.gvsig.tools.task.Cancellable; |
||
37 | import org.gvsig.tools.lang.Cloneable; |
||
38 | |||
39 | |||
40 | /**
|
||
41 | *
|
||
42 | * Interface for symbols.It is the most general one which is implemented by other
|
||
43 | * specific symbols.For this reason this interface has a method to obtain the derived
|
||
44 | * version of a common symbol(apart from others). The main purpose is to offer a set of
|
||
45 | * symbols that will be part of the FMap kernel and allow the developer to add new symbols
|
||
46 | * without changes in the initial implementation.
|
||
47 | *
|
||
48 | *
|
||
49 | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
||
50 | */
|
||
51 | public interface ISymbol extends Persistent, IPrintable, Cloneable { |
||
52 | |||
53 | public static Color SELECTION_COLOR = Color.YELLOW; |
||
54 | |||
55 | /**
|
||
56 | * Returns the derived version of the symbol that will be used to draw the
|
||
57 | * feature when it is selected.
|
||
58 | * @return <b>ISymbol</b> applied to a feature when it has been selected.
|
||
59 | */
|
||
60 | public ISymbol getSymbolForSelection();
|
||
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 properties TODO
|
||
183 | * @param g2
|
||
184 | * @throws SymbolDrawingException TODO
|
||
185 | */
|
||
186 | public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r, PrintAttributes properties) throws SymbolDrawingException; |
||
187 | |||
188 | /**
|
||
189 | * Returns the {@link Color} to use to render the symbol.
|
||
190 | * @param
|
||
191 | * @return the {@link Color} to use to render the symbol
|
||
192 | */
|
||
193 | public Color getColor(); |
||
194 | |||
195 | /**
|
||
196 | * Sets the {@link Color} to use to render the symbol.
|
||
197 | * @param color to render the symbol
|
||
198 | */
|
||
199 | public void setColor(Color color); |
||
200 | } |