Revision 2585 org.gvsig.raster.tools/trunk/org.gvsig.raster.tools/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/enhanced/ui/EnhancedListener.java
EnhancedListener.java | ||
---|---|---|
25 | 25 |
import java.awt.Component; |
26 | 26 |
import java.awt.event.ActionEvent; |
27 | 27 |
import java.awt.event.ActionListener; |
28 |
import java.awt.geom.Point2D; |
|
28 | 29 |
import java.io.File; |
30 |
import java.util.ArrayList; |
|
29 | 31 |
import java.util.List; |
30 | 32 |
|
31 | 33 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
... | ... | |
51 | 53 |
import org.gvsig.raster.swing.gcanvas.GraphicHistogram; |
52 | 54 |
import org.gvsig.raster.swing.gcanvas.IGCanvasListener; |
53 | 55 |
import org.gvsig.raster.swing.gcanvas.LogaritmicExponentialLine; |
56 |
import org.gvsig.raster.swing.gcanvas.MinMaxLines; |
|
54 | 57 |
import org.gvsig.raster.swing.gcanvas.SquareRootPowLine; |
55 | 58 |
import org.gvsig.raster.swing.gcanvas.StraightLine; |
56 | 59 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
... | ... | |
310 | 313 |
} |
311 | 314 |
|
312 | 315 |
/** |
316 |
* Gets the list of points from the stretches |
|
317 |
* @param stretch |
|
318 |
* @return |
|
319 |
*/ |
|
320 |
private List<Point2D> getPointListFromStretches(Stretch stretch) { |
|
321 |
List<Point2D> pointList = new ArrayList<Point2D>(); |
|
322 |
for (int i = 0; i < stretch.getStretchIn().length; i++) { |
|
323 |
Point2D p = new Point2D.Double( |
|
324 |
(stretch.getStretchIn()[i] - stretch.getMinValue()) / (stretch.getMaxValue() - stretch.getMinValue()), |
|
325 |
stretch.getStretchOut()[i] / 255.0D); |
|
326 |
pointList.add(p); |
|
327 |
} |
|
328 |
simplifyPointList(pointList); |
|
329 |
return pointList; |
|
330 |
} |
|
331 |
|
|
332 |
/** |
|
333 |
* Removes the first and the last point if the coordinate X don't change. |
|
334 |
* @param pointList |
|
335 |
*/ |
|
336 |
private void simplifyPointList(List<Point2D> pointList) { |
|
337 |
int lastPoint = pointList.size() - 1; |
|
338 |
if(pointList.size() > 1) { |
|
339 |
if(pointList.get(lastPoint).getX() == 1 && |
|
340 |
pointList.get(lastPoint).getY() == 1 && |
|
341 |
pointList.get(lastPoint - 1).getY() == 1) { |
|
342 |
pointList.remove(lastPoint); |
|
343 |
} |
|
344 |
} |
|
345 |
|
|
346 |
if(pointList.size() > 1) { |
|
347 |
if(pointList.get(0).getX() == 0 && |
|
348 |
pointList.get(0).getY() == 0 && |
|
349 |
pointList.get(1).getY() == 0) { |
|
350 |
pointList.remove(0); |
|
351 |
} |
|
352 |
} |
|
353 |
} |
|
354 |
|
|
355 |
/** |
|
313 | 356 |
* En la primera carga se define cada banda en los histogramas, para dejarlo en |
314 | 357 |
* su estado logico. |
315 | 358 |
* @param stretch |
... | ... | |
326 | 369 |
if (status == null) |
327 | 370 |
return; |
328 | 371 |
|
372 |
//MinMaxLines linesLayer = status.getMinMaxLines(); |
|
373 |
|
|
329 | 374 |
GCanvas canvas = RasterSwingLocator.getSwingManager().createGraphicCanvas(Color.white); |
330 | 375 |
|
331 | 376 |
switch (stretch.getFunctionType()) { |
... | ... | |
337 | 382 |
baseFunction = canvas.createStraightLineForGCanvas( |
338 | 383 |
((DrawableElement)status.getBaseFunction()).getColor()); |
339 | 384 |
((StraightLine) baseFunction).clearSquares(); |
340 |
for (int i = 0; i < stretch.getStretchIn().length; i++) { |
|
341 |
((StraightLine) baseFunction).addSquare( |
|
342 |
(stretch.getStretchIn()[i] - stretch.getMinValue()) / (stretch.getMaxValue() - stretch.getMinValue()), |
|
343 |
stretch.getStretchOut()[i] / 255.0D); |
|
385 |
List<Point2D> pointList = getPointListFromStretches(stretch); |
|
386 |
|
|
387 |
StraightLine func = ((StraightLine) baseFunction); |
|
388 |
for (int i = 0; i < pointList.size(); i++) { |
|
389 |
func.addSquare(pointList.get(i).getX(), pointList.get(i).getY()); |
|
344 | 390 |
} |
345 | 391 |
break; |
346 | 392 |
case 1: |
Also available in: Unified diff