java.lang.Object
org.bzdev.gio.OutputStreamGraphics.Surrogate
- All Implemented Interfaces:
GraphicsCreator
,OSGraphicsOps
- Enclosing class:
- OutputStreamGraphics
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
canReset()
Test if the methodOSGraphicsOps.reset()
is supported.void
close()
Close resources.Get a graphics context for drawing.void
flush()
Flush the output.Get the color model for the image that will be produced.int
Get the image height parameter in user space.int
getWidth()
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()
Reset this graphics output stream.
-
Constructor Details
-
Surrogate
public Surrogate(int width, int height, boolean requestAlpha) Constructor.- Parameters:
width
- the width of the drawing areaheight
- the height of the drawing arearequestAlpha
- 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 interfaceOSGraphicsOps
- 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 interfaceOSGraphicsOps
- 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 interfaceOSGraphicsOps
- 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 interfaceOSGraphicsOps
-
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 interfaceOSGraphicsOps
- See Also:
-
getColorModel
Description copied from interface:OSGraphicsOps
Get the color model for the image that will be produced.- Specified by:
getColorModel
in interfaceOSGraphicsOps
- Returns:
- the color model
-
createGraphics
Description copied from interface:OSGraphicsOps
Get a graphics context for drawing. The graphics context created is not valid afterOSGraphicsOps.flush()
orOSGraphicsOps.reset()
is called.- Specified by:
createGraphics
in interfaceGraphicsCreator
- Specified by:
createGraphics
in interfaceOSGraphicsOps
- 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 methodOSGraphicsOps.reset()
is supported.- Specified by:
canReset
in interfaceOSGraphicsOps
- 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 interfaceOSGraphicsOps
-
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 methodOSGraphicsOps.canReset()
can be called to test if resets are allowed.- Specified by:
imageComplete
in interfaceOSGraphicsOps
-