Package org.sikuli.script
Class ImagePath
java.lang.Object
org.sikuli.script.ImagePath
public class ImagePath extends Object
maintain the path list of locations, where images will be searched.
the first entry always is the bundlepath used on the scripting level
Python import automatically adds a sikuli bundle here
supported locations:
- absolute filesystem paths
- inside jars relative to root level given by a class found on classpath
- a location in the web given as string starting with http[s]://
- any location as a valid URL, from where image files can be loaded
the first entry always is the bundlepath used on the scripting level
Python import automatically adds a sikuli bundle here
supported locations:
- absolute filesystem paths
- inside jars relative to root level given by a class found on classpath
- a location in the web given as string starting with http[s]://
- any location as a valid URL, from where image files can be loaded
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImagePath.PathEntryrepresents an imagepath entry -
Constructor Summary
Constructors Constructor Description ImagePath() -
Method Summary
Modifier and Type Method Description static booleanadd(String mainPath)create a new PathEntry from the given absolute path name and add it to the end of the current image path
for usage with jars see;add(String, String)static booleanadd(String mainPath, String altPath)create a new PathEntry from the given absolute path name and add it to the end of the current image path
for images stored in jars:
Set the primary image path to the top folder level of a jar based on the given class name (must be found on class path).static voidadd(URL pURL)add entry to end of list (the given URL is not checked)static booleanaddHTTP(String pathHTTP)create a new PathEntry from the given net resource folder accessible via HTTP at end of the current image path
BE AWARE:
Files stored in the given remote folder must allow HTTP HEAD-requests (checked)
redirections are not followed (suppressed)static booleanaddJar(String fpJar, String fpImage)static voiddump(int lvl)print the list of path entriesstatic URLfind(String imageFileName)try to find the given relative image file name on the image path
starting from entry 0, the first found existence is taken
absolute file names are checked for existencestatic String[]get()the path list as string arraystatic StringgetBundlePath()no trailing path separatorstatic List<ImagePath.PathEntry>getPaths()get the list of path entries (as PathEntry)static booleanhasBundlePath()static booleanisImageBundled(URL fURL)static BufferedReaderopen(String fname)given absolute or relative (searched on image path) file name
is tried to open as a BufferedReader
BE AWARE: use br.close() when finishedstatic booleanremove(File directory)remove entry with given path (same as given with add)static booleanremove(String path)remove entry with given path (same as given with add)static booleanremoveHTTP(String pathHTTP)static voidreset()empty path list and keep bundlePath (entry 0)
Image cache is cleared completely convenience for the scripting levelstatic booleanreset(String path)empty path list and add given path as first entry Image cache is cleared completelystatic FilesetBundleFolder(File folder)static booleansetBundlePath(String newBundlePath)the given path replaces bundlepath (entry 0)
-
Constructor Details
-
ImagePath
public ImagePath()
-
-
Method Details
-
getPaths
get the list of path entries (as PathEntry)- Returns:
- pathentries
-
get
the path list as string array- Returns:
- an array of the file path's currently in the path list
-
dump
public static void dump(int lvl)print the list of path entries- Parameters:
lvl- debug level to use
-
reset
public static void reset()empty path list and keep bundlePath (entry 0)
Image cache is cleared completely convenience for the scripting level -
add
create a new PathEntry from the given absolute path name and add it to the end of the current image path
for usage with jars see;add(String, String)- Parameters:
mainPath- relative or absolute path- Returns:
- true if successful otherwise false
-
addHTTP
create a new PathEntry from the given net resource folder accessible via HTTP at end of the current image path
BE AWARE:
Files stored in the given remote folder must allow HTTP HEAD-requests (checked)
redirections are not followed (suppressed)- Parameters:
pathHTTP- folder address like siteaddress or siteaddress/folder/subfolder (e.g. download.sikuli.de/images)- Returns:
- true if successful otherwise false
-
removeHTTP
-
add
create a new PathEntry from the given absolute path name and add it to the end of the current image path
for images stored in jars:
Set the primary image path to the top folder level of a jar based on the given class name (must be found on class path). When not running from a jar (e.g. running in some IDE) the path will be the path to the compiled classes (for Maven based projects this is target/classes that contains all stuff copied from src/run/resources automatically)
For situations, where the images cannot be found automatically in the non-jar situation, you might give an alternative path either absolute or relative to the working folder.- Parameters:
mainPath- absolute path name or a valid classname optionally followed by /subfolder...altPath- alternative image folder, when not running from jar- Returns:
- true if successful otherwise false
-
addJar
-
add
add entry to end of list (the given URL is not checked)- Parameters:
pURL- a valid URL (not checked)
-
remove
remove entry with given path (same as given with add)- Parameters:
path- relative or absolute path- Returns:
- true on success, false otherwise
-
remove
remove entry with given path (same as given with add)- Parameters:
directory- relative or absolute path as File- Returns:
- true on success, false otherwise
-
hasBundlePath
public static boolean hasBundlePath() -
reset
empty path list and add given path as first entry Image cache is cleared completely- Parameters:
path- absolute path- Returns:
- true on success, false otherwise
-
setBundlePath
the given path replaces bundlepath (entry 0)- Parameters:
newBundlePath- an absolute file path- Returns:
- true on success, false otherwise
-
setBundleFolder
-
getBundlePath
no trailing path separator- Returns:
- the current bundle path
-
find
try to find the given relative image file name on the image path
starting from entry 0, the first found existence is taken
absolute file names are checked for existence- Parameters:
imageFileName- relative or absolute filename- Returns:
- a valid URL or null if not found/exists
-
open
given absolute or relative (searched on image path) file name
is tried to open as a BufferedReader
BE AWARE: use br.close() when finished- Parameters:
fname- relative or absolute filename- Returns:
- the BufferedReader to be used or null if not possible
-
isImageBundled
-