com.orsoncharts.renderer.xyz

## Class SurfaceRenderer

- java.lang.Object
- - com.orsoncharts.renderer.AbstractRenderer3D
  - - com.orsoncharts.renderer.xyz.AbstractXYZRenderer
    - - com.orsoncharts.renderer.xyz.SurfaceRenderer

- All Implemented Interfaces:
    ChartElement, ColorScaleRenderer, Renderer3D, XYZRenderer, java.io.Serializable

      public class SurfaceRenderer
      extends AbstractXYZRenderer
      implements XYZRenderer, ColorScaleRenderer, java.io.Serializable

  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:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from interface com.orsoncharts.renderer.Renderer3D

      `TRANSPARENT_COLOR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SurfaceRenderer(Function3D function)` Creates a new renderer for the specified function.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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`.
    `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.
    `boolean` | `equals(java.lang.Object obj)` Tests this renderer for equality with an arbitrary object.
    `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).
    `Range` | `findYRange(XYZDataset dataset)` Returns the range that the renderer requires on the y-axis to display all the data in the function.
    `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).
    `ColorScale` | `getColorScale()` Returns the color scale.
    `ComposeType` | `getComposeType()` Returns the compose-type for the renderer.
    `boolean` | `getDrawFaceOutlines()` Returns the flag that controls whether or not the faces that make up the surface have their outlines drawn during rendering.
    `int` | `getXSamples()` Returns the number of samples the renderer will take along the x-axis when plotting the function.
    `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.
    `void` | `setColorScale(ColorScale colorScale)` Sets the color scale and sends a `Renderer3DChangeEvent` to all registered listeners.
    `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.
    `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.
    `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.

    - ### Methods inherited from class com.orsoncharts.renderer.xyz.AbstractXYZRenderer

      `getColorSource, getItemLabelGenerator, getPlot, setColors, setColorSource, setItemLabelGenerator, setPlot`

    - ### Methods inherited from class com.orsoncharts.renderer.AbstractRenderer3D

      `addChangeListener, fireChangeEvent, getItemLabelBackgroundColor, getItemLabelColor, getItemLabelFont, getItemLabelPositioning, isNotify, notifyListeners, receive, removeChangeListener, setItemLabelBackgroundColor, setItemLabelColor, setItemLabelFont, setItemLabelPositioning, setNotify`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.orsoncharts.renderer.xyz.XYZRenderer

      `getColorSource, getPlot, setColors, setColorSource, setPlot`

    - ### Methods inherited from interface com.orsoncharts.renderer.Renderer3D

      `addChangeListener, removeChangeListener`

    - ### Methods inherited from interface com.orsoncharts.ChartElement

      `receive`

- - ### Constructor Detail

    - #### 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 Detail

    - #### 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:
        `setZSamples(int)`

    - #### 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:
        `setXSamples(int)`

    - #### getComposeType

          public ComposeType getComposeType()

      Returns the compose-type for the renderer. Here the value is `ComposeType.ALL` which means the plot will call the `composeAll(com.orsoncharts.plot.XYZPlot, com.orsoncharts.graphics3d.World, com.orsoncharts.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

          public ColorScale 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(java.lang.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.