Class Resources

java.lang.Object
de.edgesoft.edgeutils.files.Resources

public class Resources
extends java.lang.Object
Resources helper.

Legal stuff

Copyright 2010-2020 Ekkart Kleinod ekleinod@edgesoft.de

This file is part of edgeutils.

edgeutils is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

edgeutils is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with edgeutils. If not, see http://www.gnu.org/licenses/.

Since:
0.12.0
Author:
Ekkart Kleinod
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static java.lang.String PATH_RESOURCES
    Path for resources.
    static java.lang.String PATH_VIEW
    Path for views.
    static int USE_DEFAULT_SIZE
    Size for default size.
  • Constructor Summary

    Constructors 
    Constructor Description
    Resources()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.Integer getDefaultWidth()
    Returns default width (Prefs.SIZE_BUTTON if none given).
    static java.lang.String getExternalURI​(java.lang.String theFileName)
    Returns URI that holds in jars as well.
    static org.apache.logging.log4j.Logger getLogger()
    Returns logger, asserts not null before returning class.
    static java.util.Properties getProjectProperties()
    Loads project properties from resources.
    static java.lang.Double getScalingFactor()
    Returns scaling factor (1 if none given).
    static java.util.List<java.lang.String> getSortedFileList​(java.lang.String theResourcePath, java.lang.String theFileExtension)
    Returns filelist of resource path, either from file system or from jar.
    static void init​(java.lang.Class<? extends java.lang.Object> theProvider, org.apache.logging.log4j.Logger theLogger)
    Initializes class.
    static void init​(java.lang.Class<? extends java.lang.Object> theProvider, org.apache.logging.log4j.Logger theLogger, java.lang.Double theScalingFactor, java.lang.Integer theDefaultWidth)
    Initializes class.
    static java.lang.String loadFile​(java.lang.String theFileName)
    Loads file from resources.
    static javafx.scene.image.Image loadImage​(java.lang.String theImagePath)
    Loads image from resources.
    static javafx.scene.image.Image loadImage​(java.lang.String theImagePath, int theWidth)
    Loads image from resources, setting width (=height).
    static javafx.scene.image.Image loadImage​(java.lang.String theImagePath, int theWidth, int theHeight)
    Loads image from resources, setting width and height.
    static java.util.Map.Entry<javafx.scene.Parent,​javafx.fxml.FXMLLoader> loadNode​(java.lang.String theParentName)
    Loads fxml parent from resources.
    static java.util.Properties loadProperties​(java.lang.String theFileName)
    Loads properties from resources.
    static void setDefaultWidth​(java.lang.Integer theDefaultWidth)
    Sets default image width.
    static void setScalingFactor​(java.lang.Double theScalingFactor)
    Sets scaling factor.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • init

      public static void init​(java.lang.Class<? extends java.lang.Object> theProvider, org.apache.logging.log4j.Logger theLogger)
      Initializes class.
      Parameters:
      theProvider - providing class
      theLogger - logger
    • init

      public static void init​(java.lang.Class<? extends java.lang.Object> theProvider, org.apache.logging.log4j.Logger theLogger, java.lang.Double theScalingFactor, java.lang.Integer theDefaultWidth)
      Initializes class.
      Parameters:
      theProvider - providing class
      theLogger - logger
      theScalingFactor - scaling factor
      theDefaultWidth - default width
    • setScalingFactor

      public static void setScalingFactor​(java.lang.Double theScalingFactor)
      Sets scaling factor.
      Parameters:
      theScalingFactor - scaling factor
    • setDefaultWidth

      public static void setDefaultWidth​(java.lang.Integer theDefaultWidth)
      Sets default image width.
      Parameters:
      theDefaultWidth - default width
    • getScalingFactor

      public static java.lang.Double getScalingFactor()
      Returns scaling factor (1 if none given).
      Returns:
      scaling factor
    • getDefaultWidth

      public static java.lang.Integer getDefaultWidth()
      Returns default width (Prefs.SIZE_BUTTON if none given).
      Returns:
      default width
    • getLogger

      public static org.apache.logging.log4j.Logger getLogger()
      Returns logger, asserts not null before returning class.
      Returns:
      logger
    • loadImage

      public static javafx.scene.image.Image loadImage​(java.lang.String theImagePath)
      Loads image from resources.
      Parameters:
      theImagePath - image path
      Returns:
      loaded image
    • loadImage

      public static javafx.scene.image.Image loadImage​(java.lang.String theImagePath, int theWidth)
      Loads image from resources, setting width (=height).
      Parameters:
      theImagePath - image path
      theWidth - image width (=height)
      Returns:
      loaded image (null if an error occurred)
    • loadImage

      public static javafx.scene.image.Image loadImage​(java.lang.String theImagePath, int theWidth, int theHeight)
      Loads image from resources, setting width and height.
      Parameters:
      theImagePath - image path
      theWidth - image width
      theHeight - image height
      Returns:
      loaded image (null if an error occurred)
    • loadNode

      public static java.util.Map.Entry<javafx.scene.Parent,​javafx.fxml.FXMLLoader> loadNode​(java.lang.String theParentName)
      Loads fxml parent from resources.
      Parameters:
      theParentName - parent file name
      Returns:
      loaded parent
    • loadFile

      public static java.lang.String loadFile​(java.lang.String theFileName)
      Loads file from resources.
      Parameters:
      theFileName - file name
      Returns:
      loaded file as string
    • getProjectProperties

      public static java.util.Properties getProjectProperties()
      Loads project properties from resources.
      Returns:
      project properties
    • loadProperties

      public static java.util.Properties loadProperties​(java.lang.String theFileName)
      Loads properties from resources.
      Parameters:
      theFileName - pane name
      Returns:
      loaded file as properties
    • getExternalURI

      public static java.lang.String getExternalURI​(java.lang.String theFileName)
      Returns URI that holds in jars as well.
      Parameters:
      theFileName - file name
      Returns:
      URI in usable form
    • getSortedFileList

      public static java.util.List<java.lang.String> getSortedFileList​(java.lang.String theResourcePath, java.lang.String theFileExtension) throws java.io.IOException
      Returns filelist of resource path, either from file system or from jar. This is unexpectedly difficult, I used: http://www.uofr.net/~greg/java/get-resource-listing.html
      Parameters:
      theResourcePath - resource path
      theFileExtension - file extension to filter the files for (null for all files)
      Returns:
      list of filenames in path
      Throws:
      java.io.IOException - if an error occurred
      Since:
      0.13.0