-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
edit visual style. make colors random, and make them not change when …
…new nodes are added
- Loading branch information
Showing
5 changed files
with
113 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/main/java/org/cytoscape/WikiDataScape/internal/RandomColorMappingGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
https://github.com/svn2github/cytoscape/blob/a3df8f63dba4ec49942027c91ecac6efa920c195/csplugins/trunk/ucsd/mes/cy3-shared-local-tables/impl/vizmap-gui-impl/src/main/java/org/cytoscape/view/vizmap/gui/internal/util/mapgenerator/RandomColorMappingGenerator.java | ||
*/ | ||
package org.cytoscape.WikiDataScape.internal; | ||
|
||
import java.awt.Color; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Random; | ||
import java.util.Set; | ||
import org.cytoscape.view.vizmap.gui.util.DiscreteMappingGenerator; | ||
|
||
/** | ||
* Mapping generator from any attributes to random color | ||
*/ | ||
public class RandomColorMappingGenerator implements DiscreteMappingGenerator<Color> { | ||
|
||
private final int MAX_COLOR = 256 * 256 * 256; | ||
private final long seed = System.currentTimeMillis(); | ||
private final Random rand = new Random(seed); | ||
|
||
@Override | ||
public <T> Map<T, Color> generateMap(Set<T> attributeSet) { | ||
final Map<T, Color> valueMap = new HashMap<>(); | ||
|
||
for (T key : attributeSet) { | ||
valueMap.put(key, new Color(((Number) (rand.nextFloat() * MAX_COLOR)).intValue())); | ||
} | ||
|
||
return valueMap; | ||
} | ||
|
||
@Override | ||
public Class<Color> getDataType() { | ||
return Color.class; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters