public class SNTColor extends Object
Modifier and Type | Field and Description |
---|---|
protected static int |
SWC_TYPE_IGNORED |
Constructor and Description |
---|
SNTColor(Color color)
Instantiates a new SNT color without SWC type association
|
SNTColor(Color color,
int swcType)
Instantiates a new SNT color.
|
Modifier and Type | Method and Description |
---|---|
static Color |
alphaColor(Color c,
double percent)
Adds an alpha component to a AWT color.
|
static Color |
average(Collection<Color> colors)
Averages a collection of colors
|
Color |
color()
Retrieves the AWT color
|
static String |
colorToString(Color color)
Returns the color encoded as hex string with the format #rrggbbaa.
|
static Color |
contrastColor(Color c)
Returns a suitable 'contrast' color.
|
boolean |
equals(Object obj) |
static ColorRGB[] |
getDistinctColors(int nColors)
Returns distinct colors based on Kenneth Kelly's 22 colors of maximum
contrast (black and white excluded).
|
int |
hashCode() |
boolean |
isTypeDefined()
Checks if an SWC type has been defined.
|
void |
setAWTColor(Color color)
Re-assigns a AWT color.
|
void |
setSWCType(int swcType)
Re-assigns a SWC type integer flag
|
static Color |
stringToColor(String hex)
Returns an AWT Color from a (#)RRGGBB(AA) hex string.
|
int |
type()
Retrieves the SWC type
|
protected static final int SWC_TYPE_IGNORED
public SNTColor(Color color, int swcType)
color
- the AWT colorswcType
- the SWC type integer flag to be associated with colorpublic SNTColor(Color color)
color
- the AWT colorpublic Color color()
public int type()
public boolean isTypeDefined()
public void setAWTColor(Color color)
color
- the new colorpublic void setSWCType(int swcType)
swcType
- the new SWC typepublic static String colorToString(Color color)
color
- the input AWT colorpublic static Color stringToColor(String hex)
hex
- the input stringpublic static Color average(Collection<Color> colors)
colors
- the colors to be averagedpublic static Color alphaColor(Color c, double percent)
c
- the input colorpercent
- alpha value in percentagepublic static Color contrastColor(Color c)
c
- the input colorpublic static ColorRGB[] getDistinctColors(int nColors)
nColors
- the number of colors to be retrieved.Copyright © 2015–2021 Fiji. All rights reserved.