Class BarGraph


  • public class BarGraph
    extends AbstractBarGraph

    A concrete subclass of AbstractBarGraph that handles the simplest type of Bar Graph - a single row of bars, running across the X axis.

    By Default, the BarGraph turns off the external key by calling optionDisplayKey(Graph.KEY_NONE). This is because all the information required is displayed on the axes of the Graph.

    Here's an example showing a simple BarGraph.

        import org.faceless.graph.output.ImageOutput;
        import java.awt.Color;
    
        // Create a new Bar Graph, and set some options.
        //
        BarGraph g = new BarGraph();
        optionTitle("My First Bar Graph");
        optionXAxisLabel("Type of Fruit");
        optionYAxisLabel("Quantity Eaten");
    
        // Add some bars to the graph. Compare something
        // other than apples and oranges for a change.
        //
        g.set("Pomegranites", 20);
        g.set("Soursops", 15);
        g.set("Fejoas", 8);
        g.set("Kumquats", 9.5);
        g.set("Kiwaglis", 11.7);
        g.set("Tamarillos", 28);
        g.set("Mangosteens", 28);
    
        // Render to an image that's 400x400
        //
        ImageOutput out = new ImageOutput(400,400);
        out.render(g);
     
    • Constructor Detail

      • BarGraph

        public BarGraph()
    • Method Detail

      • setColor

        public void setColor​(java.lang.String set,
                             java.awt.Paint color)
        Set the color of an entry
      • set

        public void set​(java.lang.String set,
                        double val)

        Set the value of the specified entry

        Parameters:
        set - the entry on the X-axis to plot the value against
        val - the value to plot
        Throws:
        java.lang.IllegalArgumentException - if paramater val is infinite.
      • plotBar

        protected void plotBar​(int ix,
                               int iy,
                               int iz,
                               double endval)
        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
        endval - The value to plot.