Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / FFrameSymbol.java @ 28861

History | View | Annotate | Download (4.45 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.project.documents.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 javax.print.attribute.PrintRequestAttributeSet;
54

    
55
import org.gvsig.fmap.dal.exception.ReadException;
56
import org.gvsig.fmap.geom.Geometry;
57
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException;
58
import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory;
59

    
60
import com.iver.andami.PluginServices;
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 FFrameGraphics {
69

    
70
    private PrintRequestAttributeSet properties;
71

    
72
        /**
73
     * Crea un nuevo FFrameSymbol.
74
     */
75
    public FFrameSymbol() {
76
            super();
77
    }
78

    
79
    /**
80
     * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
81
     * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
82
     * de dibujar.
83
     *
84
     * @param g Graphics
85
     * @param at Transformada afin.
86
     * @param rv rect?ngulo sobre el que hacer un clip.
87
     * @param imgBase Imagen para acelerar el dibujado.
88
     */
89
    public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv,
90
        BufferedImage imgBase) {
91
        Rectangle2D.Double re = getBoundingBox(at);
92
        g.rotate(Math.toRadians(getRotation()), re.x + (re.width / 2),
93
            re.y + (re.height / 2));
94

    
95
        if (intersects(rv, re)) {
96
            AffineTransform mT2 = new AffineTransform();
97
            mT2.setToIdentity();
98

    
99
            Rectangle rec = new Rectangle((int) re.x, (int) re.y,
100
                    (int) (re.width), (int) (re.height));
101

    
102
            try {
103
                                getFSymbol().drawInsideRectangle(g, mT2, rec, properties);
104
                        } catch (SymbolDrawingException e) {
105
                                if (e.getType() == SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS) {
106
                                        try {
107
                                                SymbologyFactory.getWarningSymbol(
108
                                                                SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS,
109
                                                                getFSymbol().getDescription(),
110
                                                                SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS).drawInsideRectangle(g, null, rec,null);
111
                                        } catch (SymbolDrawingException e1) {
112
                                                // IMPOSSIBLE TO REACH THIS
113
                                        }
114
                                } else {
115
                                        // should be unreachable code
116
                                        throw new Error(PluginServices.getText(this, "symbol_shapetype_mismatch"));
117
                                }
118
                        }
119
        }
120

    
121
        g.rotate(Math.toRadians(-getRotation()), re.x + (re.width / 2),
122
            re.y + (re.height / 2));
123
    }
124

    
125
    /**
126
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNameFFrame()
127
     */
128
    public String getNameFFrame() {
129
        return PluginServices.getText(this, "simbolo")+num;
130
    }
131

    
132
    /**
133
     * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
134
     *      java.awt.geom.AffineTransform)
135
     */
136
    public void print(Graphics2D g, AffineTransform at, Geometry geom, PrintRequestAttributeSet printingProperties) {
137
        this.properties=printingProperties;
138
            draw(g, at, null, null);
139
            this.properties=null;
140
    }
141

    
142
    public void initialize() {
143

    
144
        }
145
    public void setBoundBox(Rectangle2D r) {
146
        m_BoundBox.setRect(r.getX(), r.getY(), r.getWidth(), r.getHeight());
147
    }
148
}