|
CSP for Java (JCSP) 1.0-rc7 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jcsp.awt.DisplayList
This implements the Display
and Paintable
interfaces and provides
a channel-like connection between user processes and an active graphics component.
ActiveCanvas
)
on which it wishes to draw.
____________________ ____________________
| | | |
| | DisplayList | |
| user process |------------>>>------------| ActiveCanvas
|
| |Display Paintable| |
|____________________| |____________________|
The user process set
s, extend
s or change
s
a list of GraphicsCommand
s maintained by the DisplayList.
Any such operation causes the Java Event thread to call back, via the active graphics
component, on its paint
or update
methods and execute
those commands.
The user process sees the Display
interface to the DisplayList
(in the same way as a writer process sees the OutputChannel interface to
a Channel). The ActiveCanvas process sees the Paintable
interface to the DisplayList (in the same way as a reader process sees
the InputChannel interface to a Channel).
Unlike a Channel, however, a DisplayList should never block any of its attached processes indefinitely, regardless of the behaviour of its partner at the other end. The DisplayList imposes mutually exclusive access to its state and there are no wait/notify operations -- so any delays should be transient. User process sets/extends/changes and ActiveCanvas paints/updates on the DisplayList, therefore, should always succeed.
Note: the cautionary note in the above paragraph is because Java makes no guarantee that any invocation of a synchronized method ever takes place. This is something with which any Java application has to live.
Any number of user processes may draw on the same component via a DisplayList -- i.e. it is a any-one channel. By reserving different sections of a DisplayList for control by different processes, complex multiple animations can be simply managed.
Note: in this release, only the extend
and
change
methods are safe for direct use by multiple
user processes on the same DisplayList. A process should only invoke
set
at times when it knows others cannot be operating
on that DisplayList. This would normally be required by an application,
since a DisplayList reset invalidates the result
returned by a previous extend and the base index used in
a change -- i.e. concurrent processes doing these things will need
to be informed before they do them again! However, if the list really needs concurrent
setting without such an arrangement, this can be done within
a synchronized block on the DisplayList.
User applications will not normally be implementing new processes that are at the receiving
end of a DisplayList. Users will only be responsible for connecting a DisplayList
to a standard jcsp.awt drawing component. This can either be done statically (e.g.
through setPaintable
) or dynamically (by sending
a GraphicsProtocol.SetPaintable
object through
a GraphicsProtocol
channel).
GraphicsCommand
,
Display
,
Paintable
,
ActiveCanvas
Constructor Summary | |
DisplayList()
|
Method Summary | |
boolean |
change(GraphicsCommand[] c,
int i)
Changes the array of GraphicsCommands to be executed by replacing elements i onwards with the new ones. |
boolean |
change(GraphicsCommand c,
int i)
Changes the array of GraphicsCommands to be executed by replacing element i with the new one. |
int |
extend(GraphicsCommand c)
Extends the array of GraphicsCommands to be executed by one command. |
int |
extend(GraphicsCommand[] c)
Extends the array of GraphicsCommands to be executed. |
GraphicsCommand[] |
get()
Returns a copy of the array of GraphicsCommands currently held. |
void |
paint(Graphics g)
This is the call-back delegated here by the registered Component. |
void |
register(Component c)
Register the Component that will delegate its paint and update methods here. |
void |
set(GraphicsCommand c)
Sets the GraphicsCommand to be executed. |
void |
set(GraphicsCommand[] c)
Sets the array of GraphicsCommands to be executed. |
void |
setMinRefreshInterval(long minRefreshInterval)
Sets the repaint interval invoked by the set ,
extend and change commands. |
void |
update(Graphics g)
This is the call-back delegated here by the registered Component. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DisplayList()
Method Detail |
public void set(GraphicsCommand[] c)
update
callback on this object.
All commands will be executed.
set
in interface Display
c
- the array of GraphicsCommands to be executed.public void set(GraphicsCommand c)
update
callback on this object.
set
in interface Display
c
- the GraphicsCommand to be executed.public int extend(GraphicsCommand[] c)
update
callback on this object.
Only the new commands will be executed.
extend
in interface Display
c
- the extra GraphicsCommands to be executed.public int extend(GraphicsCommand c)
update
callback on this object.
Only the new command will be executed.
extend
in interface Display
c
- the extra GraphicsCommand to be executed.public boolean change(GraphicsCommand[] c, int i)
update
callback on this object.
All commands will be executed.
change
in interface Display
c
- the new GraphicsCommands to be executed.i
- the start index for the replacement.public boolean change(GraphicsCommand c, int i)
update
callback on this object.
All commands will be executed.
change
in interface Display
c
- the new GraphicsCommand to be executed.i
- the index for the replacement.public GraphicsCommand[] get()
get
in interface Display
public void setMinRefreshInterval(long minRefreshInterval)
set
,
extend
and change
commands.
The default is 10 milliseconds (the normal default for the
repaint
method from Component
).
minRefreshInterval
- the display commands will be executed at most once
per minRefreshInterval milliseconds.public void register(Component c)
register
in interface Paintable
c
- the Component that will do the delegating.public void paint(Graphics g)
paint
in interface Paintable
g
- the graphics context for the painting.public void update(Graphics g)
update
in interface Paintable
g
- the graphics context for the painting.
|
CSP for Java (JCSP) 1.0-rc7 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |