root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / fframes / FFrameSymbol.java @ 24962
History | View | Annotate | Download (4.1 KB)
1 | 9392 | caballero | /*
|
---|---|---|---|
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 | 24759 | jmvivo | import org.gvsig.fmap.dal.exception.ReadException; |
54 | 20994 | jmvivo | import org.gvsig.fmap.mapcontext.rendering.symbols.SymbolDrawingException; |
55 | import org.gvsig.fmap.mapcontext.rendering.symbols.SymbologyFactory; |
||
56 | |||
57 | 9392 | caballero | import com.iver.andami.PluginServices; |
58 | |||
59 | |||
60 | /**
|
||
61 | * FFrame para introducir una S?mbolo en el Layout.
|
||
62 | *
|
||
63 | * @author Vicente Caballero Navarro
|
||
64 | */
|
||
65 | public class FFrameSymbol extends FFrameGraphics { |
||
66 | |||
67 | /**
|
||
68 | * Crea un nuevo FFrameSymbol.
|
||
69 | */
|
||
70 | public FFrameSymbol() {
|
||
71 | super();
|
||
72 | } |
||
73 | |||
74 | /**
|
||
75 | * M?todo que dibuja sobre el graphics que se le pasa como par?metro, seg?n
|
||
76 | * la transformada afin que se debe de aplicar y el rect?ngulo que se debe
|
||
77 | * de dibujar.
|
||
78 | *
|
||
79 | * @param g Graphics
|
||
80 | * @param at Transformada afin.
|
||
81 | * @param rv rect?ngulo sobre el que hacer un clip.
|
||
82 | * @param imgBase Imagen para acelerar el dibujado.
|
||
83 | */
|
||
84 | public void draw(Graphics2D g, AffineTransform at, Rectangle2D rv, |
||
85 | 21299 | vcaballero | BufferedImage imgBase) throws ReadException { |
86 | 9392 | caballero | Rectangle2D.Double re = getBoundingBox(at);
|
87 | g.rotate(Math.toRadians(getRotation()), re.x + (re.width / 2), |
||
88 | re.y + (re.height / 2));
|
||
89 | |||
90 | if (intersects(rv, re)) {
|
||
91 | AffineTransform mT2 = new AffineTransform(); |
||
92 | mT2.setToIdentity(); |
||
93 | |||
94 | Rectangle rec = new Rectangle((int) re.x, (int) re.y, |
||
95 | (int) (re.width), (int) (re.height)); |
||
96 | |||
97 | 18623 | jdominguez | try {
|
98 | getFSymbol().drawInsideRectangle(g, mT2, rec); |
||
99 | } catch (SymbolDrawingException e) {
|
||
100 | if (e.getType() == SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS) {
|
||
101 | try {
|
||
102 | SymbologyFactory.getWarningSymbol( |
||
103 | SymbolDrawingException.STR_UNSUPPORTED_SET_OF_SETTINGS, |
||
104 | getFSymbol().getDescription(), |
||
105 | SymbolDrawingException.UNSUPPORTED_SET_OF_SETTINGS).drawInsideRectangle(g, null, rec);
|
||
106 | } catch (SymbolDrawingException e1) {
|
||
107 | // IMPOSSIBLE TO REACH THIS
|
||
108 | } |
||
109 | } else {
|
||
110 | // should be unreachable code
|
||
111 | throw new Error(PluginServices.getText(this, "symbol_shapetype_mismatch")); |
||
112 | } |
||
113 | } |
||
114 | 9392 | caballero | } |
115 | |||
116 | g.rotate(Math.toRadians(-getRotation()), re.x + (re.width / 2), |
||
117 | re.y + (re.height / 2));
|
||
118 | } |
||
119 | |||
120 | /**
|
||
121 | * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#getNameFFrame()
|
||
122 | */
|
||
123 | public String getNameFFrame() { |
||
124 | return PluginServices.getText(this, "simbolo")+num; |
||
125 | } |
||
126 | |||
127 | /**
|
||
128 | * @see com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame#print(java.awt.Graphics2D,
|
||
129 | * java.awt.geom.AffineTransform)
|
||
130 | */
|
||
131 | public void print(Graphics2D g, AffineTransform at) |
||
132 | 21299 | vcaballero | throws ReadException {
|
133 | 9392 | caballero | draw(g, at, null, null); |
134 | } |
||
135 | |||
136 | public void initialize() { |
||
137 | |||
138 | } |
||
139 | } |