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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImagePath.PathEntryrepresents an imagepath entry
-
Constructor Summary
Constructors Constructor Description ImagePath()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanadd(String mainPath)create a new PathEntry from the given path and add it to the end of the current image pathstatic booleanadd(String mainPath, String altPathOrFolder)create a new PathEntry from the path 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 booleanadd(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)static booleanaddJar(String fpJar, String fpImage)static URLappend(Object what)static URLappend(Object what, String folder)static URLappend(Object what, String folder, URL where)static URLappend(Object what, URL where)static URLcheck(String name)static voidclear()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 URLget(Object what)static URLget(Object what, String folder)protected static ImagePath.PathEntrygetBundle()static StringgetBundlePath()no trailing path separatorstatic List<ImagePath.PathEntry>getPaths()get the list of path entries (as PathEntry)static booleanhas(Object what)static booleanhas(Object what, String folder)static booleanhasBundlePath()static URLinsert(Object what)static URLinsert(Object what, String folder)static URLinsert(Object what, String folder, URL where)static URLinsert(Object what, URL where)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 URLremove(Object what)static URLremove(Object what, String folder)static booleanremove(String path)remove entry with given path (same as given with add)static booleanremove(String mainPath, String altPathOrFolder)static booleanremoveHTTP(String pathHTTP)static booleanremoveJar(String fpJar)static booleanremoveJar(String fpJar, String fpImage)static URLreplace(Object what, String folder, URL where)static URLreplace(Object what, URL where)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 path as bundle path (entry 0) Image cache is cleared completelystatic FilesetBundleFolder(File folder)static booleansetBundlePath(String newBundlePath)the given path replaces bundlepath (entry 0)
-
-
-
Method Detail
-
getPaths
public static List<ImagePath.PathEntry> getPaths()
get the list of path entries (as PathEntry)- Returns:
- pathentries
-
get
public static String[] 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
-
reset
public static boolean reset(String path)
empty path list and add path as bundle path (entry 0) Image cache is cleared completely- Parameters:
path- absolute path- Returns:
- true on success, false otherwise
-
clear
public static void clear()
-
add
public static boolean add(String mainPath)
create a new PathEntry from the given path and add it to the end of the current image path- Parameters:
mainPath- relative or absolute path- Returns:
- true if successful otherwise false
-
add
public static boolean add(String mainPath, String altPathOrFolder)
create a new PathEntry from the path 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 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...altPathOrFolder- alternative image folder, when not running from jar- Returns:
- true if successful otherwise false
-
remove
public static boolean remove(String path)
remove entry with given path (same as given with add)- Parameters:
path- relative or absolute path- Returns:
- true on success, false otherwise
-
addHTTP
public static boolean addHTTP(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)- Parameters:
pathHTTP- folder address like siteaddress or siteaddress/folder/subfolder (e.g. download.sikuli.de/images)- Returns:
- true if successful otherwise false
-
removeHTTP
public static boolean removeHTTP(String pathHTTP)
-
addJar
public static boolean addJar(String fpJar)
-
removeJar
public static boolean removeJar(String fpJar)
-
add
public static boolean add(URL pURL)
add entry to end of list (the given URL is not checked)- Parameters:
pURL- a valid URL (not checked)
-
has
public static boolean has(Object what)
-
hasBundlePath
public static boolean hasBundlePath()
-
setBundlePath
public static boolean setBundlePath(String newBundlePath)
the given path replaces bundlepath (entry 0)- Parameters:
newBundlePath- an absolute file path- Returns:
- true on success, false otherwise
-
getBundlePath
public static String getBundlePath()
no trailing path separator- Returns:
- the current bundle path
-
getBundle
protected static ImagePath.PathEntry getBundle()
-
find
public static URL find(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 existence- Parameters:
imageFileName- relative or absolute filename with extension- Returns:
- a valid URL or null if not found/exists
-
open
public static BufferedReader open(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 finished- Parameters:
fname- relative or absolute filename- Returns:
- the BufferedReader to be used or null if not possible
-
isImageBundled
public static boolean isImageBundled(URL fURL)
-
-