ini.trakem2.display
Class Tree<T>

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.Tree<T>
All Implemented Interfaces:
Paintable, VectorData
Direct Known Subclasses:
AreaTree, Treeline

public abstract class Tree<T>
extends ZDisplayable
implements VectorData

A sequence of points ordered in a set of connected branches.


Nested Class Summary
static class Tree.MeasurePathDistance<I>
           
static class Tree.MeshData
          One color per vertex.
 
Nested classes/interfaces inherited from class ini.trakem2.display.Displayable
Displayable.DataPackage, Displayable.DoEdit, Displayable.DoEdits, Displayable.DoTransforms, Displayable.SliderListener
 
Field Summary
protected  java.util.Set<Node<T>> end_nodes
           
protected  java.util.Map<Layer,java.util.Set<Node<T>>> node_layer_map
           
protected  Node<T> root
           
 
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
protected Tree(Project project, long id, java.util.HashMap<java.lang.String,java.lang.String> ht_attr, java.util.HashMap<Displayable,java.lang.String> ht_links)
          Reconstruct from XML.
protected Tree(Project project, long id, java.lang.String title, float width, float height, float alpha, boolean visible, java.awt.Color color, boolean locked, java.awt.geom.AffineTransform at)
          For cloning purposes, does not call addToDatabase(), neither creates any root node.
protected Tree(Project project, java.lang.String title)
           
 
Method Summary
 boolean addNode(Node<T> parent, Node<T> child, byte confidence)
          Will call calculateBoundingBox and repaint.
protected  void addToLinkLater(Node<T> nd)
           
protected  Node<T> adjustEdgeConfidence(int inc, float x, float y, Layer layer, DisplayCanvas dc)
          Expects world coordinates.
 boolean apply(Layer la, java.awt.geom.Area roi, mpicbg.models.CoordinateTransform ict)
          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)
           
 java.util.HashMap<Node<T>,Vertex<Node<T>>> asVertices()
          Return a representation of this Tree with Vertex instead of Node.
protected  void cacheSubtree(java.lang.Iterable<Node<T>> nodes)
           
protected  boolean calculateBoundingBox(Layer la)
           
 boolean canJoin(java.util.List<? extends Tree<T>> ts)
          Join all given Trees by using the first one as the receiver, and all the others as the ones to be merged into the receiver.
protected  void clearCache()
           
protected  void clearState()
           
 java.util.HashMap<Node<T>,java.lang.Integer> computeAllDegrees()
           
 java.util.HashMap<Node<T>,java.lang.Float> computeCentrality()
          Computes betweenness centrality of each node in the tree, using Ulrik Brandes betweenness centrality algorithm.
 boolean contains(Layer layer, int x, int y)
          Returns true if the given point falls within a certain distance of any of the treeline segments, where a segment is defined as the line between a clicked point and the next.
static
<A extends Tree<?>,B extends Node<?>>
A
copyAs(Tree<?> src, java.lang.Class<A> tree_class, java.lang.Class<B> node_class)
          Can copy a Treeline to an AreaTree and viceversa.
protected  Coordinate<Node<T>> createCoordinate(Node<T> nd)
           
 java.util.concurrent.Future<javax.swing.JFrame> createMultiTableView()
          Create a GUI to list, in three tabs: starting point, branch points, end points, and all points.
protected  Node<T> createNewNode(float lx, float ly, Layer layer, Node<?> modelNode)
          Create a new node, copying some properties from the modelNode such as radius or color.
 void createReviewStack(Node<T> first, Node<T> last, Tag tag, java.lang.String filepath, int width, int height, double magnification, int image_type)
          The behavior is undefined if @param last is not a descendant of @param first.
 boolean crop(java.util.List<Layer> range)
          Retain the data within the layer range, and through out all the rest.
 void deselect()
          Tell this Displayable that is has been deselected from a Display.
 void destroy()
          Release resources.
static
<A extends Tree<?>>
java.util.Map<Tree<?>,Tree<?>>
duplicateAs(java.util.Collection<Displayable> col, java.lang.Class<A> target)
          Takes a collection of Tree instances and creates duplicate siblings of the target class.
static void exportDTD(java.lang.StringBuilder sb_header, java.util.HashSet<java.lang.String> hs, java.lang.String indent)
          Exports to type t2_treeline.
 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.
protected abstract  boolean exportXMLNodeAttributes(java.lang.StringBuilder indent, java.lang.StringBuilder sb, Node<T> node)
           
protected abstract  boolean exportXMLNodeData(java.lang.StringBuilder indent, java.lang.StringBuilder sb, Node<T> node)
           
 Node<T> findClosestNode(java.util.Collection<Node<T>> nodes, float lx, float ly, double magnification)
          Expects local coords; with precision depending on magnification.
 Node<T> findClosestNodeW(java.util.Collection<Node<T>> nodes, float wx, float wy, double magnification)
          Expects world coords; with precision depending on magnification.
 Node<T> findClosestNodeW(float wx, float wy, Layer layer, double magnification)
          Expects world coords; with precision depending on magnification.
 java.util.List<Connector>[] findConnectors()
          Returns an array of two Collection of connectors: the first one has the outgoing connectors, and the second one has the incoming connectors.
protected  Node<T> findFirstIntersectingNode(java.util.Set<Node<T>> nodes, java.awt.geom.Area a)
          Expects an Area in local coordinates.
 java.util.Map<Node<T>,java.util.Collection<Displayable>> findIntersecting(java.lang.Class<?> c)
           
protected  Coordinate<Node<T>> findNearAndGetNext(float x, float y, Layer layer, DisplayCanvas dc)
           
protected  Coordinate<Node<T>> findNearAndGetPrevious(float x, float y, Layer layer, DisplayCanvas dc)
           
 Node<T>[] findNearestEdge(float x_pl, float y_pl, Layer layer, double magnification)
          Considering only the set of consecutive layers currently painted, find a point near an edge with accuracy depending upon magnification.
 Node<T> findNearestEndNode(float lx, float ly, Layer layer)
          Find the spatially closest node, in calibrated coords.
 Node<T> findNearestNode(float lx, float ly, Layer layer)
          Find the spatially closest node, in calibrated coords; expects local coords.
 Coordinate<Node<T>> findNextBranchOrEndPoint(float x, float y, Layer layer, DisplayCanvas dc)
          If the node found near x,y,layer is a branch point, returns it; otherwise the next down the chain; on reaching an end point, returns it.
 Node<T> findNode(float lx, float ly, Layer layer, double magnification)
          Find a node in @param layer near the local coords lx,ly, with precision depending on magnification.
protected  Node<T> findNodeNear(float x, float y, Layer layer, DisplayCanvas dc)
           
protected  Node<T> findNodeNear(float x, float y, Layer layer, DisplayCanvas dc, boolean use_receiver_when_null)
          Expects world coordinates.
 Coordinate<Node<T>> findPreviousBranchOrRootPoint(float x, float y, Layer layer, DisplayCanvas dc)
           
 java.util.Set<Tag> findTags()
          Search all nodes for unique tags and returns them.
protected  void fireNodeRemoved(Node<T> nd)
           
protected  javax.vecmath.Point3f fix(javax.vecmath.Point3f p, boolean calibrated, float[] f)
          Expects a non-null float[] for reuse, and modifies @param p in place.
 ij.ImagePlus flyThrough(Node<T> first, Node<T> last, int width, int height, double magnification, int type, java.lang.String dir)
          Fly-through image stack from first to last node.
 ij.ImagePlus flyThroughMarked(int width, int height, double magnification, int type, java.lang.String dir)
          Fly-through image stack from source node to mark node.
 Bureaucrat generateAllReviewStacks()
           
 java.util.LinkedList<Region<Node<T>>> generateRegions(Node<T> first, Node<T> last, int width, int height, double magnification)
           
 Bureaucrat generateReviewStackForSlab(float x, float y, Layer layer, double magnification)
           
 Bureaucrat generateReviewStackForSlab(Node<T> node)
          Generate a review stack from the previous branch node or root, to the next branch node or end node.
 Tree.MeshData generateSkeleton(double scale_, int parallels, int resample)
           
 Bureaucrat generateSubtreeReviewStacks(int x, int y, Layer layer, double magnification)
           
 Bureaucrat generateSubtreeReviewStacks(Node<T> root)
           
 java.util.List<javax.vecmath.Point3f> generateTriangles(double scale_, int parallels, int resample)
          Deprecated. 
protected  Node<T> getActive()
           
 java.awt.geom.Area getAreaAt(Layer layer)
          In world coordinates.
