Package org.bzdev.gio

Interface OSGraphicsOps

All Superinterfaces:
GraphicsCreator
All Known Implementing Classes:
OSGBufferedImage, OutputStreamGraphics, OutputStreamGraphics.Surrogate, PanelGraphics, PrinterGraphics, ThreadedOSGraphics

public interface OSGraphicsOps extends GraphicsCreator
Basic operations for output stream graphics. This interface represents common operations that classes such as Graph use.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Test if the method reset() is supported.
    void
    Close resources.
    Get a graphics context for drawing.
    void
    Flush the output.
    Get the color model for the image that will be produced.
    int
    Get the image height parameter in user space.
    int
    Get the image width parameter in user space.
    void
    Final processing for writing an image file to the output stream.
    boolean
    Determine if this instance is requesting an alpha channel.
    void
    Reset this graphics output stream.
  • Method Details

    • requestsAlpha

      boolean requestsAlpha()
      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.
      Returns:
      true if an alpha channel is requested; false otherwise
    • getWidth

      int getWidth()
      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.

      Returns:
      the width in user-space coordinates
    • getHeight

      int getHeight()
      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.

      Returns:
      the height in user-space coordinates
    • close

      void close() throws IOException
      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.
      Throws:
      IOException - if an IO error occurred
    • flush

      void flush() throws IOException
      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.
      Throws:
      IOException - - if an IO exception occurred
      See Also:
    • getColorModel

      ColorModel getColorModel()
      Get the color model for the image that will be produced.
      Returns:
      the color model
    • createGraphics

      Graphics2D createGraphics() throws UnsupportedOperationException
      Get a graphics context for drawing. The graphics context created is not valid after flush() or reset() is called.
      Specified by:
      createGraphics in interface GraphicsCreator
      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

      boolean canReset()
      Test if the method reset() is supported.
      Returns:
      true if reset() is supported; false otherwise
    • reset

      void reset() throws UnsupportedOperationException
      Reset this graphics output stream. This is an optional operation as it is appropriate for some graphics output streams but not others
      Throws:
      UnsupportedOperationException - an instance does not support resets
    • imageComplete

      void imageComplete() throws IOException
      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 reset(). The method canReset() can be called to test if resets are allowed.

      Throws:
      IOException - IO failure, or a PrintException (which will be provided as the cause of the IOException), or an indication that this method was called multiple times