Revision 9524 branches/piloto3d/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/FLyrRaster.java
FLyrRaster.java | ||
---|---|---|
54 | 54 |
import java.lang.reflect.InvocationTargetException; |
55 | 55 |
import java.util.ArrayList; |
56 | 56 |
|
57 |
import javax.print.attribute.PrintRequestAttributeSet; |
|
57 | 58 |
import javax.swing.ImageIcon; |
58 | 59 |
|
59 | 60 |
import org.cresques.cts.IProjection; |
60 | 61 |
import org.cresques.filter.RasterFilterStack; |
61 |
import org.cresques.filter.RasterStats; |
|
62 |
import org.cresques.io.data.Grid; |
|
63 |
import org.cresques.io.datastruct.Statistic; |
|
62 | 64 |
import org.cresques.px.Extent; |
63 | 65 |
|
64 | 66 |
import com.hardcode.driverManager.Driver; |
... | ... | |
68 | 70 |
import com.iver.cit.gvsig.fmap.ViewPort; |
69 | 71 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
70 | 72 |
import com.iver.cit.gvsig.fmap.drivers.GeorreferencedRasterDriver; |
73 |
import com.iver.cit.gvsig.fmap.drivers.RasterDriver; |
|
71 | 74 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.StringXMLItem; |
72 | 75 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.XMLItem; |
76 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
|
77 |
import com.iver.utiles.DoubleUtilities; |
|
73 | 78 |
import com.iver.utiles.XMLEntity; |
74 | 79 |
import com.iver.utiles.swing.threads.Cancellable; |
75 | 80 |
|
... | ... | |
384 | 389 |
return data; |
385 | 390 |
} |
386 | 391 |
|
387 |
public XMLItem[] getInfo(Point p, double tolerance) throws DriverException { |
|
392 |
public XMLItem[] getInfo(Point p, double tolerance, Cancellable cancel) throws DriverException {
|
|
388 | 393 |
|
389 | 394 |
Point2D pReal = getMapContext().getViewPort().toMapPoint(p); |
390 | 395 |
Point2D px = null; |
... | ... | |
401 | 406 |
if(a[0].toString().equals("Height")) |
402 | 407 |
h = ((Integer)a[1]).intValue(); |
403 | 408 |
} |
404 |
px = new Point(); |
|
409 |
px = new Point2D.Double();
|
|
405 | 410 |
px.setLocation( ((pReal.getX() - this.getMinX()) * w) / getWidth(), |
406 | 411 |
((this.getMaxY() - pReal.getY()) * h) / getHeight()); |
407 | 412 |
} |
408 | 413 |
|
409 | 414 |
int[] rgb = this.getPixel(pReal.getX(), pReal.getY()); |
410 |
|
|
415 |
|
|
411 | 416 |
StringXMLItem[] item = new StringXMLItem[1]; |
412 | 417 |
String data = "<file:"+normalizeAsXMLTag(getName())+">\n"; |
413 |
|
|
418 |
|
|
414 | 419 |
data += " <raster\n"; |
415 | 420 |
data += " View_Point=\""+p.getX()+" , "+p.getY()+"\"\n"; |
416 |
data += " World_Point=\""+pReal.getX()+" , "+pReal.getY()+"\"\n";
|
|
421 |
data += " World_Point=\""+DoubleUtilities.format(pReal.getX(), 5)+" , "+DoubleUtilities.format(pReal.getY(), 5)+"\"\n";
|
|
417 | 422 |
if(px == null) |
418 | 423 |
data += " Pixel_Point=\"Out\"\n"; |
419 |
else |
|
420 |
data += " Pixel_Point=\""+px.getX()+" , "+px.getY()+"\"\n"; |
|
421 |
data += " RGB=\""+rgb[1]+", "+rgb[2]+", "+rgb[3]+"\"\n"; |
|
424 |
else{ |
|
425 |
data += " Pixel_Point=\""+(int)px.getX()+" , "+(int)px.getY()+"\"\n"; |
|
426 |
data += " Band_Value=\""; |
|
427 |
|
|
428 |
for(int i = 0; i < this.getSource().getNumBands(); i++){ |
|
429 |
Object pxData = ((RasterDriver)this.getSource().getDriver()).getData((int)px.getX(), (int)px.getY(), i); |
|
430 |
if(pxData != null){ |
|
431 |
if(this.getSource().getDataType() >= 0 && this.getSource().getDataType() <= 3) |
|
432 |
data += ((Integer)pxData).intValue()+" "; |
|
433 |
|
|
434 |
if(this.getSource().getDataType() >= 4) |
|
435 |
data += ((Float)pxData).floatValue()+" "; |
|
436 |
|
|
437 |
if(this.getSource().getDataType() >= 5) |
|
438 |
data += ((Double)pxData).doubleValue()+" "; |
|
439 |
} |
|
440 |
} |
|
441 |
data += "\"\n"; |
|
442 |
} |
|
443 |
|
|
444 |
data += " RGB=\""+rgb[1]+" "+rgb[2]+" "+rgb[3]+"\"\n"; |
|
445 |
|
|
422 | 446 |
data += " />\n"; |
423 |
|
|
424 | 447 |
data += "</file:"+normalizeAsXMLTag(getName())+">\n"; |
425 | 448 |
|
426 | 449 |
item[0] = new StringXMLItem(data, this); |
... | ... | |
542 | 565 |
/* (non-Javadoc) |
543 | 566 |
* @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) |
544 | 567 |
*/ |
545 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel,double scale)
|
|
568 |
public void print(Graphics2D g, ViewPort viewPort, Cancellable cancel, double scale, PrintRequestAttributeSet propeties)
|
|
546 | 569 |
throws DriverException { |
547 | 570 |
|
548 | 571 |
if (isVisible() && isWithinScale(scale)){ |
... | ... | |
560 | 583 |
//Si es la primera lectura salvamos los valores de m?ximo y m?nimo para la aplicaci?n |
561 | 584 |
//de realce si la imagen es de 16 bits. |
562 | 585 |
|
563 |
RasterStats stats = getSource().getFilterStack().getStats();
|
|
586 |
Statistic stats = getSource().getFilterStack().getStats();
|
|
564 | 587 |
if(stats != null) |
565 | 588 |
stats.history.add(stats.new History(getName(), stats.minBandValue, stats.maxBandValue, stats.secondMinBandValue, stats.secondMaxBandValue)); |
566 | 589 |
|
... | ... | |
760 | 783 |
public boolean isGeoreferenced() { |
761 | 784 |
return getSource().isGeoreferenced(); |
762 | 785 |
} |
786 |
|
|
787 |
/** |
|
788 |
* Obtiene el grid asociado |
|
789 |
* @return grid |
|
790 |
*/ |
|
791 |
public Grid getGrid(){ |
|
792 |
return getSource().getGrid(); |
|
793 |
} |
|
794 |
|
|
795 |
/** |
|
796 |
* Obtiene el tipo de dato de la capa raster |
|
797 |
* @return Entero que representa el tipo de dato de la capa raster. |
|
798 |
*/ |
|
799 |
public int getDataType() { |
|
800 |
return getSource().getDataType(); |
|
801 |
} |
|
802 |
|
|
803 |
/* |
|
804 |
* (non-Javadoc) |
|
805 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#cloneLayer() |
|
806 |
*/ |
|
807 |
public FLayer cloneLayer() throws Exception { |
|
808 |
FLyrRaster clonedLayer = new FLyrRaster(); |
|
809 |
|
|
810 |
File f = new File(getSource().getFiles()[0].getName()); |
|
811 |
RasterAdapter adapter = new RasterFileAdapter(f); |
|
812 |
com.hardcode.driverManager.Driver driver = LayerFactory.getDM().getDriver("gvSIG Image Driver"); |
|
813 |
adapter.setDriver(driver); |
|
814 |
|
|
815 |
clonedLayer.setName(getName()); |
|
816 |
clonedLayer.setVisible(isVisible()); |
|
817 |
clonedLayer.setSource(adapter); |
|
818 |
clonedLayer.setProjection(getProjection()); |
|
819 |
|
|
820 |
clonedLayer.setXMLEntity(getXMLEntity()); |
|
821 |
|
|
822 |
clonedLayer.load(); |
|
823 |
|
|
824 |
return clonedLayer; |
|
825 |
} |
|
763 | 826 |
} |
Also available in: Unified diff