protected  java.awt.Rectangle getBounds(java.util.Collection<Node<T>> nodes)
           
 java.awt.Rectangle getBounds(java.awt.Rectangle tmp, Layer layer)
          Will fill bounding box values into given rectangle -- only that part of this object showing in the given layer will be included in the box.
 java.util.Collection<Node<T>> getBranchAndEndNodes()
           
 java.util.Collection<Node<T>> getBranchNodes()
           
 java.util.Set<Node<T>> getEndNodes()
           
 Layer getFirstLayer()
          Returns the layer of lowest Z coordinate where this ZDisplayable has a point in.
 Coordinate<Node<T>> getLastAdded()
           
 Coordinate<Node<T>> getLastEdited()
           
 Node<T> getLastVisited()
           
 java.util.Collection<java.lang.Long> getLayerIds()
          Get the list of Layer ids on which this ZDisplayable has data on.
 java.util.Collection<Layer> getLayersWithData()
          Override it to provide Layer pointers directly.
 Node<T> getMarked()
           
protected  java.util.Set<Node<T>> getNodesToPaint(Layer active_layer)
           
protected  java.util.Set<Node<T>> getNodesToPaint(Layer active_layer, java.util.List<Layer> color_cue_layers)
           
 javax.vecmath.Point3f getOriginPoint(boolean calibrated)
           
protected  java.awt.Rectangle getPaintingBounds()
           
 Node<T> getRoot()
           
 java.lang.String getShortTitle()
          Sublcasses can override this method to provide a proper String, otherwise calls getTitle()
 boolean insertNode(Node<T> parent, Node<T> child, Node<T> in_between, byte confidence)
           
 boolean intersects(java.awt.geom.Area area, double z_first, double z_last)
           
 boolean intersects(Layer layer, java.awt.geom.Area area)
          Expects Area in world coords.
 boolean intersects(Layer layer, java.awt.Rectangle r)
          Expects Rectangle in world coords.
protected  boolean isAnyNear(java.util.Collection<Node<T>> nodes, float lx, float ly, float radius)
           
 boolean isDeletable()
           
protected  boolean isRoughlyInside(Layer layer, java.awt.Rectangle box)
          Fast and dirty, never returns a false negative but may return a false positive.
protected  boolean isTagging()
           
 boolean join(java.util.List<? extends Tree<T>> ts)
           
 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.
 boolean markNear(float x, float y, Layer layer, double magnification)
           
 ij.measure.ResultsTable measure(ij.measure.ResultsTable rt)
          Measures number of branch points and end points, and total cable length.
 double measurePathDistance(Node<T> a, Node<T> b)
          Measure the distance, in calibrated units, between nodes a and b of this tree.
 ij.measure.ResultsTable measurePathDistance(Node<T> a, Node<T> b, ij.measure.ResultsTable rt)
          Reuses @param rt unless it is null, in which case it creates a new one.
 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 layer, int x_p, int y_p, 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 mouseWheelMoved(java.awt.event.MouseWheelEvent mwe)
          Does nothing unless overriden.
protected abstract  Tree<T> newInstance()
          Create a new instance, intialized with same ZDisplayable-level parameters (affine, color, title, etc.).
protected abstract  Node<T> newNode(float lx, float ly, Layer layer, Node<?> modelNode)
           
abstract  Node<T> newNode(java.util.HashMap<java.lang.String,java.lang.String> ht_attr)
          To reconstruct from XML.
 void paint(java.awt.Graphics2D g, java.awt.Rectangle srcRect, double magnification, boolean active, int channels, Layer active_layer, java.util.List<Layer> layers)
           
 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 with_arrows)
           
 boolean paintsAt(Layer layer)
          Check if this instance will paint anything at the level of the given Layer.
 void paintSnapshot(java.awt.Graphics2D g, Layer layer, java.util.List<Layer> layers, java.awt.Rectangle srcRect, double mag)
           
 boolean popNode(Node<T> node)
          Remove a node only (not its subtree).
 boolean remove2(boolean check)
          Remove also from the trees if present; does nothing more than remove(boolean) unless overriden.
protected  void removeFromLinkLater(Node<T> nd)
           
 void removeNode(Node<T> node)
          If the tree is a cyclic graph, it may destroy all.
 Bureaucrat removeReviews()
           
 void repaint(boolean repaint_navigator, Layer la)
          Repaints in the given ImageCanvas only the area corresponding to the bounding box of this Pipe.
 boolean reRoot(float x, float y, Layer layer, double magnification)
          Reroots at the point closest to the x,y,layer_id world coordinate.
 boolean reRoot(Node<T> nd)
           
