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 booleanaddTextHeightToVerticalMarginstatic intBAR_WIDTH_DEFAULTprotected intbarWidthprotected ColorMappermapperprotected doublemaxprotected doubleminstatic intMIN_BAR_HEIGHTstatic intMIN_BAR_WIDTHprotected Coord2dpixelScaleprotected ITickProviderproviderprotected ITickRendererrendererprotected inttextToBarHorizontalMargin-
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 voiddrawBarColors(int height, int barWidth, Graphics2D graphic)Draw a bar content using the provided color mapper.protected voiddrawBarContour(int height, int barWidth, Graphics2D graphic)Draw a bar border.protected voiddrawTextAnnotations(int height, int barWidth, Graphics2D graphic)protected intgetMaxTickLabelWidth(IPainter painter)Coord2dgetPixelScale()protected intgetPreferedWidth(int maxTextWidth)intgetPreferedWidth(IPainter painter)Compute the optimal image width to contain the text as defined by the tick provided and renderer.protected intgetScaledBarWidth()intgetTextToBarHorizontalMargin()voidsetPixelScale(Coord2d pixelScale)voidsetTextToBarHorizontalMargin(int textToBarHorizontalMargin)BufferedImagetoImage(int width, int height)BufferedImagetoImage(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:
toImagein 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)
-
-