svn-gvsig-desktop / tags / Root_v061 / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameSymbol.java @ 4812
History | View | Annotate | Download (5.9 KB)
1 |
/*
|
---|---|
2 |
* Created on 09-jul-2004
|
3 |
*
|
4 |
*/
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 |
*
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package com.iver.cit.gvsig.gui.layout.fframes; |
46 |
|
47 |
import java.awt.Graphics2D; |
48 |
import java.awt.Rectangle; |
49 |
import java.awt.geom.AffineTransform; |
50 |
import java.awt.geom.Rectangle2D; |
51 |
import java.awt.image.BufferedImage; |
52 |
|
53 |
import com.iver.andami.PluginServices; |
54 |
import com.iver.cit.gvsig.fmap.DriverException; |
55 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
56 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
57 |
import com.iver.cit.gvsig.gui.layout.Layout; |
58 |
import com.iver.cit.gvsig.gui.project.SaveException; |
59 |
import com.iver.utiles.XMLEntity; |
60 |
|
61 |
|
62 |
/**
|
63 |
* FFrame para introducir una S?mbolo en el Layout.
|
64 |
*
|
65 |
* @author Vicente Caballero Navarro
|
66 |
*/
|
67 |
public class FFrameSymbol extends FFrame { |
68 |
private FSymbol m_Symbol;
|
69 |
/**
|
70 |
* Crea un nuevo FFrameSymbol.
|
71 |
*/
|
72 |
public FFrameSymbol() {
|
73 |
} |
74 |
|
75 |
/**
|
76 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
77 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
78 |
* de dibujar.
|
79 |
*
|
80 |
* @param g Graphics
|
81 |
* @param at Transformada afin.
|
82 |
* @param rv rect?ngulo sobre el que hacer un clip.
|
83 |
* @param imgBase Imagen para acelerar el dibujado.
|
84 |
*/
|
85 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
86 |
BufferedImage imgBase) {
|
87 |
Rectangle2D.Double re = getBoundingBox(at);
|
88 |
g.rotate(Math.toRadians(getRotation()), re.x + (re.width / 2), |
89 |
re.y + (re.height / 2));
|
90 |
|
91 |
if (intersects(rv, re)) {
|
92 |
AffineTransform mT2 = new AffineTransform(); |
93 |
mT2.setToIdentity(); |
94 |
|
95 |
Rectangle rec = new Rectangle((int) re.x, (int) re.y, |
96 |
(int) (re.width), (int) (re.height)); |
97 |
|
98 |
FGraphicUtilities.DrawSymbol((Graphics2D) g, mT2, rec, m_Symbol);
|
99 |
} |
100 |
|
101 |
g.rotate(Math.toRadians(-getRotation()), re.x + (re.width / 2), |
102 |
re.y + (re.height / 2));
|
103 |
} |
104 |
|
105 |
/**
|
106 |
* Pone el FSymbol.
|
107 |
*
|
108 |
* @param symbol
|
109 |
* @param type Tipo de s?mbolo.
|
110 |
*/
|
111 |
public void setSymbol(FSymbol symbol, int type) { |
112 |
m_Symbol = symbol; |
113 |
} |
114 |
|
115 |
/**
|
116 |
* @throws SaveException
|
117 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
118 |
*/
|
119 |
public XMLEntity getXMLEntity() throws SaveException { |
120 |
XMLEntity xml = new XMLEntity();
|
121 |
try{
|
122 |
xml.putProperty("className", this.getClass().getName()); |
123 |
xml.putProperty("m_name", m_name);
|
124 |
xml.putProperty("x", getBoundBox().x);
|
125 |
xml.putProperty("y", getBoundBox().y);
|
126 |
xml.putProperty("w", getBoundBox().width);
|
127 |
xml.putProperty("h", getBoundBox().height);
|
128 |
xml.putProperty("m_Selected", m_Selected);
|
129 |
xml.putProperty("type", Layout.RECTANGLESYMBOL);
|
130 |
xml.putProperty("tag", getTag());
|
131 |
xml.putProperty("m_rotation", getRotation());
|
132 |
xml.addChild(m_Symbol.getXMLEntity()); |
133 |
}catch (Exception e) { |
134 |
throw new SaveException(e,this.getClass().getName()); |
135 |
} |
136 |
return xml;
|
137 |
} |
138 |
|
139 |
/**
|
140 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
141 |
* com.iver.cit.gvsig.project.Project)
|
142 |
*/
|
143 |
public void setXMLEntity03(XMLEntity xml, Layout l) { |
144 |
if (xml.getIntProperty("m_Selected") != 0) { |
145 |
this.setSelected(true); |
146 |
} else {
|
147 |
this.setSelected(false); |
148 |
} |
149 |
|
150 |
this.m_Symbol = FSymbol.createFromXML03(xml.getChild(0)); |
151 |
} |
152 |
|
153 |
/**
|
154 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
155 |
* com.iver.cit.gvsig.project.Project)
|
156 |
*/
|
157 |
public void setXMLEntity(XMLEntity xml) { |
158 |
if (xml.getIntProperty("m_Selected") != 0) { |
159 |
this.setSelected(true); |
160 |
} else {
|
161 |
this.setSelected(false); |
162 |
} |
163 |
|
164 |
setRotation(xml.getDoubleProperty("m_rotation"));
|
165 |
this.m_Symbol = FSymbol.createFromXML(xml.getChild(0)); |
166 |
} |
167 |
|
168 |
/**
|
169 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
|
170 |
*/
|
171 |
public String getNameFFrame() { |
172 |
return PluginServices.getText(this, "simbolo"); |
173 |
} |
174 |
|
175 |
/**
|
176 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
177 |
* java.awt.geom.AffineTransform)
|
178 |
*/
|
179 |
public void print(Graphics2D g, AffineTransform at) |
180 |
throws DriverException {
|
181 |
draw(g, at, null, null); |
182 |
} |
183 |
|
184 |
/**
|
185 |
* Devuelve el s?mbolo.
|
186 |
*
|
187 |
* @return S?mbolo.
|
188 |
*/
|
189 |
public FSymbol getFSymbol() {
|
190 |
return m_Symbol;
|
191 |
} |
192 |
|
193 |
/**
|
194 |
* Inserta el s?mbolo al FFrame.
|
195 |
*
|
196 |
* @param symbol S?mbolo a insertar.
|
197 |
*/
|
198 |
public void setFSymbol(FSymbol symbol) { |
199 |
m_Symbol = symbol; |
200 |
} |
201 |
|
202 |
public void initialize() { |
203 |
// TODO Auto-generated method stub
|
204 |
|
205 |
} |
206 |
} |