protected  void setActive(Node<T> nd)
           
protected  Node<T> setEdgeConfidence(byte confidence)
          Find an edge near the world coords x,y,layer with precision depending upon magnification, and adjust its confidence to @param confidence.
protected  void setLastAdded(Node<T> nd)
           
protected  void setLastEdited(Node<T> nd)
           
protected  void setLastMarked(Node<T> nd)
           
protected  void setLastVisited(Node<T> nd)
           
 void setRoot(Node<T> new_root)
          Used when reconstructing from XML.
 java.util.List<Tree<T>> splitAt(Node<T> nd)
           
 java.util.List<Tree<T>> splitNear(float x, float y, Layer layer, double magnification)
          Split the Tree into new Tree at the point closest to the x,y,layer world coordinate.
protected  Layer toClosestPaintedNode(Layer active_layer, float wx, float wy, double magnification)
          Also sets the last visited and the receiver node.
 boolean unmark()
           
protected  void updateView()
           
protected  void updateViewData(Node<?> node)
           
 
Methods inherited from class ini.trakem2.display.ZDisplayable
exportDTD, getBucketable, getLayerSet, remove, setColor, setLayer, setLayerSet, setLayerSet, setPosition, setVisible, softRemove, transformPoints, updateBucket, updateBucket
 
Methods inherited from class ini.trakem2.display.Displayable
adjustProperties, areThereLayerCrossLinks, canSendTo, clone, clone, clone, commonDTDChildren, contains, displacePoints, exportSVG, findById, findNearestPoint, findNearestPoint, getAffineTransform, getAffineTransformCopy, getAlpha, getAnnotation, getArea, getAreaForBucket, getBoundingBox, getBoundingBox, getBoundingBox, getBounds, getColor, getComposite, getComposite, getCompositeMode, getHeight, getIntersection, getLayer, getLinked, getLinked, getLinkedBox, getLinkedGroup, getLinkedProperties, getLinkedProperties, getLinkedProperty, getLinkedProperty, getMinimalBoundingBox, getNameId, getPerimeter, getPerimeter, getProperties, getProperty, getProperty, getTitle, getWidth, getX, getXMLSafeValue, getXMLSafeValue, getY, hasLinkedGroupWithinLayer, hasProperties, intersects, intersects, inverseTransformPoint, isLinked, isLinked, isLinked, isLocked, isLocked2, isOnlyLinkedTo, isOnlyLinkedTo, isOutOfRepaintingClip, isOutOfRepaintingClip, isVisible, link, link, makeAdjustPropertiesDialog, paintAsBox, paintOffscreen, 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, getInfo, getProject, getUniqueIdentifier, removeFromDatabase, updateInDatabase
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

node_layer_map

protected final java.util.Map<Layer,java.util.Set<Node<T>>> node_layer_map

end_nodes

protected final java.util.Set<Node<T>> end_nodes

root

protected Node<T> root
Constructor Detail

Tree

protected Tree(Project project,
               java.lang.String title)

Tree

protected Tree(Project project,
               long id,
               java.util.HashMap<java.lang.String,java.lang.String> ht_attr,
               java.util.HashMap<Displayable,java.lang.String> ht_links)
Reconstruct from XML.


Tree

protected Tree(Project project,
               long id,
               java.lang.String title,
               float width,
               float height,
               float alpha,
               boolean visible,
               java.awt.Color color,
               boolean locked,
               java.awt.geom.AffineTransform at)
For cloning purposes, does not call addToDatabase(), neither creates any root node.

Method Detail

getNodesToPaint

protected final java.util.Set<Node<T>> getNodesToPaint(Layer active_layer)

getNodesToPaint

protected final java.util.Set<Node<T>> getNodesToPaint(Layer active_layer,
                                                       java.util.List<Layer> color_cue_layers)

paint

public final 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

paint

public final 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 with_arrows)

getPaintingBounds

protected java.awt.Rectangle getPaintingBounds()

getBounds

public java.awt.Rectangle getBounds(java.awt.Rectangle tmp,
                                    Layer layer)
Description copied from class: Displayable
Will fill bounding box values into given rectangle -- only that part of this object showing in the given layer will be included in the box. If @param r is null, returns a new Rectangle; else, sets the bounds into @param r and returns it. If there aren't any bounds for this object at @param layer, returns either @param r with zero width and zero height, or a new Rectangle with zero width and zero height. Never returns null.

Overrides:
getBounds in class Displayable

getBounds

