public final class HighlightGenerator extends Object implements IGenerator<IAtomContainer>
HighlightGenerator.Palette
to determine the color. The size of the highlight is
specified with the HighlightGenerator.HighlightRadius
parameter.
Basic usage:
By default colours are automatically generated, to assign specific colors a custom// create with the highlight generator AtomContainerRenderer renderer = ...; IAtomContainer m = ...; // input molecule Map<IChemObject, Integer> ids = new HashMap<>(); // set atom/bond ids, atoms with no id will not be highlighted, numbering // starts at 0 ids.put(m.getAtom(0), 0); ids.put(m.getAtom(1), 0); ids.put(m.getAtom(2), 0); ids.put(m.getAtom(5), 2); ids.put(m.getAtom(6), 1); ids.put(m.getBond(0), 0); ids.put(m.getBond(1), 0); ids.put(m.getBond(3), 1); ids.put(m.getBond(4), 2); // attach ids to the structure m.setProperty(HighlightGenerator.ID_MAP, ids); // draw renderer.paint(m, new AWTDrawVisitor(g2), bounds, true);
HighlightGenerator.Palette
must be used. Here are some examples of setting
the palette parameter in the renderer.
AtomContainerRenderer renderer = ...; // opaque colors renderer.getRenderer2DModel() .set(HighlightGenerator.HighlightPalette.class, HighlightGenerator.createPalette(Color.RED, Color.BLUE, Color.GREEN)); // opaque colors (hex) renderer.getRenderer2DModel() .set(HighlightGenerator.HighlightPalette.class, HighlightGenerator.createPalette(new Color(0xff0000), Color.BLUE, Color.GREEN)); // first color is transparent renderer.getRenderer2DModel() .set(HighlightGenerator.HighlightPalette.class, HighlightGenerator.createPalette(new Color(0x88ff0000, true), Color.BLUE, Color.GREEN));
Modifier and Type | Class and Description |
---|---|
static class |
HighlightGenerator.HighlightPalette
Defines the color palette used to provide the highlight colors.
|
static class |
HighlightGenerator.HighlightRadius
Magic number with unknown units that defines the radius around an atom,
e.g.
|
static interface |
HighlightGenerator.Palette
Defines a color palette, the palette should provide a color the specified
identifier (id).
|
Constructor and Description |
---|
HighlightGenerator() |
Modifier and Type | Method and Description |
---|---|
static HighlightGenerator.Palette |
createAutoGenPalette(boolean transparent)
Create an auto generating palette which will generate colors using the
provided parameters.
|
static HighlightGenerator.Palette |
createAutoGenPalette(float saturation,
float brightness,
boolean transparent)
Create an auto generating palette which will generate colors using the
provided parameters.
|
static HighlightGenerator.Palette |
createAutoPalette(float saturation,
float brightness,
int alpha)
Create an auto generating palette which will generate colors using the
provided parameters.
|
static HighlightGenerator.Palette |
createPalette(Color[] colors)
Create a palette which uses the provided colors.
|
static HighlightGenerator.Palette |
createPalette(Color color,
Color... colors)
Create a palette which uses the provided colors.
|
IRenderingElement |
generate(IAtomContainer container,
RendererModel model)
Converts a
IChemObject from the chemical data model into
something that can be drawn in the chemical drawing. |
List<IGeneratorParameter<?>> |
getParameters()
Returns the list of
IGeneratorParameter for this particular
generator. |
public static final String ID_MAP
public IRenderingElement generate(IAtomContainer container, RendererModel model)
IChemObject
from the chemical data model into
something that can be drawn in the chemical drawing.generate
in interface IGenerator<IAtomContainer>
container
- the chemical entity to be depictedmodel
- the rendering parameterspublic List<IGeneratorParameter<?>> getParameters()
IGeneratorParameter
for this particular
generator.getParameters
in interface IGenerator<IAtomContainer>
List
of IGeneratorParameter
spublic static HighlightGenerator.Palette createPalette(Color[] colors)
colors
- colors to use in the palettepublic static HighlightGenerator.Palette createPalette(Color color, Color... colors)
colors
- colors to use in the palettepublic static HighlightGenerator.Palette createAutoPalette(float saturation, float brightness, int alpha)
saturation
- color saturation, 0.0 < x < 1.0brightness
- color brightness, 0.0 < x < 1.0alpha
- color alpha (transparency), 0 < x < 255public static HighlightGenerator.Palette createAutoGenPalette(float saturation, float brightness, boolean transparent)
saturation
- color saturation, 0.0 < x < 1.0brightness
- color brightness, 0.0 < x < 1.0transparent
- generate transparent colors, 0 < x < 255public static HighlightGenerator.Palette createAutoGenPalette(boolean transparent)
transparent
- generate transparent colorsCopyright © 2017. All Rights Reserved.