diff --git a/src/main/java/org/mastodon/ui/coloring/GlasbeyLut.java b/src/main/java/org/mastodon/ui/coloring/GlasbeyLut.java index 93a525d5d..847d64c69 100644 --- a/src/main/java/org/mastodon/ui/coloring/GlasbeyLut.java +++ b/src/main/java/org/mastodon/ui/coloring/GlasbeyLut.java @@ -36,7 +36,7 @@ public class GlasbeyLut { - private static final Color[] colors = new Color[] { + public static final Color[] colors = new Color[] { new Color( 255, 255, 255 ), new Color( 20, 20, 255 ), new Color( 255, 20, 20 ), @@ -295,7 +295,7 @@ public class GlasbeyLut new Color( 189, 117, 101 ) }; - private static final int[] intColors; + public static final int[] intColors; static { intColors = new int[ colors.length ]; diff --git a/src/main/java/org/mastodon/ui/coloring/TrackGraphColorGenerator.java b/src/main/java/org/mastodon/ui/coloring/TrackGraphColorGenerator.java index ab0f5d7e8..4b6aa8c7d 100644 --- a/src/main/java/org/mastodon/ui/coloring/TrackGraphColorGenerator.java +++ b/src/main/java/org/mastodon/ui/coloring/TrackGraphColorGenerator.java @@ -37,7 +37,6 @@ import org.mastodon.graph.Vertex; import org.mastodon.graph.algorithm.traversal.InverseDepthFirstIterator; import org.mastodon.model.HasLabel; -import org.mastodon.views.trackscheme.util.AlphanumCompare; public class TrackGraphColorGenerator< V extends Vertex< E > & HasLabel, E extends Edge< V > > implements GraphColorGenerator< V, E > @@ -45,7 +44,7 @@ public class TrackGraphColorGenerator< V extends Vertex< E > & HasLabel, E exten private final RefIntMap< V > cache; - private final GlasbeyLut lut; + private final int[] lut; private final InverseDepthFirstIterator< V, E > iterator; @@ -62,7 +61,7 @@ public TrackGraphColorGenerator( final ListenableReadOnlyGraph< V, E > graph ) this.rootsProvider = new RootProvider<>( graph ); this.graph = graph; this.cache = RefMaps.createRefIntMap( graph.vertices(), 0 ); - this.lut = GlasbeyLut.create(); + this.lut = GlasbeyLut.intColors; this.iterator = new InverseDepthFirstIterator<>( graph ); this.toUpdate = RefCollections.createRefList( graph.vertices() ); @@ -137,12 +136,8 @@ private synchronized void rebuildRoots() if ( rootsUpToDate ) return; - final RefList< V > sortedRoots = RefCollections.createRefList( graph.vertices() ); - sortedRoots.addAll( rootsProvider.get() ); - sortedRoots.sort( ( v1, v2 ) -> AlphanumCompare.compare( v1.getLabel(), v2.getLabel() ) ); cache.clear(); - lut.reset(); - sortedRoots.forEach( r -> cache.put( r, lut.next() ) ); + rootsProvider.get().forEach( r -> cache.put( r, lut[ Math.abs( r.getLabel().hashCode() ) % lut.length ] ) ); rootsUpToDate = true; }