Revision 19945 trunk/extensions/extRasterTools-SE/src/org/gvsig/raster/beans/canvas/layers/functions/StraightLine.java

View differences:

StraightLine.java
52 52
		private double y      = 0.0D;
53 53
		private int    width  = 6;
54 54
		private Color  color  = Color.WHITE;
55
		private int    border = 2;
56 55
		
57 56
		
58 57
		/**
......
158 157
			return (int) Math.round(canvas.getCanvasMinX() + border + ((canvas.getCanvasMaxX() - canvas.getCanvasMinX() - (border * 2)) * value));
159 158
		}
160 159

  
161
		private double pixelToValueX(int pixel) {
162
			double value = ((double) (pixel - canvas.getCanvasMinX() - border) / (double) (canvas.getCanvasMaxX() - canvas.getCanvasMinX() - (border * 2.0D)));
163
			
164
			value = (value - minx) / (maxx - minx);
165
			
166
			return value;
167
		}
168

  
169 160
		private int valueToPixelY(double value) {
170 161
			value = 1.0D - value;
171 162
			return (int) Math.round(canvas.getCanvasMinY() + border + ((canvas.getCanvasMaxY() - canvas.getCanvasMinY() - (border * 2)) * value));
172 163
		}
173 164

  
174
		private double pixelToValueY(int pixel) {
175
			double div = (double) (canvas.getCanvasMaxY() - canvas.getCanvasMinY() - (border * 2.0D));
176
			if (div == 0.0D)
177
				return 0.0D;
178
			
179
			return (1.0D - ((double) (pixel - canvas.getCanvasMinY() - border) / div));
180
		}
181 165
	}
182 166
	
183 167
	/**
184 168
	 * Lista de cuadrados que intersectan con la recta
185 169
	 */
186
	protected ArrayList   listSquare        = new ArrayList();
187
	private int           pointDragged      = -1;
188
	Cursor                transparentCursor = null;
170
	protected ArrayList listSquare        = new ArrayList();
171
	private int         pointDragged      = -1;
172
	private Cursor      transparentCursor = null;
173
	private boolean     showSquares       = true;
174
	private int         border            = 2;
189 175
	
190 176
	/**
191 177
	 * Constructor. Asigna el color
......
229 215
		}
230 216

  
231 217
		// Dibujamos los cuadrados de los puntos
232
		for (int i = 0; i < listSquare.size(); i++) {
233
			square = ((Square) listSquare.get(i));
234
			square.setColor(color);
235
			if (pointDragged != i)
236
				square.paint(g);
237
			else
238
				square.paintCursor(g);
218
		if (showSquares) {
219
			for (int i = 0; i < listSquare.size(); i++) {
220
				square = ((Square) listSquare.get(i));
221
				square.setColor(color);
222
				if (pointDragged != i)
223
					square.paint(g);
224
				else
225
					square.paintCursor(g);
226
			}
239 227
		}
240 228

  
241 229
		if (pointDragged != -1) {
......
496 484
	
497 485
	public void firstActions() {}
498 486
	public void firstDrawActions() {}
487

  
488
	/**
489
	 * @param showSquares the showSquares to set
490
	 */
491
	public void setShowSquares(boolean showSquares) {
492
		this.showSquares = showSquares;
493
	}
494

  
495
	protected double pixelToValueX(int pixel) {
496
		double value = ((double) (pixel - canvas.getCanvasMinX() - border) / (double) (canvas.getCanvasMaxX() - canvas.getCanvasMinX() - (border * 2.0D)));
497
		
498
		value = (value - minx) / (maxx - minx);
499
		
500
		return value;
501
	}
502

  
503
	protected double pixelToValueY(int pixel) {
504
		double div = (double) (canvas.getCanvasMaxY() - canvas.getCanvasMinY() - (border * 2.0D));
505
		if (div == 0.0D)
506
			return 0.0D;
507
		
508
		return (1.0D - ((double) (pixel - canvas.getCanvasMinY() - border) / div));
509
	}
499 510
}

Also available in: Unified diff