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