Revision 1034 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrText.java

View differences:

FLyrText.java
1 1
/*
2 2
 * Created on 28-dic-2004
3 3
 *
4
 * TODO To change the template for this generated file go to
5
 * Window - Preferences - Java - Code Generation - Code and Comments
6 4
 */
7 5
package com.iver.cit.gvsig.fmap.layers;
8 6

  
9
import java.awt.Graphics2D;
10
import java.awt.geom.Rectangle2D;
11
import java.awt.image.BufferedImage;
12
import java.util.ArrayList;
7
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
13 8

  
14
import com.hardcode.gdbms.engine.instruction.FieldNotFoundException;
15 9
import com.iver.cit.gvsig.fmap.DriverException;
16 10
import com.iver.cit.gvsig.fmap.ViewPort;
17 11
import com.iver.cit.gvsig.fmap.core.FPoint2D;
......
24 18
import com.iver.cit.gvsig.fmap.rendering.Legend;
25 19
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend;
26 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

  
27 28
/**
29
 * Capa de texto.
30
 *
28 31
 * @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 32
 */
33 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;
34 41

  
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
    }
42
	/**
43
	 * Crea un nuevo FLyrText.
44
	 *
45
	 * @param arrayLabels DOCUMENT ME!
46
	 */
47
	public FLyrText(ArrayList arrayLabels) {
48
		m_labels = arrayLabels;
49
	}
47 50

  
48
    private void drawLabels(BufferedImage image, Graphics2D g, ViewPort viewPort,
49
			Cancellable cancel)
50
    {
51
        int numReg;
52
        Rectangle2D elExtent = viewPort.getExtent();
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();
53 63

  
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
   
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...");
62 71

  
63
        for (numReg = 0; numReg < m_labels.size(); numReg++)
64
        {
65
            if (cancel.isCanceled()) {
66
                break;
67
            }
72
		for (numReg = 0; numReg < m_labels.size(); numReg++) {
73
			if (cancel.isCanceled()) {
74
				break;
75
			}
68 76

  
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
    
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

  
80 91
	/* (non-Javadoc)
81 92
	 * @see com.iver.cit.gvsig.fmap.layers.FLayer#getFullExtent()
82 93
	 */
......
88 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)
89 100
	 */
90 101
	public void draw(BufferedImage image, Graphics2D g, ViewPort viewPort,
91
			Cancellable cancel) throws DriverException {
102
		Cancellable cancel) throws DriverException {
92 103
		drawLabels(image, g, viewPort, cancel);
93

  
94 104
	}
95 105

  
96 106
	/* (non-Javadoc)
97 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)
98 108
	 */
99 109
	public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel)
100
			throws DriverException {
110
		throws DriverException {
101 111
		drawLabels(null, g, viewPort, cancel);
102

  
103 112
	}
104 113

  
105 114
	/* (non-Javadoc)
106 115
	 * @see com.iver.cit.gvsig.fmap.layers.layerOperations.ClassifiableVectorial#setLegend(com.iver.cit.gvsig.fmap.rendering.VectorialLegend)
107 116
	 */
108
	public void setLegend(VectorialLegend r) throws DriverException, FieldNotFoundException {
109
		legend = r;		
117
	public void setLegend(VectorialLegend r)
118
		throws DriverException, FieldNotFoundException {
119
		legend = r;
110 120
	}
111 121

  
112 122
	/* (non-Javadoc)
......
114 124
	 */
115 125
	public void addLegendListener(LegendListener listener) {
116 126
		// TODO Auto-generated method stub
117
		
118 127
	}
119 128

  
120 129
	/* (non-Javadoc)
......
122 131
	 */
123 132
	public void removeLegendListener(LegendListener listener) {
124 133
		// TODO Auto-generated method stub
125
		
126 134
	}
127 135

  
128 136
	/* (non-Javadoc)
......
139 147
		return FShape.TEXT;
140 148
	}
141 149

  
150
	/**
151
	 * Devuelve un ArrayList con los textos de la capa.
152
	 *
153
	 * @return Texto de la capa.
154
	 */
142 155
	public ArrayList getLabels() {
143 156
		return m_labels;
144 157
	}
158

  
159
	/**
160
	 * Inserta los textos de la capa
161
	 *
162
	 * @param m_labels ArrayList con los textos de la capa.
163
	 */
145 164
	public void setLabels(ArrayList m_labels) {
146 165
		this.m_labels = m_labels;
147 166
	}

Also available in: Unified diff