Class SurfaceRenderer

All Implemented Interfaces:
Serializable, ChartElement, ColorScaleRenderer, Renderer3D, XYZRenderer

A renderer that plots a surface based on a function (any implementation of Function3D). This renderer is different to others in that it does not plot data from a dataset, instead it samples a function and plots those values. By default 900 samples are taken (30 x-values by 30 z-values) although this can be modified.

For the fastest rendering, the drawFaceOutlines flag can be set to false (the default is true) but this may cause slight rendering artifacts if anti-aliasing is on (note that switching off anti-aliasing as well also improves rendering performance).

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.
Since:
1.1
See Also:
  • Constructor Details

    • SurfaceRenderer

      public SurfaceRenderer(Function3D function)
      Creates a new renderer for the specified function. By default, the renderer will take 30 samples along the x-axis and 30 samples along the z-axis (this is configurable).
      Parameters:
      function - the function (null not permitted).
  • Method Details

    • getXSamples

      public int getXSamples()
      Returns the number of samples the renderer will take along the x-axis when plotting the function. The default value is 30.
      Returns:
      The number of samples.
    • setXSamples

      public void setXSamples(int count)
      Sets the number of samples the renderer will take along the x-axis when plotting the function and sends a Renderer3DChangeEvent to all registered listeners. The default value is 30, setting this to higher values will result in smoother looking plots, but they will take longer to draw.
      Parameters:
      count - the count.
      See Also:
    • getZSamples

      public int getZSamples()
      Returns the number of samples the renderer will take along the z-axis when plotting the function and sends a Renderer3DChangeEvent to all registered listeners. The default value is 30.
      Returns:
      The number of samples.
    • setZSamples

      public void setZSamples(int count)
      Sets the number of samples the renderer will take along the z-axis when plotting the function and sends a Renderer3DChangeEvent to all registered listeners. The default value is 30, setting this to higher values will result in smoother looking plots, but they will take longer to draw.
      Parameters:
      count - the count.
      See Also:
    • getComposeType

      Returns the compose-type for the renderer. Here the value is ComposeType.ALL which means the plot will call the composeAll(org.jfree.chart3d.plot.XYZPlot, org.jfree.chart3d.graphics3d.World, org.jfree.chart3d.graphics3d.Dimension3D, double, double, double) method for composing the chart.
      Specified by:
      getComposeType in interface XYZRenderer
      Overrides:
      getComposeType in class AbstractXYZRenderer
      Returns:
      The compose type (never null).
    • getColorScale

      Returns the color scale. This determines the color of the surface according to the y-value.
      Specified by:
      getColorScale in interface ColorScaleRenderer
      Returns:
      The color scale (never null).
    • setColorScale

      public void setColorScale(ColorScale colorScale)
      Sets the color scale and sends a Renderer3DChangeEvent to all registered listeners.
      Parameters:
      colorScale - the color scale (null not permitted).
    • getDrawFaceOutlines

      public boolean getDrawFaceOutlines()
      Returns the flag that controls whether or not the faces that make up the surface have their outlines drawn during rendering. The default value is true.
      Returns:
      A boolean.
    • setDrawFaceOutlines

      public void setDrawFaceOutlines(boolean draw)
      Sets a flag that controls whether or not the faces that make up the surface are drawn (as well as filled) and sends a Renderer3DChangeEvent to all registered listeners. If the face outlines are drawn (the default), the surface is solid (but takes longer to draw). If the face outlines are not drawn, Java2D can leave small gaps that you can "see" through (if you don't mind this, then the performance is better).
      Parameters:
      draw - the new flag value.
    • composeAll

      public void composeAll(XYZPlot plot, World world, Dimension3D dimensions, double xOffset, double yOffset, double zOffset)
      Composes the entire representation of the function in the supplied world.
      Specified by:
      composeAll in interface XYZRenderer
      Overrides:
      composeAll in class AbstractXYZRenderer
      Parameters:
      plot - the plot.
      world - the world.
      dimensions - the plot dimensions.
      xOffset - the x-offset.
      yOffset - the y-offset.
      zOffset - the z-offset.
    • composeItem

      public void composeItem(XYZDataset dataset, int series, int item, World world, Dimension3D dimensions, double xOffset, double yOffset, double zOffset)
      Throws an UnsupportedOperationException because this renderer does not support per-item rendering.
      Specified by:
      composeItem in interface XYZRenderer
      Parameters:
      dataset - the dataset (null not permitted).
      series - the series index.
      item - the item index.
      world - the world (null not permitted).
      dimensions - the dimensions (null not permitted).
      xOffset - the x-offset.
      yOffset - the y-offset.
      zOffset - the z-offset.
    • findXRange

      public Range findXRange(XYZDataset dataset)
      Returns the current range for the x-axis - the method is overridden because this renderer does not use a dataset (it samples and plots a function directly).
      Specified by:
      findXRange in interface XYZRenderer
      Overrides:
      findXRange in class AbstractXYZRenderer
      Parameters:
      dataset - the dataset (ignored).
      Returns:
      The x-range (never null).
    • findYRange

      public Range findYRange(XYZDataset dataset)
      Returns the range that the renderer requires on the y-axis to display all the data in the function.
      Specified by:
      findYRange in interface XYZRenderer
      Overrides:
      findYRange in class AbstractXYZRenderer
      Parameters:
      dataset - the dataset (ignored).
      Returns:
      The range.
    • findZRange

      public Range findZRange(XYZDataset dataset)
      Returns the current range for the z-axis - the method is overridden because this renderer does not use a dataset (it samples and plots a function directly).
      Specified by:
      findZRange in interface XYZRenderer
      Overrides:
      findZRange in class AbstractXYZRenderer
      Parameters:
      dataset - the dataset (ignored).
      Returns:
      The z-range (never null).
    • equals

      public boolean equals(Object obj)
      Tests this renderer for equality with an arbitrary object.
      Overrides:
      equals in class AbstractXYZRenderer
      Parameters:
      obj - the object (null not permitted).
      Returns:
      A boolean.