ini.trakem2.display
Class AreaList

java.lang.Object
  extended by ini.trakem2.persistence.DBObject
      extended by ini.trakem2.display.Displayable
          extended by ini.trakem2.display.ZDisplayable
              extended by ini.trakem2.display.AreaList
All Implemented Interfaces:
AreaContainer, Paintable, VectorData

public class AreaList
extends ZDisplayable
implements AreaContainer, VectorData

A list of brush painted areas similar to a set of labelfields in Amira. For each layer where painting has been done, there is an entry in the ht_areas HashMap that contains the layer's id as a Long, and a java.awt.geom.Area object. All Area objects are local to this AreaList's AffineTransform.


Nested Class Summary
 
Nested classes/interfaces inherited from class ini.trakem2.display.Displayable
Displayable.DataPackage, Displayable.DoEdit, Displayable.DoEdits, Displayable.DoTransforms, Displayable.SliderListener
 
Field Summary
 
Fields inherited from class ini.trakem2.display.ZDisplayable
layer_set
 
Fields inherited from class ini.trakem2.display.Displayable
alpha, annotation, at, color, COMPOSITE_ADD, COMPOSITE_COLOR_YCBCR, COMPOSITE_DIFFERENCE, COMPOSITE_MULTIPLY, COMPOSITE_NORMAL, COMPOSITE_SUBTRACT, compositeModes, height, hs_linked, last_color, layer, linked_props, linked_props_origins, locked, props, TAG_ATTR1, TAG_ATTR2, title, visible, width
 
Fields inherited from class ini.trakem2.persistence.DBObject
id, project
 
Constructor Summary
AreaList(Project project, long id, java.util.HashMap<java.lang.String,java.lang.String> ht_attributes, java.util.HashMap<Displayable,java.lang.String> ht_links)
          Reconstruct from XML.
AreaList(Project project, long id, java.lang.String title, float width, float height, float alpha, boolean visible, java.awt.Color color, boolean locked, java.util.ArrayList<java.lang.Long> al_ul, java.awt.geom.AffineTransform at)
          Reconstruct from the database.
AreaList(Project project, java.lang.String title, double x, double y)
           
 
Method Summary
 void add(long layer_id, ij.gui.ShapeRoi roi)
          Adds the given ROI, which is expected in world/LayerSet coordinates, to the area present at Layer with id layer_id, or set it if none present yet.
 void addArea(long layer_id, java.awt.geom.Area area)
          Add a copy of an Area object to the existing, if any, area object at Layer with layer_id as given, or if not existing, just set the copy as it.
 void adjustProperties()
          Shows a dialog to adjust properties of this object.
 boolean apply(Layer la, java.awt.geom.Area roi, mpicbg.models.CoordinateTransform ct)
          Applies the 2D transform @ict (which is expected to operate on the world coordinates version of the data contained here) only to the data that falls within the @param roi (in world coords), and then recomputes the bounding box and affine transform (to a translation or identity).
 boolean apply(VectorDataTransform vdt)
           
 boolean calculateBoundingBox(Layer la)
          Calculate box, make this width,height be that of the box, and translate all areas to fit in.
 Displayable clone(Project pr, boolean copy_id)
          Performs a deep copy of this object, without the links.
 boolean contains(Layer layer, int x, int y)
          Returns whether the point x,y is contained in this object at the given Layer.
 boolean crop(java.util.List<Layer> range)
          Retain the data within the layer range, and through out all the rest.
static void exportAsLabels(java.util.List<Displayable> list, ij.gui.Roi roi, float scale, int first_layer, int last_layer, boolean visible_only, boolean to_file, boolean as_amira_labels)
          Export all given AreaLists as one per pixel value, what is called a "labels" file; a file dialog is offered to save the image as a tiff stack.
