root / trunk / libraries / libFMap / src / com / iver / cit / gvsig / fmap / layers / FLyrText.java @ 1034
History | View | Annotate | Download (4.57 KB)
1 |
/*
|
---|---|
2 |
* Created on 28-dic-2004
|
3 |
*
|
4 |
*/
|
5 |
package com.iver.cit.gvsig.fmap.layers; |
6 |
|
7 |
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException; |
8 |
|
9 |
import com.iver.cit.gvsig.fmap.DriverException; |
10 |
import com.iver.cit.gvsig.fmap.ViewPort; |
11 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
12 |
import com.iver.cit.gvsig.fmap.core.FShape; |
13 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
14 |
import com.iver.cit.gvsig.fmap.core.v02.FLabel; |
15 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
16 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial; |
17 |
import com.iver.cit.gvsig.fmap.operations.Cancellable; |
18 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
19 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
20 |
|
21 |
import java.awt.Graphics2D; |
22 |
import java.awt.geom.Rectangle2D; |
23 |
import java.awt.image.BufferedImage; |
24 |
|
25 |
import java.util.ArrayList; |
26 |
|
27 |
|
28 |
/**
|
29 |
* Capa de texto.
|
30 |
*
|
31 |
* @author FJP
|
32 |
*/
|
33 |
public class FLyrText extends FLyrDefault implements ClassifiableVectorial { |
34 |
/**
|
35 |
* <code>m_labels</code> es una arrayList de FLabel (string + punto de
|
36 |
* inserci?n + rotaci?n + altura de texto
|
37 |
*/
|
38 |
private ArrayList m_labels = new ArrayList(); |
39 |
private Legend legend;
|
40 |
private Rectangle2D fullExtent; |
41 |
|
42 |
/**
|
43 |
* Crea un nuevo FLyrText.
|
44 |
*
|
45 |
* @param arrayLabels DOCUMENT ME!
|
46 |
*/
|
47 |
public FLyrText(ArrayList arrayLabels) { |
48 |
m_labels = arrayLabels; |
49 |
} |
50 |
|
51 |
/**
|
52 |
* Dibuja sobre el graphics los textos.
|
53 |
*
|
54 |
* @param image
|
55 |
* @param g Graphics.
|
56 |
* @param viewPort ViewPort.
|
57 |
* @param cancel
|
58 |
*/
|
59 |
private void drawLabels(BufferedImage image, Graphics2D g, |
60 |
ViewPort viewPort, Cancellable cancel) { |
61 |
int numReg;
|
62 |
Rectangle2D elExtent = viewPort.getExtent();
|
63 |
|
64 |
int anchoMapa;
|
65 |
int altoMapa;
|
66 |
double anchoReal;
|
67 |
double altoReal;
|
68 |
double escala;
|
69 |
FSymbol theSymbol = null;
|
70 |
System.out.println("Dibujando etiquetas..."); |
71 |
|
72 |
for (numReg = 0; numReg < m_labels.size(); numReg++) { |
73 |
if (cancel.isCanceled()) {
|
74 |
break;
|
75 |
} |
76 |
|
77 |
FLabel theLabel = (FLabel) m_labels.get(numReg); |
78 |
|
79 |
if (elExtent.contains(theLabel.getOrig())) // TODO: Aqui hay que ponerle al FLabel un getExtent() |
80 |
{ |
81 |
theSymbol = getLegend().getDefaultSymbol(); |
82 |
|
83 |
FShape shp = new FPoint2D(theLabel.getOrig().getX(),
|
84 |
theLabel.getOrig().getY()); |
85 |
FGraphicUtilities.DrawLabel(g, viewPort.getAffineTransform(), |
86 |
shp, theSymbol, theLabel); |
87 |
} |
88 |
} |
89 |
} |
90 |
|
91 |
/* (non-Javadoc)
|
92 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
|
93 |
*/
|
94 |
public Rectangle2D getFullExtent() throws DriverException { |
95 |
return fullExtent;
|
96 |
} |
97 |
|
98 |
/* (non-Javadoc)
|
99 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#draw(java.awt.image.BufferedImage, java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable)
|
100 |
*/
|
101 |
public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort, |
102 |
Cancellable cancel) throws DriverException {
|
103 |
drawLabels(image, g, viewPort, cancel); |
104 |
} |
105 |
|
106 |
/* (non-Javadoc)
|
107 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#print(java.awt.Graphics2D, com.iver.cit.gvsig.fmap.ViewPort, com.iver.cit.gvsig.fmap.operations.Cancellable)
|
108 |
*/
|
109 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel) |
110 |
throws DriverException {
|
111 |
drawLabels(null, g, viewPort, cancel);
|
112 |
} |
113 |
|
114 |
/* (non-Javadoc)
|
115 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial#setLegend(com.iver.cit.gvsig.fmap.rendering.VectorialLegend)
|
116 |
*/
|
117 |
public void setLegend(VectorialLegend r) |
118 |
throws DriverException, FieldNotFoundException {
|
119 |
legend = r; |
120 |
} |
121 |
|
122 |
/* (non-Javadoc)
|
123 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable#addLegendListener(com.iver.cit.gvsig.fmap.layers.LegendListener)
|
124 |
*/
|
125 |
public void addLegendListener(LegendListener listener) { |
126 |
// TODO Auto-generated method stub
|
127 |
} |
128 |
|
129 |
/* (non-Javadoc)
|
130 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable#removeLegendListener(com.iver.cit.gvsig.fmap.layers.LegendListener)
|
131 |
*/
|
132 |
public void removeLegendListener(LegendListener listener) { |
133 |
// TODO Auto-generated method stub
|
134 |
} |
135 |
|
136 |
/* (non-Javadoc)
|
137 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable#getLegend()
|
138 |
*/
|
139 |
public Legend getLegend() {
|
140 |
return legend;
|
141 |
} |
142 |
|
143 |
/* (non-Javadoc)
|
144 |
* @see com.iver.cit.gvsig.fmap.layers.layerOperations.Classifiable#getShapeType()
|
145 |
*/
|
146 |
public int getShapeType() throws DriverException { |
147 |
return FShape.TEXT;
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* Devuelve un ArrayList con los textos de la capa.
|
152 |
*
|
153 |
* @return Texto de la capa.
|
154 |
*/
|
155 |
public ArrayList getLabels() { |
156 |
return m_labels;
|
157 |
} |
158 |
|
159 |
/**
|
160 |
* Inserta los textos de la capa
|
161 |
*
|
162 |
* @param m_labels ArrayList con los textos de la capa.
|
163 |
*/
|
164 |
public void setLabels(ArrayList m_labels) { |
165 |
this.m_labels = m_labels;
|
166 |
} |
167 |
} |