protected java.awt.Rectangle getBounds(java.util.Collection<Node<T>> nodes)

calculateBoundingBox

protected boolean calculateBoundingBox(Layer la)
Specified by:
calculateBoundingBox in class ZDisplayable

repaint

public void repaint(boolean repaint_navigator,
                    Layer la)
Repaints in the given ImageCanvas only the area corresponding to the bounding box of this Pipe.


intersects

public boolean intersects(java.awt.geom.Area area,
                          double z_first,
                          double z_last)
Specified by:
intersects in class ZDisplayable

getFirstLayer

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

Specified by:
getFirstLayer in class ZDisplayable

addToLinkLater

protected final void addToLinkLater(Node<T> nd)

removeFromLinkLater

protected final void removeFromLinkLater(Node<T> nd)

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.

newInstance

protected abstract Tree<T> newInstance()
Create a new instance, intialized with same ZDisplayable-level parameters (affine, color, title, etc.).


newNode

protected abstract Node<T> newNode(float lx,
                                   float ly,
                                   Layer layer,
                                   Node<?> modelNode)

createNewNode

protected Node<T> createNewNode(float lx,
                                float ly,
                                Layer layer,
                                Node<?> modelNode)
Create a new node, copying some properties from the modelNode such as radius or color. The modelNode should be the node that will become the parent of the new node, but it doesn't have to be.


newNode

public abstract Node<T> newNode(java.util.HashMap<java.lang.String,java.lang.String> ht_attr)
To reconstruct from XML.


isDeletable

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

exportDTD

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


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

exportXMLNodeAttributes

protected abstract boolean exportXMLNodeAttributes(java.lang.StringBuilder indent,
                                                   java.lang.StringBuilder sb,
                                                   Node<T> node)

exportXMLNodeData

protected abstract boolean exportXMLNodeData(java.lang.StringBuilder indent,
                                             java.lang.StringBuilder sb,
                                             Node<T> node)

generateTriangles

@Deprecated
public java.util.List<javax.vecmath.Point3f> generateTriangles(double scale_,
                                                                          int parallels,
                                                                          int resample)
Deprecated. 

See Also:
generateSkeleton

generateSkeleton

public Tree.MeshData generateSkeleton(double scale_,
                                      int parallels,
                                      int resample)
Returns:
a CustomLineMesh.PAIRWISE list for a LineMesh.

reRoot

public boolean reRoot(float x,
                      float y,
                      Layer layer,
                      double magnification)
Reroots at the point closest to the x,y,layer_id world coordinate.

Returns:
true on success.

reRoot

public boolean reRoot(Node<T> nd)
Parameters:
nd - A node of this Tree.

splitNear

public java.util.List<Tree<T>> splitNear(float x,
                                         float y,
                                         Layer layer,
                                         double magnification)
Split the Tree into new Tree at the point closest to the x,y,layer world coordinate.

Returns:
null if no node was found near the x,y,layer point with precision dependent on magnification.

splitAt

public java.util.List<Tree<T>> splitAt(Node<T> nd)
Parameters:
nd - A node of this Tree.

cacheSubtree

protected void cacheSubtree(java.lang.Iterable<Node<T>> nodes)

clearCache

protected void clearCache()

contains

public boolean contains(Layer layer,
                        int x,
                        int y)
Returns true if the given point falls within a certain distance of any of the treeline segments, where a segment is defined as the line between a clicked point and the next.

Overrides:
contains in class Displayable

isAnyNear

protected boolean isAnyNear(java.util.Collection<Node<T>> nodes,
                            float lx,
                            float ly,
                            float radius)

getRoot

public Node<T> getRoot()

createCoordinate

protected Coordinate<Node<T>> createCoordinate(Node<T> nd)

findPreviousBranchOrRootPoint

public Coordinate<Node<T>> findPreviousBranchOrRootPoint(float x,
                                                         float y,
                                                         Layer layer,
                                                         DisplayCanvas dc)

findNextBranchOrEndPoint

public Coordinate<Node<T>> findNextBranchOrEndPoint(float x,
                                                    float y,
                                                    Layer layer,
                                                    DisplayCanvas dc)
If the node found near x,y,layer is a branch point, returns it; otherwise the next down the chain; on reaching an end point, returns it.


findNearAndGetNext

protected Coordinate<Node<T>> findNearAndGetNext(float x,
                                                 float y,
                                                 Layer layer,
                                                 DisplayCanvas dc)

