Create color blind friendly color palettes in Java.
Note
Note that this repository has been archived because it is not actively maintained anymore.
The color palettes provided by this library are based on the colors provided by the color brewer project,
In principle there are three types of palettes provided:
For each palette any number of steps (=colors) in the palette can be requested.
final ColorPaletteChooserDialog dialog = new ColorPaletteChooserDialog();
dialog.show();
if(dialog.wasOKPressed()) {
Color c = dialog.getColor();
}
will display this dialog:
Get a color palette with a specific number of color:
boolean colorBlindSave = true;
ColorBrewer[] sequentialPalettes = ColorBrewer.getSequentialColorPalettes(colorBlindSave);
ColorBrewer myBrewer = sequentialPalettes[0];
System.out.println( "Name of this color brewer: " myBrewer);
// I want a gradient of 8 colors:
Color[] myGradient = myBrewer.getColorPalette(8);
// These are the color codes:
for (Color color: myGradient){
// convert to hex for web display:
String hex = Integer.toHexString(color.getRGB() & 0xffffff);
System.out.println("#" hex ";");
}
return myGradient;
This provides the following 8 blue colors:
This project is now hosted on Maven Central. You can install the jar file by adding this to your project configuration:
<dependencies>
<dependency>
<groupId>org.biojava</groupId>
<artifactId>jcolorbrewer</artifactId>
<version>5.2</version>
</dependency>
</dependencies>
Here we are coloring the various components of the virus structure of the human poliovirus ( PDB ID 3J69 ) .
Colors from www.ColorBrewer.org by Cynthia A. Brewer, Geography, Pennsylvania State University.