Revision 2755 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/FFrameLegend.java
FFrameLegend.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.gui.layout.fframes; |
42 | 42 |
|
43 |
import java.awt.Color; |
|
44 |
import java.awt.Font; |
|
45 |
import java.awt.Graphics2D; |
|
46 |
import java.awt.Rectangle; |
|
47 |
import java.awt.geom.AffineTransform; |
|
48 |
import java.awt.geom.Rectangle2D; |
|
49 |
import java.awt.image.BufferedImage; |
|
50 |
import java.util.ArrayList; |
|
51 |
|
|
52 | 43 |
import com.iver.andami.PluginServices; |
44 |
|
|
53 | 45 |
import com.iver.cit.gvsig.LayoutControls; |
54 | 46 |
import com.iver.cit.gvsig.fmap.DriverException; |
55 | 47 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
... | ... | |
61 | 53 |
import com.iver.cit.gvsig.fmap.rendering.ClassifiedLegendInfo; |
62 | 54 |
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
63 | 55 |
import com.iver.cit.gvsig.gui.layout.Layout; |
56 |
|
|
64 | 57 |
import com.iver.utiles.XMLEntity; |
65 | 58 |
|
59 |
import java.awt.Color; |
|
60 |
import java.awt.Font; |
|
61 |
import java.awt.Graphics2D; |
|
62 |
import java.awt.Rectangle; |
|
63 |
import java.awt.geom.AffineTransform; |
|
64 |
import java.awt.geom.Rectangle2D; |
|
65 |
import java.awt.image.BufferedImage; |
|
66 | 66 |
|
67 |
import java.util.ArrayList; |
|
68 |
|
|
69 |
|
|
67 | 70 |
/** |
68 | 71 |
* FFrame para introducir una leyenda en el Layout. |
69 | 72 |
* |
70 | 73 |
* @author Vicente Caballero Navarro |
71 | 74 |
*/ |
72 | 75 |
public class FFrameLegend extends FFrame { |
73 |
private static final int PRESENTACION = 0; |
|
74 |
private static final int BORRADOR = 1; |
|
75 |
private int m_quality = 0; |
|
76 |
private int m_viewing = 0; |
|
77 |
//private FontRenderContext m_frc = null; |
|
78 |
//private FMap m_fmap = null; |
|
79 |
private Font m_f = new Font("Monospaced", Font.PLAIN, 9); |
|
80 |
private FFrameView fframeview = null; |
|
81 |
private int num = 0; |
|
82 |
private int m_max; |
|
83 |
private int m_numLayers; |
|
84 |
private FLayers layers = null; |
|
76 |
private static final int PRESENTACION = 0; |
|
77 |
private static final int BORRADOR = 1; |
|
78 |
private int m_quality = 0; |
|
79 |
private int m_viewing = 0; |
|
80 |
private Font m_f = new Font("Monospaced", Font.PLAIN, 9); |
|
81 |
private FFrameView fframeview = null; |
|
82 |
private int num = 0; |
|
83 |
private int m_max; |
|
84 |
private int m_numLayers; |
|
85 |
private FLayers layers = null; |
|
85 | 86 |
|
86 |
/**
|
|
87 |
* Rellena la calidad que se quiere aplicar.
|
|
88 |
*
|
|
89 |
* @param q entero que representa la calidad a aplicar.
|
|
90 |
*/
|
|
91 |
public void setQuality(int q) {
|
|
92 |
m_quality = q;
|
|
93 |
}
|
|
87 |
/**
|
|
88 |
* Rellena la calidad que se quiere aplicar.
|
|
89 |
*
|
|
90 |
* @param q entero que representa la calidad a aplicar.
|
|
91 |
*/
|
|
92 |
public void setQuality(int q) {
|
|
93 |
m_quality = q;
|
|
94 |
}
|
|
94 | 95 |
|
95 |
/**
|
|
96 |
* Devuelve un entero que representa la calidad que est? seleccionada.
|
|
97 |
*
|
|
98 |
* @return tipo de calidad selccionada.
|
|
99 |
*/
|
|
100 |
public int getQuality() {
|
|
101 |
return m_quality;
|
|
102 |
}
|
|
96 |
/**
|
|
97 |
* Devuelve un entero que representa la calidad que est? seleccionada.
|
|
98 |
*
|
|
99 |
* @return tipo de calidad selccionada.
|
|
100 |
*/
|
|
101 |
public int getQuality() {
|
|
102 |
return m_quality;
|
|
103 |
}
|
|
103 | 104 |
|
104 |
/**
|
|
105 |
* Devuelve un entero que representa la forma en que se actualiza la vista.
|
|
106 |
*
|
|
107 |
* @return forma que se actualiza la vista.
|
|
108 |
*/
|
|
109 |
public int getViewing() {
|
|
110 |
return m_viewing;
|
|
111 |
}
|
|
105 |
/**
|
|
106 |
* Devuelve un entero que representa la forma en que se actualiza la vista.
|
|
107 |
*
|
|
108 |
* @return forma que se actualiza la vista.
|
|
109 |
*/
|
|
110 |
public int getViewing() {
|
|
111 |
return m_viewing;
|
|
112 |
}
|
|
112 | 113 |
|
113 |
/**
|
|
114 |
* Inserta una FFrameView de donde se obtiene la informaci?n de las capas
|
|
115 |
* para generar la leyenda.
|
|
116 |
*
|
|
117 |
* @param f FFrameView para obtener los nombres de las capas.
|
|
118 |
*/
|
|
119 |
public void setFFrameView(FFrameView f) {
|
|
120 |
fframeview = f;
|
|
121 |
}
|
|
114 |
/**
|
|
115 |
* Inserta una FFrameView de donde se obtiene la informaci?n de las capas
|
|
116 |
* para generar la leyenda.
|
|
117 |
*
|
|
118 |
* @param f FFrameView para obtener los nombres de las capas.
|
|
119 |
*/
|
|
120 |
public void setFFrameView(FFrameView f) {
|
|
121 |
fframeview = f;
|
|
122 |
}
|
|
122 | 123 |
|
123 |
/**
|
|
124 |
* Devuelve el FFrameView utilizado para obtener la leyenda.
|
|
125 |
*
|
|
126 |
* @return FFrameView utilizado.
|
|
127 |
*/
|
|
128 |
public FFrameView getFFrameView() {
|
|
129 |
return fframeview;
|
|
130 |
}
|
|
124 |
/**
|
|
125 |
* Devuelve el FFrameView utilizado para obtener la leyenda.
|
|
126 |
*
|
|
127 |
* @return FFrameView utilizado.
|
|
128 |
*/
|
|
129 |
public FFrameView getFFrameView() {
|
|
130 |
return fframeview;
|
|
131 |
}
|
|
131 | 132 |
|
132 |
/**
|
|
133 |
* Rellena la forma de actualizar la vista.
|
|
134 |
*
|
|
135 |
* @param v entero que representa la forma de actualizar la vista.
|
|
136 |
*/
|
|
137 |
public void setViewing(int v) {
|
|
138 |
m_viewing = v;
|
|
139 |
}
|
|
133 |
/**
|
|
134 |
* Rellena la forma de actualizar la vista.
|
|
135 |
*
|
|
136 |
* @param v entero que representa la forma de actualizar la vista.
|
|
137 |
*/
|
|
138 |
public void setViewing(int v) {
|
|
139 |
m_viewing = v;
|
|
140 |
}
|
|
140 | 141 |
|
141 |
/** |
|
142 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n |
|
143 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe |
|
144 |
* de dibujar. |
|
145 |
* |
|
146 |
* @param g Graphics |
|
147 |
* @param at Transformada afin. |
|
148 |
* @param rv rect?ngulo sobre el que hacer un clip. |
|
149 |
* @param imgBase Imagen para acelerar el dibujado. |
|
150 |
* |
|
151 |
* @throws DriverException |
|
152 |
*/ |
|
153 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
|
154 |
BufferedImage imgBase) throws DriverException { |
|
155 |
Rectangle2D.Double re = getBoundingBox(at); |
|
156 |
g.rotate(Math.toRadians(getRotation()), re.x + (re.width / 2), |
|
157 |
re.y + (re.height / 2)); |
|
158 |
if ((fframeview != null) && (fframeview.getFMap() != null)) { |
|
159 |
layers = fframeview.getFMap().getLayers(); |
|
160 |
} |
|
142 |
/** |
|
143 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n |
|
144 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe |
|
145 |
* de dibujar. |
|
146 |
* |
|
147 |
* @param g Graphics |
|
148 |
* @param at Transformada afin. |
|
149 |
* @param rv rect?ngulo sobre el que hacer un clip. |
|
150 |
* @param imgBase Imagen para acelerar el dibujado. |
|
151 |
* |
|
152 |
* @throws DriverException |
|
153 |
*/ |
|
154 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
|
155 |
BufferedImage imgBase) throws DriverException { |
|
156 |
Rectangle2D.Double re = getBoundingBox(at); |
|
157 |
g.rotate(Math.toRadians(getRotation()), re.x + (re.width / 2), |
|
158 |
re.y + (re.height / 2)); |
|
161 | 159 |
|
162 |
m_max = 0; |
|
163 |
m_numLayers = 0; |
|
160 |
if ((fframeview != null) && (fframeview.getFMap() != null)) { |
|
161 |
layers = fframeview.getFMap().getLayers(); |
|
162 |
} |
|
164 | 163 |
|
165 |
if (intersects(rv, re)) { |
|
166 |
if (layers == null) { //Si no se ha seleccionado ninguna vista para crear la leyenda. |
|
167 |
drawEmpty(g); |
|
168 |
} else if ((rv == null) || (getQuality() == PRESENTACION)) { |
|
169 |
m_numLayers = getSizeNum(layers); |
|
170 |
//m_frc = g.getFontRenderContext(); |
|
164 |
m_max = 0; |
|
165 |
m_numLayers = 0; |
|
171 | 166 |
|
172 |
double h = re.getHeight() / m_numLayers; |
|
173 |
int[] n = new int[1]; |
|
174 |
n[0]=0; |
|
175 |
drawTheme(g, re, h, layers, n,Font.PLAIN); |
|
176 |
} else if (getQuality() == BORRADOR) { //Si se selecciona la calidad BORRADOR. |
|
177 |
drawDraft(g); |
|
178 |
} |
|
179 |
} |
|
180 |
g.rotate(Math.toRadians(-getRotation()), |
|
181 |
re.x + (re.width / 2), re.y + (re.height / 2)); |
|
182 |
} |
|
167 |
if (intersects(rv, re)) { |
|
168 |
if (layers == null) { //Si no se ha seleccionado ninguna vista para crear la leyenda. |
|
169 |
drawEmpty(g); |
|
170 |
} else if ((rv == null) || (getQuality() == PRESENTACION)) { |
|
171 |
m_numLayers = getSizeNum(layers); |
|
183 | 172 |
|
184 |
/** |
|
185 |
* Dibuja el nombre u s?mbolo de la capa que se pasa como par?metro. |
|
186 |
* |
|
187 |
* @param g Graphics2D sobre el que se dibuja. |
|
188 |
* @param re Rectangle a rellenar. |
|
189 |
* @param h Altura en pixels. |
|
190 |
* @param layers Capa a representar. |
|
191 |
* @param n ?ndice de la capa a dibujar. |
|
192 |
* |
|
193 |
* @return ?ndice de la capa siguiente. |
|
194 |
* |
|
195 |
* @throws DriverException |
|
196 |
*/ |
|
197 |
private void drawTheme(Graphics2D g, Rectangle2D re, double h, |
|
198 |
FLayers layers, int[] n,int typeFont) throws DriverException { |
|
199 |
//////Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics |
|
200 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
|
201 |
FLayer layer = (FLayer) layers.getLayer(i); |
|
173 |
double h = re.getHeight() / m_numLayers; |
|
174 |
int[] n = new int[1]; |
|
175 |
n[0] = 0; |
|
176 |
drawTheme(g, re, h, layers, n, Font.PLAIN); |
|
177 |
} else if (getQuality() == BORRADOR) { //Si se selecciona la calidad BORRADOR. |
|
178 |
drawDraft(g); |
|
179 |
} |
|
180 |
} |
|
202 | 181 |
|
203 |
if (layer.isVisible()) { |
|
204 |
if (layer instanceof FLayers) { |
|
205 |
n[0]++; |
|
206 |
int sizefont=0; |
|
207 |
double dX = 0; |
|
208 |
double dY = n[0] * h; |
|
209 |
int xl = (int) (re.getX() + dX); |
|
210 |
int yl = (int) (re.getY() + dY); |
|
211 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) { |
|
212 |
sizefont = (int) (re.getHeight() / m_numLayers); |
|
213 |
} else { |
|
214 |
sizefont = (int) (re.getWidth() / 8); |
|
215 |
} |
|
216 |
drawNameLegend(g,layer.getName(), re, sizefont, |
|
217 |
(int) (xl - (re.getWidth() / 5)), yl, h,Font.BOLD); |
|
218 |
n[0]++; |
|
219 |
drawTheme(g, re, h, (FLayers)layer, n,Font.ITALIC); |
|
220 |
n[0]++; |
|
221 |
} else if (layer instanceof AlphanumericData) { |
|
222 |
AlphanumericData cO = (AlphanumericData) layer; |
|
182 |
g.rotate(Math.toRadians(-getRotation()), re.x + (re.width / 2), |
|
183 |
re.y + (re.height / 2)); |
|
184 |
} |
|
223 | 185 |
|
224 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
|
225 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
|
226 |
double dX = 0; |
|
227 |
double dY = n[0] * h; |
|
186 |
/** |
|
187 |
* Dibuja el nombre u s?mbolo de la capa que se pasa como par?metro. |
|
188 |
* |
|
189 |
* @param g Graphics2D sobre el que se dibuja. |
|
190 |
* @param re Rectangle a rellenar. |
|
191 |
* @param h Altura en pixels. |
|
192 |
* @param layers Capa a representar. |
|
193 |
* @param n ?ndice de la capa a dibujar. |
|
194 |
* @param typeFont DOCUMENT ME! |
|
195 |
* |
|
196 |
* @throws DriverException |
|
197 |
*/ |
|
198 |
private void drawTheme(Graphics2D g, Rectangle2D re, double h, |
|
199 |
FLayers layers, int[] n, int typeFont) throws DriverException { |
|
200 |
//////Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics |
|
201 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
|
202 |
FLayer layer = (FLayer) layers.getLayer(i); |
|
228 | 203 |
|
229 |
int xl = (int) (re.getX() + dX);
|
|
230 |
int yl = (int) (re.getY() + dY);
|
|
231 |
int sizefont = 0;
|
|
204 |
if (layer.isVisible()) {
|
|
205 |
if (layer instanceof FLayers) {
|
|
206 |
n[0]++;
|
|
232 | 207 |
|
233 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) {
|
|
234 |
sizefont = (int) (re.getHeight() / m_numLayers);
|
|
235 |
} else {
|
|
236 |
sizefont = (int) (re.getWidth() / 8);
|
|
237 |
}
|
|
208 |
float sizefont = 0;
|
|
209 |
double dX = 0;
|
|
210 |
double dY = n[0] * h;
|
|
211 |
double xl = (re.getX() + dX);
|
|
212 |
double yl = (re.getY() + dY);
|
|
238 | 213 |
|
239 |
drawNameLegend(g, layer.getName(), re, sizefont, |
|
240 |
(int) (xl - (re.getWidth() / 5)), yl, h,typeFont); |
|
241 |
n[0]++; |
|
214 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) { |
|
215 |
sizefont = (float) (re.getHeight() / m_numLayers); |
|
216 |
} else { |
|
217 |
sizefont = (float) (re.getWidth() / 8); |
|
218 |
} |
|
242 | 219 |
|
243 |
for (int j = 0; j < cli.getValues().length; j++) { |
|
244 |
dY = n[0] * h; |
|
220 |
drawNameLegend(g, layer.getName(), re, sizefont, |
|
221 |
(xl - (re.getWidth() / 5)), yl, h, Font.BOLD); |
|
222 |
n[0]++; |
|
223 |
drawTheme(g, re, h, (FLayers) layer, n, Font.ITALIC); |
|
224 |
n[0]++; |
|
225 |
} else if (layer instanceof AlphanumericData) { |
|
226 |
AlphanumericData cO = (AlphanumericData) layer; |
|
245 | 227 |
|
246 |
xl = (int) (re.getX() + dX); |
|
247 |
yl = (int) (re.getY() + dY); |
|
228 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
|
229 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
|
230 |
double dX = 0; |
|
231 |
double dY = n[0] * h; |
|
248 | 232 |
|
249 |
String s = cli.getDescriptions()[j]; |
|
250 |
drawNameLegend(g, s, re, sizefont, xl, yl, h,typeFont); |
|
233 |
double xl = (re.getX() + dX); |
|
234 |
double yl = (re.getY() + dY); |
|
235 |
float sizefont = 0; |
|
251 | 236 |
|
252 |
FSymbol fs2d = cli.getSymbols()[j]; |
|
253 |
drawSymbolLegend(g, re, xl, yl, fs2d, sizefont, |
|
254 |
((Classifiable) cO).getShapeType(), h); |
|
237 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) { |
|
238 |
sizefont = (float) (re.getHeight() / m_numLayers); |
|
239 |
} else { |
|
240 |
sizefont = (float) (re.getWidth() / 8); |
|
241 |
} |
|
255 | 242 |
|
256 |
n[0]++; |
|
257 |
} |
|
258 |
} else { |
|
259 |
double dX = 0; |
|
260 |
double dY = n[0] * h; |
|
243 |
drawNameLegend(g, layer.getName(), re, sizefont, |
|
244 |
(xl - (re.getWidth() / 5)), yl, h, typeFont); |
|
245 |
n[0]++; |
|
261 | 246 |
|
262 |
int xl = (int) (re.getX() + dX); |
|
263 |
int yl = (int) (re.getY() + dY); |
|
264 |
int sizefont = 0; |
|
247 |
for (int j = 0; j < cli.getValues().length; j++) { |
|
248 |
dY = n[0] * h; |
|
265 | 249 |
|
266 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) { |
|
267 |
sizefont = (int) (re.getHeight() / m_numLayers); |
|
268 |
} else { |
|
269 |
sizefont = (int) (re.getWidth() / 8); |
|
270 |
} |
|
250 |
xl = (re.getX() + dX); |
|
251 |
yl = (re.getY() + dY); |
|
271 | 252 |
|
272 |
drawNameLegend(g, layer.getName(), re, sizefont, xl, |
|
273 |
yl, h,typeFont); |
|
253 |
String s = cli.getDescriptions()[j]; |
|
254 |
drawNameLegend(g, s, re, sizefont, xl, yl, h, |
|
255 |
typeFont); |
|
274 | 256 |
|
275 |
//FStyle2D fs2d = cO.getLegendInfo().getSymbol(); |
|
276 |
//drawSymbolLegend(g, re, xl, yl, fs2d,sizefont,cO.getShapeType()); |
|
277 |
FSymbol fs2d = ((Classifiable) cO).getLegend() |
|
278 |
.getDefaultSymbol(); |
|
257 |
FSymbol fs2d = cli.getSymbols()[j]; |
|
258 |
drawSymbolLegend(g, re, xl, yl, fs2d, sizefont, |
|
259 |
((Classifiable) cO).getShapeType(), h); |
|
279 | 260 |
|
280 |
//System.out.println("sizefont = " + sizefont); |
|
281 |
drawSymbolLegend(g, re, xl, yl, fs2d, sizefont, |
|
282 |
((Classifiable) cO).getShapeType(), h); |
|
261 |
n[0]++; |
|
262 |
} |
|
263 |
} else { |
|
264 |
double dX = 0; |
|
265 |
double dY = n[0] * h; |
|
283 | 266 |
|
284 |
//System.out.println("cO.getShapeType()= " + |
|
285 |
// cO.getShapeType()); |
|
286 |
n[0]++; |
|
287 |
} |
|
288 |
} |
|
289 |
} |
|
290 |
} |
|
267 |
double xl = (re.getX() + dX); |
|
268 |
double yl = (re.getY() + dY); |
|
269 |
float sizefont = 0; |
|
291 | 270 |
|
292 |
//return n; |
|
293 |
} |
|
271 |
if ((re.getHeight() / m_numLayers) < (re.getWidth() / 8)) { |
|
272 |
sizefont = (float) (re.getHeight() / m_numLayers); |
|
273 |
} else { |
|
274 |
sizefont = (float) (re.getWidth() / 8); |
|
275 |
} |
|
294 | 276 |
|
295 |
/** |
|
296 |
* Dibuja sobre el graphics el nombre de la capa que se pasa como |
|
297 |
* par?metro. |
|
298 |
* |
|
299 |
* @param g Graphics2D sobre el que dibujar. |
|
300 |
* @param name Nombre de la capa. |
|
301 |
* @param re Rect?ngulo a ocupar por el nombre. |
|
302 |
* @param sizefont tama?o de la fuente. |
|
303 |
* @param x Posici?n X. |
|
304 |
* @param y Posici?n Y. |
|
305 |
* @param h Altura. |
|
306 |
*/ |
|
307 |
private void drawNameLegend(Graphics2D g, String name, Rectangle2D re, |
|
308 |
int sizefont, int x, int y, double h,int typeFont) { |
|
309 |
Font f = new Font("SansSerif", typeFont, sizefont); |
|
310 |
g.setFont(f); |
|
311 |
g.setColor(Color.black); |
|
312 |
g.drawString(name, (int) (x + (re.getWidth() / 4)), (int) (y + (h / 2))); |
|
313 |
} |
|
277 |
drawNameLegend(g, layer.getName(), re, sizefont, xl, |
|
278 |
yl, h, typeFont); |
|
314 | 279 |
|
315 |
/** |
|
316 |
* A?ade al Layout un nuevo FFrameText a partir de los par?metros de entrada. |
|
317 |
* |
|
318 |
* @param layout Layout sobre el que se crea el nuevo FFrame. |
|
319 |
* @param name Texto. |
|
320 |
* @param re Rect?ngulo del FFrame. |
|
321 |
* @param sizefont tama?o de la fuente. |
|
322 |
* @param x Posici?n X. |
|
323 |
* @param y Posici?n Y. |
|
324 |
* @param h Altura. |
|
325 |
*/ |
|
326 |
private void toFFrameText(Layout layout, String name, Rectangle2D re, |
|
327 |
int sizefont, int x, int y, double h) { |
|
328 |
int wl = (int) (re.getWidth() / 1.5); |
|
329 |
int haux = (int) (sizefont * 0.7); |
|
330 |
Rectangle2D rAux = new Rectangle2D.Double((int) x, y, wl, |
|
331 |
haux); |
|
332 |
FFrameText text = new FFrameText(); |
|
333 |
text.setBoundBox(FLayoutUtilities.toSheetRect(rAux, layout.getAT())); |
|
334 |
text.addText(name); |
|
335 |
layout.addFFrame(text, false); |
|
336 |
} |
|
280 |
FSymbol fs2d = ((Classifiable) cO).getLegend() |
|
281 |
.getDefaultSymbol(); |
|
337 | 282 |
|
338 |
/** |
|
339 |
* Dibuja sobre el Graphics2D el s?mbolo. |
|
340 |
* |
|
341 |
* @param g Graphics2D. |
|
342 |
* @param re Rect?ngulo a cubrir por el s?mbolo. |
|
343 |
* @param x Posici?n X. |
|
344 |
* @param y Posici?n Y. |
|
345 |
* @param fs2d S?mbolo a dibujar. |
|
346 |
* @param sizefont Tama?o de la fuente. |
|
347 |
* @param type Tipo de s?mbolo. |
|
348 |
* @param h Altura. |
|
349 |
*/ |
|
350 |
private void drawSymbolLegend(Graphics2D g, Rectangle2D re, int x, int y, |
|
351 |
FSymbol fs2d, int sizefont, int type, double h) { |
|
352 |
double pW = 5; |
|
353 |
//double pH = m_numLayers; |
|
354 |
int wl = (int) (re.getWidth() / pW); |
|
355 |
int haux = (int) (sizefont * 0.7); |
|
356 |
Font font=fs2d.getFont(); |
|
357 |
if (font !=null) |
|
358 |
fs2d.setFont(new Font(font.getFontName(),font.getStyle(),wl/6)); |
|
359 |
FGraphicUtilities.DrawSymbol(g, new AffineTransform(), |
|
360 |
new Rectangle(x, (int) ((y + (h / 2)) - haux), wl, haux), fs2d); |
|
361 |
} |
|
283 |
drawSymbolLegend(g, re, xl, yl, fs2d, sizefont, |
|
284 |
((Classifiable) cO).getShapeType(), h); |
|
285 |
n[0]++; |
|
286 |
} |
|
287 |
} |
|
288 |
} |
|
289 |
} |
|
290 |
} |
|
362 | 291 |
|
363 |
/** |
|
364 |
* A?ade al Layout un nuevo FFrameSymbol. |
|
365 |
* |
|
366 |
* @param layout Layout sobe el que se a?ade el FFrame. |
|
367 |
* @param re Rect?ngulo del FFrame. |
|
368 |
* @param x Posici?n X. |
|
369 |
* @param y Posici?n Y. |
|
370 |
* @param fs2d S?mbolo a a?adir. |
|
371 |
* @param sizefont tama?o de la fuente. |
|
372 |
* @param type Tipo de s?mbolo. |
|
373 |
* @param h Altura. |
|
374 |
*/ |
|
375 |
private void toFFrameSymbol(Layout layout, Rectangle2D re, int x, int y, |
|
376 |
FSymbol fs2d, int sizefont, int type, double h) { |
|
377 |
double pW = 5; |
|
378 |
//double pH = m_numLayers; |
|
379 |
int wl = (int) (re.getWidth() / pW); |
|
292 |
/** |
|
293 |
* Dibuja sobre el graphics el nombre de la capa que se pasa como |
|
294 |
* par?metro. |
|
295 |
* |
|
296 |
* @param g Graphics2D sobre el que dibujar. |
|
297 |
* @param name Nombre de la capa. |
|
298 |
* @param re Rect?ngulo a ocupar por el nombre. |
|
299 |
* @param sizefont tama?o de la fuente. |
|
300 |
* @param x Posici?n X. |
|
301 |
* @param y Posici?n Y. |
|
302 |
* @param h Altura. |
|
303 |
* @param typeFont DOCUMENT ME! |
|
304 |
*/ |
|
305 |
private void drawNameLegend(Graphics2D g, String name, Rectangle2D re, |
|
306 |
float sizefont, double x, double y, double h, int typeFont) { |
|
307 |
Font f = new Font("SansSerif", typeFont, (int) sizefont); |
|
308 |
g.setFont(f); |
|
309 |
g.setColor(Color.black); |
|
310 |
g.drawString(name, (float) (x + (re.getWidth() / 4)), |
|
311 |
(float) (y + (h / 2))); |
|
312 |
} |
|
380 | 313 |
|
381 |
int haux = (int) (sizefont * 0.7); |
|
382 |
Rectangle2D rAux3 = new Rectangle2D.Double(x, |
|
383 |
(int) ((y + (h / 2)) - haux), wl, haux); |
|
384 |
FFrameSymbol symbol = new FFrameSymbol(); |
|
385 |
symbol.setBoundBox(FLayoutUtilities.toSheetRect(rAux3, layout.getAT())); |
|
386 |
symbol.setSymbol(fs2d, type); |
|
387 |
layout.addFFrame(symbol, false); |
|
388 |
} |
|
314 |
/** |
|
315 |
* A?ade al Layout un nuevo FFrameText a partir de los par?metros de |
|
316 |
* entrada. |
|
317 |
* |
|
318 |
* @param layout Layout sobre el que se crea el nuevo FFrame. |
|
319 |
* @param name Texto. |
|
320 |
* @param re Rect?ngulo del FFrame. |
|
321 |
* @param sizefont tama?o de la fuente. |
|
322 |
* @param x Posici?n X. |
|
323 |
* @param y Posici?n Y. |
|
324 |
* @param h Altura. |
|
325 |
*/ |
|
326 |
private void toFFrameText(Layout layout, String name, Rectangle2D re, |
|
327 |
float sizefont, double x, double y, double h) { |
|
328 |
double wl = (re.getWidth() / 1.5); |
|
329 |
double haux = (sizefont * 0.7); |
|
330 |
Rectangle2D rAux = new Rectangle2D.Double(x, y, wl, haux); |
|
331 |
FFrameText text = new FFrameText(); |
|
332 |
text.setBoundBox(FLayoutUtilities.toSheetRect(rAux, layout.getAT())); |
|
333 |
text.addText(name); |
|
334 |
layout.addFFrame(text, false); |
|
335 |
} |
|
389 | 336 |
|
390 |
/** |
|
391 |
* Devuelve el n?mero total de capas incluyendo las subcapas. |
|
392 |
* |
|
393 |
* @param layers Capa a contar. |
|
394 |
* |
|
395 |
* @return N?mero de capas y subcapas. |
|
396 |
*/ |
|
397 |
private int getSizeNum(FLayers layers) { |
|
398 |
int n = 0; |
|
337 |
/** |
|
338 |
* Dibuja sobre el Graphics2D el s?mbolo. |
|
339 |
* |
|
340 |
* @param g Graphics2D. |
|
341 |
* @param re Rect?ngulo a cubrir por el s?mbolo. |
|
342 |
* @param x Posici?n X. |
|
343 |
* @param y Posici?n Y. |
|
344 |
* @param fs2d S?mbolo a dibujar. |
|
345 |
* @param sizefont Tama?o de la fuente. |
|
346 |
* @param type Tipo de s?mbolo. |
|
347 |
* @param h Altura. |
|
348 |
*/ |
|
349 |
private void drawSymbolLegend(Graphics2D g, Rectangle2D re, double x, |
|
350 |
double y, FSymbol fs2d, float sizefont, int type, double h) { |
|
351 |
double pW = 5; |
|
352 |
double wl = (re.getWidth() / pW); |
|
353 |
double haux = (sizefont * 0.7); |
|
354 |
Font font = fs2d.getFont(); |
|
399 | 355 |
|
400 |
/////Aqu? hay que calcular cuantos layers y sublayers hay, para saber que distancias dejar entre uno y otro.
|
|
401 |
///y adem?s el tama?o de cada uno de ellos para saber que anchura dejar.
|
|
402 |
for (int i = 0; i < layers.getLayersCount(); i++) {
|
|
403 |
FLayer layer = (FLayer) layers.getLayer(i);
|
|
356 |
if (font != null) {
|
|
357 |
fs2d.setFont(new Font(font.getFontName(), font.getStyle(),
|
|
358 |
(int) (wl / 6)));
|
|
359 |
}
|
|
404 | 360 |
|
405 |
if (layer.isVisible()) {
|
|
406 |
if (layer.getName().length() > m_max) {
|
|
407 |
m_max = layer.getName().length();
|
|
408 |
}
|
|
361 |
FGraphicUtilities.DrawSymbol(g, new AffineTransform(),
|
|
362 |
new Rectangle((int) x, (int) ((y + (h / 2)) - haux), (int) wl,
|
|
363 |
(int) haux), fs2d);
|
|
364 |
}
|
|
409 | 365 |
|
410 |
if (layer instanceof FLayers) { |
|
411 |
n=n+3; |
|
412 |
n += getSizeNum((FLayers) layer); //m_numLayers += getNumInLyrGroup((FLayers) layer); |
|
413 |
} else if (layer instanceof AlphanumericData) { |
|
414 |
AlphanumericData cO = (AlphanumericData) layer; |
|
415 |
n++; |
|
366 |
/** |
|
367 |
* A?ade al Layout un nuevo FFrameSymbol. |
|
368 |
* |
|
369 |
* @param layout Layout sobe el que se a?ade el FFrame. |
|
370 |
* @param re Rect?ngulo del FFrame. |
|
371 |
* @param x Posici?n X. |
|
372 |
* @param y Posici?n Y. |
|
373 |
* @param fs2d S?mbolo a a?adir. |
|
374 |
* @param sizefont tama?o de la fuente. |
|
375 |
* @param type Tipo de s?mbolo. |
|
376 |
* @param h Altura. |
|
377 |
*/ |
|
378 |
private void toFFrameSymbol(Layout layout, Rectangle2D re, double x, |
|
379 |
double y, FSymbol fs2d, float sizefont, int type, double h) { |
|
380 |
double pW = 5; |
|
381 |
double wl = (re.getWidth() / pW); |
|
382 |
double haux = (sizefont * 0.7); |
|
383 |
Rectangle2D rAux3 = new Rectangle2D.Double(x, ((y + (h / 2)) - haux), |
|
384 |
wl, haux); |
|
385 |
FFrameSymbol symbol = new FFrameSymbol(); |
|
386 |
symbol.setBoundBox(FLayoutUtilities.toSheetRect(rAux3, layout.getAT())); |
|
387 |
symbol.setSymbol(fs2d, type); |
|
388 |
layout.addFFrame(symbol, false); |
|
389 |
} |
|
416 | 390 |
|
417 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
|
418 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
|
391 |
/** |
|
392 |
* Devuelve el n?mero total de capas incluyendo las subcapas. |
|
393 |
* |
|
394 |
* @param layers Capa a contar. |
|
395 |
* |
|
396 |
* @return N?mero de capas y subcapas. |
|
397 |
*/ |
|
398 |
private int getSizeNum(FLayers layers) { |
|
399 |
int n = 0; |
|
419 | 400 |
|
420 |
for (int j = 0; j < cli.getValues().length; j++) { |
|
421 |
String s = cli.getDescriptions()[j]; |
|
401 |
/////Aqu? hay que calcular cuantos layers y sublayers hay, para saber que distancias dejar entre uno y otro. |
|
402 |
///y adem?s el tama?o de cada uno de ellos para saber que anchura dejar. |
|
403 |
for (int i = 0; i < layers.getLayersCount(); i++) { |
|
404 |
FLayer layer = (FLayer) layers.getLayer(i); |
|
422 | 405 |
|
423 |
if (s.length() > m_max) { |
|
424 |
m_max = s.length(); |
|
425 |
} |
|
406 |
if (layer.isVisible()) { |
|
407 |
if (layer.getName().length() > m_max) { |
|
408 |
m_max = layer.getName().length(); |
|
409 |
} |
|
426 | 410 |
|
427 |
n++;
|
|
428 |
}
|
|
429 |
}
|
|
430 |
}
|
|
431 |
}
|
|
432 |
}
|
|
411 |
if (layer instanceof FLayers) {
|
|
412 |
n = n + 3;
|
|
413 |
n += getSizeNum((FLayers) layer); //m_numLayers += getNumInLyrGroup((FLayers) layer);
|
|
414 |
} else if (layer instanceof AlphanumericData) {
|
|
415 |
AlphanumericData cO = (AlphanumericData) layer;
|
|
416 |
n++;
|
|
433 | 417 |
|
434 |
return n;
|
|
435 |
}
|
|
418 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) {
|
|
419 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend();
|
|
436 | 420 |
|
437 |
/** |
|
438 |
* Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText. |
|
439 |
* |
|
440 |
* @param layout Layout sobre el que a?adir los FFrame nuevos y sobre el que elimnar el FFrameLegend anterior. |
|
441 |
*/ |
|
442 |
public void toFFrames(Layout layout) { |
|
443 |
Rectangle2D rectangle = getBoundingBox(null); |
|
444 |
double h = rectangle.getHeight() / m_numLayers; |
|
445 |
FLayers lays = layers; |
|
446 |
toFFrames(layout, lays, rectangle, h, 0); |
|
447 |
layout.getFFrames().remove(this); |
|
448 |
} |
|
421 |
for (int j = 0; j < cli.getValues().length; j++) { |
|
422 |
String s = cli.getDescriptions()[j]; |
|
449 | 423 |
|
450 |
/** |
|
451 |
* Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText. |
|
452 |
* |
|
453 |
* @param layout Referencia al Layout. |
|
454 |
* @param lays Layers a a?adir |
|
455 |
* @param rectangle Rect?ngulo del FFrameLegend. |
|
456 |
* @param h Altura |
|
457 |
* @param n n?mero de Capa a?adida. |
|
458 |
* |
|
459 |
* @return n?mero de Capa a a?adir. |
|
460 |
*/ |
|
461 |
public int toFFrames(Layout layout, FLayers lays, Rectangle2D rectangle, |
|
462 |
double h, int n) { |
|
463 |
//TODO Falta que implementar. |
|
464 |
////// Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics |
|
465 |
//int d = 4; |
|
424 |
if (s.length() > m_max) { |
|
425 |
m_max = s.length(); |
|
426 |
} |
|
466 | 427 |
|
467 |
for (int i = 0; i < lays.getLayersCount(); i++) { |
|
468 |
FLayer layer = (FLayer) lays.getLayer(i); |
|
428 |
n++; |
|
429 |
} |
|
430 |
} |
|
431 |
} |
|
432 |
} |
|
433 |
} |
|
469 | 434 |
|
470 |
if (layer.isVisible()) { |
|
471 |
if (layer instanceof FLayers) { |
|
472 |
rectangle.setRect(rectangle.getX(), |
|
473 |
rectangle.getY() + (h * n), rectangle.getWidth(), |
|
474 |
rectangle.getHeight()); |
|
475 |
n += toFFrames(layout, lays, rectangle, h, n); //drawTheme(g, re, h, layers, n); |
|
476 |
} else if (layer instanceof AlphanumericData) { |
|
477 |
AlphanumericData cO = (AlphanumericData) layer; |
|
435 |
return n; |
|
436 |
} |
|
478 | 437 |
|
479 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
|
480 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
|
481 |
double dX = rectangle.getWidth() / 4; |
|
482 |
double dY = n * h; |
|
438 |
/** |
|
439 |
* Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText. |
|
440 |
* |
|
441 |
* @param layout Layout sobre el que a?adir los FFrame nuevos y sobre el |
|
442 |
* que elimnar el FFrameLegend anterior. |
|
443 |
*/ |
|
444 |
public void toFFrames(Layout layout) { |
|
445 |
Rectangle2D rectangle = getBoundingBox(null); |
|
446 |
double h = rectangle.getHeight() / m_numLayers; |
|
447 |
FLayers lays = layers; |
|
448 |
toFFrames(layout, lays, rectangle, h, 0); |
|
449 |
layout.getFFrames().remove(this); |
|
450 |
} |
|
483 | 451 |
|
484 |
int xl = (int) (rectangle.getX() + dX); |
|
485 |
int yl = (int) (rectangle.getY() + dY); |
|
486 |
int sizefont = 0; |
|
452 |
/** |
|
453 |
* Transforma el FFrameLegend en diferentes FFrameSymbol y FFrameText. |
|
454 |
* |
|
455 |
* @param layout Referencia al Layout. |
|
456 |
* @param lays Layers a a?adir |
|
457 |
* @param rectangle Rect?ngulo del FFrameLegend. |
|
458 |
* @param h Altura |
|
459 |
* @param n n?mero de Capa a?adida. |
|
460 |
* |
|
461 |
* @return n?mero de Capa a a?adir. |
|
462 |
*/ |
|
463 |
public int toFFrames(Layout layout, FLayers lays, Rectangle2D rectangle, |
|
464 |
double h, int n) { |
|
465 |
////// Se recorren los layers dibujando el s?mbolo y su nombre sobre el graphics |
|
466 |
for (int i = 0; i < lays.getLayersCount(); i++) { |
|
467 |
FLayer layer = (FLayer) lays.getLayer(i); |
|
487 | 468 |
|
488 |
if ((rectangle.getHeight() / m_numLayers) < (rectangle.getWidth() / 8)) {
|
|
489 |
sizefont = (int) (rectangle.getHeight() / m_numLayers);
|
|
490 |
} else {
|
|
491 |
sizefont = (int) (rectangle.getWidth() / 8);
|
|
492 |
}
|
|
493 |
toFFrameText(layout, layer.getName(), rectangle,
|
|
494 |
sizefont, xl, yl, h);
|
|
495 |
n++;
|
|
469 |
if (layer.isVisible()) {
|
|
470 |
if (layer instanceof FLayers) {
|
|
471 |
rectangle.setRect(rectangle.getX(),
|
|
472 |
rectangle.getY() + (h * n), rectangle.getWidth(),
|
|
473 |
rectangle.getHeight());
|
|
474 |
n += toFFrames(layout, lays, rectangle, h, n); //drawTheme(g, re, h, layers, n);
|
|
475 |
} else if (layer instanceof AlphanumericData) {
|
|
476 |
AlphanumericData cO = (AlphanumericData) layer;
|
|
496 | 477 |
|
497 |
for (int j = 0; j < cli.getValues().length; j++) { |
|
498 |
dY = n * h; |
|
478 |
if (((Classifiable) cO).getLegend() instanceof ClassifiedLegendInfo) { |
|
479 |
ClassifiedLegendInfo cli = (ClassifiedLegendInfo) ((Classifiable) cO).getLegend(); |
|
480 |
double dX = rectangle.getWidth() / 4; |
|
481 |
double dY = n * h; |
|
499 | 482 |
|
500 |
xl = (int) (rectangle.getX() + dX); |
|
501 |
yl = (int) (rectangle.getY() + dY); |
|
483 |
double xl = (rectangle.getX() + dX); |
|
484 |
double yl = (rectangle.getY() + dY); |
|
485 |
float sizefont = 0; |
|
502 | 486 |
|
503 |
String s = cli.getDescriptions()[j]; |
|
504 |
toFFrameText(layout, s, rectangle, sizefont, xl, |
|
505 |
yl, h); |
|
506 |
FSymbol fs2d = cli.getSymbols()[j]; |
|
487 |
if ((rectangle.getHeight() / m_numLayers) < (rectangle.getWidth() / 8)) { |
|
488 |
sizefont = (float) (rectangle.getHeight() / m_numLayers); |
|
489 |
} else { |
|
490 |
sizefont = (float) (rectangle.getWidth() / 8); |
|
491 |
} |
|
507 | 492 |
|
508 |
try { |
|
509 |
toFFrameSymbol(layout, rectangle, |
|
510 |
(int) rectangle.getX(), yl, fs2d, sizefont, |
|
511 |
((Classifiable) cO).getShapeType(), h); |
|
512 |
} catch (DriverException e) { |
|
513 |
e.printStackTrace(); |
|
514 |
} |
|
493 |
toFFrameText(layout, layer.getName(), rectangle, |
|
494 |
sizefont, xl, yl, h); |
|
495 |
n++; |
|
515 | 496 |
|
516 |
n++; |
|
517 |
} |
|
518 |
} else { |
|
519 |
double dX = rectangle.getWidth() / 4; |
|
520 |
double dY = n * h; |
|
497 |
for (int j = 0; j < cli.getValues().length; j++) { |
|
498 |
dY = n * h; |
|
521 | 499 |
|
522 |
int xl = (int) (rectangle.getX() + dX); |
|
523 |
int yl = (int) (rectangle.getY() + dY); |
|
524 |
int sizefont = 0; |
|
500 |
xl = (rectangle.getX() + dX); |
|
501 |
yl = (rectangle.getY() + dY); |
|
525 | 502 |
|
526 |
if ((rectangle.getHeight() / m_numLayers) < (rectangle.getWidth() / 8)) { |
|
527 |
sizefont = (int) (rectangle.getHeight() / m_numLayers); |
|
528 |
} else { |
|
529 |
sizefont = (int) (rectangle.getWidth() / 8); |
|
530 |
} |
|
531 |
toFFrameText(layout, layer.getName(), rectangle, |
|
532 |
sizefont, xl, yl, h); |
|
533 |
FSymbol fs2d = ((Classifiable) cO).getLegend() |
|
534 |
.getDefaultSymbol(); |
|
503 |
String s = cli.getDescriptions()[j]; |
|
504 |
toFFrameText(layout, s, rectangle, sizefont, xl, |
|
505 |
yl, h); |
|
535 | 506 |
|
536 |
try { |
|
537 |
toFFrameSymbol(layout, rectangle, |
|
538 |
(int) rectangle.getX(), yl, fs2d, sizefont, |
|
539 |
((Classifiable) cO).getShapeType(), h); |
|
540 |
} catch (DriverException e) { |
|
541 |
e.printStackTrace(); |
|
542 |
} |
|
543 |
n++; |
|
544 |
} |
|
545 |
} |
|
546 |
} |
|
547 |
} |
|
548 |
return n; |
|
549 |
} |
|
507 |
FSymbol fs2d = cli.getSymbols()[j]; |
|
550 | 508 |
|
551 |
/** |
|
552 |
* Rellena la fuente a utilizar al dibujar los String sobre el graphics. |
|
553 |
* |
|
554 |
* @param f Font. |
|
555 |
*/ |
|
556 |
public void setFont(Font f) { |
|
557 |
m_f = f; |
|
558 |
} |
|
509 |
try { |
|
510 |
toFFrameSymbol(layout, rectangle, |
|
511 |
rectangle.getX(), yl, fs2d, sizefont, |
|
512 |
((Classifiable) cO).getShapeType(), h); |
|
513 |
} catch (DriverException e) { |
|
514 |
e.printStackTrace(); |
|
515 |
} |
|
559 | 516 |
|
560 |
/** |
|
561 |
* Devuelve la fuente que esta utilizando. |
|
562 |
* |
|
563 |
* @return Font. |
|
564 |
*/ |
|
565 |
public Font getFont() { |
|
566 |
if (m_f != null) { |
|
567 |
return new Font(m_f.getFontName(), m_f.getStyle(), 9); |
|
568 |
} |
|
517 |
n++; |
|
518 |
} |
|
519 |
} else { |
|
520 |
double dX = rectangle.getWidth() / 4; |
|
521 |
double dY = n * h; |
|
569 | 522 |
|
570 |
return null; |
|
571 |
} |
|
523 |
double xl = (rectangle.getX() + dX); |
|
524 |
double yl = (rectangle.getY() + dY); |
|
525 |
float sizefont = 0; |
|
572 | 526 |
|
573 |
/** |
|
574 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity() |
|
575 |
*/ |
|
576 |
public XMLEntity getXMLEntity() { |
|
577 |
XMLEntity xml = new XMLEntity(); |
|
578 |
xml.putProperty("className", this.getClass().getName()); |
|
579 |
xml.putProperty("m_name", m_name); |
|
580 |
xml.putProperty("x", getBoundBox().x); |
|
581 |
xml.putProperty("y", getBoundBox().y); |
|
582 |
xml.putProperty("w", getBoundBox().width); |
|
583 |
xml.putProperty("h", getBoundBox().height); |
|
584 |
xml.putProperty("m_Selected", m_Selected); |
|
585 |
xml.putProperty("type", Layout.RECTANGLELEGEND); |
|
586 |
xml.putProperty("m_numLayers", m_numLayers); |
|
587 |
xml.putProperty("m_max", m_max); |
|
588 |
xml.putProperty("m_quality", m_quality); |
|
589 |
xml.putProperty("m_viewing", m_viewing); |
|
590 |
xml.putProperty("fontName", m_f.getFontName()); |
|
591 |
xml.putProperty("fontStyle", m_f.getStyle()); |
|
592 |
xml.putProperty("tag", getTag()); |
|
593 |
xml.putProperty("m_rotation",getRotation()); |
|
594 |
///xml.addChild(fframeview.getXMLEntity()); |
|
595 |
LayoutControls lc = (LayoutControls) PluginServices.getExtension(LayoutControls.class); |
|
596 |
Layout layout = lc.getLayout(); |
|
597 |
ArrayList fframes = layout.getFFrames(); |
|
527 |
if ((rectangle.getHeight() / m_numLayers) < (rectangle.getWidth() / 8)) { |
|
528 |
sizefont = (float) (rectangle.getHeight() / m_numLayers); |
|
529 |
} else { |
|
530 |
sizefont = (float) (rectangle.getWidth() / 8); |
|
531 |
} |
|
598 | 532 |
|
599 |
for (int i = 0; i < fframes.size(); i++) { |
|
600 |
if (fframes.get(i) instanceof FFrameView) { |
|
601 |
if (fframeview != null && fframeview.getView().getName().equals(((FFrameView) fframes |
|
602 |
.get(i)).getView() |
|
603 |
.getName())) { |
|
604 |
xml.putProperty("index", i); |
|
605 |
} |
|
606 |
} |
|
607 |
} |
|
533 |
toFFrameText(layout, layer.getName(), rectangle, |
|
534 |
sizefont, xl, yl, h); |
|
608 | 535 |
|
609 |
/*ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
|
610 |
ArrayList views = pe.getProject().getViews(); |
|
611 |
boolean hasIndex = false; |
|
612 |
for (int i = 0; i < views.size(); i++) { |
|
613 |
if (fframeview.getView() == ((ProjectView) views.get(i))) { |
|
614 |
xml.putProperty("indice", i); |
|
615 |
hasIndex = true; |
|
616 |
} |
|
617 |
} |
|
618 |
if (!hasIndex) { |
|
619 |
xml.putProperty("indice", -1); |
|
620 |
} |
|
621 |
*/ |
|
536 |
FSymbol fs2d = ((Classifiable) cO).getLegend() |
|
537 |
.getDefaultSymbol(); |
|
622 | 538 |
|
623 |
//De este ?ndice se debe de obtener el arrayList de layers. |
|
539 |
try { |
|
540 |
toFFrameSymbol(layout, rectangle, rectangle.getX(), |
|
541 |
yl, fs2d, sizefont, |
|
542 |
((Classifiable) cO).getShapeType(), h); |
|
543 |
} catch (DriverException e) { |
|
544 |
e.printStackTrace(); |
|
545 |
} |
|
624 | 546 |
|
625 |
/* ProjectExtension pe = (ProjectExtension) App.instance.getPc() |
|
626 |
.getExtension(ProjectExtension.class); |
|
627 |
ArrayList views = pe.getProject().getViews(); |
|
628 |
boolean hasIndex = false; |
|
629 |
for (int i = 0; i < views.size(); i++) { |
|
630 |
if (m_fmap == ((ProjectView) views.get(i)).getMapContext()) { |
|
631 |
xml.putProperty("indice", i); |
|
632 |
hasIndex = true; |
|
633 |
} |
|
634 |
} |
|
635 |
if (!hasIndex) { |
|
636 |
xml.putProperty("indice", -1); |
|
637 |
} |
|
638 |
*/ |
|
639 |
return xml; |
|
640 |
} |
|
547 |
n++; |
|
548 |
} |
|
549 |
} |
|
550 |
} |
|
551 |
} |
|
641 | 552 |
|
642 |
/** |
|
643 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity, |
|
644 |
* com.iver.cit.gvsig.project.Project) |
|
645 |
*/ |
|
646 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
|
647 |
if (xml.getIntProperty("m_Selected") != 0) { |
|
648 |
this.setSelected(true); |
|
649 |
} else { |
|
650 |
this.setSelected(false); |
|
651 |
} |
|
553 |
return n; |
|
554 |
} |
|
652 | 555 |
|
653 |
this.m_numLayers = xml.getIntProperty("m_numLayers"); |
|
654 |
this.m_max = xml.getIntProperty("m_max"); |
|
655 |
this.m_quality = xml.getIntProperty("m_quality"); |
|
656 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
|
657 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
|
658 |
xml.getIntProperty("fontStyle"), 9); |
|
556 |
/** |
|
557 |
* Rellena la fuente a utilizar al dibujar los String sobre el graphics. |
|
558 |
* |
|
559 |
* @param f Font. |
|
560 |
*/ |
|
561 |
public void setFont(Font f) { |
|
562 |
m_f = f; |
|
563 |
} |
|
659 | 564 |
|
660 |
//this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0), |
|
661 |
// p)); |
|
565 |
/** |
|
566 |
* Devuelve la fuente que esta utilizando. |
|
567 |
* |
|
568 |
* @return Font. |
|
569 |
*/ |
|
570 |
public Font getFont() { |
|
571 |
if (m_f != null) { |
|
572 |
return new Font(m_f.getFontName(), m_f.getStyle(), 9); |
|
573 |
} |
|
662 | 574 |
|
663 |
/* int indice = xml.getIntProperty("indice"); |
|
664 |
if (indice != -1) { |
|
665 |
ProjectView view = (ProjectView) p.getViews().get(indice); |
|
666 |
|
|
667 |
fframeview.setView((ProjectView) view); |
|
668 |
} |
|
669 |
*/ |
|
670 |
ArrayList fframes = l.getFFrames(); |
|
671 |
fframeview = (FFrameView) fframes.get(xml.getIntProperty("index")); |
|
575 |
return null; |
|
576 |
} |
|
672 | 577 |
|
673 |
/* LayoutControls lc=(LayoutControls)PluginServices.getExtension(LayoutControls.class); |
|
674 |
Layout layout=lc.getLayout(); |
|
675 |
ArrayList fframes=layout.getFFrames(); |
|
676 |
fframeview=(FFrameView)fframes.get(xml.getIntProperty("index")); |
|
677 |
*/ |
|
578 |
/** |
|
579 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity() |
|
580 |
*/ |
|
581 |
public XMLEntity getXMLEntity() { |
|
582 |
XMLEntity xml = new XMLEntity(); |
|
583 |
xml.putProperty("className", this.getClass().getName()); |
|
584 |
xml.putProperty("m_name", m_name); |
|
585 |
xml.putProperty("x", getBoundBox().x); |
|
586 |
xml.putProperty("y", getBoundBox().y); |
|
587 |
xml.putProperty("w", getBoundBox().width); |
|
588 |
xml.putProperty("h", getBoundBox().height); |
|
589 |
xml.putProperty("m_Selected", m_Selected); |
|
590 |
xml.putProperty("type", Layout.RECTANGLELEGEND); |
|
591 |
xml.putProperty("m_numLayers", m_numLayers); |
|
592 |
xml.putProperty("m_max", m_max); |
|
593 |
xml.putProperty("m_quality", m_quality); |
|
594 |
xml.putProperty("m_viewing", m_viewing); |
|
595 |
xml.putProperty("fontName", m_f.getFontName()); |
|
596 |
xml.putProperty("fontStyle", m_f.getStyle()); |
|
597 |
xml.putProperty("tag", getTag()); |
|
598 |
xml.putProperty("m_rotation", getRotation()); |
|
678 | 599 |
|
679 |
//this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0),
|
|
680 |
// p));
|
|
681 |
}
|
|
600 |
LayoutControls lc = (LayoutControls) PluginServices.getExtension(LayoutControls.class);
|
|
601 |
Layout layout = lc.getLayout();
|
|
602 |
ArrayList fframes = layout.getFFrames();
|
|
682 | 603 |
|
683 |
/**
|
|
684 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
|
685 |
* com.iver.cit.gvsig.project.Project)
|
|
686 |
*/
|
|
687 |
public void setXMLEntity(XMLEntity xml, Layout l) {
|
|
688 |
if (xml.getIntProperty("m_Selected") != 0) {
|
|
689 |
this.setSelected(true);
|
|
690 |
} else {
|
|
691 |
this.setSelected(false);
|
|
692 |
}
|
|
604 |
for (int i = 0; i < fframes.size(); i++) {
|
|
605 |
if (fframes.get(i) instanceof FFrameView) {
|
|
606 |
if ((fframeview != null) &&
|
|
607 |
fframeview.getView().getName().equals(((FFrameView) fframes
|
|
608 |
.get(i)).getView()
|
|
609 |
.getName())) {
|
|
610 |
xml.putProperty("index", i);
|
|
611 |
}
|
|
612 |
}
|
|
613 |
}
|
|
693 | 614 |
|
694 |
this.m_numLayers = xml.getIntProperty("m_numLayers"); |
|
695 |
this.m_max = xml.getIntProperty("m_max"); |
|
696 |
this.m_quality = xml.getIntProperty("m_quality"); |
|
697 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
|
698 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
|
699 |
xml.getIntProperty("fontStyle"), 9); |
|
700 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
701 |
//this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0), |
|
702 |
// p)); |
|
615 |
return xml; |
|
616 |
} |
|
703 | 617 |
|
704 |
/* int indice = xml.getIntProperty("indice"); |
|
705 |
if (indice != -1) { |
|
706 |
ProjectView view = (ProjectView) p.getViews().get(indice); |
|
707 |
|
|
708 |
fframeview.setView((ProjectView) view); |
|
709 |
} |
|
710 |
*/ |
|
711 |
ArrayList fframes = l.getFFrames(); |
|
712 |
if (xml.contains("index")){ |
|
713 |
fframeview = (FFrameView) fframes.get(xml.getIntProperty("index")); |
|
714 |
} |
|
715 |
/* LayoutControls lc=(LayoutControls)PluginServices.getExtension(LayoutControls.class); |
|
716 |
Layout layout=lc.getLayout(); |
|
717 |
ArrayList fframes=layout.getFFrames(); |
|
718 |
fframeview=(FFrameView)fframes.get(xml.getIntProperty("index")); |
|
719 |
*/ |
|
618 |
/** |
|
619 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity, |
|
620 |
* com.iver.cit.gvsig.project.Project) |
|
621 |
*/ |
|
622 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
|
623 |
if (xml.getIntProperty("m_Selected") != 0) { |
|
624 |
this.setSelected(true); |
|
625 |
} else { |
|
626 |
this.setSelected(false); |
|
627 |
} |
|
720 | 628 |
|
721 |
//this.setFFrameView((FFrameView) FFrameView.createFFrame(xml.getChild(0), |
|
722 |
// p)); |
|
723 |
} |
|
629 |
this.m_numLayers = xml.getIntProperty("m_numLayers"); |
|
630 |
this.m_max = xml.getIntProperty("m_max"); |
|
631 |
this.m_quality = xml.getIntProperty("m_quality"); |
|
632 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
|
633 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
|
634 |
xml.getIntProperty("fontStyle"), 9); |
|
724 | 635 |
|
725 |
/** |
|
726 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame() |
|
727 |
*/ |
|
728 |
public String getNameFFrame() { |
|
729 |
return PluginServices.getText(this, "leyenda") + num; |
|
730 |
} |
|
636 |
ArrayList fframes = l.getFFrames(); |
|
637 |
fframeview = (FFrameView) fframes.get(xml.getIntProperty("index")); |
|
638 |
} |
|
731 | 639 |
|
732 |
/** |
|
733 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D, |
|
734 |
* java.awt.geom.AffineTransform) |
|
735 |
*/ |
|
736 |
public void print(Graphics2D g, AffineTransform at) |
|
737 |
throws DriverException { |
|
738 |
draw(g, at, null, null); |
|
739 |
} |
|
640 |
/** |
|
641 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity, |
|
642 |
* com.iver.cit.gvsig.project.Project) |
|
643 |
*/ |
|
644 |
public void setXMLEntity(XMLEntity xml, Layout l) { |
|
645 |
if (xml.getIntProperty("m_Selected") != 0) { |
|
646 |
this.setSelected(true); |
|
647 |
} else { |
|
648 |
this.setSelected(false); |
|
649 |
} |
|
650 |
|
|
651 |
this.m_numLayers = xml.getIntProperty("m_numLayers"); |
|
652 |
this.m_max = xml.getIntProperty("m_max"); |
|
653 |
this.m_quality = xml.getIntProperty("m_quality"); |
|
654 |
this.m_viewing = xml.getIntProperty("m_viewing"); |
|
655 |
this.m_f = new Font(xml.getStringProperty("fontName"), |
|
656 |
xml.getIntProperty("fontStyle"), 9); |
|
657 |
setRotation(xml.getDoubleProperty("m_rotation")); |
|
658 |
|
|
659 |
ArrayList fframes = l.getFFrames(); |
|
660 |
|
|
661 |
if (xml.contains("index")) { |
|
662 |
fframeview = (FFrameView) fframes.get(xml.getIntProperty("index")); |
|
663 |
} |
|
664 |
} |
|
665 |
|
|
666 |
/** |
|
667 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame() |
|
668 |
*/ |
|
669 |
public String getNameFFrame() { |
|
670 |
return PluginServices.getText(this, "leyenda") + num; |
|
671 |
} |
|
672 |
|
|
673 |
/** |
|
674 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D, |
|
675 |
* java.awt.geom.AffineTransform) |
|
676 |
*/ |
|
677 |
public void print(Graphics2D g, AffineTransform at) |
|
678 |
throws DriverException { |
|
679 |
draw(g, at, null, null); |
|
680 |
} |
|
740 | 681 |
} |
Also available in: Unified diff