Class DepthBarGraph


  • public class DepthBarGraph
    extends AbstractBarGraph

    A concrete subclass of AbstractBarGraph that describes Bar Graphs with X and Z axes - i.e. they go both across and "into" the screen.

    By default, Depth Bar graphs turn off the external key by calling optionDisplayKey(Graph.KEY_NONE). This is because all the information needed is displayed on the Graph as values on the X and Z axes. If you would prefer to use the external key rather than put the keys on the Z axis, set the following options to turn back on the key and turn off the Z-axis entries:

       optionDisplayKey(Graph.KEY_BOXED_BELOW);     // or your preference
       optionZFormatter(new NullFormatter());
     

    Here's an example showing a simple Depth Bar Graph. The exact same methods can be used on a Tower Bar Graph for a different view on the data.

        import org.faceless.graph.output.ImageOutput;
        import java.awt.Color;
    
        // Create a new Bar Graph, and set some options - give
        // it a title and make each bar a different color. Also
        // give labels to the X and Y axes.
        //
        DepthBarGraph g = new DepthBarGraph();
        g.optionTitle("My First Bar Graph");
        g.optionXAxisLabel("Type of Fruit");
        g.optionYAxisLabel("Quantity Eaten");
    
        // Add some bars to the graph.
        //
        g.set("Soursops", "2000", 15);
        g.set("Fejoas", "2000", 8);
        g.set("Kiwaglis", "2000", 11.7);
        g.set("Mangosteens", "2000", 28);
    
        g.set("Soursops", "2001", 7.2);
        g.set("Fejoas", "2001", 3);
        g.set("Kiwaglis", "2001", 5);
        // Mangosteens were off in 2001
    
        // Render to an image that's 400x400
        //
        ImageOutput out = new ImageOutput(400,400);
        out.render(g);
     
    • Constructor Detail

      • DepthBarGraph

        public DepthBarGraph()
    • Method Detail

      • optionKeyOnX

        public void optionKeyOnX​(boolean val)
        Whether the X-axis will be the multiple colored one, rather than the Z-axis. Make sure you set this before adding any data to the set, otherwise unpredictable results may occur

        Default: false

      • setColor

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

        public void set​(java.lang.String xset,
                        java.lang.String zset,
                        double val)
        Set the value of the specified entry.
        Parameters:
        xset - the entry on the X-axis to plot the value against
        zset - the entry on the Z-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.