findNearAndGetPrevious

protected Coordinate<Node<T>> findNearAndGetPrevious(float x,
                                                     float y,
                                                     Layer layer,
                                                     DisplayCanvas dc)

getLastEdited

public Coordinate<Node<T>> getLastEdited()

getLastAdded

public Coordinate<Node<T>> getLastAdded()

setEdgeConfidence

protected Node<T> setEdgeConfidence(byte confidence)
Find an edge near the world coords x,y,layer with precision depending upon magnification, and adjust its confidence to @param confidence.

Returns:
the node whose parent edge is altered, or null if none found.

adjustEdgeConfidence

protected Node<T> adjustEdgeConfidence(int inc,
                                       float x,
                                       float y,
                                       Layer layer,
                                       DisplayCanvas dc)
Expects world coordinates.


findNode

public Node<T> findNode(float lx,
                        float ly,
                        Layer layer,
                        double magnification)
Find a node in @param layer near the local coords lx,ly, with precision depending on magnification.


findClosestNodeW

public Node<T> findClosestNodeW(float wx,
                                float wy,
                                Layer layer,
                                double magnification)
Expects world coords; with precision depending on magnification.


findClosestNodeW

public Node<T> findClosestNodeW(java.util.Collection<Node<T>> nodes,
                                float wx,
                                float wy,
                                double magnification)
Expects world coords; with precision depending on magnification.


toClosestPaintedNode

protected Layer toClosestPaintedNode(Layer active_layer,
                                     float wx,
                                     float wy,
                                     double magnification)
Also sets the last visited and the receiver node. This is a GUI method.


findClosestNode

public Node<T> findClosestNode(java.util.Collection<Node<T>> nodes,
                               float lx,
                               float ly,
                               double magnification)
Expects local coords; with precision depending on magnification.


findNearestNode

public Node<T> findNearestNode(float lx,
                               float ly,
                               Layer layer)
Find the spatially closest node, in calibrated coords; expects local coords.


findNearestEndNode

public Node<T> findNearestEndNode(float lx,
                                  float ly,
                                  Layer layer)
Find the spatially closest node, in calibrated coords.


insertNode

public boolean insertNode(Node<T> parent,
                          Node<T> child,
                          Node<T> in_between,
                          byte confidence)

findNearestEdge

public Node<T>[] findNearestEdge(float x_pl,
                                 float y_pl,
                                 Layer layer,
                                 double magnification)
Considering only the set of consecutive layers currently painted, find a point near an edge with accuracy depending upon magnification.

Returns:
null if none of the edges is close enough, or an array of parent and child describing the edge.

addNode

public boolean addNode(Node<T> parent,
                       Node<T> child,
                       byte confidence)
Will call calculateBoundingBox and repaint.


popNode

public boolean popNode(Node<T> node)
Remove a node only (not its subtree).

Returns:
true on success. Will return false when the node has 2 or more children. The new edge confidence is that of the parent to the @param node.

removeNode

public void removeNode(Node<T> node)
If the tree is a cyclic graph, it may destroy all.


canJoin

public boolean canJoin(java.util.List<? extends Tree<T>> ts)
Join all given Trees by using the first one as the receiver, and all the others as the ones to be merged into the receiver. Requires each Tree to have a non-null marked Node; otherwise, returns false.


join

public boolean join(java.util.List<? extends Tree<T>> ts)

findNodeNear

protected Node<T> findNodeNear(float x,
                               float y,
                               Layer layer,
                               DisplayCanvas dc)

findNodeNear

protected Node<T> findNodeNear(float x,
                               float y,
                               Layer layer,
                               DisplayCanvas dc,
                               boolean use_receiver_when_null)
Expects world coordinates. If no node is near x,y but there is only one node in the current Display view of the layer, then it returns that node.


markNear

public boolean markNear(float x,
                        float y,
                        Layer layer,
                        double magnification)

unmark

public boolean unmark()

setActive

protected void setActive(Node<T> nd)

getActive

protected Node<T> getActive()

setLastEdited

protected void setLastEdited(Node<T> nd)

setLastAdded

protected void setLastAdded(Node<T> nd)

setLastMarked

protected void setLastMarked(Node<T> nd)

setLastVisited

protected void setLastVisited(Node<T> nd)

getMarked

public Node<T> getMarked()

getLastVisited

public Node<T> getLastVisited()

deselect

