Class JRFillChart

java.lang.Object
net.sf.jasperreports.engine.fill.JRFillElement
net.sf.jasperreports.charts.fill.JRFillChart
All Implemented Interfaces:
Cloneable, JRChart, DynamicPropertiesHolder, JRFillCloneable, JRAnchor, JRBoxContainer, JRChild, JRCloneable, JRCommonElement, JRElement, JREvaluation, JRHyperlink, JRIdentifiable, JRPropertiesHolder, JRStyleContainer, JRStyleSetter, JRVisitable
Direct Known Subclasses:
JRFillChartForAxis

public class JRFillChart extends JRFillElement implements JRChart
Author:
Teodor Danciu (teodord@users.sourceforge.net), Some enhancements by Barry Klawans (bklawans@users.sourceforge.net)
  • Field Details

    • EXCEPTION_MESSAGE_KEY_CUSTOMIZER_INSTANCE_ERROR

      public static final String EXCEPTION_MESSAGE_KEY_CUSTOMIZER_INSTANCE_ERROR
      See Also:
    • EXCEPTION_MESSAGE_KEY_MULTIAXIS_PLOT_TYPES_MIX_NOT_ALLOWED

      public static final String EXCEPTION_MESSAGE_KEY_MULTIAXIS_PLOT_TYPES_MIX_NOT_ALLOWED
      See Also:
    • EXCEPTION_MESSAGE_KEY_MULTIAXIS_PLOT_NOT_SUPPORTED

      public static final String EXCEPTION_MESSAGE_KEY_MULTIAXIS_PLOT_NOT_SUPPORTED
      See Also:
    • chartType

      protected ChartTypeEnum chartType
    • titleFont

      protected JRFont titleFont
    • subtitleFont

      protected JRFont subtitleFont
    • legendFont

      protected JRFont legendFont
    • initLineBox

      protected final JRLineBox initLineBox
    • lineBox

      protected JRLineBox lineBox
    • dataset

      protected JRFillChartDataset dataset
    • plot

      protected JRChartPlot plot
    • renderer

      protected Renderable renderer
    • chartCustomizers

      protected List<JRChartCustomizer> chartCustomizers
    • renderType

      protected String renderType
    • theme

      protected ChartTheme theme
    • jfreeChart

      protected org.jfree.chart.JFreeChart jfreeChart
    • chartHyperlinkProvider

      protected ChartHyperlinkProvider chartHyperlinkProvider
  • Constructor Details

  • Method Details

    • getStyleResolver

      protected StyleResolver getStyleResolver()
      Overrides:
      getStyleResolver in class JRFillElement
    • createAndInitCustomizer

      protected JRChartCustomizer createAndInitCustomizer(String customizerClassName, String customizerName)
    • setBand

      public void setBand(JRFillBand band)
      Overrides:
      setBand in class JRFillElement
    • evaluateStyle

      protected void evaluateStyle(byte evaluation) throws JRException
      Overrides:
      evaluateStyle in class JRFillElement
      Throws:
      JRException
    • getMode

      public ModeEnum getMode()
      Description copied from interface: JRCommonElement
      Returns the element transparency mode. The default value depends on the type of the report element. Graphic elements like rectangles and lines are opaque by default, but the images are transparent. Both static texts and text fields are transparent by default, and so are the subreport elements.
      Specified by:
      getMode in interface JRCommonElement
      Overrides:
      getMode in class JRFillElement
    • getShowLegend

      public Boolean getShowLegend()
      Specified by:
      getShowLegend in interface JRChart
    • setShowLegend

      public void setShowLegend(Boolean isShowLegend)
      Specified by:
      setShowLegend in interface JRChart
    • getRenderType

      public String getRenderType()
      Specified by:
      getRenderType in interface JRChart
    • setRenderType

      public void setRenderType(String renderType)
      Specified by:
      setRenderType in interface JRChart
    • getTheme

      public String getTheme()
      Specified by:
      getTheme in interface JRChart
    • setTheme

      public void setTheme(String theme)
      Specified by:
      setTheme in interface JRChart
    • getEvaluationTime

      public EvaluationTimeEnum getEvaluationTime()
      Description copied from interface: JREvaluation
      Gets the evaluation time for this text field.
      Specified by:
      getEvaluationTime in interface JREvaluation
      Overrides:
      getEvaluationTime in class JRFillElement
      Returns:
      one of the evaluation time constants in JRExpression
    • getEvaluationGroup

      public String getEvaluationGroup()
      Description copied from interface: JREvaluation
      Gets the evaluation group for this text field. Used only when evaluation time is group.
      Specified by:
      getEvaluationGroup in interface JREvaluation
      See Also:
    • getLineBox

      public JRLineBox getLineBox()
      Specified by:
      getLineBox in interface JRBoxContainer
    • getTitleFont

      public JRFont getTitleFont()
      Specified by:
      getTitleFont in interface JRChart
    • getTitlePosition

      public EdgeEnum getTitlePosition()
      Description copied from interface: JRChart
      Gets the title position relative to the chart.
      Specified by:
      getTitlePosition in interface JRChart
    • setTitlePosition

      public void setTitlePosition(EdgeEnum titlePosition)
      Description copied from interface: JRChart
      Sets the title position relative to the chart.
      Specified by:
      setTitlePosition in interface JRChart
    • getTitleColor

      public Color getTitleColor()
      Specified by:
      getTitleColor in interface JRChart
    • getOwnTitleColor

      public Color getOwnTitleColor()
      Specified by:
      getOwnTitleColor in interface JRChart
    • setTitleColor

      public void setTitleColor(Color titleColor)
      Specified by:
      setTitleColor in interface JRChart
    • getSubtitleFont

      public JRFont getSubtitleFont()
      Specified by:
      getSubtitleFont in interface JRChart
    • getOwnSubtitleColor

      public Color getOwnSubtitleColor()
      Specified by:
      getOwnSubtitleColor in interface JRChart
    • getSubtitleColor

      public Color getSubtitleColor()
      Specified by:
      getSubtitleColor in interface JRChart
    • setSubtitleColor

      public void setSubtitleColor(Color subtitleColor)
      Specified by:
      setSubtitleColor in interface JRChart
    • getOwnLegendColor

      public Color getOwnLegendColor()
      Returns the color to use for text in the legend.
      Specified by:
      getOwnLegendColor in interface JRChart
      Returns:
      the color to use for text in the legend
    • getLegendColor

      public Color getLegendColor()
      Returns the inherited color to use for text in the legend.
      Specified by:
      getLegendColor in interface JRChart
      Returns:
      the color to use for text in the legend
    • setLegendColor

      public void setLegendColor(Color legendColor)
      Sets the color to use for text in the legend.
      Specified by:
      setLegendColor in interface JRChart
      Parameters:
      legendColor - the color to use for text in the legend
    • getOwnLegendBackgroundColor

      public Color getOwnLegendBackgroundColor()
      Returns the color to use as the background of the legend.
      Specified by:
      getOwnLegendBackgroundColor in interface JRChart
      Returns:
      the color to use as the background of the legend
    • getLegendBackgroundColor

      public Color getLegendBackgroundColor()
      Returns the color to use as the background of the legend.
      Specified by:
      getLegendBackgroundColor in interface JRChart
      Returns:
      the color to use as the background of the legend
    • setLegendBackgroundColor

      public void setLegendBackgroundColor(Color legendBackgroundColor)
      Sets the color to use for the background of the legend.
      Specified by:
      setLegendBackgroundColor in interface JRChart
      Parameters:
      legendBackgroundColor - the color to use for the background of the legend
    • getLegendFont

      public JRFont getLegendFont()
      Returns the font to use in the legend.
      Specified by:
      getLegendFont in interface JRChart
      Returns:
      the font to use in the legend
    • getLegendPosition

      public EdgeEnum getLegendPosition()
      Specified by:
      getLegendPosition in interface JRChart
    • setLegendPosition

      public void setLegendPosition(EdgeEnum legendPosition)
      Specified by:
      setLegendPosition in interface JRChart
    • getTitleExpression

      public JRExpression getTitleExpression()
      Description copied from interface: JRChart
      Gets the expression whose evaluation will form the title.
      Specified by:
      getTitleExpression in interface JRChart
    • getSubtitleExpression

      public JRExpression getSubtitleExpression()
      Description copied from interface: JRChart
      Gets the expression whose evaluation will form the subtitle.
      Specified by:
      getSubtitleExpression in interface JRChart
    • getHyperlinkType

      public HyperlinkTypeEnum getHyperlinkType()
      Description copied from interface: JRHyperlink
      Retrieves the hyperlink type for the element.

      The actual hyperlink type is determined by getLinkType(). This method can is used to determine whether the hyperlink type is one of the built-in types or a custom type. When hyperlink is of custom type, CUSTOM is returned.

      Specified by:
      getHyperlinkType in interface JRHyperlink
      Returns:
      one of the hyperlink type constants
      See Also:
    • getHyperlinkTarget

      public HyperlinkTargetEnum getHyperlinkTarget()
      Description copied from interface: JRHyperlink
      Retrieves the hyperlink target for the element.

      The actual hyperlink target is determined by getLinkTarget(). This method can is used to determine whether the hyperlink target is one of the built-in target names or a custom one. When hyperlink has a custom target name, HyperlinkTargetEnum.CUSTOM is returned.

      Specified by:
      getHyperlinkTarget in interface JRHyperlink
      Returns:
      one of the hyperlink target constants
      See Also:
    • getAnchorNameExpression

      public JRExpression getAnchorNameExpression()
      Description copied from interface: JRAnchor
      Returns an expression whose value represents the anchor name.
      Specified by:
      getAnchorNameExpression in interface JRAnchor
    • getBookmarkLevelExpression

      public JRExpression getBookmarkLevelExpression()
      Description copied from interface: JRAnchor
      Returns an expression whose value represents the bookmark level (starting from 1) corresponding to this anchor. When the expression is set and its value is not null, it will override the value of the bookmarkLevel attribute.
      Specified by:
      getBookmarkLevelExpression in interface JRAnchor
    • getHyperlinkReferenceExpression

      public JRExpression getHyperlinkReferenceExpression()
      Description copied from interface: JRHyperlink
      Returns the expression whose value represents the hyperlink reference. It is only used when the hyperlink type is reference or anchor
      Specified by:
      getHyperlinkReferenceExpression in interface JRHyperlink
    • getHyperlinkWhenExpression

      public JRExpression getHyperlinkWhenExpression()
      Description copied from interface: JRHyperlink
      Returns the expression that is evaluated in order to decide if the hyperlink should be displayed. This expression always returns a boolean value.
      Specified by:
      getHyperlinkWhenExpression in interface JRHyperlink
    • getHyperlinkAnchorExpression

      public JRExpression getHyperlinkAnchorExpression()
      Description copied from interface: JRHyperlink
      Returns the expression whose value represents the anchor. It is only used when the hyperlink type is anchor.
      Specified by:
      getHyperlinkAnchorExpression in interface JRHyperlink
    • getHyperlinkPageExpression

      public JRExpression getHyperlinkPageExpression()
      Description copied from interface: JRHyperlink
      Returns an integer representing the page index of the link. It is only used when the hyperlink type is page. If the expression does not evaluate to an integer, an exception will be thrown.
      Specified by:
      getHyperlinkPageExpression in interface JRHyperlink
    • getLocale

      public Locale getLocale()
    • getTimeZone

      public TimeZone getTimeZone()
      Overrides:
      getTimeZone in class JRFillElement
    • getDataset

      public JRChartDataset getDataset()
      Description copied from interface: JRChart
      Gets the chart dataset. Most chart types have different dataset structures, depending on the chart type.
      Specified by:
      getDataset in interface JRChart
    • setDataset

      public void setDataset(JRFillChartDataset dataset)
    • getPlot

      public JRChartPlot getPlot()
      Description copied from interface: JRChart
      Gets the chart plot. Plots are used to define various chart visual properties, such as colors and transparency.
      Specified by:
      getPlot in interface JRChart
    • getRenderable

      protected Renderable getRenderable()
    • getAnchorName

      protected String getAnchorName()
    • getHyperlinkReference

      protected String getHyperlinkReference()
    • getHyperlinkAnchor

      protected String getHyperlinkAnchor()
    • getHyperlinkPage

      protected Integer getHyperlinkPage()
    • getHyperlinkTooltip

      protected String getHyperlinkTooltip()
    • getDefaultLineColor

      public Color getDefaultLineColor()
      Specified by:
      getDefaultLineColor in interface JRBoxContainer
    • getJRTemplateImage

      protected JRTemplateImage getJRTemplateImage()
    • createElementTemplate

      protected JRTemplateElement createElementTemplate()
      Specified by:
      createElementTemplate in class JRFillElement
    • rewind

      protected void rewind()
      Specified by:
      rewind in class JRFillElement
    • evaluate

      protected void evaluate(byte evaluation) throws JRException
      Specified by:
      evaluate in class JRFillElement
      Throws:
      JRException
    • evaluateRenderer

      protected void evaluateRenderer(byte evaluation) throws JRException
      Throws:
      JRException
    • getHyperlinkProvider

      protected ChartHyperlinkProvider getHyperlinkProvider()
    • evaluateChart

      protected org.jfree.chart.JFreeChart evaluateChart(byte evaluation) throws JRException
      Throws:
      JRException
    • prepare

      protected boolean prepare(int availableHeight, boolean isOverflow, boolean isOverflowAllowed)
      Overrides:
      prepare in class JRFillElement
    • fill

      protected JRPrintElement fill()
      Specified by:
      fill in class JRFillElement
    • copy

      protected void copy(JRPrintImage printImage)
    • getChartType

      public ChartTypeEnum getChartType()
      Description copied from interface: JRChart
      Gets the chart type. It must be one of the chart type constants in this class.
      Specified by:
      getChartType in interface JRChart
    • collectExpressions

      public void collectExpressions(JRExpressionCollector collector)
      Specified by:
      collectExpressions in interface JRElement
    • visit

      public void visit(JRVisitor visitor)
      Specified by:
      visit in interface JRVisitable
    • createChartHyperlinkProvider

      protected ChartHyperlinkProvider createChartHyperlinkProvider()
    • createMultiAxisChart

      protected void createMultiAxisChart(byte evaluation) throws JRException
      Build and configure a multiple axis chart. A multiple axis chart support more than one range axis. Multiple datasets using different ranges can be displayed as long as they share a common domain axis. Each dataset can be rendered differently, so one chart can contain (for example) two line charts, a bar chart and an area chart.

      Multiple axis charts are handled differently than the other chart types. They do not have a dataset, as each chart that is added to the multiple axis chart has its own dataset. For simplicity, each dataset is treated as its own chart, and in fact we reuse the design of all the chart types and let JFreeChart actually run them. Then we pull out the bits we need and add it to the common chart. All the plot and chart options on the nested charts is ignored, and all formatting is controlled by the plot attached to the multiAxisChart. The one exception is seriesColor, which can be used in a nested report to specify a color for a specific series in that report.
      Parameters:
      evaluation - current expression evaluation phase
      Throws:
      JRException
    • convertRange

      protected org.jfree.data.Range convertRange(JRDataRange dataRange, byte evaluation) throws JRException
      Converts a JasperReport data range into one understood by JFreeChart.
      Parameters:
      dataRange - the JasperReport version of the range
      evaluation - current expression evaluation phase
      Returns:
      the JFreeChart version of the range
      Throws:
      JRException - thrown when the low value of the range is greater than the high value
    • convertInterval

      protected org.jfree.chart.plot.MeterInterval convertInterval(JRMeterInterval interval, byte evaluation) throws JRException
      Converts a JasperReports meter interval to one that JFreeChart understands.
      Parameters:
      interval - the JasperReports definition of an interval
      evaluation - current evaluation time
      Returns:
      the JFreeChart version of the same interval
      Throws:
      JRException - thrown when the interval contains an invalid range
    • getChartAxisLocation

      protected org.jfree.chart.axis.AxisLocation getChartAxisLocation(JRFillChartAxis chartAxis)
    • resolveElement

      protected void resolveElement(JRPrintElement element, byte evaluation) throws JRException
      Description copied from class: JRFillElement
      Resolves an element.
      Specified by:
      resolveElement in class JRFillElement
      Parameters:
      element - the element
      evaluation - the evaluation type
      Throws:
      JRException
    • getBookmarkLevel

      public int getBookmarkLevel()
      Description copied from interface: JRAnchor
      Returns the level of the bookmark corresponding to the anchor.
      Specified by:
      getBookmarkLevel in interface JRAnchor
      Returns:
      the level of the bookmark corresponding to the anchor (starting from 1) or NO_BOOKMARK if no bookmark should be created for this anchor
    • getCustomizerClass

      public String getCustomizerClass()
      Description copied from interface: JRChart
      Gets a user specified chart customizer class name.
      Specified by:
      getCustomizerClass in interface JRChart
      See Also:
    • createClone

      public JRFillCloneable createClone(JRFillCloneFactory factory)
      Description copied from interface: JRFillCloneable
      Creates a working clone of itself.
      Specified by:
      createClone in interface JRFillCloneable
      Parameters:
      factory - the clone factory to use while creating the clone
      Returns:
      a working clone of itself
    • getHyperlinkParameters

      public JRHyperlinkParameter[] getHyperlinkParameters()
      Description copied from interface: JRHyperlink
      Returns the list of hyperlink parameters.

      The parameters can be used by custom hyperlink types to generate dynamic links.

      Specified by:
      getHyperlinkParameters in interface JRHyperlink
      Returns:
      the list of hyperlink parameters
    • getLinkType

      public String getLinkType()
      Description copied from interface: JRHyperlink
      Returns the hyperlink type.

      The type can be one of the built-in types (Reference, LocalAnchor, LocalPage, RemoteAnchor, RemotePage), or can be an arbitrary type.

      Specified by:
      getLinkType in interface JRHyperlink
      Returns:
      the hyperlink type
    • getLinkTarget

      public String getLinkTarget()
      Description copied from interface: JRHyperlink
      Returns the hyperlink target name.

      The type can be one of the built-in names (Self, Blank, Top, Parent), or can be an arbitrary name.

      Specified by:
      getLinkTarget in interface JRHyperlink
      Returns:
      the hyperlink target name
    • getHyperlinkTooltipExpression

      public JRExpression getHyperlinkTooltipExpression()
      Description copied from interface: JRHyperlink
      Returns the expression which will generate the hyperlink tooltip.
      Specified by:
      getHyperlinkTooltipExpression in interface JRHyperlink
      Returns:
      the expression which will generate the hyperlink tooltip