public class Model extends Object
This is a relatively large class, with a lot of public methods. This complexity arose because this class handles data storage and manipulation, through user manual editing and automatic processing. To avoid conflicting accesses to the data, some specialized methods had to be created, hopefully built in coherent sets.
Modifier and Type | Field and Description |
---|---|
protected SpotCollection |
spots
The spots managed by this model.
|
Constructor and Description |
---|
Model() |
Modifier and Type | Method and Description |
---|---|
org.jgrapht.graph.DefaultWeightedEdge |
addEdge(Spot source,
Spot target,
double weight)
Creates a new edge between two spots, with the specified weight.
|
void |
addModelChangeListener(ModelChangeListener listener) |
Spot |
addSpotTo(Spot spotToAdd,
Integer toFrame)
Adds a single spot to the collections managed by this model, mark it as
visible, then update its features.
|
void |
beginUpdate() |
void |
clearSpots(boolean doNotify)
Removes all the spots from this model.
|
void |
clearTracks(boolean doNotify)
Removes all the tracks from this model.
|
protected FeatureModel |
createFeatureModel()
Instantiates a blank
FeatureModel to use whithin this model. |
protected TrackModel |
createTrackModel()
Instantiates a blank
TrackModel to use whithin this model. |
void |
endUpdate() |
void |
filterSpots(Collection<FeatureFilter> spotFilters,
boolean doNotify)
Filters the
SpotCollection managed by this model with the
FeatureFilter s specified. |
FeatureModel |
getFeatureModel() |
Logger |
getLogger()
Return the logger currently set for this model.
|
Set<ModelChangeListener> |
getModelChangeListener() |
String |
getSpaceUnits()
Returns the spatial units for the quantities stored in this model.
|
SpotCollection |
getSpots()
Returns the spot collection managed by this model.
|
String |
getTimeUnits()
Returns the time units for the quantities stored in this model.
|
TrackModel |
getTrackModel()
Returns the
TrackModel that manages the tracks for this model. |
Spot |
moveSpotFrom(Spot spotToMove,
Integer fromFrame,
Integer toFrame)
Moves a single spot from a frame to another, make it visible if it was
not, then mark it for feature update.
|
void |
notifyFeaturesComputed()
Notify the
ModelChangeListener s of this model that feature values
have been computed. |
boolean |
removeEdge(org.jgrapht.graph.DefaultWeightedEdge edge)
Removes an existing edge from the model.
|
org.jgrapht.graph.DefaultWeightedEdge |
removeEdge(Spot source,
Spot target)
Removes an edge between two spots and returns it.
|
boolean |
removeModelChangeListener(ModelChangeListener listener) |
Spot |
removeSpot(Spot spotToRemove)
Removes a single spot from the collections managed by this model.
|
void |
setEdgeWeight(org.jgrapht.graph.DefaultWeightedEdge edge,
double weight)
Sets the weight of the specified edge.
|
void |
setLogger(Logger logger)
Set the logger that will receive the messages from the processes
occurring within this trackmate.
|
void |
setPhysicalUnits(String spaceUnits,
String timeUnits)
Sets the physical units for the quantities stored in this model.
|
void |
setSpots(SpotCollection spots,
boolean doNotify)
Set the
SpotCollection managed by this model. |
void |
setTracks(org.jgrapht.graph.SimpleWeightedGraph<Spot,org.jgrapht.graph.DefaultWeightedEdge> graph,
boolean doNotify)
Sets the tracks stored in this model in bulk.
|
boolean |
setTrackVisibility(Integer trackID,
boolean visible)
Sets the visibility of the specified track.
|
String |
toString() |
void |
updateFeatures(Spot spotToUpdate)
Mark the specified spot for update.
|
protected SpotCollection spots
protected TrackModel createTrackModel()
TrackModel
to use whithin this model.
Subclassers can override this method to have the model work with their
own subclass of TrackModel
.
TrackModel
.protected FeatureModel createFeatureModel()
FeatureModel
to use whithin this model.
Subclassers can override this method to have the model work with their
own subclass of FeatureModel
.
FeatureModel
.public void addModelChangeListener(ModelChangeListener listener)
public boolean removeModelChangeListener(ModelChangeListener listener)
public Set<ModelChangeListener> getModelChangeListener()
public void setPhysicalUnits(String spaceUnits, String timeUnits)
spaceUnits
- the spatial units (e.g. μm).timeUnits
- the time units (e.g. min).public String getSpaceUnits()
public String getTimeUnits()
public void beginUpdate()
public void endUpdate()
public void clearTracks(boolean doNotify)
doNotify
- if true
, model listeners will be notified with a
ModelChangeEvent.TRACKS_COMPUTED
event.public TrackModel getTrackModel()
TrackModel
that manages the tracks for this model.public void setTracks(org.jgrapht.graph.SimpleWeightedGraph<Spot,org.jgrapht.graph.DefaultWeightedEdge> graph, boolean doNotify)
Clears the tracks of this model and replace it by the tracks found by inspecting the specified graph. All new tracks found will be made visible and will be given a default name.
graph
- the graph to parse for tracks.doNotify
- if true
, model listeners will be notified with a
ModelChangeEvent.TRACKS_COMPUTED
event.public SpotCollection getSpots()
public void clearSpots(boolean doNotify)
doNotify
- if true
, model listeners will be notified with a
ModelChangeEvent.SPOTS_COMPUTED
event.public void setSpots(SpotCollection spots, boolean doNotify)
SpotCollection
managed by this model.doNotify
- if true, will file a ModelChangeEvent.SPOTS_COMPUTED
event.spots
- the SpotCollection
to set.public void filterSpots(Collection<FeatureFilter> spotFilters, boolean doNotify)
SpotCollection
managed by this model with the
FeatureFilter
s specified.spotFilters
- the FeatureFilter
collection to use for filtering.doNotify
- if true, will file a ModelChangeEvent.SPOTS_FILTERED
event.public void notifyFeaturesComputed()
ModelChangeListener
s of this model that feature values
have been computed. This method serves as a manual trigger for this
event.public void setLogger(Logger logger)
logger
- the Logger
to use.public Logger getLogger()
Logger
used.public FeatureModel getFeatureModel()
public Spot moveSpotFrom(Spot spotToMove, Integer fromFrame, Integer toFrame)
null
is
returned.
For the model update to happen correctly and listeners to be notified properly, a call to this method must happen within a transaction, as in:
model.beginUpdate(); try { ... // model modifications here } finally { model.endUpdate(); }
spotToMove
- the spot to movefromFrame
- the frame the spot originated fromtoFrame
- the destination framenull
if it could not be
found in the source framepublic Spot addSpotTo(Spot spotToAdd, Integer toFrame)
For the model update to happen correctly and listeners to be notified properly, a call to this method must happen within a transaction, as in:
model.beginUpdate(); try { ... // model modifications here } finally { model.endUpdate(); }
spotToAdd
- the spot to add.toFrame
- the frame to add it to.public Spot removeSpot(Spot spotToRemove)
null
is returned.
For the model update to happen correctly and listeners to be notified properly, a call to this method must happen within a transaction, as in:
model.beginUpdate(); try { ... // model modifications here } finally { model.endUpdate(); }
spotToRemove
- the spot to remove.null
if it could not be found.public void updateFeatures(Spot spotToUpdate)
For the model update to happen correctly and listeners to be notified properly, a call to this method must happen within a transaction, as in:
model.beginUpdate(); try { ... // model modifications here } finally { model.endUpdate(); }
spotToUpdate
- the spot to mark for updatepublic org.jgrapht.graph.DefaultWeightedEdge addEdge(Spot source, Spot target, double weight)
For the model update to happen correctly and listeners to be notified properly, a call to this method must happen within a transaction, as in:
model.beginUpdate(); try { ... // model modifications here } finally { model.endUpdate(); }
source
- the source spot.target
- the target spot.weight
- the weight of the edge.public org.jgrapht.graph.DefaultWeightedEdge removeEdge(Spot source, Spot target)
null
and do nothing to the tracks if the edge did not exist.source
- the source spot.target
- the target spot.public boolean removeEdge(org.jgrapht.graph.DefaultWeightedEdge edge)
For the model update to happen correctly and listeners to be notified properly, a call to this method must happen within a transaction, as in:
model.beginUpdate(); try { ... // model modifications here } finally { model.endUpdate(); }
edge
- the edge to remove.true
if the edge existed in the model and was
successfully, false
otherwise.public void setEdgeWeight(org.jgrapht.graph.DefaultWeightedEdge edge, double weight)
For the model update to happen correctly and listeners to be notified properly, a call to this method must happen within a transaction, as in:
model.beginUpdate(); try { ... // model modifications here } finally { model.endUpdate(); }
edge
- the edge.weight
- the weight to set.public boolean setTrackVisibility(Integer trackID, boolean visible)
NullPointerException
if the track ID is unknown to the model.
For the model update to happen correctly and listeners to be notified properly, a call to this method must happen within a transaction, as in:
model.beginUpdate(); try { ... // model modifications here } finally { model.endUpdate(); }
trackID
- the track ID.visible
- the desired visibility.Copyright © 2015–2021 Fiji. All rights reserved.