Class DialGraph


  • public class DialGraph
    extends Graph
    A subclass of Graph for drawing "Dials". Dials are very simple graphs, made up of "segments" which define a zone on the graph and "needles" which add a pointer to the graph.
    Since:
    2.3.1
    • Constructor Detail

      • DialGraph

        public DialGraph()
        Create a new DialGraph
    • Method Detail

      • addSegment

        public void addSegment​(double start,
                               double end,
                               double inner,
                               double outer,
                               Style style)
        Add a colored "segment" to the graph.
        Parameters:
        start - the start angle of the segment, in degrees clockwise from 12 o'clock
        end - the end angle of the segment, in degrees clockwise from 12 o'clock
        inner - the distance from the center of the graph to the inner edge of the range - 0 means the center of the graph, 100 is the outside edge.
        outer - the distance from the center of the graph to the outer edge of the range - 0 means the center of the graph, 100 is the outside edge.
        style - the Style to draw the slice in.
      • addNeedle

        public void addNeedle​(double angle,
                              double start,
                              double startwidth,
                              double waist,
                              double waistwidth,
                              double end,
                              double endwidth,
                              Style style,
                              int arrow)
        Add a "needle" the graph. A needle is drawn between two points, one of which is typically (but not necessarily) the center of the graph. It also may have a "waist", which allows the needle to bulge out slightly at the center. A typical value for the widths would be in the range 0 to 10.
        Parameters:
        angle - the angle of the needle, in degrees clockwise from 12 o'clock
        start - the distance from the center, with 0 being the center and 100 being the radius
        startwidth - the width of the needle at the start
        waist - The distance from the start to the waist - between 0 and 100, or Double.NaN to draw no waist. Must be greater than "start".
        waistwidth - the width at the waist
        end - The distance from the center of the graph to the end of the needle, with 0 being the center and 100 being the radius. Must be greater than "start" and "waist".
        endwidth - the width of the needle at the end
        style - the Style to paint the needle in.
        arrow - one of ARROW_NONE, ARROW_SMALL, ARROW_MEDIUM or ARROW_LARGE
      • setSliceSize

        public void setSliceSize​(double size)
        Set the number of degrees each straight line makes up in a DialGraph. Smaller values give rounder pies and smoother shading, but will a) take longer to render and b) for vector files like PDF or SVG, result in larger files (although this may be minimized by compression in PDF). The minimal value is 0.5 and the maximum is 5.
      • addLabel

        public void addLabel​(AbstractMarker label,
                             double angle,
                             double distance)
        Add a marker to one of the slices of the DialGraph.
        Parameters:
        label - the marker to display
        angle - the angle to draw the marker at, in degrees clockwise from 12 o'clock
        distance - the distance from the center of the graph to draw the marker, with 0 being the center of the graph and 100 the radius. Values > 100 position the marker outside the graph.
      • addLabels

        public void addLabels​(double startangle,
                              double endangle,
                              double anglestep,
                              double distance,
                              boolean rotate,
                              TextStyle style,
                              NumberFormat format,
                              double startvalue,
                              double endvalue)
        Add numerical labels around the edge of the dial graph. This method creates a number of appropriate Text objects and passes them into addLabel(), which we recommend doing if this method doesn't do exactly what you want.
        Parameters:
        startangle - the angle of the first label, in degrees clockwise from 12 o'clock
        endangle - the angle of the last label, in degrees clockwise from 12 o'clock
        anglestep - the increment between values
        distance - the distance from the center of the graph to the label
        rotate - whether to rotate the labels to match the graph
        style - the style in which the labels are to be rendered
        format - the format to use for the labels
        startvalue - the value of the first label
        endvalue - the value of the last label
      • addTick

        public void addTick​(double angle,
                            double start,
                            double end,
                            Style style)
        Add a tick to the graph
        Parameters:
        angle - the angle of the tick, in degrees clockwise from 12 o'clock
        start - the distance from the center of the graph to the start of the tick, with 100 being the outer edge
        end - the distance from the center of the graph to the end of the tick, with 100 being the outer edge
        style - the style of the tick, or null for a simple black line
      • addTicks

        public void addTicks​(double startangle,
                             double endangle,
                             double anglestep,
                             double start,
                             double end,
                             Style style)
        Add several ticks at equally spaced intervals around the graph
        Parameters:
        startangle - the angle in degrees at which to start drawing the ticks, in degrees clockwise from 12 o'clock
        endangle - the angle in degrees at which to stop drawing the ticks, in degrees clockwise from 12 o'clock
        anglestep - how many degrees should be between each tick.
        start - the distance from the center of the graph to the start of the tick, with 100 being the outer edge
        end - the distance from the center of the graph to the end of the tick, with 100 being the outer edge
        style - the style of the ticks, or null for a simple black line