Package org.jzy3d.plot2d.primitive
Class AWTColorbarImageGenerator
- java.lang.Object
-
- org.jzy3d.plot2d.primitive.AWTAbstractImageGenerator
-
- org.jzy3d.plot2d.primitive.AWTColorbarImageGenerator
-
- All Implemented Interfaces:
AWTImageGenerator
public class AWTColorbarImageGenerator extends AWTAbstractImageGenerator implements AWTImageGenerator
- Author:
- Martin Pernollet
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
addTextHeightToVerticalMargin
static int
BAR_WIDTH_DEFAULT
protected int
barWidth
protected ColorMapper
mapper
protected double
max
protected double
min
static int
MIN_BAR_HEIGHT
static int
MIN_BAR_WIDTH
protected Coord2d
pixelScale
protected ITickProvider
provider
protected ITickRenderer
renderer
protected int
textToBarHorizontalMargin
-
Fields inherited from class org.jzy3d.plot2d.primitive.AWTAbstractImageGenerator
awtFont, backgroundColor, font, foregroundColor, hasBackground, textSize
-
-
Constructor Summary
Constructors Constructor Description AWTColorbarImageGenerator(ColorMapper mapper, ITickProvider provider, ITickRenderer renderer)
AWTColorbarImageGenerator(IColorMap map, float min, float max, ITickProvider provider, ITickRenderer renderer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
drawBarColors(int height, int barWidth, Graphics2D graphic)
Draw a bar content using the provided color mapper.protected void
drawBarContour(int height, int barWidth, Graphics2D graphic)
Draw a bar border.protected void
drawTextAnnotations(int height, int barWidth, Graphics2D graphic)
protected int
getMaxTickLabelWidth(IPainter painter)
Coord2d
getPixelScale()
protected int
getPreferedWidth(int maxTextWidth)
int
getPreferedWidth(IPainter painter)
Compute the optimal image width to contain the text as defined by the tick provided and renderer.protected int
getScaledBarWidth()
int
getTextToBarHorizontalMargin()
void
setPixelScale(Coord2d pixelScale)
void
setTextToBarHorizontalMargin(int textToBarHorizontalMargin)
BufferedImage
toImage(int width, int height)
BufferedImage
toImage(int width, int height, int barWidth)
Renders the colorbar to an image.-
Methods inherited from class org.jzy3d.plot2d.primitive.AWTAbstractImageGenerator
configureText, drawBackground, drawBorder, getAWTFont, getBackgroundColor, getFont, getForegroundColor, hasBackground, setAWTFont, setBackgroundColor, setFont, setForegroundColor, setHasBackground
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jzy3d.plot2d.primitive.AWTImageGenerator
getAWTFont, getBackgroundColor, getFont, getForegroundColor, hasBackground, setAWTFont, setBackgroundColor, setFont, setForegroundColor, setHasBackground
-
-
-
-
Field Detail
-
MIN_BAR_WIDTH
public static final int MIN_BAR_WIDTH
- See Also:
- Constant Field Values
-
MIN_BAR_HEIGHT
public static final int MIN_BAR_HEIGHT
- See Also:
- Constant Field Values
-
mapper
protected ColorMapper mapper
-
provider
protected ITickProvider provider
-
renderer
protected ITickRenderer renderer
-
min
protected double min
-
max
protected double max
-
BAR_WIDTH_DEFAULT
public static int BAR_WIDTH_DEFAULT
-
barWidth
protected int barWidth
-
textToBarHorizontalMargin
protected int textToBarHorizontalMargin
-
addTextHeightToVerticalMargin
protected boolean addTextHeightToVerticalMargin
-
pixelScale
protected Coord2d pixelScale
-
-
Constructor Detail
-
AWTColorbarImageGenerator
public AWTColorbarImageGenerator(IColorMap map, float min, float max, ITickProvider provider, ITickRenderer renderer)
-
AWTColorbarImageGenerator
public AWTColorbarImageGenerator(ColorMapper mapper, ITickProvider provider, ITickRenderer renderer)
-
-
Method Detail
-
toImage
public BufferedImage toImage(int width, int height)
- Specified by:
toImage
in interfaceAWTImageGenerator
-
toImage
public BufferedImage toImage(int width, int height, int barWidth)
Renders the colorbar to an image.
-
drawBarContour
protected void drawBarContour(int height, int barWidth, Graphics2D graphic)
Draw a bar border. Keep a space of half text height between the top of image and top of colorbar (same for bottom) to ensure a tick label at max or min position would not be cut at image border. The text size is given byAWTAbstractImageGenerator.setFont(org.jzy3d.painters.Font)
- Parameters:
height
-barWidth
-graphic
-
-
drawBarColors
protected void drawBarColors(int height, int barWidth, Graphics2D graphic)
Draw a bar content using the provided color mapper.- Parameters:
height
-barWidth
-graphic
-
-
drawTextAnnotations
protected void drawTextAnnotations(int height, int barWidth, Graphics2D graphic)
-
getPixelScale
public Coord2d getPixelScale()
-
setPixelScale
public void setPixelScale(Coord2d pixelScale)
-
getScaledBarWidth
protected int getScaledBarWidth()
-
getPreferedWidth
public int getPreferedWidth(IPainter painter)
Compute the optimal image width to contain the text as defined by the tick provided and renderer.
-
getPreferedWidth
protected int getPreferedWidth(int maxTextWidth)
-
getTextToBarHorizontalMargin
public int getTextToBarHorizontalMargin()
-
setTextToBarHorizontalMargin
public void setTextToBarHorizontalMargin(int textToBarHorizontalMargin)
-
getMaxTickLabelWidth
protected int getMaxTickLabelWidth(IPainter painter)
-
-