root / branches / gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameSymbol.java @ 1822
History | View | Annotate | Download (4.44 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 com.iver.andami.PluginServices; |
48 |
|
49 |
import com.iver.cit.gvsig.fmap.DriverException; |
50 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
51 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
52 |
import com.iver.cit.gvsig.gui.layout.Layout; |
53 |
|
54 |
import com.iver.utiles.XMLEntity; |
55 |
|
56 |
import java.awt.Graphics2D; |
57 |
import java.awt.Rectangle; |
58 |
import java.awt.geom.AffineTransform; |
59 |
import java.awt.geom.Rectangle2D; |
60 |
import java.awt.image.BufferedImage; |
61 |
|
62 |
|
63 |
/**
|
64 |
* FFrame para introducir una S?mbolo en el Layout.
|
65 |
*
|
66 |
* @author Vicente Caballero Navarro
|
67 |
*/
|
68 |
public class FFrameSymbol extends FFrame { |
69 |
private FSymbol m_Symbol;
|
70 |
private int m_type; |
71 |
|
72 |
/**
|
73 |
* Crea un nuevo FFrameSymbol.
|
74 |
*/
|
75 |
public FFrameSymbol() {
|
76 |
} |
77 |
|
78 |
/**
|
79 |
* M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
80 |
* la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
81 |
* de dibujar.
|
82 |
*
|
83 |
* @param g Graphics
|
84 |
* @param at Transformada afin.
|
85 |
* @param rv rect?ngulo sobre el que hacer un clip.
|
86 |
* @param imgBase Imagen para acelerar el dibujado.
|
87 |
*/
|
88 |
public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
89 |
BufferedImage imgBase) {
|
90 |
Rectangle2D.Double re = getBoundingBox(at);
|
91 |
|
92 |
if (intersects(rv, re)) {
|
93 |
Rectangle r = new Rectangle((int) re.x, (int) re.y, (int) re.width, |
94 |
(int) re.height);
|
95 |
AffineTransform mT2 = new AffineTransform(); |
96 |
mT2.setToIdentity(); |
97 |
|
98 |
Rectangle rec = new Rectangle((int) re.x, (int) re.y, |
99 |
(int) (re.width), (int) (re.height)); |
100 |
|
101 |
//SymbolPreviewDrawer pSD = new SymbolPreviewDrawer(m_Symbol);
|
102 |
//pSD.draw(g, r, m_type);
|
103 |
FGraphicUtilities.DrawSymbol((Graphics2D) g, mT2, rec, m_Symbol);
|
104 |
} |
105 |
} |
106 |
|
107 |
/**
|
108 |
* Pone el FSymbol.
|
109 |
*
|
110 |
* @param symbol
|
111 |
* @param type Tipo de s?mbolo.
|
112 |
*/
|
113 |
public void setSymbol(FSymbol symbol, int type) { |
114 |
m_Symbol = symbol; |
115 |
m_type = type; |
116 |
} |
117 |
|
118 |
/**
|
119 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
|
120 |
*/
|
121 |
public XMLEntity getXMLEntity() {
|
122 |
XMLEntity xml = new XMLEntity();
|
123 |
xml.putProperty("className", this.getClass().getName()); |
124 |
xml.putProperty("m_name", m_name);
|
125 |
xml.putProperty("x", getBoundBox().x);
|
126 |
xml.putProperty("y", getBoundBox().y);
|
127 |
xml.putProperty("w", getBoundBox().width);
|
128 |
xml.putProperty("h", getBoundBox().height);
|
129 |
xml.putProperty("m_Selected", m_Selected);
|
130 |
xml.putProperty("type", Layout.RECTANGLESYMBOL);
|
131 |
xml.putProperty("tag", getTag());
|
132 |
|
133 |
xml.addChild(m_Symbol.getXMLEntity()); |
134 |
|
135 |
return xml;
|
136 |
} |
137 |
|
138 |
/**
|
139 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
|
140 |
* com.iver.cit.gvsig.project.Project)
|
141 |
*/
|
142 |
public void setXMLEntity(XMLEntity xml, Layout l) { |
143 |
if (xml.getIntProperty("m_Selected") != 0) { |
144 |
this.setSelected(true); |
145 |
} else {
|
146 |
this.setSelected(false); |
147 |
} |
148 |
|
149 |
this.m_Symbol = FSymbol.createFromXML(xml.getChild(0)); |
150 |
} |
151 |
|
152 |
/**
|
153 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
|
154 |
*/
|
155 |
public String getNameFFrame() { |
156 |
return PluginServices.getText(this, "simbolo"); |
157 |
} |
158 |
|
159 |
/**
|
160 |
* @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
161 |
* java.awt.geom.AffineTransform)
|
162 |
*/
|
163 |
public void print(Graphics2D g, AffineTransform at) |
164 |
throws DriverException {
|
165 |
draw(g, at, null, null); |
166 |
} |
167 |
} |