Class Axis

java.lang.Object
uk.ac.starlink.ttools.plot2.Axis

@Equality public class Axis extends Object
Does geometry and drawing for a straight line axis.
Since:
12 Feb 2013
Author:
Mark Taylor
  • Constructor Summary

    Constructors
    Constructor
    Description
    Axis(int glo, int ghi, double dlo, double dhi, Scale scale, boolean flip)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    dataPan(double d0, double d1)
    Returns the data bounds that result from performing an axis pan between two given data positions.
    double
    dataToGraphics(double d)
    Converts a data coordinate to the graphics position on this axis.
    double[]
    dataZoom(double d0, double factor)
    Returns the data bounds that result from performing an axis zoom about a given data position.
    void
    drawLabels(Tick[] ticks, String title, Captioner captioner, TickLook tickLook, Orientation orient, boolean invert, Graphics g)
    Draws an axis title and supplied tickmarks.
    boolean
     
    double[]
    Returns the axis data bounds.
    int[]
    Returns the axis graphics bounds.
    getLabelBounds(Tick[] ticks, String title, Captioner captioner, Orientation orient, boolean invert)
    Determines the bounds for axis and tickmark annotations.
    Returns the scale used by this axis.
    double
    graphicsToData(double g)
    Converts a graphics position on this axis to a data coordinate.
    int
     
    boolean
    Indicates whether this axis has the scaling reversed.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Axis

      public Axis(int glo, int ghi, double dlo, double dhi, Scale scale, boolean flip)
      Constructor.
      Parameters:
      glo - minimum graphics coordinate
      ghi - maximum graphics coordinate
      dlo - minimum data coordinate
      dhi - maximum data coordinate
      scale - scaling function
      flip - true if the data coordinates should run in the opposite sense to the graphics coordinates
  • Method Details

    • dataToGraphics

      public double dataToGraphics(double d)
      Converts a data coordinate to the graphics position on this axis.
      Parameters:
      d - data coordinate
      Returns:
      graphics coordinate
    • graphicsToData

      public double graphicsToData(double g)
      Converts a graphics position on this axis to a data coordinate.
      Parameters:
      g - graphics coordinate
      Returns:
      data coordinate
    • dataZoom

      public double[] dataZoom(double d0, double factor)
      Returns the data bounds that result from performing an axis zoom about a given data position.
      Parameters:
      d0 - data reference position for zoom
      factor - amount to zoom
      Returns:
      2-element array giving new new data min/max coordinates
    • dataPan

      public double[] dataPan(double d0, double d1)
      Returns the data bounds that result from performing an axis pan between two given data positions.
      Parameters:
      d0 - source data position
      d1 - destination data position
      Returns:
      2-element array giving new new data min/max coordinates
    • getGraphicsLimits

      public int[] getGraphicsLimits()
      Returns the axis graphics bounds. The first element of the result (glo) is always strictly less than the second (ghi).
      Returns:
      2-element array giving the graphics min/max coordinates
    • getDataLimits

      public double[] getDataLimits()
      Returns the axis data bounds. The first element of the result (dlo) is always strictly less than the second (dhi).
      Returns:
      2-element array giving the data min/max coordinates
    • getScale

      public Scale getScale()
      Returns the scale used by this axis.
      Returns:
      scale
    • isFlip

      public boolean isFlip()
      Indicates whether this axis has the scaling reversed.
      Returns:
      true iff graphics and data coordinates increase in opposite directions
    • drawLabels

      public void drawLabels(Tick[] ticks, String title, Captioner captioner, TickLook tickLook, Orientation orient, boolean invert, Graphics g)
      Draws an axis title and supplied tickmarks.
      Parameters:
      ticks - tickmark array
      title - axis label text, may be null
      captioner - text positioning object
      tickLook - tick drawing style
      orient - axis orientation code
      invert - whether to reverse sense of axis
      g - graphics context
    • getLabelBounds

      public Rectangle getLabelBounds(Tick[] ticks, String title, Captioner captioner, Orientation orient, boolean invert)
      Determines the bounds for axis and tickmark annotations. The returned value is a bounding box for everything that would be drawn by a corresponding call to drawLabels(Tick[], String, Captioner, TickLook, Orientation, boolean, Graphics).
      Parameters:
      ticks - tickmark array
      title - axis label text, may be null
      captioner - text positioning object
      orient - axis orientation code
      invert - whether to reverse sense of axis
      Returns:
      bounding box for all annotations
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object