static void exportDTD(java.lang.StringBuilder sb_header, java.util.HashSet<java.lang.String> hs, java.lang.String indent)
           
 void exportXML(java.lang.StringBuilder sb_body, java.lang.String indent, java.lang.Object any)
          The oid is this objects' id, whereas the 'id' tag will be the id of the wrapper Thing object.
 void fillHoles(Layer la)
           
 java.util.List<javax.vecmath.Point3f> generateTriangles(double scale, int resample)
           
 java.util.HashMap<java.lang.Long,java.util.ArrayList<java.util.ArrayList<java.awt.Point>>> getAllPaths()
          Returns a table of Long layer ids versus the ArrayList that getPaths(long) returns for it.
 java.awt.geom.Area getArea(Layer la)
           
 java.awt.geom.Area getArea(long layer_id)
           
 java.awt.geom.Area getAreaAt(Layer layer)
          In world coordinates, a copy of the area at .
 java.util.List<java.awt.geom.Area> getAreas(Layer layer, java.awt.Rectangle box)
           
 java.awt.Rectangle getBounds(java.awt.Rectangle r, Layer layer)
          Returns the bounds of this object as it shows in the given layer.
 Layer getFirstLayer()
          Returns the layer of lowest Z coordinate Layer where this ZDisplayable has a point in.
 java.lang.String getInfo()
          Measure the volume (in voxels) of this AreaList, and the surface area, the latter estimated as the number of voxels that make the outline.
 Layer getLastLayer()
          Returns the layer of highest Z coordinate Layer where this ZDisplayable has a point in.
 java.util.Collection<java.lang.Long> getLayerIds()
          Get the list of Layer ids on which this ZDisplayable has data on.
 java.util.List<Layer> getLayerRange()
          Get the range of layers betweeh the first and last layers in which this AreaList paints to.
 int getNAreas()
          How many layers does this object paint to.
 java.util.ArrayList<java.util.ArrayList<java.awt.Point>> getPaths(long layer_id)
          Returns an ArrayList of ArrayList of Point as value with all paths for the Area of the given layer_id.
 ij.ImagePlus getStack(int type, double scale)
          Returns a stack of images representing the pixel data of this LayerSet inside this AreaList.
 boolean interpolate(Layer first, Layer last, boolean always_use_distance_map)
          Interpolate areas between the given first and last layers, both of which must contain an area.
 boolean intersects(java.awt.geom.Area area, double z_first, double z_last)
           
 boolean intersects(Layer layer, java.awt.geom.Area area)
          Calls intersects(area) unless overriden -- intended for ZDisplayable objects to return whether they intersect the given area at the given layer.
 boolean intersects(Layer layer, java.awt.Rectangle r)
           
 boolean isDeletable()
           
 boolean isFillPaint()
           
 boolean isRoughlyInside(Layer layer, java.awt.Rectangle box)
          If this Displayable intersects with @param r or almost intersects, then returns true.
 void keyPressed(java.awt.event.KeyEvent ke)
           
protected  boolean layerRemoved(Layer la)
          Update internal datastructures to reflect the fact that @param layer has been removed from the containing LayerSet.
 boolean linkPatches()
          Link the Patch objects that lay underneath the part of the bounding box of this profile that shows in the current layer, so that they cannot be dragged independently.
 double[] measure()
          Returns a double array with 0=volume, 1=lower_bound_surface, 2=upper_bound_surface_smoothed, 3=upper_bound_surface, 4=max_diameter, 5=all_tops_and_bottoms All measures are approximate.
 ij.measure.ResultsTable measure(ij.measure.ResultsTable rt)
          Does nothing unless overriden.
 ij.measure.ResultsTable measureAreas(ij.measure.ResultsTable rt)
           
