Class Plot3D

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
CartesianPlot3D, SphericalPlot3D

public abstract class Plot3D extends TablePlot
Component which paints a 3d plot.
Since:
22 Nov 2005
Author:
Mark Taylor
See Also:
  • Field Details

    • loBounds_

      protected double[] loBounds_
    • hiBounds_

      protected double[] hiBounds_
    • loBoundsG_

      protected double[] loBoundsG_
    • hiBoundsG_

      protected double[] hiBoundsG_
  • Constructor Details

    • Plot3D

      public Plot3D()
      Constructor.
  • Method Details

    • configureRanges

      protected abstract Plot3D.RangeChecker configureRanges(Plot3DState state)
      Provides notification that the range constraints are now as described in a supplied state object. A suitable Plot3D.RangeChecker object should be returned, but the implementation should take care of any other updates to its internal state which are required as well.
      Parameters:
      state - plot state
      Returns:
      a range checker appropriate to state's range constraints
    • getPadding

      protected abstract double getPadding(Plot3DState state, Graphics g, int[] padBorders)
      Works out padding factors to be used for the plot volume. The return value is the padFactor; the amount of space outside the unit cube in both dimensions. 1 means no extra space. The padBorders array is a 4-element array whose values on entry are ignored; on exit it should contain space, additional to padFactor, to be left around the edges of the plot. The order is (left,right,bottom,top).
      Parameters:
      state - plot state
      g - graphics context
      padBorders - 4-element array, filled on return
      Returns:
      pad factor (>=1)
      See Also:
    • frontOnly

      protected abstract boolean frontOnly(Plot3DState state)
      Indicates whether only the front part of the plot should be plotted.
      Parameters:
      state - plot state
      Returns:
      true iff parts of the plot behind the centre of the Z axis should be ignored
    • get3DLogFlags

      protected abstract boolean[] get3DLogFlags()
      Returns an array of 3 flags which indicate whether logarithmic scaling is in force on the X, Y and Z axes respectively.
      Returns:
      3-element array of Cartesian axis log scaling flags
    • plotAxes

      protected abstract void plotAxes(Plot3DState state, Graphics g, Plot3D.Transformer3D trans, PlotVolume vol, boolean front)
      Draws grid lines which contain all the known points. According to the value of the front parameter, either the lines which are behind all the data points, or the lines which are in front of all the data points are drawn. Thus, the routine needs to be called twice to plot all the lines. The graphics context has had all the customisation it needs.
      Parameters:
      state - plot state
      g - graphics context
      trans - transformer which maps data space to 3d graphics space
      vol - the plotting volume onto which the plot is done
      front - true for lines in front of data, false for lines behind
    • setState

      public void setState(PlotState state)
      Description copied from class: TablePlot
      Sets the plot state for this plot. This characterises how the plot will be done next time this component is painted.
      Overrides:
      setState in class TablePlot
      Parameters:
      state - plot state
    • getPlotBounds

      public Rectangle getPlotBounds()
      Returns the bounds of the actual plotting area.
      Specified by:
      getPlotBounds in class TablePlot
      Returns:
      plot area bounds
    • getDisplayBounds

      public Rectangle getDisplayBounds()
      Returns the bounds of the apparent display area. This is the actual plotting area with some padding.
      Returns:
      display area bounds
    • getPlottedPointIterator

      public PointIterator getPlottedPointIterator()
      Returns an iterator over the points plotted last time this component painted itself.
      Returns:
      point iterator
    • getPointPlacer

      public PointPlacer getPointPlacer()
      Returns a point placer for mapping 3D data points to the screen.
      Returns:
      point placer
    • logize

      protected static boolean logize(double[] coords, boolean[] logFlags)
      Converts coordinates to logarithmic values if necessary. The coords array holds the input values on entry, and each of these will be turned into logarithms of themselves on exit iff the corresponding element of the logFlags array is true. The return value will be true if the conversion went OK, and false if it couldn't be done for at least one coordinate, because it was non-positive.
      Parameters:
      coords - 3-element coordinate array
    • transformErrors

      protected static boolean transformErrors(Plot3D.Transformer3D trans, Plot3D.RangeChecker ranger, boolean[] logFlags, double[][] errors, double[] xerrs, double[] yerrs, double[] zerrs)
      Transforms errors from the form they assume in input data (offsets to a central data point in data space) to a set of absolute coordinates of points in the transformed graphics space. The arrangement of the input data offsets (loErrs, hiErrs) is as determined by the PlotData object. The number and ordering of the output data points (xerrs, yerrs, zerrs) are as required by ErrorRenderer objects.

      Points which don't represent errors, either because they have zero offsets or because they fall outside of the range of this 3D plot, are represented in the output coordinates as Double.NaN. The return value indicates whether any of the transformed values have non-blank values - if false, then error drawing is pointless.

      Parameters:
      trans - data space -> graphics space transformer
      ranger - range checker - anything out of range will be discarded
      logFlags - flags for which axes will be plotted logarithmically
      errors - data space error points, in pairs
      xerrs - graphics space X coordinates for error points
      yerrs - graphics space Y coordinates for error points
      zerrs - graphics space Z coordinates for error points
      Returns:
      true if some of the calculated errors are non-blank
    • rotateXY

      public static double[] rotateXY(double[] base, double phi, double psi)
      Takes a view rotation matrix and adds to it the effect of rotations about X and Y directions.
      Parameters:
      base - 9-element array giving initial view rotation matrix
      phi - angle to rotate around Y axis
      psi - angle to rotate around X axis
      Returns:
      9-element array giving combined rotation matrix
    • rotate

      public static double[] rotate(double[] base, double[] screenAxis, double theta)
      Calculates a rotation matrix for rotating around a screen axis by a given angle. Note this axis is in the view space, not the data space.
      Parameters:
      base - rotation matrix defining the view orientation (9-element array)
      screenAxis - axis in view space about which rotation is required (3-element array)
      theta - rotation angle in radians
    • paintMemoryError

      protected boolean paintMemoryError(OutOfMemoryError e)
      Hook for handling OutOfMemoryErrors which may be generated during plotting. May be called from the event dispatch thread. The Plot3D implementation returns false.
      Parameters:
      e - error
      Returns:
      true iff the error is handled (for intance user is informed)