Developer Documentation
PATH  Mac OS X Documentation > Application Kit Reference: Java


[Previous] [Class List] [Next]

NSGraphicsContext


Inherits from: NSObject
Package: com.apple.yellow.applicaton


Class Description


The NSGraphicsContext class is the abstract programmatic interface to objects that represent graphics contexts. A context can be thought of as a destination to which drawing and graphics state operations are sent for execution. Each graphics context contains its own graphics environment and state.

At any time there is the notion of the current context. The current context for the current thread may be set using setCurrentContext.

The NSGraphicsContext class is an abstract superclass for platform-specific graphics contexts. The most familiar subclass of the NSGraphicsContext for OPENSTEP programmers is the NSDPSContext class. The NSApplication object creates an NSDPSContext by default.

Graphics contexts are maintained on a stack. You push a graphics context onto the stack by sending it a saveGraphicsState message, and push it off the stack by sending it a restoreGraphicsState message. By sending restoreGraphicsState to an NSGraphicsContext object you remove it from the stack and the next graphics context on stack becomes the current graphics context.


Method Types


Testing the drawing destination
isDrawingToScreen
Setting and identifying the current context
currentContext
setCurrentContext
Controlling the context - flush
isDrawingToScreen
restoreGraphicsState
saveGraphicsState
synchronize

Static Methods



currentContext

public static NSGraphicsContext currentContext()

Returns the current graphics context of the current thread. Returns a concrete subclass of NSGraphicsContext.

setCurrentContext

public static void setCurrentContext(NSGraphicsContext context)

Sets the current graphics context of the current thread to context. context must be a concrete subclass of NSGraphicsContext.


Instance Methods



flush

public void flush()

Forces any buffered operations or data to be sent to the receiver's destination. Graphics contexts use buffers to queue pending operations but for efficiency reasons may not always empty those buffers immediately. This method forces the buffers to be emptied.

flushGraphics

public void flushGraphics()

<<Documentation Forthcoming>>

isDrawingToScreen

public boolean isDrawingToScreen()

Returns true if the drawing destination is the screen, false otherwise.

The default implementation of this method throws an exception to indicate that the method must be overridden in a concrete subclass.



restoreGraphicsState

public void restoreGraphicsState()

Removes the receiver's graphics state from the top of the graphics state stack and makes the next graphics state the current graphics state. This method must have been proceeded with a saveGraphicsState message to add the graphics state to the stack. Invocations of saveGraphicsState and restoreGraphicsState methods may be nested.

Restoring the graphics state restores such attributes as the current drawing style, transformation matrix, color, and font of the original graphics state.

The default implementation of this method throws an exception to indicate that the method must be overridden in a concrete subclass.



saveGraphicsState

public void saveGraphicsState()

Saves the current graphics state and creates a new graphics state on the top of the stack. The new graphics state is a copy of the previous state that can be modified to handle new drawing operations.

Saving the graphics state saves such attributes as the current drawing style, transformation matrix, color, and font. To set drawing style attrbutes, use the methods of NSBezierPath. Other attributes are accessed through appropriate objects such as NSAffineTransform, NSColor, and NSFont.

The default implementation of this method throws an exception to indicate that the method must be overridden in a concrete subclass.



synchronize

public void synchronize()

Waits until the NSGraphicsContext's destination is ready to receive more input. This method returns when the underlying graphics subsystem has processed all operations sent through this context.

The default implementation of this method throws an exception to indicate that the method must be overridden in a concrete subclass.




[Previous] [Next]