public class Viewer3D
extends java.lang.Object
org.jzy3d
package.Modifier and Type | Class and Description |
---|---|
static class |
Viewer3D.ViewMode
Presets of a scene's view point.
|
Constructor and Description |
---|
Viewer3D()
Instantiates Viewer3D without the 'Controls' dialog ('kiosk mode').
|
Viewer3D(org.scijava.Context context)
Instantiates an interactive Viewer3D with GUI Controls to import, manage
and customize the Viewer's scene.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.Object object)
|
void |
addColorBarLegend(net.imglib2.display.ColorTable colorTable,
double min,
double max)
Adds a color bar legend (LUT ramp) using default settings.
|
void |
addColorBarLegend(net.imglib2.display.ColorTable colorTable,
double min,
double max,
java.awt.Font font,
int steps,
int precision)
Adds a color bar legend (LUT ramp).
|
void |
addLabel(java.lang.String label)
Adds an annotation label to the scene.
|
boolean |
addMesh(OBJMesh objMesh)
Loads a Wavefront .OBJ file.
|
void |
addTree(Tree tree)
Adds a tree to this viewer.
|
Annotation3D |
annotateLine(java.util.Collection<? extends SNTPoint> points,
java.lang.String label)
Adds a line annotation to this viewer.
|
Annotation3D |
annotatePoint(SNTPoint point,
java.lang.String label)
Adds an highlighting point annotation to this viewer.
|
Annotation3D |
annotatePoints(java.util.Collection<? extends SNTPoint> points,
java.lang.String label)
Adds a scatter (point cloud) annotation to this viewer.
|
Annotation3D |
annotateSurface(java.util.Collection<? extends SNTPoint> points,
java.lang.String label)
Computes a Delaunay surface from a collection of points and adds it to the
scene as an annotation.
|
double[] |
colorCode(java.util.Collection<java.lang.String> treeLabels,
java.lang.String measurement,
net.imglib2.display.ColorTable colorTable)
Runs
MultiTreeColorMapper on the specified collection of
Tree s. |
double[] |
colorCode(java.lang.String treeLabel,
java.lang.String measurement,
net.imglib2.display.ColorTable colorTable)
Runs
TreeColorMapper on the specified Tree . |
void |
dispose()
Closes and releases all the resources used by this viewer.
|
boolean |
equals(java.lang.Object o) |
int |
getID()
Returns this Viewer's id.
|
boolean |
isDarkModeOn()
Checks if scene is being rendered under dark or light background.
|
boolean |
isSNTInstance()
Checks whether this instance is SNT's Reconstruction Viewer.
|
OBJMesh |
loadMesh(java.lang.String filePath,
org.scijava.util.ColorRGB color,
double transparencyPercent)
Loads a Wavefront .OBJ file.
|
OBJMesh |
loadRefBrain(java.lang.String template)
Loads the surface mesh of a supported reference brain/neuropil.
|
void |
logSceneControls()
Logs API calls controlling the scene (view point, bounds, etc.) to Console.
|
static void |
main(java.lang.String[] args) |
Annotation3D |
mergeAnnotations(java.util.Collection<Annotation3D> annotations,
java.lang.String label)
Merges a collection of annotations into a single object.
|
void |
recordRotation(float angle,
int frames,
java.io.File destinationDirectory)
Records an animated rotation of the scene as a sequence of images.
|
void |
remove(java.lang.Object object)
|
void |
removeAllMeshes()
Removes all loaded OBJ meshes from current viewer
|
void |
removeAllTrees()
Removes all the Trees from current viewer
|
boolean |
removeMesh(OBJMesh mesh)
Removes the specified OBJ mesh.
|
boolean |
removeMesh(java.lang.String meshLabel)
Removes the specified OBJ mesh.
|
boolean |
removeTree(java.lang.String treeLabel)
Removes the specified Tree.
|
boolean |
removeTree(Tree tree)
Removes the specified Tree.
|
void |
rotate(float degrees)
Rotates the scene.
|
boolean |
saveSnapshot()
Saves a snapshot of current scene as a PNG image.
|
boolean |
saveSnapshot(java.lang.String filePath)
Saves a snapshot of current scene as a PNG image to the specified path.
|
void |
setAnimationEnabled(boolean enabled)
Toggles the Viewer's animation.
|
void |
setBounds(float xMin,
float xMax,
float yMin,
float yMax,
float zMin,
float zMax)
Sets a manual bounding box for the scene.
|
void |
setDefaultColor(org.scijava.util.ColorRGB color)
Sets the default color for rendering
Tree s. |
void |
setDefaultThickness(float thickness)
Sets the line thickness for rendering
Tree s that have no specified
radius. |
void |
setEnableDarkMode(boolean enable)
Enables/disables "Dark Mode" mode
|
void |
setEnableDebugMode(boolean enable)
Enables/disables debug mode
|
void |
setFont(java.awt.Font font,
float angle,
org.scijava.util.ColorRGB color)
Sets the font for label annotations
|
void |
setFrameSize(int width,
int height)
Resizes the viewer to the specified dimensions.
|
void |
setLabelLocation(float x,
float y)
Sets the location for annotation labels
|
void |
setSceneUpdatesEnabled(boolean enabled)
Sets whether the scene should update (refresh) every time a new
reconstruction (or mesh) is added/removed from the scene.
|
void |
setSnapshotDir(java.lang.String path)
Sets the directory for storing snapshots.
|
void |
setSomasDisplayed(boolean displayed)
Toggles the visibility of somas for all trees in the scene.
|
void |
setSomasDisplayed(java.util.Collection<java.lang.String> labels,
boolean displayed)
Toggles the visibility of somas for subset of trees.
|
void |
setTreesThickness(java.util.Collection<java.lang.String> labels,
float thickness)
Applies a constant thickness (line width) to a subset of rendered trees.
|
void |
setTreesThickness(float thickness)
Applies a constant thickness to all rendered trees.
|
void |
setViewMode(Viewer3D.ViewMode viewMode)
Renders the scene from a specified camera angle.
|
void |
setViewPoint(double r,
double t)
Renders the scene from a specified camera angle using polar coordinates
relative to the the center of the scene.
|
void |
setViewPointCC(double x,
double y)
Calls
setViewPoint(double, double) using Cartesian coordinates. |
void |
setVisible(java.lang.String label,
boolean visible)
Toggles the visibility of a rendered Tree, a loaded OBJ mesh, or an
annotation.
|
java.awt.Frame |
show()
Displays the Viewer and returns a reference to its frame.
|
java.awt.Frame |
show(int width,
int height)
Displays the viewer under specified dimensions.
|
boolean |
syncPathManagerList()
(Re)loads the current list of Paths in the Path Manager list.
|
void |
translate(java.util.Collection<java.lang.String> treeLabels,
SNTPoint offset)
Translates the specified collection of
Tree s. |
void |
translate(Tree tree,
SNTPoint offset)
Translates the specified Tree.
|
void |
updateColorBarLegend(double min,
double max)
Updates the existing color bar legend to new properties.
|
void |
updateView()
Updates the scene bounds to ensure all visible objects are displayed.
|
void |
validate()
Checks if all drawables in the 3D scene are being rendered properly,
rebuilding the entire scene if not.
|
public Viewer3D()
Tree
s to
be added concurrently.public Viewer3D(org.scijava.Context context)
context
- the SciJava application context providing the services
required by the classpublic int getID()
public void setSceneUpdatesEnabled(boolean enabled)
enabled
- Whether scene updates should be enabledpublic void validate()
updateView()
public void setEnableDebugMode(boolean enable)
enable
- true to enable debug mode, otherwise falsepublic void setEnableDarkMode(boolean enable)
enable
- true to enable "Dark Mode", "Light Mode" otherwisepublic void rotate(float degrees) throws java.lang.IllegalArgumentException
degrees
- the angle, in degreesjava.lang.IllegalArgumentException
- if current view mode does not allow
rotationspublic void recordRotation(float angle, int frames, java.io.File destinationDirectory) throws java.lang.IllegalArgumentException, java.lang.SecurityException
angle
- the rotation angle (e.g., 360 for a full rotation)frames
- the number of frames in the animated sequencedestinationDirectory
- the directory where the image sequence will be
stored.java.lang.IllegalArgumentException
- if no view exists, or current view is
constrained and does not allow 360 degrees rotationjava.lang.SecurityException
- if it was not possible to save files to
destinationDirectory
public boolean isDarkModeOn()
public void addTree(Tree tree)
updateView()
may be
required to ensure that the current View's bounding box includes the added
Tree.tree
- the Tree
to be added. The Tree's label will be used as
identifier. It is expected to be unique when rendering multiple
Trees, if not (or no label exists) a unique label will be
generated.Tree.getLabel()
,
removeTree(String)
,
updateView()
public Annotation3D annotateSurface(java.util.Collection<? extends SNTPoint> points, java.lang.String label)
points
- the collection of points defining the triangulated surfacelabel
- the (optional) annotation identifier. If null or empty, a
unique label will be generated.Annotation3D
public Annotation3D annotatePoint(SNTPoint point, java.lang.String label)
point
- the point to be highlightedlabel
- the (optional) annotation identifier. If null or empty, a unique
label will be generated.Annotation3D
public Annotation3D annotatePoints(java.util.Collection<? extends SNTPoint> points, java.lang.String label)
points
- the collection of points in the annotationlabel
- the (optional) annotation identifier. If null or empty, a
unique label will be generated.Annotation3D
public Annotation3D annotateLine(java.util.Collection<? extends SNTPoint> points, java.lang.String label)
points
- the collection of points in the line annotation (at least 2
elements required). Start and end of line are highlighted if 2
points are specified.label
- the (optional) annotation identifier. If null or empty, a
unique label will be generated.Annotation3D
or null if collection contains less than 2
elementspublic Annotation3D mergeAnnotations(java.util.Collection<Annotation3D> annotations, java.lang.String label)
annotations
- the collection of annotations.label
- the (optional) identifier for the merged annotation. If
null or empty, a unique label will be generated.Annotation3D
public void updateView()
rebuild()
public void addColorBarLegend(net.imglib2.display.ColorTable colorTable, double min, double max)
colorTable
- the color tablemin
- the minimum value in the color tablemax
- the maximum value in the color tablepublic void updateColorBarLegend(double min, double max)
min
- the minimum value in the color tablemax
- the maximum value in the color tablepublic void addColorBarLegend(net.imglib2.display.ColorTable colorTable, double min, double max, java.awt.Font font, int steps, int precision)
colorTable
- the color tablemin
- the minimum value in the color tablemax
- the maximum value in the color tablefont
- the font the legend font.steps
- the number of ticks in the legend. Tick placement is computed
automatically if negative.precision
- the number of decimal places of tick labels. scientific
notation is used if negative.public java.awt.Frame show()
public java.awt.Frame show(int width, int height)
width
- the width of the frameheight
- the height of the frameshow()
public void setFrameSize(int width, int height)
width
- the width of the frameheight
- the height of the frameshow(int, int)
public boolean removeTree(Tree tree)
tree
- the tree to be removed.addTree(Tree)
public boolean removeTree(java.lang.String treeLabel)
treeLabel
- the key defining the tree to be removed.addTree(Tree)
public boolean removeMesh(OBJMesh mesh)
mesh
- the OBJ mesh to be removed.loadMesh(String, ColorRGB, double)
public boolean removeMesh(java.lang.String meshLabel)
meshLabel
- the key defining the OBJ mesh to be removed.loadMesh(String, ColorRGB, double)
public void removeAllMeshes()
public void removeAllTrees()
public void add(java.lang.Object object)
Tree
,
OBJMesh
, AbstractDrawable
, etc.) to this viewer.object
- the object to be addedjava.lang.IllegalArgumentException
- if object is not supportedpublic void remove(java.lang.Object object)
Tree
, OBJMesh
,
AbstractDrawable
, etc.) from this viewer's scene.object
- the object to be removed, or the unique String identifying itjava.lang.IllegalArgumentException
- if object is not supportedpublic boolean syncPathManagerList() throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationException
- if SNT is not runningpublic void setVisible(java.lang.String label, boolean visible)
label
- the unique identifier of the Tree (as per
addTree(Tree)
), the filename/identifier of the loaded
OBJ loadMesh(String, ColorRGB, double)
, or annotation
label.visible
- whether the Object should be displayedpublic double[] colorCode(java.util.Collection<java.lang.String> treeLabels, java.lang.String measurement, net.imglib2.display.ColorTable colorTable)
MultiTreeColorMapper
on the specified collection of
Tree
s.treeLabels
- the collection of Tree identifiers (as per
addTree(Tree)
) specifying the Trees to be color mappedmeasurement
- the mapping measurement e.g.,
MultiTreeColorMapper.TOTAL_LENGTH
MultiTreeColorMapper.TOTAL_N_TIPS
, etc.colorTable
- the mapping color table (LUT), e.g.,
ColorTables.ICE
), or any other known to LutServicepublic void setAnimationEnabled(boolean enabled)
enabled
- if true animation starts. Stops if falsepublic void setBounds(float xMin, float xMax, float yMin, float yMax, float zMin, float zMax)
xMin
- the X coordinate of the box originxMax
- the X coordinate of the box origin oppositeyMin
- the Y coordinate of the box originyMax
- the Y coordinate of the box origin oppositezMin
- the Z coordinate of the box originzMax
- the X coordinate of the box origin oppositepublic double[] colorCode(java.lang.String treeLabel, java.lang.String measurement, net.imglib2.display.ColorTable colorTable)
TreeColorMapper
on the specified Tree
.treeLabel
- the identifier of the Tree (as per addTree(Tree)
)to
be color mappedmeasurement
- the mapping measurement e.g.,
TreeColorMapper.BRANCH_ORDER
TreeColorMapper.PATH_DISTANCE
, etc.colorTable
- the mapping color table (LUT), e.g.,
ColorTables.ICE
), or any other known to LutServicepublic void setViewMode(Viewer3D.ViewMode viewMode)
viewMode
- the view mode, e.g., Viewer3D.ViewMode.DEFAULT
,
Viewer3D.ViewMode.SIDE
, etc.public void setViewPoint(double r, double t)
logSceneControls()
.r
- the radial coordinatet
- the angle coordinate (in radians)public void setViewPointCC(double x, double y)
setViewPoint(double, double)
using Cartesian coordinates.x
- the X coordinatey
- the Y coordinatepublic void addLabel(java.lang.String label)
label
- the annotation textsetFont(Font, float, ColorRGB)
,
setLabelLocation(float, float)
public void setLabelLocation(float x, float y)
x
- the x position of the labely
- the y position of the labelpublic void setFont(java.awt.Font font, float angle, org.scijava.util.ColorRGB color)
font
- the font label, e.g.,
new Font(Font.SANS_SERIF, Font.ITALIC, 20)
angle
- the angle in degrees for rotated labelscolor
- the font color, e.g., org.scijava.util.Colors.ORANGE
public boolean saveSnapshot()
setSnapshotDir(String)
public boolean saveSnapshot(java.lang.String filePath)
filePath
- the absolute path of the destination filepublic void setSnapshotDir(java.lang.String path)
path
- the absolute path to the new snapshot directory.public OBJMesh loadMesh(java.lang.String filePath, org.scijava.util.ColorRGB color, double transparencyPercent) throws java.lang.IllegalArgumentException
validate()
should be called to ensure all meshes are visible.filePath
- the absolute file path (or URL) of the file to be imported.
The filename is used as unique identifier of the object (see
setVisible(String, boolean)
)color
- the color to render the imported filetransparencyPercent
- the color transparency (in percentage)java.lang.IllegalArgumentException
- if filePath is invalid or file does not
contain a compilable meshpublic boolean addMesh(OBJMesh objMesh) throws java.lang.IllegalArgumentException
validate()
should be
called to ensure all meshes are visible.objMesh
- the mesh to be loadedjava.lang.IllegalArgumentException
- if mesh could not be compiledpublic OBJMesh loadRefBrain(java.lang.String template) throws java.lang.IllegalArgumentException
template
- the reference brain to be loaded (case-insensitive). E.g.,
"zebrafish" (MP ZBA); "mouse" (Allen CCF); "JFRC2", "JFRC3"
"FCWB" (adult), "L1", "L3", "VNC" (Drosophila)java.lang.IllegalArgumentException
- if template
is not recognizedAllenUtils
,
VFBUtils
,
ZBAtlasUtils
public void logSceneControls()
public void dispose()
public void setDefaultThickness(float thickness)
Tree
s that have no specified
radius.thickness
- the new line thickness. Note that this value only applies
to Paths that have no specified radiuspublic void setDefaultColor(org.scijava.util.ColorRGB color)
Tree
s.color
- the new color. Note that this value only applies to Paths that
have no specified color and no colors assigned to its nodespublic void setTreesThickness(java.util.Collection<java.lang.String> labels, float thickness)
labels
- the Collection of keys specifying the subset of treesthickness
- the thickness (line width)setTreesThickness(float)
public void setTreesThickness(float thickness)
thickness
- the thickness (line width)setTreesThickness(Collection, float)
public void translate(Tree tree, SNTPoint offset)
tree
- the Tree to be translatedoffset
- the translation offset. If null, tree position will be reset to
their original location.public void translate(java.util.Collection<java.lang.String> treeLabels, SNTPoint offset)
Tree
s.treeLabels
- the collection of Tree identifiers (as per
addTree(Tree)
) specifying the Trees to be translatedoffset
- the translation offset. If null, trees position will be reset
to their original location.public void setSomasDisplayed(java.util.Collection<java.lang.String> labels, boolean displayed)
labels
- the Collection of keys specifying the subset of trees to be
affecteddisplayed
- whether soma should be displayedpublic void setSomasDisplayed(boolean displayed)
displayed
- whether soma should be displayedpublic boolean isSNTInstance()
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public static void main(java.lang.String[] args) throws java.lang.InterruptedException
java.lang.InterruptedException