Package org.openjump.core.apitools
Class IOTools
- java.lang.Object
-
- org.openjump.core.apitools.IOTools
-
public class IOTools extends Object
-
-
Constructor Summary
Constructors Constructor Description IOTools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static StringconvertPathToSystemIndependentPath(String oldPath)Converts a system-dependent path into an independent onestatic voidcopyFileToFolder(File inputFile, String outputDir)Simple method to copy a file to a folderstatic FeatureCollectionload(String filename)static FeatureCollectionload(String filename, String zipFileName)static FeatureCollectionloaddBaseFile(String sFilename)static FeatureCollectionloadFMEGML(String filename)static voidloadImageAsLayer(File file, WorkbenchContext wcontext, String extension)Load an image file as ReferenceImageLayer.class defining its extensionstatic FeatureCollectionloadJMLFile(String filename)static FeatureCollectionloadShapefile(String filename)static FeatureCollectionloadShapefile(String filename, String zipFileName)static voidloadSimbology_Jump(File file, Layer layer)Method to load an OpenJUMP symbology file (xml jump) into a layerstatic voidloadSimbology_SLD(File file, PlugInContext context)Method to load a style file ( SLD - Spatial layer descriptor) into a layerstatic FeatureCollectionloadWKT(String filename)static voidprint(FeatureCollection fc)static FilerecompileXMLFile(File file, String directory)This method will recompile the XML file according to location (folder) of the image symbology files used by Load JUMP Symbology methodstatic voidsave(FeatureCollection fc, String filename)static voidsaveCSV(JTable table, String filename)Export jtable to csv file using commas as separatorsstatic voidsaveCSV(JTable table, String filename, String cellseparator)Export jtable to csv file using a cell separatorstatic voidsavedBaseFile(FeatureCollection featureCollection, String fname, Charset charset)static voidsaveDbfFile(FeatureCollection fc, String filename)static voidsaveGeoTIFF(BufferedImage image, org.locationtech.jts.geom.Envelope envelope, double cellsizex, double cellsizey, int compression, double nodata, File file)Save a given BufferedImage and envelope to GeoTIFF file, giving nodata value, x and y values of cell size and compsessionstatic voidsaveGeoTIFF(BufferedImage image, org.locationtech.jts.geom.Envelope envelope, File file)Save a BufferedImage and envelope to GeoTIFF file.static voidsaveJMLFile(FeatureCollection fc, String filename)static voidsaveJMLFile(Layer layer, String filename)static voidsaveShapefile(FeatureCollection fc, String filename)static voidsaveShapefile(Layer layer, String filename)static voidsaveSimbology_Jump(File file, Layer layer)Method to save Openjump symbology of a layer to a XML filestatic voidsaveSimbology_SLD(File file, Layer layer)Method to save the style of a layer as SLD (Spatial layer descriptor) filestatic voidsaveSimbology_SLD2(File file, Layer layer)static voidsaveStyleToFile(Layer layer, String path)
-
-
-
Method Detail
-
load
public static FeatureCollection load(String filename) throws Exception
- Throws:
Exception
-
load
public static FeatureCollection load(String filename, String zipFileName) throws Exception
- Throws:
Exception
-
loadJMLFile
public static FeatureCollection loadJMLFile(String filename) throws Exception
- Throws:
Exception
-
loadShapefile
public static FeatureCollection loadShapefile(String filename) throws Exception
- Throws:
Exception
-
loadShapefile
public static FeatureCollection loadShapefile(String filename, String zipFileName) throws Exception
- Throws:
Exception
-
loadFMEGML
public static FeatureCollection loadFMEGML(String filename) throws Exception
- Throws:
Exception
-
loadWKT
public static FeatureCollection loadWKT(String filename) throws Exception
- Throws:
Exception
-
save
public static void save(FeatureCollection fc, String filename) throws Exception
- Throws:
Exception
-
saveShapefile
public static void saveShapefile(FeatureCollection fc, String filename) throws Exception
- Throws:
Exception
-
saveJMLFile
public static void saveJMLFile(FeatureCollection fc, String filename) throws Exception
- Throws:
Exception
-
saveDbfFile
public static void saveDbfFile(FeatureCollection fc, String filename) throws Exception
- Throws:
Exception
-
saveCSV
public static void saveCSV(JTable table, String filename) throws Exception
Export jtable to csv file using commas as separators- Parameters:
table- the JTable containing the data to save to CSV filefilename- the target file name- Throws:
Exception- if an Exception occurs
-
saveCSV
public static void saveCSV(JTable table, String filename, String cellseparator) throws Exception
Export jtable to csv file using a cell separator- Parameters:
table- JTablefilename- output file name: C:\folder\file.csvcellseparator- cell break to separate values: "," ";" tab etc- Throws:
Exception- if an Exception occurs
-
saveShapefile
public static void saveShapefile(Layer layer, String filename) throws Exception
- Throws:
Exception
-
saveJMLFile
public static void saveJMLFile(Layer layer, String filename) throws Exception
- Throws:
Exception
-
saveStyleToFile
public static void saveStyleToFile(Layer layer, String path) throws Exception
- Throws:
Exception
-
print
public static void print(FeatureCollection fc)
-
saveSimbology_Jump
public static void saveSimbology_Jump(File file, Layer layer) throws Exception
Method to save Openjump symbology of a layer to a XML file- Parameters:
file- file to save (ex. file.style.xml)layer- source layer- Throws:
Exception- if an Exception occurs
-
copyFileToFolder
public static void copyFileToFolder(File inputFile, String outputDir) throws IOException
Simple method to copy a file to a folder- Parameters:
inputFile- input FileoutputDir- output directory- Throws:
IOException- if an IOException occurs
-
convertPathToSystemIndependentPath
public static String convertPathToSystemIndependentPath(String oldPath)
Converts a system-dependent path into an independent one- Parameters:
oldPath- the old path- Returns:
- the new path
-
recompileXMLFile
public static File recompileXMLFile(File file, String directory) throws ParserConfigurationException, SAXException, IOException, TransformerException
This method will recompile the XML file according to location (folder) of the image symbology files used by Load JUMP Symbology method- Parameters:
file- XML filedirectory- Folder where the images are stored- Returns:
- File
- Throws:
ParserConfigurationExceptionSAXExceptionIOExceptionTransformerException
-
loadSimbology_Jump
public static void loadSimbology_Jump(File file, Layer layer) throws Exception
Method to load an OpenJUMP symbology file (xml jump) into a layer- Parameters:
file- file to load (ex. file.style.xml)layer- target layer- Throws:
Exception- if an Exception occurs
-
loadSimbology_SLD
public static void loadSimbology_SLD(File file, PlugInContext context) throws SAXException, IOException, ParserConfigurationException
Method to load a style file ( SLD - Spatial layer descriptor) into a layer- Parameters:
file- file to load (ex. file.sld)context- plugin context- Throws:
Exception- if an Exception occursSAXExceptionIOExceptionParserConfigurationException
-
saveSimbology_SLD
public static void saveSimbology_SLD(File file, Layer layer) throws Exception
Method to save the style of a layer as SLD (Spatial layer descriptor) file- Parameters:
file- file to save (ex. file.style.sld)layer- source layer- Throws:
Exception- if an Exception occurs
-
saveSimbology_SLD2
public static void saveSimbology_SLD2(File file, Layer layer) throws Exception
- Throws:
Exception
-
loadImageAsLayer
public static void loadImageAsLayer(File file, WorkbenchContext wcontext, String extension) throws Exception
Load an image file as ReferenceImageLayer.class defining its extension- Parameters:
file- File to loadwcontext- WorkbenchContextextension- extension of the file, eg. "tif"- Throws:
Exception- if an Exception occurs
-
saveGeoTIFF
public static void saveGeoTIFF(BufferedImage image, org.locationtech.jts.geom.Envelope envelope, File file) throws IOException
Save a BufferedImage and envelope to GeoTIFF file. cellsize is calculate from parameters (raster and envelope) nodata is set to SAGA standard value (-99999.00) compression is set to packbits- Parameters:
image- BufferedImage to saveenvelope- an Envelopefile- output file- Throws:
IOException- if an IOException occurs
-
saveGeoTIFF
public static void saveGeoTIFF(BufferedImage image, org.locationtech.jts.geom.Envelope envelope, double cellsizex, double cellsizey, int compression, double nodata, File file)
Save a given BufferedImage and envelope to GeoTIFF file, giving nodata value, x and y values of cell size and compsession- Parameters:
image- BufferedImage to saveenvelope- an Envelopecellsizex- Double cell size in x directioncellsizey- Double cell size in y directionnodata- Double nodata valuecompression- Integer, see com.sun.media.jai.codec.TIFFEncodeParamfile- output file- Throws:
IOException- if an IOException occurs
-
loaddBaseFile
public static FeatureCollection loaddBaseFile(String sFilename)
-
savedBaseFile
public static void savedBaseFile(FeatureCollection featureCollection, String fname, Charset charset) throws Exception
- Throws:
Exception
-
-