Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color per tracks. #254

Merged
merged 7 commits into from
Oct 23, 2023
Merged

Color per tracks. #254

merged 7 commits into from
Oct 23, 2023

Conversation

tinevez
Copy link
Contributor

@tinevez tinevez commented Aug 25, 2023

This PR adds a new coloring feature: the spots and links are colored by the track they belong to, picking a color in a Glasbey-like LUT:

Screenshot 2023-08-25 at 18 49 02

The colors are generated on the fly and are not stored in the project.

@tinevez tinevez changed the base branch from master to rework-app-model August 25, 2023 17:08
@tinevez tinevez added this to the Mastodon-beta-27 milestone Aug 29, 2023
Base automatically changed from rework-app-model to dev October 22, 2023 15:26
tinevez and others added 7 commits October 23, 2023 16:07
Iterate over sorted roots, so that the track id has the
same order than in default TrackScheme. So the track with
track ID 0 is the leftmost in default TrackScheme, and it
increases from left to right.
Also fix the javadoc of bimap for the branch edges.
Copied and adapted from TrackMate.
It works like this:
- First all the roots of a graph are collected.
- They are sorted alpha-numerically, so that they are iterated in
the same order than for default TrackScheme (with no fusion points).
- Each root is given a color from the Glasbey LUT, in order. This
ensures that all track color generators will give the same color
for one vertex.
- When the color for a vertex is quiered, we look in a cache. If the
color is not in the cache, then we iterate 'upward' in the graph
(reverse depth-first order) until we meet a spot that has a color
in the cache. All the spots we iterated until then receives this
color in the cache.
- For edges, we quiery the color of the source vertex.

The color generator listens to graph changes, so that new colors are
generated when the user adds a new track or split one in two.
Its de/registration as a listener must be handled outside.
Listening to graph changes can be paused.
Also the corresponding GUI state is properly de/serialized.
Similar to RootFinder, except that it tries not to walk the full
graph everytime it is queried for the roots.

The root set is updated by listening to graph changes. So to work,
aninstance of this class must be first registered as a GraphListener
to the graph it will analyze, and then have its graphRebuilt() method
called once.

If this works well, this should be transferred to mastodon-graph,
in the package org.mastodon.graph.algorithm
I foresee that it will not be good to generate the track colors,
by waling the full graph ONCE per opened view TIMES ONCE per
change in the graph.

So this version:

- Is based on the RootProvider, and listens to it to only regenerate
the cache when the set of roots changes.

- There is only one common instance of the track color generator,
use by all views, and it is registered as a manager in the window
manager. I took some care of what happens if several threads try to
query the track color concurrently, at least partially.

- The color cache is regenerated only if there is a change in the
root set AND if at least one view is using the 'Per track' coloring
mode.
@tinevez tinevez merged commit b785d9e into dev Oct 23, 2023
1 check passed
@tinevez tinevez deleted the track-color-generator branch October 23, 2023 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

1 participant