Statistics
| Revision:

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 312 fernando
/*
2
 * Created on 09-jul-2004
3
 *
4
 */
5 1103 fjp
/* 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 312 fernando
package com.iver.cit.gvsig.gui.layout.fframes;
46
47 3170 caballero
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 312 fernando
53 3170 caballero
import com.iver.andami.PluginServices;
54 654 fernando
import com.iver.cit.gvsig.fmap.DriverException;
55 1274 vcaballero
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities;
56
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
57 596 fernando
import com.iver.cit.gvsig.gui.layout.Layout;
58 3183 caballero
import com.iver.cit.gvsig.gui.project.SaveException;
59 596 fernando
import com.iver.utiles.XMLEntity;
60 312 fernando
61 596 fernando
62 312 fernando
/**
63
 * FFrame para introducir una S?mbolo en el Layout.
64
 *
65
 * @author Vicente Caballero Navarro
66
 */
67 3170 caballero
public class FFrameSymbol extends FFrame {
68 3135 caballero
    private FSymbol m_Symbol;
69
    /**
70
     * Crea un nuevo FFrameSymbol.
71
     */
72
    public FFrameSymbol() {
73
    }
74 312 fernando
75 3135 caballero
    /**
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 1657 vcaballero
91 3135 caballero
        if (intersects(rv, re)) {
92
            AffineTransform mT2 = new AffineTransform();
93
            mT2.setToIdentity();
94 312 fernando
95 3135 caballero
            Rectangle rec = new Rectangle((int) re.x, (int) re.y,
96
                    (int) (re.width), (int) (re.height));
97 312 fernando
98 3135 caballero
            FGraphicUtilities.DrawSymbol((Graphics2D) g, mT2, rec, m_Symbol);
99
        }
100 1657 vcaballero
101 3135 caballero
        g.rotate(Math.toRadians(-getRotation()), re.x + (re.width / 2),
102
            re.y + (re.height / 2));
103
    }
104 398 vcaballero
105 3135 caballero
    /**
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 312 fernando
115 3135 caballero
    /**
116 3183 caballero
     * @throws SaveException
117 3135 caballero
     * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
118
     */
119 3183 caballero
    public XMLEntity getXMLEntity() throws SaveException {
120 3135 caballero
        XMLEntity xml = new XMLEntity();
121 3183 caballero
        try{
122 3135 caballero
        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 3183 caballero
        }catch (Exception e) {
134
                        throw new SaveException(e,this.getClass().getName());
135
                }
136 3135 caballero
        return xml;
137
    }
138 2183 fernando
139 3135 caballero
    /**
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 2183 fernando
150 3135 caballero
        this.m_Symbol = FSymbol.createFromXML03(xml.getChild(0));
151
    }
152 649 vcaballero
153 3135 caballero
    /**
154
     * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
155
     *      com.iver.cit.gvsig.project.Project)
156
     */
157 3170 caballero
    public void setXMLEntity(XMLEntity xml) {
158 3135 caballero
        if (xml.getIntProperty("m_Selected") != 0) {
159
            this.setSelected(true);
160
        } else {
161
            this.setSelected(false);
162
        }
163 649 vcaballero
164 3135 caballero
        setRotation(xml.getDoubleProperty("m_rotation"));
165
        this.m_Symbol = FSymbol.createFromXML(xml.getChild(0));
166
    }
167 2589 caballero
168 3135 caballero
    /**
169
     * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
170
     */
171
    public String getNameFFrame() {
172
        return PluginServices.getText(this, "simbolo");
173
    }
174 2589 caballero
175 3135 caballero
    /**
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 4209 jaume
202
        public void initialize() {
203
                // TODO Auto-generated method stub
204
205
        }
206 398 vcaballero
}