public final class Layer extends DBObject implements Bucketable, Comparable<Layer>
Modifier and Type | Class and Description |
---|---|
protected static class |
Layer.DoMoveDisplayable |
Modifier and Type | Field and Description |
---|---|
static Comparator<Layer> |
COMPARATOR
Compare layers by Z.
|
static int |
IMAGE |
static int |
IMAGEPLUS |
static int |
IMAGEPROCESSOR |
static int |
PIXELARRAY |
Constructor and Description |
---|
Layer(Project project,
double z,
double thickness,
LayerSet parent) |
Layer(Project project,
long id,
double z,
double thickness)
Reconstruct from database
|
Layer(Project project,
long id,
HashMap<String,String> ht_attributes)
Reconstruct from XML file.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Displayable displ)
Add a displayable and update all Display instances showing this Layer.
|
void |
add(Displayable displ,
boolean update_displays) |
void |
add(Displayable displ,
boolean update_displays,
boolean update_db) |
void |
addSilently(DBObject displ)
Used for reconstruction purposes.
|
void |
apply(Class<?> c,
AffineTransform at)
Preconcatenate the given AffineTransform to all Displayable objects of class c, without respecting their links.
|
void |
checkBuckets() |
Layer |
clone(Project pr,
LayerSet ls,
Rectangle roi,
boolean copy_id,
boolean ignore_hidden_patches)
Make a copy of this layer into the given LayerSet, enclosing only Displayable objects within the roi, and translating them for that roi x,y.
|
int |
compareTo(Layer layer) |
boolean |
contains(Class<?> c)
Returns true if any of the Displayable objects are of the given class.
|
boolean |
contains(Class<?> c,
boolean visible_only)
Returns true if any of the Displayable objects are of the given class; if
visible_only is true,
will return true only if at least one of the matched objects is visible. |
boolean |
contains(Displayable displ) |
boolean |
contains(int x,
int y,
int inset) |
int |
count(Class<?> c)
Count instances of the given Class.
|
static Layer |
create(Project project,
LayerSet parent)
Creates a new Layer asking for z and thickness, and adds it to the parent and returns it.
|
static List<Layer> |
createMany(Project project,
LayerSet parent)
Pops up a dialog to choose the first Z coord, the thickness, the number of layers,
and whether to skip the creation of any layers whose Z and thickness match
that of existing layers.
|
void |
destroy() |
static void |
exportDTD(StringBuilder sb_header,
HashSet<String> hs,
String indent)
Includes all Displayable objects in the list of possible children.
|
void |
exportXML(StringBuilder sb_body,
String indent,
XMLOptions options)
Subclasses can override this method to store the instance as XML.
|
Collection<Displayable> |
find(Class<?> c,
double x,
double y) |
Collection<Displayable> |
find(Class<?> c,
double x,
double y,
boolean visible_only)
Find the Displayable objects of Class c that contain the point, with class equality.
|
Collection<Displayable> |
find(Class<?> c,
double x,
double y,
boolean visible_only,
boolean instance_of)
Find the Displayable objects of Class c that contain the point, with instanceof if instance_of is true.
|
Collection<Displayable> |
find(Class<?> c,
Rectangle r,
boolean visible_only) |
Collection<Displayable> |
find(Class<?> c,
Rectangle r,
boolean visible_only,
boolean instance_of)
Find the Displayable objects whose bounding box intersects with the given rectangle.
|
Collection<Displayable> |
find(double x,
double y) |
Collection<Displayable> |
find(double x,
double y,
boolean visible_only)
Find the Displayable objects that contain the point.
|
Collection<Displayable> |
find(Rectangle r) |
Collection<Displayable> |
find(Rectangle r,
boolean visible_only)
Find the Displayable objects whose bounding box intersects with the given rectangle.
|
DBObject |
findById(long id) |
Displayable |
get(long id) |
<T extends Displayable> |
getAll(Class<T> c)
Returns a list of Displayable of class c only.
|
HashMap<Displayable,HashSet<Bucket>> |
getBucketMap(Layer layer) |
double |
getCalibratedThickness() |
double |
getCalibratedZ() |
ArrayList<Displayable> |
getDisplayableList()
Returns the real list of displayables, not a copy.
|
ArrayList<Displayable> |
getDisplayables()
Returns a copy of the list of Displayable objects.
|
ArrayList<Displayable> |
getDisplayables(Class<?> c)
Returns a list of Displayable of class c only.
|
Collection<Displayable> |
getDisplayables(Class<?> c,
Area aroi,
boolean visible_only)
Returns a list of all Displayable of class c that intersect the given area.
|
Collection<Displayable> |
getDisplayables(Class<?> c,
Area aroi,
boolean visible_only,
boolean instance_of)
Check class identity by instanceof instead of equality.
|
ArrayList<Displayable> |
getDisplayables(Class<?> c,
boolean visible_only)
Check class identity with equality, so no superclasses or interfaces are possible.
|
ArrayList<Displayable> |
getDisplayables(Class<?> c,
boolean visible_only,
boolean instance_of) |
Collection<Displayable> |
getDisplayables(Class<?> c,
Rectangle roi)
Returns a list of all Displayable of class c that intersect the given rectangle.
|
<T extends Displayable> |
getIntersecting(Displayable d,
Class<T> target)
Find the Displayable objects of class 'target' whose perimeter (not just the bounding box)
intersect the given Displayable (which is itself included if present in this very Layer).
|
float |
getLayerHeight() |
protected String |
getLayerThingTitle() |
float |
getLayerWidth() |
Rectangle |
getMinimalBoundingBox(Class<?> c)
Returns null if no Displayable objects of class c exist.
|
Rectangle |
getMinimalBoundingBox(Class<?> c,
boolean visible_only)
Returns null if no Displayable objects of class c exist (or are visible if
visible_only is true). |
int |
getNDisplayables() |
Overlay |
getOverlay()
Return the current Overlay or a new one if none yet.
|
LayerSet |
getParent() |
Area |
getPatchArea(boolean visible_only)
Returns an Area in world coordinates that represents the inside of all Patches.
|
ArrayList<Patch> |
getPatches(boolean visible_only) |
int[] |
getPixel(int x,
int y,
double mag)
Don't use this for fast pixel grabbing; this is intended for the dropper tool and status bar reporting by mouse motion.
|
String |
getPrintableTitle()
Returns a title such as 018__4-K4_2__z1.67 , which is [layer_set index]__[title]__[z coord] .
|
double |
getThickness() |
String |
getTitle()
Sublcasses can override this method to provide a proper String, otherwise calls toString()
|
double |
getZ() |
Object |
grab(Rectangle r,
double scale,
Class<?> c,
int c_alphas,
int format,
int type)
Returns the region defined by the rectangle as an image in the type and format specified.
|
HashSet<Displayable> |
hideExcept(ArrayList<Class<?>> type,
boolean repaint)
Hide all except those whose type is in 'type' list, whose visibility flag is left unchanged.
|
int |
indexOf(Displayable d)
Returns -1 if not found.
|
boolean |
isBottom(Displayable d)
Within its own class only.
|
boolean |
isEmpty()
Checks if there are any Displayable or if any ZDisplayable paints in this layer.
|
boolean |
isTop(Displayable d)
Within its own class only.
|
void |
moveBottom(Displayable d)
Within its own class only.
|
void |
moveDown(Displayable d)
Within its own class only.
|
void |
moveTop(Displayable d)
Within its own class only.
|
void |
moveUp(Displayable d)
Within its own class only.
|
void |
recreateBuckets() |
int |
relativeIndexOf(Displayable d)
Get the index of the given Displayable relative to the rest of its class.
|
boolean |
remove(boolean check)
Remove this layer and all its contents from the project.
|
boolean |
remove(Displayable displ)
Will recreate the buckets; if you intend to remove many, use "removeAll" instead,
so that the expensive operation of recreating the buckets is done only once.
|
boolean |
removeAll(Set<Displayable> ds)
Remove a set of children.
|
Collection<Displayable> |
setAllVisible(boolean repaint)
Returns the collection of Displayable whose visibility state has changed.
|
void |
setBucketsEnabled(boolean b) |
Overlay |
setOverlay(Overlay o)
Set to null to remove the Overlay.
|
void |
setParent(LayerSet layer_set) |
void |
setParentSilently(LayerSet layer_set)
Used for reconstruction purposes.
|
void |
setThickness(double thickness) |
HashSet<Displayable> |
setVisible(String type,
boolean visible,
boolean repaint)
Note: Not recursive into embedded LayerSet objects.
|
void |
setZ(double z) |
Coordinate<Patch> |
toPatchCoordinate(double world_x,
double world_y)
Transfer the world coordinate specified by
world_x ,world_y
in pixels, to the local coordinate of the Patch immediately present under it. |
String |
toString() |
void |
updateBucket(Displayable d,
Layer layer)
Update buckets of a position change for the given Displayable.
|
void |
updateLayerTree()
Recursive into nested LayerSet objects.
|
addToDatabase, getId, getInfo, getProject, getShortTitle, getUniqueIdentifier, removeFromDatabase, updateInDatabase, updateInDatabase
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getProject
public static final Comparator<Layer> COMPARATOR
public static final int IMAGEPROCESSOR
public static final int PIXELARRAY
public static final int IMAGE
public static final int IMAGEPLUS
public Layer(Project project, long id, double z, double thickness)
public static Layer create(Project project, LayerSet parent)
public static List<Layer> createMany(Project project, LayerSet parent)
public String getPrintableTitle()
public void add(Displayable displ)
public void add(Displayable displ, boolean update_displays)
public void add(Displayable displ, boolean update_displays, boolean update_db)
public HashMap<Displayable,HashSet<Bucket>> getBucketMap(Layer layer)
getBucketMap
in interface Bucketable
public void addSilently(DBObject displ)
public boolean remove(Displayable displ)
public boolean removeAll(Set<Displayable> ds)
public void setParentSilently(LayerSet layer_set)
public void setParent(LayerSet layer_set)
public LayerSet getParent()
public double getZ()
public double getThickness()
public double getCalibratedZ()
public double getCalibratedThickness()
public boolean remove(boolean check)
public void setZ(double z)
public void setThickness(double thickness)
public boolean contains(int x, int y, int inset)
public boolean contains(Displayable displ)
public boolean contains(Class<?> c)
public boolean contains(Class<?> c, boolean visible_only)
visible_only
is true,
will return true only if at least one of the matched objects is visible.public int count(Class<?> c)
public boolean isEmpty()
public ArrayList<Displayable> getDisplayables()
public final ArrayList<Displayable> getDisplayableList()
getDisplayableList
in interface Bucketable
public int getNDisplayables()
public <T extends Displayable> ArrayList<T> getAll(Class<T> c)
public ArrayList<Displayable> getDisplayables(Class<?> c)
public ArrayList<Displayable> getDisplayables(Class<?> c, boolean visible_only, boolean instance_of)
public Collection<Displayable> getDisplayables(Class<?> c, Rectangle roi)
public Collection<Displayable> getDisplayables(Class<?> c, Area aroi, boolean visible_only)
public Collection<Displayable> getDisplayables(Class<?> c, Area aroi, boolean visible_only, boolean instance_of)
public ArrayList<Displayable> getDisplayables(Class<?> c, boolean visible_only)
public Displayable get(long id)
public float getLayerWidth()
getLayerWidth
in interface Bucketable
public float getLayerHeight()
getLayerHeight
in interface Bucketable
public Collection<Displayable> find(double x, double y)
public Collection<Displayable> find(double x, double y, boolean visible_only)
public Collection<Displayable> find(Class<?> c, double x, double y)
public Collection<Displayable> find(Class<?> c, double x, double y, boolean visible_only)
public Collection<Displayable> find(Class<?> c, double x, double y, boolean visible_only, boolean instance_of)
public Collection<Displayable> find(Rectangle r)
public Collection<Displayable> find(Rectangle r, boolean visible_only)
public Collection<Displayable> find(Class<?> c, Rectangle r, boolean visible_only)
public Collection<Displayable> find(Class<?> c, Rectangle r, boolean visible_only, boolean instance_of)
public <T extends Displayable> Collection<T> getIntersecting(Displayable d, Class<T> target)
public final int indexOf(Displayable d)
public void moveUp(Displayable d)
public void moveDown(Displayable d)
public void moveTop(Displayable d)
public void moveBottom(Displayable d)
public boolean isTop(Displayable d)
public boolean isBottom(Displayable d)
public int relativeIndexOf(Displayable d)
public HashSet<Displayable> setVisible(String type, boolean visible, boolean repaint)
public Collection<Displayable> setAllVisible(boolean repaint)
public HashSet<Displayable> hideExcept(ArrayList<Class<?>> type, boolean repaint)
public void exportXML(StringBuilder sb_body, String indent, XMLOptions options)
DBObject
public static void exportDTD(StringBuilder sb_header, HashSet<String> hs, String indent)
protected String getLayerThingTitle()
public String getTitle()
DBObject
public void destroy()
public Rectangle getMinimalBoundingBox(Class<?> c)
public Rectangle getMinimalBoundingBox(Class<?> c, boolean visible_only)
visible_only
is true).public Area getPatchArea(boolean visible_only)
public void apply(Class<?> c, AffineTransform at)
public Layer clone(Project pr, LayerSet ls, Rectangle roi, boolean copy_id, boolean ignore_hidden_patches)
public Object grab(Rectangle r, double scale, Class<?> c, int c_alphas, int format, int type)
public DBObject findById(long id)
public void updateLayerTree()
public int[] getPixel(int x, int y, double mag)
public void recreateBuckets()
public void updateBucket(Displayable d, Layer layer)
updateBucket
in interface Bucketable
public void checkBuckets()
public void setBucketsEnabled(boolean b)
public Overlay getOverlay()
public Overlay setOverlay(Overlay o)
public int compareTo(Layer layer)
compareTo
in interface Comparable<Layer>
public Coordinate<Patch> toPatchCoordinate(double world_x, double world_y) throws NoninvertibleTransformException, NoninvertibleModelException
world_x
,world_y
in pixels, to the local coordinate of the Patch
immediately present under it.Patch
is under the coordinate, else the Coordinate
with the x, y, Layer
and the Patch
.NoninvertibleModelException
NoninvertibleTransformException
Copyright © 2015–2021 Fiji. All rights reserved.