Class VerticalBarPlot

  • All Implemented Interfaces:
    com.jrefinery.chart.CategoryPlot, com.jrefinery.chart.event.AxisChangeListener, com.jrefinery.chart.event.ChartChangeListener, com.jrefinery.chart.VerticalValuePlot

    public class VerticalBarPlot
    extends com.jrefinery.chart.BarPlot
    implements com.jrefinery.chart.VerticalValuePlot
    A Plot that displays data in the form of a bar chart, using data from any class that implements the CategoryDataSource interface.
    See Also:
    Plot, I (Ulrich Küster) needed to change this class as I couldn't extend it, because the method I needed to change (draw) accesses a private method (getBars). I added the method getBarAreas() to receive a Vector with the areas of the bars on the screen, that is needed in SkillChartJFreeChartPanel to show tooltips on them.
    • Field Summary

      • Fields inherited from class com.jrefinery.chart.BarPlot

        categoryGap, introGap, seriesGap, trailGap
      • Fields inherited from class com.jrefinery.chart.Plot

        backgroundPaint, chart, HORIZONTAL_AXIS, horizontalAxis, insets, listeners, outlinePaint, outlineStroke, VERTICAL_AXIS, verticalAxis, ZERO
    • Constructor Summary

      Constructors 
      Constructor Description
      VerticalBarPlot​(com.jrefinery.chart.JFreeChart chart, com.jrefinery.chart.Axis horizontalAxis, com.jrefinery.chart.Axis verticalAxis)
      Standard constructor - builds a VerticalBarPlot with mostly default attributes.
      VerticalBarPlot​(com.jrefinery.chart.JFreeChart chart, com.jrefinery.chart.Axis horizontal, com.jrefinery.chart.Axis vertical, java.awt.Insets insets, int introGap, int trailGap, int categoryGap, int seriesGap)
      Standard constructor: returns a BarPlot with attributes specified by the caller.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void draw​(java.awt.Graphics2D g2, java.awt.geom.Rectangle2D drawArea)
      Draws the plot on a Java 2D graphics device (such as the screen or a printer).
      java.util.Vector<java.awt.geom.Rectangle2D> getBarAreas()
      DOCUMENT-ME
      java.util.List<?> getCategories()
      A convenience method that returns a list of the categories in the data source.
      com.jrefinery.chart.CategoryAxis getCategoryAxis()
      A convenience method that returns a reference to the horizontal axis cast as a CategoryAxis.
      double getCategoryCoordinate​(int category, java.awt.geom.Rectangle2D area)
      Returns the x-coordinate (in Java 2D User Space) of the center of the specified category.
      com.jrefinery.chart.CategoryDataSource getDataSource()
      A convenience method that returns the data source for the plot, cast as a CategoryDataSource.
      java.lang.Number getMaximumVerticalDataValue()
      Returns the maximum value in either the domain or the range, whichever is displayed against the vertical axis for the particular type of plot implementing this interface.
      java.lang.Number getMinimumVerticalDataValue()
      Returns the minimum value in the range, since this is plotted against the vertical axis for BarPlot.
      java.lang.String getPlotType()
      Returns a short string describing the type of plot.
      com.jrefinery.chart.VerticalNumberAxis getValueAxis()
      A convenience method that returns a reference to the vertical axis cast as a VerticalNumberAxis.
      boolean isCompatibleHorizontalAxis​(com.jrefinery.chart.Axis axis)
      Checks the compatibility of a horizontal axis, returning true if the axis is compatible with the plot, and false otherwise.
      boolean isCompatibleVerticalAxis​(com.jrefinery.chart.Axis axis)
      Checks the compatibility of a vertical axis, returning true if the axis is compatible with the plot, and false otherwise.
      void setHorizontalAxis​(com.jrefinery.chart.Axis axis)
      Sets the horizontal axis for the plot.
      void setVerticalAxis​(com.jrefinery.chart.Axis vAxis)
      Sets the vertical axis for the plot.
      • Methods inherited from class com.jrefinery.chart.BarPlot

        getCategoryGap, getIntroGap, getSeriesGap, getTrailGap, setCategoryGap, setIntroGap, setSeriesGap, setTrailGap
      • Methods inherited from class com.jrefinery.chart.Plot

        addChangeListener, axisChanged, chartChanged, drawOutlineAndBackground, getAxis, getBackgroundPaint, getChart, getHorizontalAxis, getInsets, getOutlinePaint, getOutlineStroke, getVerticalAxis, notifyListeners, removeChangeListener, setBackgroundPaint, setChart, setInsets, setOutlinePaint, setOutlineStroke
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • VerticalBarPlot

        public VerticalBarPlot​(com.jrefinery.chart.JFreeChart chart,
                               com.jrefinery.chart.Axis horizontal,
                               com.jrefinery.chart.Axis vertical,
                               java.awt.Insets insets,
                               int introGap,
                               int trailGap,
                               int categoryGap,
                               int seriesGap)
                        throws com.jrefinery.chart.AxisNotCompatibleException
        Standard constructor: returns a BarPlot with attributes specified by the caller.
        Parameters:
        chart - The chart that the plot belongs to;
        horizontal - The horizontal axis;
        vertical - The vertical axis;
        introGap - The gap before the first bar in the plot;
        trailGap - The gap after the last bar in the plot;
        categoryGap - The gap between the last bar in one category and the first bar in the next category;
        seriesGap - The gap between bars within the same category.
        Throws:
        com.jrefinery.chart.AxisNotCompatibleException - DOCUMENT-ME
      • VerticalBarPlot

        public VerticalBarPlot​(com.jrefinery.chart.JFreeChart chart,
                               com.jrefinery.chart.Axis horizontalAxis,
                               com.jrefinery.chart.Axis verticalAxis)
                        throws com.jrefinery.chart.AxisNotCompatibleException
        Standard constructor - builds a VerticalBarPlot with mostly default attributes.
        Parameters:
        chart - The chart that the plot belongs to;
        horizontalAxis - The horizontal axis;
        verticalAxis - The vertical axis;
        Throws:
        com.jrefinery.chart.AxisNotCompatibleException - DOCUMENT-ME
    • Method Detail

      • getDataSource

        public com.jrefinery.chart.CategoryDataSource getDataSource()
        A convenience method that returns the data source for the plot, cast as a CategoryDataSource.
        Specified by:
        getDataSource in interface com.jrefinery.chart.CategoryPlot
        Overrides:
        getDataSource in class com.jrefinery.chart.BarPlot
      • getValueAxis

        public com.jrefinery.chart.VerticalNumberAxis getValueAxis()
        A convenience method that returns a reference to the vertical axis cast as a VerticalNumberAxis.
      • setVerticalAxis

        public void setVerticalAxis​(com.jrefinery.chart.Axis vAxis)
                             throws com.jrefinery.chart.AxisNotCompatibleException
        Sets the vertical axis for the plot. This method should throw an exception if the axis doesn't implement the required interfaces.
        Overrides:
        setVerticalAxis in class com.jrefinery.chart.BarPlot
        Parameters:
        vAxis - The new vertical axis.
        Throws:
        com.jrefinery.chart.AxisNotCompatibleException - DOCUMENT-ME
      • getCategoryAxis

        public com.jrefinery.chart.CategoryAxis getCategoryAxis()
        A convenience method that returns a reference to the horizontal axis cast as a CategoryAxis.
      • setHorizontalAxis

        public void setHorizontalAxis​(com.jrefinery.chart.Axis axis)
                               throws com.jrefinery.chart.AxisNotCompatibleException
        Sets the horizontal axis for the plot. This method should throw an exception if the axis doesn't implement the required interfaces.
        Overrides:
        setHorizontalAxis in class com.jrefinery.chart.BarPlot
        Parameters:
        axis - The new horizontal axis.
        Throws:
        com.jrefinery.chart.AxisNotCompatibleException - DOCUMENT-ME
      • getCategories

        public java.util.List<?> getCategories()
        A convenience method that returns a list of the categories in the data source.
        Specified by:
        getCategories in interface com.jrefinery.chart.CategoryPlot
        Overrides:
        getCategories in class com.jrefinery.chart.BarPlot
      • getCategoryCoordinate

        public double getCategoryCoordinate​(int category,
                                            java.awt.geom.Rectangle2D area)
        Returns the x-coordinate (in Java 2D User Space) of the center of the specified category.
        Specified by:
        getCategoryCoordinate in interface com.jrefinery.chart.CategoryPlot
        Specified by:
        getCategoryCoordinate in class com.jrefinery.chart.BarPlot
        Parameters:
        category - The index of the category of interest (first category index = 0);
        area - The region within which the plot will be drawn.
      • isCompatibleHorizontalAxis

        public boolean isCompatibleHorizontalAxis​(com.jrefinery.chart.Axis axis)
        Checks the compatibility of a horizontal axis, returning true if the axis is compatible with the plot, and false otherwise.
        Specified by:
        isCompatibleHorizontalAxis in class com.jrefinery.chart.Plot
        Parameters:
        axis - The horizontal axis;
      • isCompatibleVerticalAxis

        public boolean isCompatibleVerticalAxis​(com.jrefinery.chart.Axis axis)
        Checks the compatibility of a vertical axis, returning true if the axis is compatible with the plot, and false otherwise.
        Specified by:
        isCompatibleVerticalAxis in class com.jrefinery.chart.Plot
        Parameters:
        axis - The vertical axis;
      • draw

        public void draw​(java.awt.Graphics2D g2,
                         java.awt.geom.Rectangle2D drawArea)
        Draws the plot on a Java 2D graphics device (such as the screen or a printer).
        Specified by:
        draw in class com.jrefinery.chart.Plot
        Parameters:
        g2 - The graphics device;
        drawArea - The area within which the plot should be drawn.
      • getPlotType

        public java.lang.String getPlotType()
        Returns a short string describing the type of plot.
        Specified by:
        getPlotType in class com.jrefinery.chart.Plot
      • getMinimumVerticalDataValue

        public java.lang.Number getMinimumVerticalDataValue()
        Returns the minimum value in the range, since this is plotted against the vertical axis for BarPlot.
        Specified by:
        getMinimumVerticalDataValue in interface com.jrefinery.chart.VerticalValuePlot
      • getMaximumVerticalDataValue

        public java.lang.Number getMaximumVerticalDataValue()
        Returns the maximum value in either the domain or the range, whichever is displayed against the vertical axis for the particular type of plot implementing this interface.
        Specified by:
        getMaximumVerticalDataValue in interface com.jrefinery.chart.VerticalValuePlot
      • getBarAreas

        public java.util.Vector<java.awt.geom.Rectangle2D> getBarAreas()
        DOCUMENT-ME