static AreaList merge(java.util.ArrayList<Displayable> al)
          Merge all arealists contained in the ArrayList to the first one found, and remove the others from the project, and only if they belong to the same LayerSet.
 void mouseDragged(java.awt.event.MouseEvent me, Layer la, int x_p, int y_p, int x_d, int y_d, int x_d_old, int y_d_old)
           
 void mousePressed(java.awt.event.MouseEvent me, Layer la, int x_p_w, int y_p_w, double mag)
           
 void mouseReleased(java.awt.event.MouseEvent me, Layer la, int x_p, int y_p, int x_d, int y_d, int x_r, int y_r)
           
 void paint(java.awt.Graphics2D g, java.awt.Rectangle srcRect, double magnification, boolean active, int channels, Layer active_layer, java.util.List<Layer> layers)
           
 boolean paintsAt(Layer layer)
          Check if this instance will paint anything at the level of the given Layer.
 AreaList part(long layer_id, ij.gui.ShapeRoi sroi)
          Subtracts the given ROI, and then creates a new AreaList with identical properties and the content of the subtracted part.
 void setArea(long layer_id, java.awt.geom.Area area)
          Directly place an Area for the specified layer.
 void subtract(long layer_id, ij.gui.ShapeRoi roi)
          Subtracts the given ROI, which is expected in world/LayerSet coordinates, to the area present at Layer with id layer_id, or set it if none present yet.
 void transformPoints(Layer layer, double dx, double dy, double rot, double xo, double yo)
          Transform points falling within the given layer; translate by dx,dy and rotate by rot relative to origin xo,yo
 
Methods inherited from class ini.trakem2.display.ZDisplayable
exportDTD, getBucketable, getLayerSet, remove, remove2, setColor, setLayer, setLayerSet, setLayerSet, setPosition, setVisible, softRemove, updateBucket, updateBucket
 
Methods inherited from class ini.trakem2.display.Displayable
areThereLayerCrossLinks, canSendTo, clone, clone, commonDTDChildren, contains, deselect, destroy, displacePoints, exportSVG, findById, findNearestPoint, findNearestPoint, getAffineTransform, getAffineTransformCopy, getAlpha, getAnnotation, getArea, getAreaForBucket, getBoundingBox, getBoundingBox, getBoundingBox, getBounds, getColor, getComposite, getComposite, getCompositeMode, getHeight, getIntersection, getLayer, getLayersWithData, getLinked, getLinked, getLinkedBox, getLinkedGroup, getLinkedProperties, getLinkedProperties, getLinkedProperty, getLinkedProperty, getMinimalBoundingBox, getNameId, getPerimeter, getPerimeter, getProperties, getProperty, getProperty, getShortTitle, getTitle, getWidth, getX, getXMLSafeValue, getXMLSafeValue, getY, hasLinkedGroupWithinLayer, hasProperties, intersects, intersects, inverseTransformPoint, isLinked, isLinked, isLinked, isLocked, isLocked2, isOnlyLinkedTo, isOnlyLinkedTo, isOutOfRepaintingClip, isOutOfRepaintingClip, isVisible, link, link, makeAdjustPropertiesDialog, mouseWheelMoved, paintAsBox, paintOffscreen, paintSnapshot, prePaint, preTransform, processAdjustPropertiesDialog, removeLinkedProperties, removeLinkedPropertiesFromOrigins, repaint, restXML, rotate, rotate, rotatePoints, scale, scale, scalePoints, setAffineTransform, setAlpha, setAlpha, setAnnotation, setCompositeMode, setDimensions, setDimensions, setLayer, setLinkedProperties, setLinkedProperty, setLocation, setLocked, setProperty, setTitle, setVisible, snapTo, toString, transform, transformPoint, transformPoint, transformPoints, transformPoints, transformPoints, transformPoints, transformPoints, transformPoints, transformPoints, transformPoints, transformPoints, transformRectangle, translate, translate, unlink, unlink, unlinkAll, updateInDatabase, xmlError, xmlError
 
Methods inherited from class ini.trakem2.persistence.DBObject
addToDatabase, getId, getProject, getUniqueIdentifier, removeFromDatabase, updateInDatabase
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AreaList

public AreaList(Project project,
                java.lang.String title,
                double x,
                double y)

AreaList

public AreaList(Project project,
                long id,
                java.util.HashMap<java.lang.String,java.lang.String> ht_attributes,
                java.util.HashMap<Displayable,java.lang.String> ht_links)
Reconstruct from XML.


AreaList

