Revision 18250 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/tools/Behavior/PolygonBehavior.java

View differences:

PolygonBehavior.java
40 40
 */
41 41
package com.iver.cit.gvsig.fmap.tools.Behavior;
42 42

  
43
import java.awt.Color;
44 43
import java.awt.Graphics;
45
import java.awt.Graphics2D;
46 44
import java.awt.event.MouseEvent;
47 45
import java.awt.geom.Point2D;
48 46

  
......
55 53
 * Behaviour que espera un listener de tipo MeasureListener.
56 54
 *
57 55
 * @author Vicente Caballero Navarro
56
 * @author Pablo Piqueras Bartolom?
58 57
 */
59 58
public class PolygonBehavior extends PolylineBehavior {
60 59
	/**
......
70 69
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
71 70
	 */
72 71
	public void paintComponent(Graphics g) {
73
		g.drawImage(getMapControl().getImage(), 0, 0, null);
74
		g.setColor(Color.black);
75

  
76
		if (!arrayX.isEmpty()) {
77
			drawPolyLine((Graphics2D) g);
78
		}
72
		super.paintComponent(g);
79 73
	}
80 74

  
81 75
	/**
......
85 79
	 *
86 80
	 * @throws BehaviorException Excepci?n lanzada cuando el Behavior.
87 81
	 */
88
	public void mousePressed(MouseEvent E) throws BehaviorException {
89
		if (E.getClickCount() == 2) {
90
			listener.polylineFinished(new MeasureEvent(
91
					(Double[]) arrayX.toArray(new Double[0]),
92
					(Double[]) arrayY.toArray(new Double[0]), E));
82
	public void mousePressed(MouseEvent e) throws BehaviorException {
83
		if (e.getClickCount() == 2) {
84
			listener.polylineFinished(new MeasureEvent((Double[]) arrayX.toArray(new Double[arrayX.size()]), (Double[]) arrayY.toArray(new Double[arrayY.size()]), e));
85

  
93 86
			arrayX.clear();
94 87
			arrayY.clear();
88

  
95 89
			isClicked = false;
96 90
		} else {
97 91
			isClicked = true;
98 92

  
99 93
			if (arrayX.size() == 0) {
100
				addPoint(getMapControl().getViewPort().toMapPoint(E.getPoint()));
101
				addPoint(getMapControl().getViewPort().toMapPoint(E.getPoint()));
102
				addPoint(getMapControl().getViewPort().toMapPoint(E.getPoint()));
94
				addPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
95
				addPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
96
				addPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
103 97
			} else {
104
				addAntPoint(getMapControl().getViewPort().toMapPoint(E.getPoint()));
98
				addAntPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
105 99
			}
106 100

  
107
			listener.pointFixed(new MeasureEvent(
108
					(Double[]) arrayX.toArray(new Double[0]),
109
					(Double[]) arrayY.toArray(new Double[0]), E));
101
			listener.pointFixed(new MeasureEvent((Double[]) arrayX.toArray(new Double[arrayX.size()]), (Double[]) arrayY.toArray(new Double[arrayY.size()]), e));
110 102
		}
111 103
	}
112 104

  
......
139 131
	 *
140 132
	 * @throws BehaviorException Excepci?n lanzada cuando el Behavior.
141 133
	 */
142
	public void mouseMoved(MouseEvent E) throws BehaviorException {
134
	public void mouseMoved(MouseEvent e) throws BehaviorException {
143 135
		if (isClicked) {
144
			changeAntPoint(getMapControl().getViewPort().toMapPoint(E.getPoint()));
136
			changeAntPoint(getMapControl().getViewPort().toMapPoint(e.getPoint()));
145 137

  
146
			MeasureEvent event = new MeasureEvent((Double[]) arrayX.toArray(
147
						new Double[0]),
148
					(Double[]) arrayY.toArray(new Double[0]), E);
138
			MeasureEvent event = new MeasureEvent((Double[]) arrayX.toArray(new Double[arrayX.size()]), (Double[]) arrayY.toArray(new Double[arrayY.size()]), e);
139

  
149 140
			listener.points(event);
141

  
150 142
			getMapControl().repaint();
151 143
		}
152 144
	}

Also available in: Unified diff