root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / core / symbols / ISymbol.java @ 38563
History | View | Annotate | Download (6.4 KB)
1 | 12728 | jaume | /* gvSIG. Sistema de Informaci�n Geogr�fica de la Generalitat Valenciana
|
---|---|---|---|
2 | 9641 | jaume | *
|
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 | 12728 | jaume | * Av. Blasco Ib��ez, 50
|
24 | 9641 | jaume | * 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 | 12728 | jaume | import java.awt.Color; |
44 | 9641 | jaume | import java.awt.Graphics2D; |
45 | import java.awt.Rectangle; |
||
46 | import java.awt.geom.AffineTransform; |
||
47 | |||
48 | 28367 | vcaballero | import javax.print.attribute.PrintRequestAttributeSet; |
49 | |||
50 | 18621 | jdominguez | import com.iver.cit.gvsig.fmap.ViewPort; |
51 | 9641 | jaume | import com.iver.cit.gvsig.fmap.core.FShape; |
52 | import com.iver.cit.gvsig.fmap.core.IGeometry; |
||
53 | import com.iver.cit.gvsig.fmap.core.IPrintable; |
||
54 | 13913 | jaume | import com.iver.utiles.IPersistence; |
55 | 9641 | jaume | import com.iver.utiles.XMLEntity; |
56 | 13953 | jaume | import com.iver.utiles.swing.threads.Cancellable; |
57 | 9641 | jaume | |
58 | 10679 | jaume | /**
|
59 | 12985 | jvidal | *
|
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 | 10679 | jaume | * @author jaume dominguez faus - jaume.dominguez@iver.es
|
68 | */
|
||
69 | 18621 | jdominguez | public interface ISymbol extends IPersistence, IPrintable { |
70 | 12728 | jaume | public static Color SELECTION_COLOR = Color.YELLOW; |
71 | 12985 | jvidal | |
72 | 9641 | jaume | /**
|
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 | 10679 | jaume | public ISymbol getSymbolForSelection();
|
78 | 9641 | jaume | |
79 | 12985 | jvidal | /**
|
80 | 13073 | jvidal | * Used when a symbol is going to be drawn.The method to do
|
81 | 12985 | jvidal | * it will depend on the derived version of the symbol.
|
82 | * @param g
|
||
83 | * @param affineTransform
|
||
84 | * @param shp
|
||
85 | 13953 | jaume | * @param cancel TODO
|
86 | 12985 | jvidal | */
|
87 | 13953 | jaume | public void draw(Graphics2D g, AffineTransform affineTransform, FShape shp, Cancellable cancel); |
88 | 9641 | jaume | |
89 | /**
|
||
90 | 18621 | jdominguez | * <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(FShape shp, float[] distances, ViewPort viewPort, int dpi); |
||
127 | |||
128 | /**
|
||
129 | 12985 | jvidal | * Returns the rgb of the symbol when it is drawn like a point.
|
130 | 9641 | jaume | *
|
131 | 12985 | jvidal | * @return rgb of the symbol.
|
132 | 9641 | jaume | */
|
133 | public int getOnePointRgb(); |
||
134 | |||
135 | /**
|
||
136 | 12985 | jvidal | * Allows the symbol to be persisted during sessions.With this method, the symbol is
|
137 | * automatically described to be integrated as a part of the project file.Use it to
|
||
138 | * specify how do you want to write the symbol in .gvp project
|
||
139 | 9641 | jaume | * @return
|
140 | */
|
||
141 | 10679 | jaume | public XMLEntity getXMLEntity();
|
142 | 10900 | jaume | |
143 | 10679 | jaume | /**
|
144 | * Called by the factory, this method will set up the symbol and after call it, the
|
||
145 | 10900 | jaume | * symbol must be fully functional and ready to be used.
|
146 | 10679 | jaume | */
|
147 | public void setXMLEntity(XMLEntity xml); |
||
148 | 9641 | jaume | |
149 | 10679 | jaume | |
150 | 9641 | jaume | /**
|
151 | 10679 | jaume | * The description is a human-readable text used to label it when show in a symbol menu or something like that.
|
152 | * @return description of this symbol.
|
||
153 | * @uml.property name="description"
|
||
154 | 9641 | jaume | */
|
155 | 10679 | jaume | public String getDescription(); |
156 | 9641 | jaume | |
157 | /**
|
||
158 | * Tells whether the shape of the symbol will be drawn or not.
|
||
159 | *
|
||
160 | * @return <b>true</b> if Shape must be drawn. Useful if you are labelling
|
||
161 | */
|
||
162 | 10679 | jaume | public boolean isShapeVisible(); |
163 | 9641 | jaume | |
164 | /**
|
||
165 | * Sets the description of this symbol
|
||
166 | 10679 | jaume | * @param desc, a string with the description
|
167 | * @see ISymbol.getDescription();
|
||
168 | * @uml.property name="description"
|
||
169 | 9641 | jaume | */
|
170 | 10679 | jaume | public void setDescription(String desc); |
171 | 9641 | jaume | |
172 | /**
|
||
173 | * The use of this method -and its mechanism- is being valorated. It probably
|
||
174 | * will be <b>deprecated</b>.
|
||
175 | * @return FSymbol constants. I think it is better to use isSuitableFor
|
||
176 | *
|
||
177 | */
|
||
178 | 10679 | jaume | public int getSymbolType(); |
179 | 9641 | jaume | |
180 | /**
|
||
181 | * True if this symbol is ok for the geometry. For example, a FillSymbol will
|
||
182 | * be suitable for a Polygon.
|
||
183 | * @param geom
|
||
184 | * @return
|
||
185 | */
|
||
186 | 10679 | jaume | public boolean isSuitableFor(IGeometry geom); |
187 | 9641 | jaume | |
188 | /**
|
||
189 | * Useful to render the symbol inside the TOC, or inside little
|
||
190 | * rectangles. For example, think about rendering a Label with size
|
||
191 | * in meters => You will need to specify a size in pixels.
|
||
192 | * Of course, you can also to choose to render a prepared image, etc.
|
||
193 | * @param scaleInstance
|
||
194 | * @param r
|
||
195 | 28367 | vcaballero | * @param properties TODO
|
196 | * @param g2
|
||
197 | 18621 | jdominguez | * @throws SymbolDrawingException TODO
|
198 | 9641 | jaume | */
|
199 | 28367 | vcaballero | public void drawInsideRectangle(Graphics2D g, AffineTransform scaleInstance, Rectangle r, PrintRequestAttributeSet properties) throws SymbolDrawingException; |
200 | 9641 | jaume | |
201 | 21535 | vcaballero | |
202 | 9641 | jaume | } |
203 |