Package org.bzdev.gio

Class OutputStreamGraphics.Surrogate

java.lang.Object
org.bzdev.gio.OutputStreamGraphics.Surrogate
All Implemented Interfaces:
GraphicsCreator, OSGraphicsOps
Enclosing class:
OutputStreamGraphics

public static class OutputStreamGraphics.Surrogate extends Object implements OSGraphicsOps
This class represents a surrogate OSGraphicsOps. It is is used as a placeholder for an instance of OSGraphicsOps that will be provided at a later point in time, and its constructor is expected to provide quantities that are compatible with the instance of OSGraphicsOps that will replace this object.

One of its uses is in a constructor for Graph, where an argument to the constructor is an instance of ISWriterOps.

  • Constructor Details

    • Surrogate

      public Surrogate(int width, int height, boolean requestAlpha)
      Constructor.
      Parameters:
      width - the width of the drawing area
      height - the height of the drawing area
      requestAlpha - true if the drawing area should be configured with an alpha channel; false otherwise
  • Method Details

    • requestsAlpha

      public boolean requestsAlpha()
      Description copied from interface: OSGraphicsOps
      Determine if this instance is requesting an alpha channel. The value may be changed from that provided in the constructor due to the capabilities of a particular image format.
      Specified by:
      requestsAlpha in interface OSGraphicsOps
      Returns:
      true if an alpha channel is requested; false otherwise
    • getWidth

      public int getWidth()
      Description copied from interface: OSGraphicsOps
      Get the image width parameter in user space. Unless a graphics context is modified, this value represents an upper bound on the X coordinate of points that will appear in the image in the coordinate system used by the graphics context independent of the orientation.

      The parameter typically refers to some object such as a buffered image so that the value returned by this method is constant.

      Specified by:
      getWidth in interface OSGraphicsOps
      Returns:
      the width in user-space coordinates
    • getHeight

      public int getHeight()
      Description copied from interface: OSGraphicsOps
      Get the image height parameter in user space. Unless a graphics context is modified, this value represents an upper bound on the Y coordinate of points that will appear in the image in the coordinate system used by the graphics context independent of the orientation.

      The parameter typically refers to some object such as a buffered image so that the value returned by this method is constant.

      Specified by:
      getHeight in interface OSGraphicsOps
      Returns:
      the height in user-space coordinates
    • close

      public void close()
      Description copied from interface: OSGraphicsOps
      Close resources. Typically this method will perform some action when a class that implements this interface has an associated output stream or a resource that can be closed. If there are no such resources, this method should simply return. Classes that implement this method should document what they actually do.
      Specified by:
      close in interface OSGraphicsOps
    • flush

      public void flush()
      Description copied from interface: OSGraphicsOps
      Flush the output. This method will provide a partial image or partial graphics if possible or feasible. After this method is called, the user must not use graphics contexts that were previously created. Whether this method performs any action depends on the implementation of each class or subclass implementing this interface.
      Specified by:
      flush in interface OSGraphicsOps
      See Also:
    • getColorModel

      public ColorModel getColorModel()
      Description copied from interface: OSGraphicsOps
      Get the color model for the image that will be produced.
      Specified by:
      getColorModel in interface OSGraphicsOps
      Returns:
      the color model
    • createGraphics

      public Graphics2D createGraphics() throws UnsupportedOperationException
      Description copied from interface: OSGraphicsOps
      Get a graphics context for drawing. The graphics context created is not valid after OSGraphicsOps.flush() or OSGraphicsOps.reset() is called.
      Specified by:
      createGraphics in interface GraphicsCreator
      Specified by:
      createGraphics in interface OSGraphicsOps
      Returns:
      a new graphics context.
      Throws:
      UnsupportedOperationException - this operation is not supported, typically because the implementation can only create an instance of Graphics, not Graphics2D (something that would rarely, if ever, occur in practice)
    • canReset

      public boolean canReset()
      Description copied from interface: OSGraphicsOps
      Test if the method OSGraphicsOps.reset() is supported.
      Specified by:
      canReset in interface OSGraphicsOps
      Returns:
      true if OSGraphicsOps.reset() is supported; false otherwise
    • reset

      public void reset()
      Description copied from interface: OSGraphicsOps
      Reset this graphics output stream. This is an optional operation as it is appropriate for some graphics output streams but not others
      Specified by:
      reset in interface OSGraphicsOps
    • imageComplete

      public void imageComplete()
      Description copied from interface: OSGraphicsOps
      Final processing for writing an image file to the output stream. This method does not close an IO stream, but will flush it.

      Subclasses should implement this method so that it throws an exception if called multiple times without a successful intervening call to OSGraphicsOps.reset(). The method OSGraphicsOps.canReset() can be called to test if resets are allowed.

      Specified by:
      imageComplete in interface OSGraphicsOps