public void deselect()
Description copied from class: Displayable
Tell this Displayable that is has been deselected from a Display. If multiple displays have the same Displayable in their Selection, this Diplayabale is to act as if it has been deselected from all.

Overrides:
deselect in class Displayable

fireNodeRemoved

protected void fireNodeRemoved(Node<T> nd)

clearState

protected void clearState()

mousePressed

public void mousePressed(java.awt.event.MouseEvent me,
                         Layer layer,
                         int x_p,
                         int y_p,
                         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

isTagging

protected boolean isTagging()

keyPressed

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

mouseWheelMoved

public void mouseWheelMoved(java.awt.event.MouseWheelEvent mwe)
Description copied from class: Displayable
Does nothing unless overriden.

Overrides:
mouseWheelMoved in class Displayable

setRoot

public void setRoot(Node<T> new_root)
Used when reconstructing from XML.


paintSnapshot

public void paintSnapshot(java.awt.Graphics2D g,
                          Layer layer,
                          java.util.List<Layer> layers,
                          java.awt.Rectangle srcRect,
                          double mag)
Overrides:
paintSnapshot in class Displayable

getEndNodes

public java.util.Set<Node<T>> getEndNodes()

flyThroughMarked

public ij.ImagePlus flyThroughMarked(int width,
                                     int height,
                                     double magnification,
                                     int type,
                                     java.lang.String dir)
Fly-through image stack from source node to mark node.

Parameters:
type - is ImagePlus.GRAY8 or .COLOR_RGB

generateRegions

public java.util.LinkedList<Region<Node<T>>> generateRegions(Node<T> first,
                                                             Node<T> last,
                                                             int width,
                                                             int height,
                                                             double magnification)

flyThrough

public ij.ImagePlus flyThrough(Node<T> first,
                               Node<T> last,
                               int width,
                               int height,
                               double magnification,
                               int type,
                               java.lang.String dir)
Fly-through image stack from first to last node. If first is not lower order than last, then start to last is returned.

Parameters:
type - is ImagePlus.GRAY8 or .COLOR_RGB

measure

public ij.measure.ResultsTable measure(ij.measure.ResultsTable rt)
Measures number of branch points and end points, and total cable length. Cable length is measured as: Cable length: the sum of all distances between all consecutive pairs of nodes. Lower-bound cable length: the sum of all distances between all end points to branch points, branch points to other branch points, and first branch point to root.

Overrides:
measure in class Displayable

intersects

public boolean intersects(Layer layer,
                          java.awt.Rectangle r)
Expects Rectangle in world coords.

Overrides:
intersects in class Displayable

intersects

public boolean intersects(Layer layer,
                          java.awt.geom.Area area)
Expects Area in world coords.

Overrides:
intersects in class Displayable

findFirstIntersectingNode

protected Node<T> findFirstIntersectingNode(java.util.Set<Node<T>> nodes,
                                            java.awt.geom.Area a)
Expects an Area in local coordinates.


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

createMultiTableView

public java.util.concurrent.Future<javax.swing.JFrame> createMultiTableView()
Create a GUI to list, in three tabs: starting point, branch points, end points, and all points. The table has columns for X, Y, Z, data (radius or area), Layer, and tags. Double-click on a row positions the front display at that coordinate. An extra tab has a search field, to list nodes for a given typed-in (regex) tag.


updateView

protected void updateView()

updateViewData

protected void updateViewData(Node<?> node)

remove2

public boolean remove2(boolean check)
Description copied from class: Displayable
Remove also from the trees if present; does nothing more than remove(boolean) unless overriden.

Overrides:
remove2 in class ZDisplayable

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 ict)
              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.
ict - 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

getLayersWithData

public java.util.Collection<Layer> getLayersWithData()
Description copied from class: Displayable
Override it to provide Layer pointers directly.

Overrides:
getLayersWithData in class Displayable

getAreaAt

public java.awt.geom.Area getAreaAt(Layer layer)
In world coordinates. Returns an empty area when there aren't any nodes in @param layer.

Overrides:
getAreaAt in class Displayable

isRoughlyInside

protected boolean isRoughlyInside(Layer layer,
                                  java.awt.Rectangle box)
Fast and dirty, never returns a false negative but may return a false positive.

Overrides:
isRoughlyInside in class Displayable

crop

public boolean crop(java.util.List<Layer> range)
Retain the data within the layer range, and through out all the rest. Does NOT call calculateBoundingBox or updateBucket; that is your responsibility.

Overrides:
crop in class ZDisplayable