public AreaList(Project project,
                long id,
                java.lang.String title,
                float width,
                float height,
                float alpha,
                boolean visible,
                java.awt.Color color,
                boolean locked,
                java.util.ArrayList<java.lang.Long> al_ul,
                java.awt.geom.AffineTransform at)
Reconstruct from the database.

Method Detail

paint

public void paint(java.awt.Graphics2D g,
                  java.awt.Rectangle srcRect,
                  double magnification,
                  boolean active,
                  int channels,
                  Layer active_layer,
                  java.util.List<Layer> layers)
Specified by:
paint in interface Paintable
Overrides:
paint in class Displayable

transformPoints

public void transformPoints(Layer layer,
                            double dx,
                            double dy,
                            double rot,
                            double xo,
                            double yo)
Description copied from class: ZDisplayable
Transform points falling within the given layer; translate by dx,dy and rotate by rot relative to origin xo,yo

Overrides:
transformPoints in class ZDisplayable

getFirstLayer

public Layer getFirstLayer()
Returns the layer of lowest Z coordinate Layer where this ZDisplayable has a point in.

Specified by:
getFirstLayer in class ZDisplayable

getLastLayer

public Layer getLastLayer()
Returns the layer of highest Z coordinate Layer where this ZDisplayable has a point in.


getLayerRange

public java.util.List<Layer> getLayerRange()
Get the range of layers betweeh the first and last layers in which this AreaList paints to.


linkPatches

public boolean linkPatches()
Description copied from class: ZDisplayable
Link the Patch objects that lay underneath the part of the bounding box of this profile that shows in the current layer, so that they cannot be dragged independently.

Specified by:
linkPatches in class ZDisplayable
Returns:
whether the locking state changed.

contains

public boolean contains(Layer layer,
                        int x,
                        int y)
Returns whether the point x,y is contained in this object at the given Layer.

Overrides:
contains in class Displayable

intersects

public boolean intersects(Layer layer,
                          java.awt.Rectangle r)
Overrides:
intersects in class Displayable

intersects

public boolean intersects(Layer layer,
                          java.awt.geom.Area area)
Description copied from class: Displayable
Calls intersects(area) unless overriden -- intended for ZDisplayable objects to return whether they intersect the given area at the given layer.

Overrides:
intersects in class Displayable

getBounds

public java.awt.Rectangle getBounds(java.awt.Rectangle r,
                                    Layer layer)
Returns the bounds of this object as it shows in the given layer.

Overrides:
getBounds in class Displayable

isDeletable

public boolean isDeletable()
Specified by:
isDeletable in class Displayable

mousePressed

public void mousePressed(java.awt.event.MouseEvent me,
                         Layer la,
                         int x_p_w,
                         int y_p_w,
                         double mag)
Overrides:
mousePressed in class Displayable

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me,
                         Layer la,
                         int x_p,
                         int y_p,
                         int x_d,
                         int y_d,
                         int x_d_old,
                         int y_d_old)
Overrides:
mouseDragged in class Displayable

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent me,
                          Layer la,
                          int x_p,
                          int y_p,
                          int x_d,
                          int y_d,
                          int x_r,
                          int y_r)
Overrides:
mouseReleased in class Displayable

calculateBoundingBox

public boolean calculateBoundingBox(Layer la)
Calculate box, make this width,height be that of the box, and translate all areas to fit in. @param lid is the currently active Layer.

Specified by:
calculateBoundingBox in interface AreaContainer
Specified by:
calculateBoundingBox in class ZDisplayable
Returns:
Whether this Displayable's bounding box was modified.

exportDTD

public static void exportDTD(java.lang.StringBuilder sb_header,
                             java.util.HashSet<java.lang.String> hs,
                             java.lang.String indent)

exportXML

public void exportXML(java.lang.StringBuilder sb_body,
                      java.lang.String indent,
                      java.lang.Object any)
Description copied from class: Displayable
The oid is this objects' id, whereas the 'id' tag will be the id of the wrapper Thing object.

Overrides:
exportXML in class ZDisplayable

getPaths

