CategoryAxis
org.jfree.chart.axis

Class CategoryAxis

    • Field Detail

      • DEFAULT_AXIS_MARGIN

        public static final double DEFAULT_AXIS_MARGIN
        The default margin for the axis (used for both lower and upper margins).
        See Also:
        Constant Field Values
      • DEFAULT_CATEGORY_MARGIN

        public static final double DEFAULT_CATEGORY_MARGIN
        The default margin between categories (a percentage of the overall axis length).
        See Also:
        Constant Field Values
    • Constructor Detail

      • CategoryAxis

        public CategoryAxis()
        Creates a new category axis with no label.
      • CategoryAxis

        public CategoryAxis(String label)
        Constructs a category axis, using default values where necessary.
        Parameters:
        label - the axis label (null permitted).
    • Method Detail

      • setLowerMargin

        public void setLowerMargin(double margin)
        Sets the lower margin for the axis and sends an AxisChangeEvent to all registered listeners.
        Parameters:
        margin - the margin as a percentage of the axis length (for example, 0.05 is five percent).
        See Also:
        getLowerMargin()
      • setUpperMargin

        public void setUpperMargin(double margin)
        Sets the upper margin for the axis and sends an AxisChangeEvent to all registered listeners.
        Parameters:
        margin - the margin as a percentage of the axis length (for example, 0.05 is five percent).
        See Also:
        getUpperMargin()
      • getCategoryMargin

        public double getCategoryMargin()
        Returns the category margin.
        Returns:
        The margin.
        See Also:
        setCategoryMargin(double)
      • setCategoryMargin

        public void setCategoryMargin(double margin)
        Sets the category margin and sends an AxisChangeEvent to all registered listeners. The overall category margin is distributed over N-1 gaps, where N is the number of categories on the axis.
        Parameters:
        margin - the margin as a percentage of the axis length (for example, 0.05 is five percent).
        See Also:
        getCategoryMargin()
      • getMaximumCategoryLabelLines

        public int getMaximumCategoryLabelLines()
        Returns the maximum number of lines to use for each category label.
        Returns:
        The maximum number of lines.
        See Also:
        setMaximumCategoryLabelLines(int)
      • setMaximumCategoryLabelLines

        public void setMaximumCategoryLabelLines(int lines)
        Sets the maximum number of lines to use for each category label and sends an AxisChangeEvent to all registered listeners.
        Parameters:
        lines - the maximum number of lines.
        See Also:
        getMaximumCategoryLabelLines()
      • setMaximumCategoryLabelWidthRatio

        public void setMaximumCategoryLabelWidthRatio(float ratio)
        Sets the maximum category label width ratio and sends an AxisChangeEvent to all registered listeners.
        Parameters:
        ratio - the ratio.
        See Also:
        getMaximumCategoryLabelWidthRatio()
      • getCategoryLabelPositionOffset

        public int getCategoryLabelPositionOffset()
        Returns the offset between the axis and the category labels (before label positioning is taken into account).
        Returns:
        The offset (in Java2D units).
        See Also:
        setCategoryLabelPositionOffset(int)
      • setCategoryLabelPositionOffset

        public void setCategoryLabelPositionOffset(int offset)
        Sets the offset between the axis and the category labels (before label positioning is taken into account) and sends a change event to all registered listeners.
        Parameters:
        offset - the offset (in Java2D units).
        See Also:
        getCategoryLabelPositionOffset()
      • getTickLabelFont

        public Font getTickLabelFont(Comparable category)
        Returns the font for the tick label for the given category.
        Parameters:
        category - the category (null not permitted).
        Returns:
        The font (never null).
        See Also:
        setTickLabelFont(Comparable, Font)
      • setTickLabelFont

        public void setTickLabelFont(Comparable category,                    Font font)
        Sets the font for the tick label for the specified category and sends an AxisChangeEvent to all registered listeners.
        Parameters:
        category - the category (null not permitted).
        font - the font (null permitted).
        See Also:
        getTickLabelFont(Comparable)
      • getTickLabelPaint

        public Paint getTickLabelPaint(Comparable category)
        Returns the paint for the tick label for the given category.
        Parameters:
        category - the category (null not permitted).
        Returns:
        The paint (never null).
        See Also:
        Axis.setTickLabelPaint(Paint)
      • setTickLabelPaint

        public void setTickLabelPaint(Comparable category,                     Paint paint)
        Sets the paint for the tick label for the specified category and sends an AxisChangeEvent to all registered listeners.
        Parameters:
        category - the category (null not permitted).
        paint - the paint (null permitted).
        See Also:
        getTickLabelPaint(Comparable)
      • addCategoryLabelURL

        public void addCategoryLabelURL(Comparable category,                       String url)
        Adds a URL (to be used in image maps) to the specified category and sends an AxisChangeEvent to all registered listeners.
        Parameters:
        category - the category (null not permitted).
        url - the URL text (null permitted).
        See Also:
        removeCategoryLabelURL(Comparable)
      • getCategoryJava2DCoordinate

        public double getCategoryJava2DCoordinate(CategoryAnchor anchor,                                 int category,                                 int categoryCount,                                 Rectangle2D area,                                 org.jfree.ui.RectangleEdge edge)
        Returns the Java 2D coordinate for a category.
        Parameters:
        anchor - the anchor point.
        category - the category index.
        categoryCount - the category count.
        area - the data area.
        edge - the location of the axis.
        Returns:
        The coordinate.
      • getCategorySeriesMiddle

        public double getCategorySeriesMiddle(Comparable category,                             Comparable seriesKey,                             CategoryDataset dataset,                             double itemMargin,                             Rectangle2D area,                             org.jfree.ui.RectangleEdge edge)
        Returns the middle coordinate (in Java2D space) for a series within a category.
        Parameters:
        category - the category (null not permitted).
        seriesKey - the series key (null not permitted).
        dataset - the dataset (null not permitted).
        itemMargin - the item margin (0.0 <= itemMargin < 1.0);
        area - the area (null not permitted).
        edge - the edge (null not permitted).
        Returns:
        The coordinate in Java2D space.
      • getCategorySeriesMiddle

        public double getCategorySeriesMiddle(int categoryIndex,                             int categoryCount,                             int seriesIndex,                             int seriesCount,                             double itemMargin,                             Rectangle2D area,                             org.jfree.ui.RectangleEdge edge)
        Returns the middle coordinate (in Java2D space) for a series within a category.
        Parameters:
        categoryIndex - the category index.
        categoryCount - the category count.
        seriesIndex - the series index.
        seriesCount - the series count.
        itemMargin - the item margin (0.0 <= itemMargin < 1.0);
        area - the area (null not permitted).
        edge - the edge (null not permitted).
        Returns:
        The coordinate in Java2D space.
      • reserveSpace

        public AxisSpace reserveSpace(Graphics2D g2,                     Plot plot,                     Rectangle2D plotArea,                     org.jfree.ui.RectangleEdge edge,                     AxisSpace space)
        Estimates the space required for the axis, given a specific drawing area.
        Specified by:
        reserveSpace in class Axis
        Parameters:
        g2 - the graphics device (used to obtain font information).
        plot - the plot that the axis belongs to.
        plotArea - the area within which the axis should be drawn.
        edge - the axis location (top or bottom).
        space - the space already reserved.
        Returns:
        The space required to draw the axis.
      • configure

        public void configure()
        Configures the axis against the current plot.
        Specified by:
        configure in class Axis
      • draw

        public AxisState draw(Graphics2D g2,             double cursor,             Rectangle2D plotArea,             Rectangle2D dataArea,             org.jfree.ui.RectangleEdge edge,             PlotRenderingInfo plotState)
        Draws the axis on a Java 2D graphics device (such as the screen or a printer).
        Specified by:
        draw in class Axis
        Parameters:
        g2 - the graphics device (null not permitted).
        cursor - the cursor location.
        plotArea - the area within which the axis should be drawn (null not permitted).
        dataArea - the area within which the plot is being drawn (null not permitted).
        edge - the location of the axis (null not permitted).
        plotState - collects information about the plot (null permitted).
        Returns:
        The axis state (never null).
      • refreshTicks

        public List refreshTicks(Graphics2D g2,                AxisState state,                Rectangle2D dataArea,                org.jfree.ui.RectangleEdge edge)
        Creates a temporary list of ticks that can be used when drawing the axis.
        Specified by:
        refreshTicks in class Axis
        Parameters:
        g2 - the graphics device (used to get font measurements).
        state - the axis state.
        dataArea - the area inside the axes.
        edge - the location of the axis.
        Returns:
        A list of ticks.
      • drawTickMarks

        public void drawTickMarks(Graphics2D g2,                 double cursor,                 Rectangle2D dataArea,                 org.jfree.ui.RectangleEdge edge,                 AxisState state)
        Draws the tick marks.
        Parameters:
        g2 - the graphics target.
        cursor - the cursor position (an offset when drawing multiple axes)
        dataArea - the area for plotting the data.
        edge - the location of the axis.
        state - the axis state.
      • equals

        public boolean equals(Object obj)
        Tests this axis for equality with an arbitrary object.
        Overrides:
        equals in class Axis
        Parameters:
        obj - the object (null permitted).
        Returns:
        A boolean.
      • hashCode

        public int hashCode()
        Returns a hash code for this object.
        Overrides:
        hashCode in class Axis
        Returns:
        A hash code.

SCaVis 2.1 © jWork.ORG