Class FloatingBarGraph


  • public class FloatingBarGraph
    extends AbstractBarGraph

    A type of Bar graph where the bars float above the axis. It's used to show a range of values, with the average, median or some other value in the middle. The graph only extends along the X axis (i.e. it has no depth).

    There are two datasets defined, called MIN and MAX (for the bottom and top parts of the bar). You can change the colors of these sets with setColor("MIN", color)

    Here's an example showing a simple FloatingBarGraph.

        import org.faceless.graph.output.ImageOutput;
        import java.awt.Color;
    
        // Create a new Floating Bar Graph and
        // set the color of the bars.
        //
        FloatingBarGraph g = new FloatingBarGraph();
        g.optionTitle("My First Floating Bar Graph");
        g.setColor("MIN", Color.yellow);
        g.setColor("MAX", Color.green);
    
        // Add some bars to the graph. The averages
        // in this example aren't very useful...
        //
        g.set("Cabbages", 10, (10+18)/2, 18);
        g.set("Cauliflower", 12, (12+19)/2, 19);
        g.set("Courgettes", 11, (11+15)/2, 15);
    
        // Render to an image that's 400x400
        //
        ImageOutput out = new ImageOutput(400,400);
        out.render(g);
     
    • Constructor Detail

      • FloatingBarGraph

        public FloatingBarGraph()
    • Method Detail

      • set

        public void set​(java.lang.String xset,
                        double min,
                        double center,
                        double max)
        Add a bar with the specified bottom, middle and top values.
        Parameters:
        xset - The data set on the X axis. If it doesn't exist, it's created.
        min - The Y axis value for the bottom of the bar
        center - The value at which to end the bottom half and start the top half of the bar
        max - The Y axis value for the top of the bar
        Throws:
        java.lang.IllegalArgumentException - If paramaters min, max or center are infite.
      • setColor

        public void setColor​(java.lang.String name,
                             java.awt.Paint color)
        Set the color of a dataset. The set must be either MIN or MAX, otherwise an IllegalArgumentException is thrown.
        Parameters:
        name - the name of the dataset, either MIN or MAX
        color - the color to set this dataset to.
      • plotBar

        protected void plotBar​(int ix,
                               int iy,
                               int iz,
                               double maxval)
        Description copied from class: AbstractBarGraph
        Needs to be completed by concrete subclasses of this class.
        Specified by:
        plotBar in class AbstractBarGraph
        Parameters:
        ix - The X position of this value
        iy - The Y position of this value
        iz - The Z position of this value
        maxval - The value to plot.