public java.util.ArrayList<java.util.ArrayList<java.awt.Point>> getPaths(long layer_id)
Returns an ArrayList of ArrayList of Point as value with all paths for the Area of the given layer_id.


getAllPaths

public java.util.HashMap<java.lang.Long,java.util.ArrayList<java.util.ArrayList<java.awt.Point>>> getAllPaths()
Returns a table of Long layer ids versus the ArrayList that getPaths(long) returns for it.


fillHoles

public void fillHoles(Layer la)

paintsAt

public boolean paintsAt(Layer layer)
Description copied from class: ZDisplayable
Check if this instance will paint anything at the level of the given Layer.

Overrides:
paintsAt in class ZDisplayable

adjustProperties

public void adjustProperties()
Description copied from class: Displayable
Shows a dialog to adjust properties of this object.

Overrides:
adjustProperties in class Displayable

isFillPaint

public boolean isFillPaint()

merge

public static AreaList merge(java.util.ArrayList<Displayable> al)
Merge all arealists contained in the ArrayList to the first one found, and remove the others from the project, and only if they belong to the same LayerSet. Returns the merged AreaList object.


getNAreas

public int getNAreas()
How many layers does this object paint to.


getArea

public java.awt.geom.Area getArea(Layer la)

getArea

public java.awt.geom.Area getArea(long layer_id)

clone

public Displayable clone(Project pr,
                         boolean copy_id)
Performs a deep copy of this object, without the links.

Specified by:
clone in class Displayable

generateTriangles

public java.util.List<javax.vecmath.Point3f> generateTriangles(double scale,
                                                               int resample)

setArea

public void setArea(long layer_id,
                    java.awt.geom.Area area)
Directly place an Area for the specified layer. Keep in mind it will be added in this AreaList coordinate space, not the overall LayerSet coordinate space. Does not make it local, you should call calculateBoundingBox() after setting an area.


addArea

public void addArea(long layer_id,
                    java.awt.geom.Area area)
Add a copy of an Area object to the existing, if any, area object at Layer with layer_id as given, or if not existing, just set the copy as it. The area is expected in this AreaList coordinate space. Does not make it local, you should call calculateBoundingBox when done.


add

public void add(long layer_id,
                ij.gui.ShapeRoi roi)
         throws java.awt.geom.NoninvertibleTransformException
Adds the given ROI, which is expected in world/LayerSet coordinates, to the area present at Layer with id layer_id, or set it if none present yet.

Throws:
java.awt.geom.NoninvertibleTransformException

subtract

public void subtract(long layer_id,
                     ij.gui.ShapeRoi roi)
              throws java.awt.geom.NoninvertibleTransformException
Subtracts the given ROI, which is expected in world/LayerSet coordinates, to the area present at Layer with id layer_id, or set it if none present yet.

Throws:
java.awt.geom.NoninvertibleTransformException

part

public AreaList part(long layer_id,
                     ij.gui.ShapeRoi sroi)
              throws java.awt.geom.NoninvertibleTransformException
Subtracts the given ROI, and then creates a new AreaList with identical properties and the content of the subtracted part. Returns null if there is no intersection between sroi and the Area for layer_id.

Throws:
java.awt.geom.NoninvertibleTransformException

keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Overrides:
keyPressed in class Displayable

getInfo

public java.lang.String getInfo()
Measure the volume (in voxels) of this AreaList, and the surface area, the latter estimated as the number of voxels that make the outline. If the width and height of this AreaList cannot be fit in memory, scaled down versions will be used, and thus the results will be approximate.

Overrides:
getInfo in class DBObject

intersects

public boolean intersects(java.awt.geom.Area area,
                          double z_first,
                          double z_last)
Specified by:
intersects in class ZDisplayable
Parameters:
area - is expected in world coordinates.

exportAsLabels

public static void exportAsLabels(java.util.List<Displayable> list,
                                  ij.gui.Roi roi,
                                  float scale,
                                  int first_layer,
                                  int last_layer,
                                  boolean visible_only,
                                  boolean to_file,
                                  boolean as_amira_labels)
