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.StringPATH_RESOURCESPath for resources.static java.lang.StringPATH_VIEWPath for views.static intUSE_DEFAULT_SIZESize for default size. -
Constructor Summary
Constructors Constructor Description Resources() -
Method Summary
Modifier and Type Method Description static java.lang.IntegergetDefaultWidth()Returns default width (Prefs.SIZE_BUTTONif none given).static java.lang.StringgetExternalURI(java.lang.String theFileName)Returns URI that holds in jars as well.static org.apache.logging.log4j.LoggergetLogger()Returns logger, asserts not null before returning class.static java.util.PropertiesgetProjectProperties()Loads project properties from resources.static java.lang.DoublegetScalingFactor()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 voidinit(java.lang.Class<? extends java.lang.Object> theProvider, org.apache.logging.log4j.Logger theLogger)Initializes class.static voidinit(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.StringloadFile(java.lang.String theFileName)Loads file from resources.static javafx.scene.image.ImageloadImage(java.lang.String theImagePath)Loads image from resources.static javafx.scene.image.ImageloadImage(java.lang.String theImagePath, int theWidth)Loads image from resources, setting width (=height).static javafx.scene.image.ImageloadImage(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.PropertiesloadProperties(java.lang.String theFileName)Loads properties from resources.static voidsetDefaultWidth(java.lang.Integer theDefaultWidth)Sets default image width.static voidsetScalingFactor(java.lang.Double theScalingFactor)Sets scaling factor.
-
Field Details
-
PATH_RESOURCES
public static final java.lang.String PATH_RESOURCESPath for resources.- See Also:
- Constant Field Values
-
PATH_VIEW
public static final java.lang.String PATH_VIEWPath for views.- See Also:
- Constant Field Values
-
USE_DEFAULT_SIZE
public static final int USE_DEFAULT_SIZESize for default size.- See Also:
- Constant Field Values
-
-
Constructor Details
-
Resources
public Resources()
-
-
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 classtheLogger- 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 classtheLogger- loggertheScalingFactor- scaling factortheDefaultWidth- 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_BUTTONif 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 paththeWidth- 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 paththeWidth- image widththeHeight- 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.IOExceptionReturns 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 paththeFileExtension- 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
-