Package org.jgroups.demos
Class Draw
java.lang.Object
org.jgroups.demos.Draw
- All Implemented Interfaces:
ActionListener,EventListener,ChannelListener,Receiver
Shared whiteboard, each new instance joins the same group. Each instance chooses a random color,
mouse moves are broadcast to all group members, which then apply them to their canvas
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Colorprivate JChannelprivate JButtonprotected Stringprivate final Color(package private) booleanprivate JButtonprivate JFrameprivate int(package private) booleanprivate Draw.DrawPanelprivate final Randomprotected booleanprivate longprivate JPanelprivate booleanprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidchannelConnected(JChannel channel) Channel has been connected notification callbackvoidchannelDisconnected(JChannel channel) Channel has been disconnected notification callbackvoidvoidgetState(OutputStream ostream) Allows an application to write the state to an OutputStream.voidgo()(package private) static voidhelp()static voidvoidCalled when a message is received.private Colorvoidprotected voidsendOwnState(Map<Point, Color> copy) private voidsendToAll(byte[] buf) voidsetClusterName(String clustername) voidsetState(InputStream istream) Allows an application to read the state from an InputStream.(package private) voidsetTitle()(package private) voidvoidstop()voidviewAccepted(View v) Called when a change in membership has occurred.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.jgroups.ChannelListener
channelClosed
-
Field Details
-
cluster_name
-
channel
-
member_size
private int member_size -
mainFrame
-
sub_panel
-
panel
-
clear_button
-
leave_button
-
random
-
draw_color
-
background_color
-
no_channel
boolean no_channel -
jmx
boolean jmx -
use_state
private boolean use_state -
state_timeout
private long state_timeout -
use_unicasts
private boolean use_unicasts -
send_own_state_on_merge
protected boolean send_own_state_on_merge -
members
-
-
Constructor Details
-
Method Details
-
getClusterName
-
setClusterName
-
main
-
help
static void help() -
selectColor
-
sendToAll
- Throws:
Exception
-
go
- Throws:
Exception
-
setTitle
-
setTitle
void setTitle() -
receive
Description copied from interface:ReceiverCalled when a message is received. -
viewAccepted
Description copied from interface:ReceiverCalled when a change in membership has occurred. No long running actions, sending of messages or anything that could block should be done in this callback. If some long running action needs to be performed, it should be done in a separate thread.Note that on reception of the first view (a new member just joined), the channel will not yet be in the connected state. This only happens when
JChannel.connect(String)returns.- Specified by:
viewAcceptedin interfaceReceiver
-
getState
Description copied from interface:ReceiverAllows an application to write the state to an OutputStream. After the state has been written, the OutputStream doesn't need to be closed as stream closing is automatically done when a calling thread returns from this callback. -
setState
Description copied from interface:ReceiverAllows an application to read the state from an InputStream. After the state has been read, the InputStream doesn't need to be closed as stream closing is automatically done when a calling thread returns from this callback. -
clearPanel
public void clearPanel() -
sendClearPanelMsg
public void sendClearPanelMsg() -
actionPerformed
- Specified by:
actionPerformedin interfaceActionListener
-
stop
public void stop() -
sendOwnState
-
channelConnected
Description copied from interface:ChannelListenerChannel has been connected notification callback- Specified by:
channelConnectedin interfaceChannelListener- Parameters:
channel- the channel that has been connected
-
channelDisconnected
Description copied from interface:ChannelListenerChannel has been disconnected notification callback- Specified by:
channelDisconnectedin interfaceChannelListener- Parameters:
channel- the disconnected channel
-