Class IOTools

java.lang.Object
org.openjump.core.apitools.IOTools

public class IOTools extends Object
  • Constructor Details

    • IOTools

      public IOTools()
  • Method Details

    • 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 file
      filename - 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 - JTable
      filename - output file name: C:\folder\file.csv
      cellseparator - 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 File
      outputDir - 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 file
      directory - Folder where the images are stored
      Returns:
      File
      Throws:
      ParserConfigurationException
      SAXException
      IOException
      TransformerException
    • 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 occurs
      SAXException
      IOException
      ParserConfigurationException
    • 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 load
      wcontext - WorkbenchContext
      extension - 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 save
      envelope - an Envelope
      file - 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 save
      envelope - an Envelope
      cellsizex - Double cell size in x direction
      cellsizey - Double cell size in y direction
      compression - Integer, see com.sun.media.jai.codec.TIFFEncodeParam
      nodata - Double nodata value
      file - 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