Class AbstractAxis3D

java.lang.Object
org.jfree.chart3d.axis.AbstractAxis3D
All Implemented Interfaces:
Serializable, EventListener, Axis3D, ChartElement, MarkerChangeListener
Direct Known Subclasses:
AbstractValueAxis3D, StandardCategoryAxis3D

public abstract class AbstractAxis3D extends Object implements Axis3D, MarkerChangeListener, Serializable
A base class that can be used to create an Axis3D implementation. This class implements the core axis attributes as well as the change listener mechanism required to enable automatic repainting of charts.

NOTE: This class is serializable, but the serialization format is subject to change in future releases and should not be relied upon for persisting instances of this class.
See Also:
  • Field Details

    • DEFAULT_LABEL_FONT

      public static final Font DEFAULT_LABEL_FONT
      The default axis label font (in most circumstances this will be overridden by the chart style).
      Since:
      1.2
    • DEFAULT_LABEL_COLOR

      public static final Color DEFAULT_LABEL_COLOR
      The default axis label color (in most circumstances this will be overridden by the chart style).
      Since:
      1.2
    • DEFAULT_LABEL_OFFSET

      public static final double DEFAULT_LABEL_OFFSET
      The default label offset.
      Since:
      1.2
      See Also:
    • DEFAULT_TICK_LABEL_FONT

      public static final Font DEFAULT_TICK_LABEL_FONT
      The default tick label font (in most circumstances this will be overridden by the chart style).
      Since:
      1.2
    • DEFAULT_TICK_LABEL_COLOR

      public static final Color DEFAULT_TICK_LABEL_COLOR
      The default tick label color (in most circumstances this will be overridden by the chart style).
      Since:
      1.2
    • DEFAULT_LINE_STROKE

      public static final Stroke DEFAULT_LINE_STROKE
      The default stroke for the axis line.
      Since:
      1.2
    • DEFAULT_LINE_COLOR

      public static final Color DEFAULT_LINE_COLOR
      The default color for the axis line.
      Since:
      1.2
  • Constructor Details

    • AbstractAxis3D

      public AbstractAxis3D(String label)
      Creates a new label with the specified label. If the supplied label is null, the axis will be shown without a label.
      Parameters:
      label - the axis label (null permitted).
  • Method Details

    • isVisible

      public boolean isVisible()
      Returns the flag that determines whether or not the axis is drawn on the chart.
      Specified by:
      isVisible in interface Axis3D
      Returns:
      A boolean.
      See Also:
    • setVisible

      public void setVisible(boolean visible)
      Sets the flag that determines whether or not the axis is drawn on the chart and sends an Axis3DChangeEvent to all registered listeners.
      Specified by:
      setVisible in interface Axis3D
      Parameters:
      visible - the flag.
      See Also:
    • getLabel

      public String getLabel()
      Returns the axis label - the text that describes what the axis measures. The description should usually specify the units. When this attribute is null, the axis is drawn without a label.
      Returns:
      The axis label (possibly null).
    • setLabel

      public void setLabel(String label)
      Sets the axis label and sends an Axis3DChangeEvent to all registered listeners. If the supplied label is null, the axis will be drawn without a label.
      Parameters:
      label - the label (null permitted).
    • getLabelFont

      public Font getLabelFont()
      Returns the font used to display the main axis label. The default value is Font("SansSerif", Font.BOLD, 12).
      Specified by:
      getLabelFont in interface Axis3D
      Returns:
      The font used to display the axis label (never null).
    • setLabelFont

      public void setLabelFont(Font font)
      Sets the font used to display the main axis label and sends an Axis3DChangeEvent to all registered listeners.
      Specified by:
      setLabelFont in interface Axis3D
      Parameters:
      font - the new font (null not permitted).
    • getLabelColor

      public Color getLabelColor()
      Returns the color used for the label. The default value is Color.BLACK.
      Specified by:
      getLabelColor in interface Axis3D
      Returns:
      The label paint (never null).
    • setLabelColor

      public void setLabelColor(Color color)
      Sets the color used to draw the axis label and sends an Axis3DChangeEvent to all registered listeners.
      Specified by:
      setLabelColor in interface Axis3D
      Parameters:
      color - the color (null not permitted).
    • getLabelOffset

      public double getLabelOffset()
      Returns the offset between the tick labels and the axis label, measured in Java2D units. The default value is DEFAULT_LABEL_OFFSET.
      Returns:
      The offset.
      Since:
      1.2
    • setLabelOffset

      public void setLabelOffset(double offset)
      Sets the offset between the tick labels and the axis label and sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      offset - the offset.
      Since:
      1.2
    • getLineStroke

      Returns the stroke used to draw the axis line. The default value is DEFAULT_LINE_STROKE.
      Returns:
      The stroke used to draw the axis line (never null).
    • setLineStroke

      public void setLineStroke(Stroke stroke)
      Sets the stroke used to draw the axis line and sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      stroke - the new stroke (null not permitted).
    • getLineColor

      public Color getLineColor()
      Returns the color used to draw the axis line. The default value is DEFAULT_LINE_COLOR.
      Returns:
      The color used to draw the axis line (never null).
    • setLineColor

      public void setLineColor(Color color)
      Sets the color used to draw the axis line and sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      color - the new color (null not permitted).
    • getTickLabelsVisible

      public boolean getTickLabelsVisible()
      Returns the flag that controls whether or not the tick labels are drawn. The default value is true.
      Returns:
      A boolean.
    • setTickLabelsVisible

      public void setTickLabelsVisible(boolean visible)
      Sets the flag that controls whether or not the tick labels are drawn, and sends a change event to all registered listeners. You should think carefully before setting this flag to false, because if the tick labels are not shown it will be hard for the reader to understand the resulting chart.
      Parameters:
      visible - visible?
    • getTickLabelFont

      Returns the font used to display the tick labels. The default value is DEFAULT_TICK_LABEL_FONT.
      Specified by:
      getTickLabelFont in interface Axis3D
      Returns:
      The font (never null).
    • setTickLabelFont

      public void setTickLabelFont(Font font)
      Sets the font used to display tick labels and sends an Axis3DChangeEvent to all registered listeners.
      Specified by:
      setTickLabelFont in interface Axis3D
      Parameters:
      font - the font (null not permitted).
    • getTickLabelColor

      Returns the foreground color for the tick labels. The default value is DEFAULT_LABEL_COLOR.
      Specified by:
      getTickLabelColor in interface Axis3D
      Returns:
      The foreground color (never null).
    • setTickLabelColor

      public void setTickLabelColor(Color color)
      Sets the foreground color for the tick labels and sends an Axis3DChangeEvent to all registered listeners.
      Specified by:
      setTickLabelColor in interface Axis3D
      Parameters:
      color - the color (null not permitted).
    • receive

      public abstract void receive(ChartElementVisitor visitor)
      Receives a ChartElementVisitor. This method is part of a general mechanism for traversing the chart structure and performing operations on each element in the chart. You will not normally call this method directly.
      Specified by:
      receive in interface ChartElement
      Parameters:
      visitor - the visitor (null not permitted).
      Since:
      1.2
    • drawAxisLabel

      protected Shape drawAxisLabel(String label, Graphics2D g2, Line2D axisLine, Point2D opposingPt, double offset, RenderingInfo info, boolean hinting)
      Draws the specified text as the axis label and returns a bounding shape (2D) for the text.
      Parameters:
      label - the label (null not permitted).
      g2 - the graphics target (null not permitted).
      axisLine - the axis line (null not permitted).
      opposingPt - an opposing point (null not permitted).
      offset - the offset.
      info - collects rendering info (null permitted).
      hinting - perform element hinting?
      Returns:
      A bounding shape.
    • axisStr

      protected abstract String axisStr()
      Returns a string representing the configured type of the axis ("row", "column", "value", "x", "y" or "z" - other values may be possible in the future). A row axis on a CategoryPlot3D is in the position of a z-axis (depth), a column axis is in the position of an x-axis (width), a value axis is in the position of a y-axis (height).
      Returns:
      A string (never null).
      Since:
      1.3
    • draw

      public abstract void draw(Graphics2D g2, Point2D startPt, Point2D endPt, Point2D opposingPt, List<TickData> tickData, RenderingInfo info, boolean hinting)
      Draws the axis along an arbitrary line (between startPt and endPt). The opposing point is used as a reference point to know on which side of the axis to draw the labels.
      Specified by:
      draw in interface Axis3D
      Parameters:
      g2 - the graphics target (null not permitted).
      startPt - the starting point (null not permitted).
      endPt - the end point (null not permitted)
      opposingPt - an opposing point (null not permitted).
      tickData - info about the ticks to draw (null not permitted).
      info - an object to be populated with rendering info (null permitted).
      hinting - a flag that controls whether or not element hinting should be performed.
    • equals

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

      public int hashCode()
      Returns a hash code for this instance.
      Overrides:
      hashCode in class Object
      Returns:
      A hash code.
    • addChangeListener

      public void addChangeListener(Axis3DChangeListener listener)
      Registers a listener so that it will receive axis change events.
      Specified by:
      addChangeListener in interface Axis3D
      Parameters:
      listener - the listener (null not permitted).
    • removeChangeListener

      Unregisters a listener so that it will no longer receive axis change events.
      Specified by:
      removeChangeListener in interface Axis3D
      Parameters:
      listener - the listener (null not permitted).
    • notifyListeners

      public void notifyListeners(Axis3DChangeEvent event)
      Notifies all registered listeners that the axis has been modified.
      Parameters:
      event - information about the change event.
    • fireChangeEvent

      protected void fireChangeEvent(boolean requiresWorldUpdate)
      Sends an Axis3DChangeEvent to all registered listeners.
      Parameters:
      requiresWorldUpdate - a flag indicating whether this change requires the 3D world to be updated.
    • markerChanged

      public void markerChanged(MarkerChangeEvent event)
      Receives notification of a change to a marker managed by this axis - the response is to fire a change event for the axis (to eventually trigger a repaint of the chart). Marker changes don't require the world model to be updated.
      Specified by:
      markerChanged in interface MarkerChangeListener
      Parameters:
      event - the event.
      Since:
      1.2