Export all given AreaLists as one per pixel value, what is called a "labels" file; a file dialog is offered to save the image as a tiff stack.


measure

public ij.measure.ResultsTable measure(ij.measure.ResultsTable rt)
Description copied from class: Displayable
Does nothing unless overriden.

Overrides:
measure in class Displayable

measure

public double[] measure()
Returns a double array with 0=volume, 1=lower_bound_surface, 2=upper_bound_surface_smoothed, 3=upper_bound_surface, 4=max_diameter, 5=all_tops_and_bottoms All measures are approximate. [0] Volume: sum(area * thickness) for all sections [1] Lower Bound Surface: measure area per section, compute radius of circumference of identical area, compute then area of the sides of the truncated cone of height thickness, for each section. Plus top and bottom areas when visiting sections without a painted area. [2] Upper Bound Surface Smoothed: measure smoothed perimeter lengths per section, multiply by thickness to get lateral area. Plus tops and bottoms. [3] Upper Bound Surface: measure raw pixelated perimeter lengths per section, multiply by thickness to get lateral area. Plus top and bottoms. [4] Maximum diameter: longest distance between any two points in the contours of all painted areas. [5] All tops and bottoms: Sum of all included surface areas that are not part of side area.


crop

public boolean crop(java.util.List<Layer> range)
Retain the data within the layer range, and through out all the rest.

Overrides:
crop in class ZDisplayable

getStack

public ij.ImagePlus getStack(int type,
                             double scale)
Returns a stack of images representing the pixel data of this LayerSet inside this AreaList.


getAreas

public java.util.List<java.awt.geom.Area> getAreas(Layer layer,
                                                   java.awt.Rectangle box)
Specified by:
getAreas in interface AreaContainer

layerRemoved

protected boolean layerRemoved(Layer la)
Description copied from class: ZDisplayable
Update internal datastructures to reflect the fact that @param layer has been removed from the containing LayerSet.

Overrides:
layerRemoved in class ZDisplayable

apply

public boolean apply(Layer la,
                     java.awt.geom.Area roi,
                     mpicbg.models.CoordinateTransform ct)
              throws java.lang.Exception
Description copied from interface: VectorData
Applies the 2D transform @ict (which is expected to operate on the world coordinates version of the data contained here) only to the data that falls within the @param roi (in world coords), and then recomputes the bounding box and affine transform (to a translation or identity). Does not consider links.

Specified by:
apply in interface VectorData
Parameters:
la - Only data at this Layer may be transformed.
roi - Only data inside this world-coordinates Area may be transformed.
ct - The transform to apply to the data that is in @param la and within @param roi.
Throws:
java.lang.Exception

apply

public boolean apply(VectorDataTransform vdt)
              throws java.lang.Exception
Specified by:
apply in interface VectorData
Throws:
java.lang.Exception

getLayerIds

public java.util.Collection<java.lang.Long> getLayerIds()
Description copied from class: ZDisplayable
Get the list of Layer ids on which this ZDisplayable has data on.

Overrides:
getLayerIds in class ZDisplayable

getAreaAt

public java.awt.geom.Area getAreaAt(Layer layer)
In world coordinates, a copy of the area at . May be null.

Overrides:
getAreaAt in class Displayable

isRoughlyInside

public boolean isRoughlyInside(Layer layer,
                               java.awt.Rectangle box)
Description copied from class: Displayable
If this Displayable intersects with @param r or almost intersects, then returns true. This method is meant to be very fast, and err on the "yes" and never on the "no".

Overrides:
isRoughlyInside in class Displayable

measureAreas

public ij.measure.ResultsTable measureAreas(ij.measure.ResultsTable rt)
Specified by:
measureAreas in interface AreaContainer

interpolate

public boolean interpolate(Layer first,
                           Layer last,
                           boolean always_use_distance_map)
                    throws java.lang.Exception
Interpolate areas between the given first and last layers, both of which must contain an area.

Returns:
false if the interpolation could not be done.
Throws:
java.lang.Exception