Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / FFrameSymbol.java @ 686

History | View | Annotate | Download (3.88 KB)

1
/*
2
 * Created on 09-jul-2004
3
 *
4
 * To change the template for this generated file go to
5
 * Window>Preferences>Java>Code Generation>Code and Comments
6
 */
7
package com.iver.cit.gvsig.gui.layout.fframes;
8

    
9
import java.awt.Graphics2D;
10
import java.awt.Rectangle;
11
import java.awt.geom.AffineTransform;
12
import java.awt.geom.Rectangle2D;
13
import java.awt.image.BufferedImage;
14

    
15
import com.iver.andami.PluginServices;
16
import com.iver.cit.gvsig.fmap.DriverException;
17
import com.iver.cit.gvsig.fmap.rendering.styling.FStyle2D;
18
import com.iver.cit.gvsig.fmap.rendering.styling.SymbolPreviewDrawer;
19
import com.iver.cit.gvsig.gui.layout.Layout;
20
import com.iver.utiles.XMLEntity;
21

    
22

    
23
/**
24
 * FFrame para introducir una S?mbolo en el Layout.
25
 *
26
 * @author Vicente Caballero Navarro
27
 */
28
public class FFrameSymbol extends FFrame {
29
        private FStyle2D m_Symbol;
30
        private int m_type;
31

    
32
        /**
33
         * Crea un nuevo FFrameSymbol.
34
         */
35
        public FFrameSymbol() {
36
        }
37

    
38
        /**
39
         * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
40
         * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
41
         * de dibujar.
42
         *
43
         * @param g Graphics
44
         * @param at Transformada afin.
45
         * @param rv rect?ngulo sobre el que hacer un clip.
46
         * @param imgBase DOCUMENT ME!
47
         */
48
        public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
49
                BufferedImage imgBase) {
50
                Rectangle2D.Double re = getBoundingBox(at);
51

    
52
                if (intersects(rv, re)) {
53
                        Rectangle r = new Rectangle((int) re.x, (int) re.y, (int) re.width,
54
                                        (int) re.height);
55
                        AffineTransform mT2 = new AffineTransform();
56
                        mT2.setToIdentity();
57

    
58
                        //   Rectangle rec = new Rectangle((int) re.x, (int) re.y,
59
                        //         (int) (re.width), (int) (re.height));
60
                        SymbolPreviewDrawer pSD = new SymbolPreviewDrawer(m_Symbol);
61
                        pSD.draw(g, r, m_type);
62

    
63
                        //              FGraphicUtilities.DrawSymbol((Graphics2D) g, mT2, rec, m_Symbol);
64
                }
65
        }
66

    
67
        /**
68
         * Pone el FSymbol.
69
         *
70
         * @param symbol
71
         * @param type DOCUMENT ME!
72
         */
73
        public void setSymbol(FStyle2D symbol, int type) {
74
                m_Symbol = symbol;
75
                m_type = type;
76
        }
77

    
78
        /**
79
         * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getXMLEntity()
80
         */
81
        public XMLEntity getXMLEntity() {
82
                XMLEntity xml = new XMLEntity();
83
                xml.putProperty("nameClass", this.getClass().getName());
84
                xml.putProperty("m_name", m_name);
85
                xml.putProperty("x", getBoundBox().x);
86
                xml.putProperty("y", getBoundBox().y);
87
                xml.putProperty("w", getBoundBox().width);
88
                xml.putProperty("h", getBoundBox().height);
89
                xml.putProperty("m_Selected", m_Selected);
90
                xml.putProperty("type", Layout.RECTANGLESYMBOL);
91
                xml.putProperty("tag", getTag());
92

    
93
                //// xml.addChild(m_Symbol.getXMLEntity());
94
                return xml;
95
        }
96

    
97
        /**
98
         * Crea un Objeto de esta clase a partir de la informaci?n del XMLEntity.
99
         *
100
         * @param xml XMLEntity
101
         * @param p DOCUMENT ME!
102
         */
103

    
104
        /*  public static FFrameSymbol createFFrameSymbol(XMLEntity xml) {
105
           FFrameSymbol fframe = new FFrameSymbol();
106
        
107
           if (xml.getIntProperty("m_Selected") != 0) {
108
               fframe.setSelected(true);
109
           } else {
110
               fframe.setSelected(false);
111
           }
112
           fframe.m_Symbol = FSymbol.createFSymbol(xml.getChild(0));
113
           return fframe;
114
           }
115
         */
116

    
117
        /**
118
         * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#setXMLEntity(com.iver.utiles.XMLEntity,
119
         *                 com.iver.cit.gvsig.project.Project)
120
         */
121
        public void setXMLEntity(XMLEntity xml, Layout l) {
122
                if (xml.getIntProperty("m_Selected") != 0) {
123
                        this.setSelected(true);
124
                } else {
125
                        this.setSelected(false);
126
                }
127

    
128
                /// this.m_Symbol = FStyle2D.createFSymbol(xml.getChild(0));
129
        }
130

    
131
        /**
132
         * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#getNameFFrame()
133
         */
134
        public String getNameFFrame() {
135
                return PluginServices.getText(this, "simbolo");
136
        }
137

    
138
        /**
139
         * @see com.iver.cit.gvsig.gui.layout.fframes.IFFrame#print(java.awt.Graphics2D,
140
         *                 java.awt.geom.AffineTransform)
141
         */
142
        public void print(Graphics2D g, AffineTransform at)
143
                throws DriverException {
144
                draw(g, at, null, null);
145
        }
146
}