@MinDoc(copyright="Copyright 2000 - 2009, 2016 A. Weinert", author="Albrecht Weinert", version="V.65", lastModified="3.06.2024", purpose="graphical helpers") public interface ColorHelper extends ColorVal
Modifier and Type | Interface and Description |
---|---|
static class |
ColorHelper.Impl
Private helper class.
|
Modifier and Type | Field and Description |
---|---|
static Action.Filter |
colourChooseFilter
A filter for Actions by code.
|
static ConcurrentHashMap<String,Color> |
colourCmap
HashMap for colours.
|
static CleverSSS |
rkColIs
The subsequence "color=" for white space and case ignoring search.
|
Modifier and Type | Method and Description |
---|---|
static Color |
calcFgColor(Color bg)
Determine a foreground colour for a given background colour.
|
static Color |
getColor(CharSequence colourDef)
Determine a colour by a character sequence.
|
static BufferedImage |
scaleImage(Image img,
Color bgColor,
int newWidth,
int newHeight)
Scaling a picture.
|
static void |
setBgColor(Component c,
Color bg)
Set a component's foreground and background colours.
|
static BufferedImage |
surrondImage(Image img,
Color bgColor,
int upM,
int loM,
int leM,
int riM)
Surround a picture.
|
static final ConcurrentHashMap<String,Color> colourCmap
getColor(CharSequence)
.static final CleverSSS rkColIs
static final Action.Filter colourChooseFilter
Action
,
Action.SCOLOR
static Color calcFgColor(Color bg)
bg
is
either white ColorVal.ws
) or black (ColorVal.sw
), depending
on the (weighted) brightness of bg
.bg
's RGB values a gray value will be calculated,
using ITU standard weights (222, 707, 71; according to recommendation 709,
D65). About 51% will be used as threshold.bg
- the background colour (null returns black)static void setBgColor(Component c, Color bg)
c
will be set by bg
.bg
.calcFgColor(Color)
static Color getColor(CharSequence colourDef)
colourDef
is stripped from surrounding
whitespace and quotes. If null or empty null is returned.colourDef
only the token following the = is
considered.colourDef
or its remaining token is interpreted
decimal, octal or hexadecimal as 24 bit number to define a colour
as RGB (0xrrggbb); see also
Color.decode(String)
. A leading sharp (#)
will be replaced before by 0x (#FFC0C0 -> 0xffcoco) to accept HTML
colour values, too.colourDef
is as an English,
German or French colour name or industry standard abbreviation.ColorVal.COLOR_CHOOSE
.colourDef
is used as key
to a cache
used and filled by this method.
This partly avoids double decoding and generating.colourDef
- the colour definitionColorVal.COLOR_CHOOSE
,
Action
static BufferedImage surrondImage(Image img, Color bgColor, int upM, int loM, int leM, int riM)
img
( 3 * 8 bit colour model) will be enlarged
by the given margins (the result being returned as new image).img
null or of zero or unknown size, null will be
returned.img
- the picture to be surroundedbgColor
- background respectively margin colour (default ColorVal.ws
).upM
- upper margin in pixel (0..400).loM
- leM - riM - ditto lower, left and right.static BufferedImage scaleImage(Image img, Color bgColor, int newWidth, int newHeight)
img
( 3 * 8 bit colour model) will be stretched
or shrunk to the given size and returned as BufferedImage
.img
null or of zero or unknown size, null or is the one of the
wanted sizes less than 1, null will be returned.img
of type
BufferedImage
, img
itself will be returned (not
copied).img
- the picture to scalebgColor
- background colour (used to prefill the new buffered
image, if not null)newHeight
- new heightnewWidth
- new width