generateAllReviewStacks

public Bureaucrat generateAllReviewStacks()

generateSubtreeReviewStacks

public Bureaucrat generateSubtreeReviewStacks(Node<T> root)

createReviewStack

public void createReviewStack(Node<T> first,
                              Node<T> last,
                              Tag tag,
                              java.lang.String filepath,
                              int width,
                              int height,
                              double magnification,
                              int image_type)
The behavior is undefined if @param last is not a descendant of @param first.


removeReviews

public Bureaucrat removeReviews()

findIntersecting

public java.util.Map<Node<T>,java.util.Collection<Displayable>> findIntersecting(java.lang.Class<?> c)
                                                                          throws java.lang.Exception
Throws:
java.lang.Exception

findConnectors

public java.util.List<Connector>[] findConnectors()
                                           throws java.lang.Exception
Returns an array of two Collection of connectors: the first one has the outgoing connectors, and the second one has the incoming connectors.

Throws:
java.lang.Exception

getShortTitle

public java.lang.String getShortTitle()
Description copied from class: DBObject
Sublcasses can override this method to provide a proper String, otherwise calls getTitle()

Overrides:
getShortTitle in class Displayable

getOriginPoint

public javax.vecmath.Point3f getOriginPoint(boolean calibrated)

fix

protected javax.vecmath.Point3f fix(javax.vecmath.Point3f p,
                                    boolean calibrated,
                                    float[] f)
Expects a non-null float[] for reuse, and modifies @param p in place.


duplicateAs

public static <A extends Tree<?>> java.util.Map<Tree<?>,Tree<?>> duplicateAs(java.util.Collection<Displayable> col,
                                                                             java.lang.Class<A> target)
                                                  throws java.lang.Exception
Takes a collection of Tree instances and creates duplicate siblings of the target class. Will ignore any non-tree Displayable instances in the Collection. The duplicated trees are added to the ProjectTree as siblings of the originals, and to the LayerSet.

Returns:
The map of original trees vs copies in target class form.
Throws:
java.lang.Exception

copyAs

public static <A extends Tree<?>,B extends Node<?>> A copyAs(Tree<?> src,
                                                             java.lang.Class<A> tree_class,
                                                             java.lang.Class<B> node_class)
                                throws java.lang.Exception
Can copy a Treeline to an AreaTree and viceversa. Copies the transform, the nodes (with tags and confidence), and the color. The transparency, locked stated and links are not copied.

Throws:
java.lang.Exception

generateReviewStackForSlab

public Bureaucrat generateReviewStackForSlab(float x,
                                             float y,
                                             Layer layer,
                                             double magnification)
Returns:
null if no node is near @param x, @param y

generateSubtreeReviewStacks

public Bureaucrat generateSubtreeReviewStacks(int x,
                                              int y,
                                              Layer layer,
                                              double magnification)

generateReviewStackForSlab

public Bureaucrat generateReviewStackForSlab(Node<T> node)
Generate a review stack from the previous branch node or root, to the next branch node or end node.


measurePathDistance

public ij.measure.ResultsTable measurePathDistance(Node<T> a,
                                                   Node<T> b,
                                                   ij.measure.ResultsTable rt)
Reuses @param rt unless it is null, in which case it creates a new one. Will check if both nodes belong to this tree.

Returns:
The used ResultsTable instance.

measurePathDistance

public double measurePathDistance(Node<T> a,
                                  Node<T> b)
                           throws java.lang.Exception
Measure the distance, in calibrated units, between nodes a and b of this tree. Does not check if the nodes really belong to this tree.

Throws:
java.lang.Exception

findTags

public java.util.Set<Tag> findTags()
Search all nodes for unique tags and returns them.


destroy

public void destroy()
Description copied from class: Displayable
Release resources.

Overrides:
destroy in class Displayable

computeAllDegrees

public java.util.HashMap<Node<T>,java.lang.Integer> computeAllDegrees()

getBranchNodes

public java.util.Collection<Node<T>> getBranchNodes()

getBranchAndEndNodes

public java.util.Collection<Node<T>> getBranchAndEndNodes()

asVertices

public java.util.HashMap<Node<T>,Vertex<Node<T>>> asVertices()
Return a representation of this Tree with Vertex instead of Node.


computeCentrality

public java.util.HashMap<Node<T>,java.lang.Float> computeCentrality()
Computes betweenness centrality of each node in the tree, using Ulrik Brandes betweenness centrality algorithm.