public final class FSLoader extends Loader
Loader.ImageLoadingLock
Modifier and Type | Field and Description |
---|---|
static Pattern |
ABS_PATH |
static ScheduledExecutorService |
autosaver |
static String[] |
MIPMAP_FORMATS |
static int |
MIPMAP_JPEG |
static int |
MIPMAP_PNG |
static int |
MIPMAP_RAG |
static int |
MIPMAP_RAW |
static int |
MIPMAP_TIFF |
static ExecutorService |
repainter |
AREA_DOWNSAMPLING, changes, db_lock, DEFAULT_MIPMAPS_MODE, ERROR_PATH_NOT_FOUND, GAUSSIAN, GRAY_LUT, hs_unloadable, mawts, MAX_RETRIES, MIN_FREE_BYTES, MIPMAP_MODES, mipmaps_regen, NOT_FOUND, opener, PREPROCESSED, REGENERATING, RUNTIME, v_loaders
Constructor and Description |
---|
FSLoader()
Used to open a project from an existing XML file.
|
FSLoader(String storage_folder)
Used to create a new project, NOT from an XML file.
|
Modifier and Type | Method and Description |
---|---|
void |
addedPatchFrom(String path,
Patch patch)
All backslashes are converted to slashes to avoid havoc in MSWindows.
|
boolean |
addToDatabase(DBObject ob) |
static String |
asSafePath(String name)
Takes a String and returns a copy with the following conversions: / to -, space to _, and \ to -.
|
boolean |
checkMipMapFileExists(Patch p,
double magnification)
Checks if the mipmap file for the Patch and closest upper level to the desired magnification exists.
|
boolean |
clearIntensityMap(Patch p)
Clear the intensity map coefficients for a patch.
|
static String |
createIdPath(String sid,
String filename,
String ext)
For sid=12345 creates 12/34/5.${filename}.jpg
Will be fine with other filename-valid chars in sid.
|
static String |
createMipMapRelPath(Patch p,
String ext)
For Patch id=12345 creates 12/34/5.${filename}.jpg
|
boolean |
deleteStaleFiles(boolean coordinate_transforms,
boolean alpha_masks)
Delete stale files under the
unuid folder. |
void |
destroy()
Release all memory and unregister itself.
|
long |
estimateImageFileSize(Patch p,
int level)
Compute the number of bytes that the ImagePlus of a Patch will take.
|
Area |
fetchArea(long area_list_id,
long layer_id)
Loaded in full from XML file
|
ArrayList<?> |
fetchBallPoints(long id)
Loaded in full from XML file
|
double[][][] |
fetchBezierArrays(long id)
Loaded in full from XML file
|
MipMapImage |
fetchDataImage(Patch p,
double mag)
Waits until a proper image of the desired size or larger can be returned, which is never the Loader.REGENERATING image.
|
Object |
fetchImage(Patch p,
int format)
So far accepts Layer.IMAGEPLUS and Layer.IMAGEPROCESSOR as format.
|
ij.process.ByteProcessor |
fetchImageMask(Patch p)
Returns the alpha mask image from a file, or null if none stored.
|
ij.ImagePlus |
fetchImagePlus(Patch p) |
ij.ImagePlus |
fetchImagePlus(Stack stack) |
ij.process.ImageProcessor |
fetchImageProcessor(Patch p)
Fetch the ImageProcessor in a synchronized manner, so that there are no conflicts in retrieving the ImageProcessor for a specific stack slice, for example.
|
Object[] |
fetchLabel(DLabel label)
Loaded in full from XML file
|
MipMapImage |
fetchMipMap(Patch patch,
int level,
long n_bytes)
Does the actual fetching of the file.
|
protected MipMapImage |
fetchMipMapAWT(Patch patch,
int level,
long n_bytes)
Loads the file containing the scaled image corresponding to the given level
(or the maximum possible level, if too large)
and returns it as an awt.Image, or null if not found.
|
ij.ImagePlus |
fetchOriginal(Patch patch)
Loads and returns the original image, which is not cached, or returns null if it's not different than the working image.
|
ArrayList<?> |
fetchPipePoints(long id)
Loaded in full from XML file
|
boolean |
fixStorageFolders()
Convert old-style storage folders to new style.
|
void |
flushMipMaps(boolean forget_dir_mipmaps)
Remove all mipmap images from the cache, and optionally set the dir_mipmaps to null.
|
void |
flushMipMaps(long id)
Remove from the cache all images of level larger than zero corresponding to the given patch id.
|
Bureaucrat |
generateMipMaps(Collection<Displayable> patches,
boolean overwrite)
Generate image pyramids and store them into files under the dir_mipmaps for each Patch object in the Project.
|
protected boolean |
generateMipMaps(Patch patch)
Given an image and its source file name (without directory prepended), generate
a pyramid of images until reaching an image not smaller than 32x32 pixels.
|
String |
getAbsolutePath(Patch patch)
With slice info appended at the end; only if it exists, otherwise null.
|
String |
getAbsolutePath(String path)
Return an absolute path made from path: if it's already absolute, retursn itself; otherwise, the parent folder of all relative paths of this Loader is prepended.
|
int |
getClosestMipMapLevel(Patch patch,
int level,
int max_level)
Return the closest level to
level that exists as a file. |
String |
getCoordinateTransformsFolder()
Returns null unless overriden.
|
String |
getImageFilePath(Patch p)
Returns null unless overriden.
|
String |
getImageStorageFolder()
Returns a folder proven to be writable for images can be stored into.
|
String |
getMasksFolder()
Returns null unless override.
|
int |
getMipMapFormat()
|
String |
getMipMapsFolder()
Returns the path to the directory hosting the file image pyramids.
|
long |
getNextBlobId()
Get the next unique id to be used for the
Patch 's CoordinateTransform or alpha mask. |
long |
getNextId()
Get the next unique id, not shared by any other object within the same project.
|
static Project |
getOpenProject(String project_file_path) |
String |
getParentFolder()
Return the path to the folder containing the project XML file.
|
String |
getPath(Patch patch)
Returns the stored path for the given Patch image, which may be relative and may contain slice information appended.
|
protected Map<Long,String> |
getPathsCopy() |
String |
getProjectXMLPath() |
String |
getStorageFolder()
Return the folder selected by a user to store files into; it's also the parent folder of the UNUId folder, and the recommended folder to store the XML file into.
|
String |
getUNUId()
Get the Universal Near-Unique Id for the project hosted by this loader.
|
String |
getUNUIdFolder()
Returns the near-unique folder for the project hosted by this FSLoader.
|
static Object |
grabPixels(BufferedImage bi)
Returns the array of pixels, whose type depends on the bi.getType(); for example, for a BufferedImage.TYPE_BYTE_INDEXED, returns a byte[].
|
String |
handlePathlessImage(ij.ImagePlus imp)
Returns the path where the imp is saved to: the storage folder plus a name.
|
protected Patch |
importStackAsPatches(Project project,
Layer first_layer,
double x,
double y,
ij.ImagePlus imp_stack,
boolean as_copy,
String filepath)
Returns the last Patch.
|
void |
insertXMLOptions(StringBuilder sb_body,
String indent)
Specific options for the Loader which exist as attributes to the Project XML node.
|
static boolean |
isRelativePath(String path) |
static boolean |
isURL(String path) |
protected void |
makeAllPathsRelativeTo(String xml_path,
Project project)
Try to make all paths in ht_paths be relative to the given xml_path.
|
String |
makeProjectName() |
String |
makeRelativePath(String path)
Takes the given path and tries to makes it relative to this instance's project_file_path, if possible.
|
protected boolean |
mapIntensities(Patch p,
ij.ImagePlus imp) |
static int |
nStaticServiceThreads() |
Object[] |
openFSProject(String path,
boolean open_displays)
Returns TMLHandler.getProjectData() .
|
void |
parseXMLOptions(HashMap<String,String> ht_attributes)
Specific options for the Loader which exist as attributes to the Project XML node.
|
void |
queueForMipmapRemoval(Patch p,
boolean yes)
Queue/unqueue for mipmap removal on shutdown without saving;
the
yes , when true, makes the p be queued,
and when false, be removed from the queue. |
Bureaucrat |
regenerateMipMaps(Collection<? extends Displayable> patches)
Order the regeneration of all mipmaps for the Patch instances in
patches , setting up a task that blocks input until all completed. |
Future<Boolean> |
regenerateMipMaps(Patch patch)
Queue the regeneration of mipmaps for the Patch; returns immediately, having submitted the job to an executor queue;
returns a Future if the task was submitted, null if not.
|
boolean |
removeFromDatabase(DBObject ob) |
Future<Boolean> |
removeMipMaps(Patch p)
Gets data from the Patch and queues a new task to do the file removal in a separate task manager thread.
|
boolean |
removeSerializedFeatures(Patch patch)
Remove the file, if it exists, with serialized features for patch.
|
boolean |
removeSerializedPointMatches(Patch patch)
Remove the file, if it exists, with serialized point matches for patch.
|
static void |
restartMipMapThreads(int n_threads)
Restart the ExecutorService for mipmaps with
n_threads . |
protected void |
restorePaths(Map<Long,String> copy,
String mipmaps_folder,
String storage_folder) |
String |
save(Project project,
XMLOptions options)
Overwrites the XML file.
|
String |
saveAs(Project project,
XMLOptions options)
The saveAs called from menus via saveTask.
|
String |
saveAs(String path,
XMLOptions options)
Meant for programmatic access, such as calls to project.saveAs(path, overwrite) which call exactly this method.
|
String |
setImageFile(Patch p,
ij.ImagePlus imp)
Returns the absolute path to a file that contains the given ImagePlus image - which may be the path as described in the ImagePlus FileInfo object itself, or a totally new file.
|
boolean |
setMipMapFormat(int format)
Does nothing unless overriden.
|
void |
setMipMapsRegeneration(boolean b) |
void |
setupMenuItems(JMenu menu,
Project project)
Adds a "Save" and "Save as" menu items.
|
void |
tagForMipmapRemoval(Patch p,
boolean yes)
Queue/unqueue for mipmap removal on shutdown without saving;
the
yes , when true, makes the p be queued,
and when false, be removed from the queue. |
boolean |
updateInDatabase(DBObject ob,
Set<String> keys) |
boolean |
updateInDatabase(DBObject ob,
String key) |
Bureaucrat |
updateMipMapsFormat(int old_format,
int new_format)
Removes all mipmap files and recreates them with the currently set mipmaps format.
|
boolean |
usesMipMapsFolder()
Does nothing and returns false unless overriden.
|
addCrossLink, addJob, addNewImage, addNewImage, adjustChannels, askForXMLTemplate, cache, cache, cacheAWT, cacheImagePlus, canReadAndWriteTo, commitLargeUpdate, computeDesirableMinFreeBytes, countObjects, createFlyThrough, createLazyFlyThrough, createZippedStream, debug, decache, decacheAWT, decacheImagePlus, decacheImagePlus, deserialize, destroyPreloader, doGUILater, doLater, embedAlpha, embedAlpha, embedAlphaPre, enhanceContrast, enhanceContrast, enoughFreeMemory, export, exportImage, exportImage, fetchAWTImage, fetchImage, fetchImage, flush, generateLayerMipMaps, generateMipMaps, generateMipMaps, getCached, getCachedAWT, getCachedClosestAboveImage, getCachedClosestBelowImage, getCachedImagePlus, getCurrentMemory, getDimensions, getDimensions, getFileName, getFlatAWTImage, getFlatAWTImage, getFlatImage, getFlatImage, getFlatImage, getFlatImage, getFlatImage, getFlatImage, getHighestMipMapLevel, getHighestMipMapLevel, getInternalFileName, getJobsPopup, getMipMapLevel, getMipMapModeIndex, getMipMapModeName, getMipMapsRegenerationEnabled, getNextTempId, getOrMakeImageLoadingLock, getOrMakeImageLoadingLock, getPreprocessorScriptPath, handleCacheError, hasChanges, importGrid, importGrid, importImage, importImage, importImage, importImages, importImages, importLabelsAsAreaLists, importLabelsAsAreaLists, importNextImage, importSequenceAsGrid, importSequenceAsGrid, importSequenceAsGrid, importStack, importStack, importStack, importStackAsPatches, isAsynchronous, isCached, isImagePlusCached, isMipMapsRegenerationEnabled, isSignalImage, isSnapPaintable, isUnloadable, makeFlatImage, makeFlatImage, makeFlatImage, makeGrayLut, makePatchesDir, makePrescaledTiles, markStaleFileForDeletionUponSaving, maskBorders, maskBorders, maskBordersLayerWise, maxDim, measureSize, openImage, openImagePlus, openStack, preload, preload, preProcess, printCache, printCaches, printCacheStatus, printMemState, quitJob, recoverOOME, recreateBuckets, recreateBuckets, releaseAll, releaseAllCaches, releaseMemory, releaseMemory2, releaseToFit, releaseToFit, removeAlphaMask, removeCached, removeCached, removeCrossLink, removeFromUnloadable, removeImageLoadingLock, removeJob, rollback, saveAs, saveTask, scaleImage, scaleImage, serialize, setChanged, setDesirableMinFreeBytes, setHeapFraction, setMinAndMax, setPreprocessorScriptPath, setPreprocessorScriptPathSilently, setupPreloader, setupPreloaderThreads, startLargeUpdate, storeAlphaMask, unzipTiff, writeXMLTo
public static final Pattern ABS_PATH
public static ExecutorService repainter
public static ScheduledExecutorService autosaver
public static final String[] MIPMAP_FORMATS
public static final int MIPMAP_JPEG
public static final int MIPMAP_PNG
public static final int MIPMAP_TIFF
public static final int MIPMAP_RAW
public static final int MIPMAP_RAG
public String getProjectXMLPath()
public String getStorageFolder()
getStorageFolder
in class Loader
public String getImageStorageFolder()
getImageStorageFolder
in class Loader
public Object[] openFSProject(String path, boolean open_displays)
public static final int nStaticServiceThreads()
public static final void restartMipMapThreads(int n_threads)
n_threads
.public void destroy()
Loader
public long getNextId()
public long getNextBlobId()
Patch
's CoordinateTransform
or alpha mask.getNextBlobId
in class Loader
public double[][][] fetchBezierArrays(long id)
fetchBezierArrays
in class Loader
public ArrayList<?> fetchPipePoints(long id)
fetchPipePoints
in class Loader
public ArrayList<?> fetchBallPoints(long id)
fetchBallPoints
in class Loader
public Area fetchArea(long area_list_id, long layer_id)
public ij.ImagePlus fetchImagePlus(Patch p)
fetchImagePlus
in class Loader
public ij.process.ImageProcessor fetchImageProcessor(Patch p)
fetchImageProcessor
in class Loader
public Object fetchImage(Patch p, int format)
public ij.process.ByteProcessor fetchImageMask(Patch p)
fetchImageMask
in class Loader
Patch.getAlphaMask()
public final String getMasksFolder()
Loader
getMasksFolder
in class Loader
public final String getCoordinateTransformsFolder()
Loader
getCoordinateTransformsFolder
in class Loader
public Object[] fetchLabel(DLabel label)
fetchLabel
in class Loader
public ij.ImagePlus fetchOriginal(Patch patch)
fetchOriginal
in class Loader
public boolean addToDatabase(DBObject ob)
addToDatabase
in class Loader
public boolean updateInDatabase(DBObject ob, String key)
updateInDatabase
in class Loader
public boolean updateInDatabase(DBObject ob, Set<String> keys)
updateInDatabase
in class Loader
public boolean removeFromDatabase(DBObject ob)
removeFromDatabase
in class Loader
public String setImageFile(Patch p, ij.ImagePlus imp)
setImageFile
in class Loader
public String getAbsolutePath(Patch patch)
getAbsolutePath
in class Loader
public String getAbsolutePath(String path)
public final String getImageFilePath(Patch p)
Loader
getImageFilePath
in class Loader
public static final boolean isURL(String path)
public static final boolean isRelativePath(String path)
public void addedPatchFrom(String path, Patch patch)
addedPatchFrom
in class Loader
public static String asSafePath(String name)
public String save(Project project, XMLOptions options)
public String saveAs(Project project, XMLOptions options)
public String saveAs(String path, XMLOptions options)
public String getPath(Patch patch)
protected Map<Long,String> getPathsCopy()
getPathsCopy
in class Loader
protected void makeAllPathsRelativeTo(String xml_path, Project project)
dir_storage
and dir_mipmaps
remain untouched--otherwise,
after a saveAs
, images would not be found.makeAllPathsRelativeTo
in class Loader
protected void restorePaths(Map<Long,String> copy, String mipmaps_folder, String storage_folder)
restorePaths
in class Loader
public String makeRelativePath(String path)
makeRelativePath
in class Loader
public void setupMenuItems(JMenu menu, Project project)
setupMenuItems
in class Loader
protected Patch importStackAsPatches(Project project, Layer first_layer, double x, double y, ij.ImagePlus imp_stack, boolean as_copy, String filepath)
importStackAsPatches
in class Loader
public void parseXMLOptions(HashMap<String,String> ht_attributes)
public Bureaucrat regenerateMipMaps(Collection<? extends Displayable> patches)
patches
, setting up a task that blocks input until all completed.regenerateMipMaps
in class Loader
public void insertXMLOptions(StringBuilder sb_body, String indent)
insertXMLOptions
in class Loader
public final String getParentFolder()
getParentFolder
in class Loader
public String getMipMapsFolder()
getMipMapsFolder
in class Loader
public static final Object grabPixels(BufferedImage bi)
public void queueForMipmapRemoval(Patch p, boolean yes)
yes
, when true, makes the p
be queued,
and when false, be removed from the queue.queueForMipmapRemoval
in class Loader
public void tagForMipmapRemoval(Patch p, boolean yes)
yes
, when true, makes the p
be queued,
and when false, be removed from the queue.tagForMipmapRemoval
in class Loader
protected boolean generateMipMaps(Patch patch)
Such images are stored as jpeg 85% quality in a folder named trakem2.mipmaps.
The Patch id and the right extension will be appended to the filename in all cases.
Any equally named files will be overwritten.
generateMipMaps
in class Loader
public boolean removeSerializedFeatures(Patch patch)
public boolean removeSerializedPointMatches(Patch patch)
public Bureaucrat generateMipMaps(Collection<Displayable> patches, boolean overwrite)
patches
- : the list of Patch instances to generate mipmaps for.overwrite
- : whether to overwrite any existing mipmaps, or save only those that don't exist yet for whatever reason. This flag provides the means for minimal effort mipmap regeneration.)public String getUNUIdFolder()
getUNUIdFolder
in class Loader
public void setMipMapsRegeneration(boolean b)
setMipMapsRegeneration
in class Loader
public void flushMipMaps(boolean forget_dir_mipmaps)
flushMipMaps
in class Loader
public void flushMipMaps(long id)
flushMipMaps
in class Loader
public Future<Boolean> removeMipMaps(Patch p)
removeMipMaps
in class Loader
public boolean usesMipMapsFolder()
Loader
usesMipMapsFolder
in class Loader
public int getClosestMipMapLevel(Patch patch, int level, int max_level)
level
that exists as a file.
If no valid path is found for the patch, returns ERROR_PATH_NOT_FOUND.getClosestMipMapLevel
in class Loader
public boolean checkMipMapFileExists(Patch p, double magnification)
checkMipMapFileExists
in class Loader
protected MipMapImage fetchMipMapAWT(Patch patch, int level, long n_bytes)
fetchMipMapAWT
in class Loader
public final MipMapImage fetchMipMap(Patch patch, int level, long n_bytes)
public final Future<Boolean> regenerateMipMaps(Patch patch)
regenerateMipMaps
in class Loader
public long estimateImageFileSize(Patch p, int level)
estimateImageFileSize
in class Loader
public String makeProjectName()
makeProjectName
in class Loader
public String handlePathlessImage(ij.ImagePlus imp)
handlePathlessImage
in class Loader
public boolean fixStorageFolders()
public static final String createMipMapRelPath(Patch p, String ext)
public static final String createIdPath(String sid, String filename, String ext)
public String getUNUId()
Loader
public MipMapImage fetchDataImage(Patch p, double mag)
fetchDataImage
in class Loader
public ij.ImagePlus fetchImagePlus(Stack stack)
fetchImagePlus
in class Loader
public boolean deleteStaleFiles(boolean coordinate_transforms, boolean alpha_masks)
unuid
folder.
These include "*.ct" files (for CoordinateTransform
)
and "*.zip" files (for alpha mask images) that are not referenced from any Patch
.deleteStaleFiles
in class Loader
public final int getMipMapFormat()
getMipMapFormat
in class Loader
public final boolean setMipMapFormat(int format)
Loader
setMipMapFormat
in class Loader
public Bureaucrat updateMipMapsFormat(int old_format, int new_format)
updateMipMapsFormat
in class Loader
old_format
- Any of MIPMAP_JPEG, MIPMAP_PNG in which files were saved before.protected boolean mapIntensities(Patch p, ij.ImagePlus imp)
mapIntensities
in class Loader
public boolean clearIntensityMap(Patch p)
Loader
clearIntensityMap
in class Loader
Copyright © 2015–2021 Fiji. All rights reserved.