Revision 864 org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.fmap/src/main/java/org/gvsig/raster/fmap/layers/DefaultFLyrRaster.java
DefaultFLyrRaster.java | ||
---|---|---|
830 | 830 |
return data; |
831 | 831 |
} |
832 | 832 |
|
833 |
// /* |
|
834 |
// * (non-Javadoc) |
|
835 |
// * @see com.iver.cit.gvsig.fmap.layers.layerOperations.InfoByPoint#getInfo(java.awt.Point, double, com.iver.utiles.swing.threads.Cancellable) |
|
836 |
// */ |
|
837 |
// public XMLItem[] getInfo(Point p, double tolerance, Cancellable cancel) |
|
838 |
// throws ReadException { |
|
839 |
// if (!isOpen()) { |
|
840 |
// StringXMLItem[] item = new StringXMLItem[1]; |
|
841 |
// String data = "<file:" + normalizeAsXMLTag(getName()) + ">\n"; |
|
842 |
// data += " <raster\n" + " Layer=\" Not available\"\n" + " />\n"; |
|
843 |
// data += "</file:" + normalizeAsXMLTag(getName()) + ">\n"; |
|
844 |
// item[0] = new StringXMLItem(data, this); |
|
845 |
// return item; |
|
846 |
// } |
|
847 |
// |
|
848 |
// Point2D pReal = getMapContext().getViewPort().toMapPoint(p); |
|
849 |
// Point2D px = new Point2D.Double(); |
|
850 |
// if( pReal.getX() > this.getMinX() && |
|
851 |
// pReal.getX() < this.getMaxX() && |
|
852 |
// pReal.getY() > this.getMinY() && |
|
853 |
// pReal.getY() < this.getMaxY()) |
|
854 |
// try { |
|
855 |
// px = transformPoint(0, pReal); |
|
856 |
// } catch (NoninvertibleTransformException e) { |
|
857 |
// throw new ReadException("Error in the transformation", e); |
|
858 |
// } |
|
859 |
// int[] rgb = getPixel((int) p.getX(), (int) p.getY()); |
|
860 |
// ColorConversion conv = new ColorConversion(); |
|
861 |
// |
|
862 |
// StringXMLItem[] item = new StringXMLItem[1]; |
|
863 |
// String data = "<file:" + normalizeAsXMLTag(getName()) + ">\n"; |
|
864 |
// |
|
865 |
// data += " <raster\n"; |
|
866 |
// data += " View_Point=\"" + p.getX() + " , " + p.getY() + "\"\n"; |
|
867 |
// data += " World_Point=\"" + MathUtils.format(pReal.getX(), 3) + " , " + MathUtils.format(pReal.getY(), 3) + "\"\n"; |
|
868 |
// if (px == null) |
|
869 |
// data += " Pixel_Point=\"Out\"\n"; |
|
870 |
// else |
|
871 |
// data += " Pixel_Point=\"" + (int) px.getX() + " , " + (int) px.getY() + "\"\n"; |
|
872 |
// data += " RGB=\"" + rgb[1] + " " + rgb[2] + " " + rgb[3] + "\"\n"; |
|
873 |
// double[] cmyk = conv.RGBtoCMYK(rgb[1] & 0xff, rgb[2] & 0xff, rgb[3] & 0xff, 1D); |
|
874 |
// data += " CMYK=\"" + MathUtils.format(cmyk[0], 4) + ", " + MathUtils.format(cmyk[1], 4) + ", " + MathUtils.format(cmyk[2], 4) + "," + MathUtils.format(cmyk[3], 4) + "\"\n"; |
|
875 |
// double[] hsl = conv.RGBtoHSL(rgb[1] & 0xff, rgb[2] & 0xff, rgb[3] & 0xff); |
|
876 |
// hsl[0] = (int)(255.0 * hsl[0] / 360.0 + 0.5); |
|
877 |
// hsl[2] = (int) (hsl[2] * 255. + 0.5); |
|
878 |
// hsl[1] = (int) (hsl[1] * 255. + 0.5); |
|
879 |
// data += " HSL=\"" + MathUtils.format(hsl[0], 4) + ", " + MathUtils.format(hsl[1], 4) + ", " + MathUtils.format(hsl[2], 4) + "\"\n"; |
|
880 |
// data += " Band_Value=\""; |
|
881 |
// try { |
|
882 |
// if (px != null) { |
|
883 |
// if(getDataType()[0] >= 0 && getDataType()[0] <= 3) |
|
884 |
// for(int i = 0; i < getBandCount(); i++) |
|
885 |
// if(getDataSource().isInside(pReal)) { |
|
886 |
// Point2D pxAux = transformPoint(i, pReal); |
|
887 |
// data += ((Integer)getDataSource().getData((int)pxAux.getX(), (int)pxAux.getY(), i)).intValue() + " "; |
|
888 |
// } |
|
889 |
// if(getDataType()[0] == 4) |
|
890 |
// for(int i = 0; i < getBandCount(); i++) |
|
891 |
// if(getDataSource().isInside(pReal)) { |
|
892 |
// Point2D pxAux = transformPoint(i, pReal); |
|
893 |
// data += ((Float)getDataSource().getData((int)pxAux.getX(), (int)pxAux.getY(), i)).floatValue() + " "; |
|
894 |
// } |
|
895 |
// if(getDataType()[0] == 5) |
|
896 |
// for(int i = 0; i < getBandCount(); i++) |
|
897 |
// if(getDataSource().isInside(pReal)) { |
|
898 |
// Point2D pxAux = transformPoint(i, pReal); |
|
899 |
// data += ((Double)getDataSource().getData((int)pxAux.getX(), (int)pxAux.getY(), i)).doubleValue() + " "; |
|
900 |
// } |
|
901 |
// } |
|
902 |
// } catch (RasterDriverException ex) { |
|
903 |
// throw new ReadException("Error en el acceso al dataset", ex); |
|
904 |
// } catch (InvalidSetViewException ex) { |
|
905 |
// throw new ReadException( |
|
906 |
// "Error en la asignaci?n de la vista en getData", ex); |
|
907 |
// } catch (FileNotOpenException ex) { |
|
908 |
// throw new ReadException("Fichero no abierto en el dataset", ex); |
|
909 |
// } catch (NoninvertibleTransformException ex) { |
|
910 |
// throw new ReadException("Error in the transformation", ex); |
|
911 |
// } |
|
912 |
// data += "\"\n"; |
|
913 |
// data += " />\n"; |
|
914 |
// data += "</file:" + normalizeAsXMLTag(getName()) + ">\n"; |
|
915 |
// |
|
916 |
// item[0] = new StringXMLItem(data, this); |
|
917 |
// return item; |
|
918 |
// } |
|
919 |
|
|
920 | 833 |
/** |
921 | 834 |
* Filters a string for being suitable as XML Tag, erasing |
922 | 835 |
* all not alphabetic or numeric characters. |
... | ... | |
947 | 860 |
return attr; |
948 | 861 |
} |
949 | 862 |
|
950 |
/** |
|
951 |
* Escribe en el proyecto la capa actual |
|
952 |
* @throws XMLException |
|
953 |
* @see com.iver.cit.gvsig.fmap.layers.FLayer#getProperties() |
|
954 |
*/ |
|
955 |
public XMLEntity getXMLEntity() throws XMLException { |
|
956 |
if(isClosed() || isAwake()) |
|
957 |
return null; |
|
958 | 863 |
|
959 |
// XMLEntity xml = super.getXMLEntity(); |
|
960 |
// if(getFile() != null) |
|
961 |
// xml.putProperty("file", getFile()); |
|
962 |
// xml.putProperty("driverName", "gvSIG Raster Driver"); |
|
963 |
// |
|
964 |
// // Si no hay ning?n Status aplicamos el StatusLayerRaster que se usa por defecto |
|
965 |
// if (status == null) |
|
966 |
// status = new StatusLayerRaster(); |
|
967 |
// status.getXMLEntity(xml, true, this); |
|
968 |
// |
|
969 |
// return xml; |
|
970 |
return null; |
|
971 |
} |
|
972 |
|
|
973 |
/** |
|
974 |
* Recupera de disco los datos de la capa. |
|
975 |
*/ |
|
976 |
public void setXMLEntity(XMLEntity xml) throws XMLException { |
|
977 |
// for (int i = 0; i < xml.getPropertyCount(); i++) { |
|
978 |
// String key = xml.getPropertyName(i); |
|
979 |
// if(key.startsWith("raster.file")) { |
|
980 |
// if(xml.getPropertyValue(i).startsWith(RasterLibrary.getTemporalPath())) |
|
981 |
// throw new XMLLayerException("Trying to load temporary layer", null); |
|
982 |
// } |
|
983 |
// } |
|
984 |
// super.setXMLEntity(xml); |
|
985 |
// |
|
986 |
// try { |
|
987 |
// params = new File(xml.getStringProperty("file")); |
|
988 |
// |
|
989 |
// if(params != null && getName() != null && getName().compareTo("") != 0) |
|
990 |
// try { |
|
991 |
// enableAwake(); |
|
992 |
// } catch (NotAvailableStateException e) { |
|
993 |
// RasterToolsUtil.messageBoxError("Fallo el estado de open. Closed=" + isClosed() + " Active=" + isOpen(), this, e); |
|
994 |
// } |
|
995 |
// if(!super.getFLayerStatus().visible) |
|
996 |
// enableStopped(); |
|
997 |
// |
|
998 |
// // Para notificar al adapter-driver cual es la proyecci?n. |
|
999 |
// setProjection(super.getProjection()); |
|
1000 |
// |
|
1001 |
// //Inicializamos la clase a la que se usa por defecto para |
|
1002 |
// //compatibilidad con proyectos antiguos |
|
1003 |
// String claseStr = StatusLayerRaster.defaultClass; |
|
1004 |
// if (xml.contains("raster.class")) |
|
1005 |
// claseStr = xml.getStringProperty("raster.class"); |
|
1006 |
// |
|
1007 |
// if (status != null) |
|
1008 |
// status.setXMLEntity(xml, this); |
|
1009 |
// else if (claseStr != null && !claseStr.equals("")) |
|
1010 |
// try { |
|
1011 |
// // Class clase = |
|
1012 |
// // LayerFactory.getLayerClassForLayerClassName(claseStr); |
|
1013 |
// Class clase = this.getClass(); |
|
1014 |
// Constructor constr = clase.getConstructor(null); |
|
1015 |
// status = (IStatusRaster) constr.newInstance(null); |
|
1016 |
// if (status != null) { |
|
1017 |
// ((StatusLayerRaster)status).setNameClass(claseStr); |
|
1018 |
// status.setXMLEntity(xml, this); |
|
1019 |
// filterArguments = status.getFilterArguments(); |
|
1020 |
// |
|
1021 |
// //Creamos la tabla de color |
|
1022 |
// ArrayList color = (ArrayList) filterArguments.clone(); |
|
1023 |
// loadedFromProject = ColorTableListManager.createColorTableFromArray(color); |
|
1024 |
// } |
|
1025 |
// // } catch (ClassNotFoundException exc) { |
|
1026 |
// // throw new XMLLayerException("", exc); |
|
1027 |
// } catch (InstantiationException exc) { |
|
1028 |
// throw new XMLLayerException("", exc); |
|
1029 |
// } catch (IllegalAccessException exc) { |
|
1030 |
// throw new XMLLayerException("", exc); |
|
1031 |
// } catch (NoSuchMethodException exc) { |
|
1032 |
// throw new XMLLayerException("", exc); |
|
1033 |
// } catch (InvocationTargetException exc) { |
|
1034 |
// throw new XMLLayerException("", exc); |
|
1035 |
// } |
|
1036 |
// firstLoad = true; |
|
1037 |
// } catch (NotExistInXMLEntity e) { |
|
1038 |
// |
|
1039 |
// } |
|
1040 |
} |
|
1041 |
|
|
1042 | 864 |
/* (non-Javadoc) |
1043 | 865 |
* @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) |
1044 | 866 |
*/ |
Also available in: Unified diff