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


[Previous] [Class List] [Next]

NSDPSContext


Inherits from: NSGraphicsContext : NSObject
Package: com.apple.yellow.application


Class Description


The NSDPSContext class is the programmatic interface to objects that represent Display PostScript System contexts. A context can be thought of as a destination to which PostScript code is sent for execution. Each Display PostScript context contains its own complete PostScript environment including its own local VM (PostScript Virtual Memory). Every context has its own set of stacks, including an operand stack, graphics state stack, dictionary stack, and execution stack. Every context also contains a FontDirectory which is local to that context, plus a SharedFontDirectory that is shared across all contexts. There are three built-in dictionaries in the dictionary stack. From top to bottom, they are userdict, globaldict, and systemdict. userdict is private to the context, while globaldict and systemdict are shared by all contexts. globaldict is a modifiable dictionary containing information common to all contexts. systemdict is a read-only dictionary containing all the PostScript operators.

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

NSDPSContext objects by default write their output to a specified data destination. This is used for printing, faxing, and for generation of saved EPS (Encapsulated PostScript) code. The means to create contexts that interact with displays are platform-specific.

The NSApplication object creates an NSDPSContext by default.

NSDPSContext Objects and Display PostScript System Context Records

When an NSDPSContext object is created, it creates and manages a DPSContext record. Programmers familiar with the client side C function interface to the Display PostScript System can access the DPSContext record by sending a context message to an NSDPSContext object. You can then operate on this context record using any of the functions or single operator functions defined in the Display PostScript System client library. Conversely, you can create an NSDPSContext object from a DPSContext record with the DPSContextObject function, as defined in "Client Library Functions". You can then work with the created NSDPSContext object using any of the methods described here.

General Exception Conditions

A variety of exceptions can be thrown by NSDPSContext. In most cases, exceptions are thrown because of errors returned from the Display PostScript Server. Exceptions are listed under "Types and Constants." Also see the Display PostScript System, Client Library Reference Manual, by Adobe Systems Incorporated, for more details on Display PostScript System error names and their possible causes.


Method Types


Initializing a context
initWithMutableData:forDebugging:languageEncoding:nameEncoding:textProc:errorProc:
Testing the drawing destination
isDrawingToScreen
Accessing context data
mutableData
Setting and identifying the current context
currentContext
setCurrentContext
DPSContext
Controlling the context
flush
interruptExecution
notifyObjectWhenFinishedExecuting
resetCommunication
wait
Managing returned text and errors
stringForDPSError:
errorProc
setErrorProc:
setTextProc:
textProc
Sending raw data
printFormat:
printFormat:arguments:
writeData
writePostScriptWithLanguageEncodingConversion
Managing binary object sequences
awaitReturnValues
writeBOSArray:count:ofType:
writeBOSNumString:length:ofType:scale:
writeBOSString:length:
writeBinaryObjectSequence:length:
updateNameMap
Managing chained contexts
chainChildContext
childContext
parentContext
unchainContext
Controlling the wait cursor
startWaitCursorTimer
setWaitCursorEnabled
isWaitCursorEnabled
Debugging aids
areAllContextsOutputTraced
areAllContextsSynchronized
setAllContextsOutputTraced
setAllContextsSynchronized
isOutputTraced
isSynchronized
setOutputTraced
setSynchronized

Constructors


NSDPSContext

public NSDPSContext()

Static Methods



areAllContextsOutputTraced

public static boolean areAllContextsOutputTraced()

Returns true if the data flowing between the application's contexts and their destinations is copied to diagnostic output.

areAllContextsSynchronized

public static boolean areAllContextsSynchronized()

Returns true if all NSPDSContext objects invoke the wait method after sending each batch of output.

contextForSecondaryThread

public static NSDPSContext contextForSecondaryThread()



currentContext

public static NSGraphicsContext currentContext()

Returns the current context of the current thread.

setAllContextsOutputTraced

public static void setAllContextsOutputTraced(boolean flag)

Causes the data (PostScript code, return values, and so forth) flowing between all the application's contexts and their destinations to be copied to diagnostic output.

setAllContextsSynchronized

public static void setAllContextsSynchronized(boolean flag)

Causes the wait method to be invoked each time an NSDPSContext object sends a batch of output to its destination.

setCurrentContext

public static void setCurrentContext(NSGraphicsContext context)

Installs context as the current context of the current thread.


Instance Methods



awaitReturnValues

public void awaitReturnValues()

Waits for all return values from the result table.

chainChildContext

public void chainChildContext(NSDPSContext child)

Links child (and all of its children) to the receiver as its chained context, a context that receives a copy of all PostScript code sent to the receiver.

childContext

public NSDPSContext childContext()

Returns the receiver's child context, or null if none exists.

flush

public void flush()

Forces any buffered data to be sent to its destination.

flushGraphics

public void flushGraphics()



interruptExecution

public void interruptExecution()

Interrupts execution in the receiver's context.

isDrawingToScreen

public boolean isDrawingToScreen()

Returns true if the drawing destination is the screen.

isOutputTraced

public boolean isOutputTraced()

Returns true if the data flowing between the application's single context and its destination is copied to diagnostic output.

isSynchronized

public boolean isSynchronized()

Returns whether the wait method is invoked each time the receiver sends a batch of output to the server.

isWaitCursorEnabled

public boolean isWaitCursorEnabled()

Returns whether the wait cursor is enabled.

See Also: PScurrentwaitcursorenabled (function)



mutableData

public NSMutableData mutableData()

Returns the receiver's data object.

notifyObjectWhenFinishedExecuting

public void notifyObjectWhenFinishedExecuting(NSDPSContextNotification object)

Registers object to receive a contextFinishedExecuting: message when the NSDPSContext's destination is ready to receive more input. The registered object must support the NSDPSContextNotification protocol.

parentContext

public NSDPSContext parentContext()

Returns the receiver's parent context, or null if none exists.

resetCommunication

public void resetCommunication()

Discards any data that hasn't already been sent to its destination.

setOutputTraced

public void setOutputTraced(boolean flag)

Causes the data (PostScript code, return values, and so on) flowing between the application's single context and the Display PostScript server to be copied to diagnostic output.

setSynchronized

public void setSynchronized(boolean flag)

Sets whether the wait method is invoked each time the receiver sends a batch of output to its destination.

setWaitCursorEnabled

public void setWaitCursorEnabled(boolean flag)

Sets whether the wait cursor is enabled or disabled according to flag.

See Also: PSsetwaitcursorenabled (function)



startWaitCursorTimer

public void startWaitCursorTimer()

Generates a pseudo-event to start wait cursor timer.

See Also: setWaitCursorEnabled



synchronize

public void synchronize()



unchainContext

public void unchainContext()

Unlinks the child context (and all of it's children) from the receiver's list of chained contexts.

updateNameMap

public void updateNameMap()

Updates the context's name map from the client library's name map.

writeData

public void writeData(NSData buf)

Sends the PostScript data in buf to the context's destination.

writePostScriptWithLanguageEncodingConversion

public void writePostScriptWithLanguageEncodingConversion(NSData buf)

Writes the PostScript data in buf to the context's destination. The data, formatted as plain text, encoded tokens, or a binary object sequence, is converted as necessary depending on the language encoding of the receiving context.


[Previous] [Next]