/** * * Program SampleManager.java * * Author Tomomi Kawashima * * Date 2003/10/06 * * This class is a manager. Developer must register methods in this class to RoomMsgReceiver * to get a message from RoomMsgReceiver. The message was processed by the method according * to the object ID. * */ package tomscop.application.sample; import java.awt.Color; import tomscop.util.PeerUtilities; public class SampleManager { private PeerUtilities peerutilities = PeerUtilities.getInstance(); private SampleUtilities utilities = SampleUtilities.getInstance(); /** * this method process a message from RoomMsgReceiver. * Set background of canvas panel according to the OID. * @param OID * @param source */ public void setBackColor(int OID, String source, String sourceID ) { // if source peer is not me if( !sourceID.equals(peerutilities.getPeerID())) { switch(OID) { // Object ID is RED case SampleUtilities.WHITE: // set canvasPanel to RED utilities.getCanvasPanel().setBackground(Color.WHITE); break; // Object ID is BLUE case SampleUtilities.BLUE: // set canvasPanel to BLUE utilities.getCanvasPanel().setBackground(Color.BLUE); break; } } } /** * This method show got message from other peer at the message label. * @param OID * @param source * @param message */ public void setMessage( int OID, String source, String sourceID, String message ) { // if source peer is not me if( !sourceID.equals(peerutilities.getPeerID())) { switch(OID) { // Object ID is MESSAGE case SampleUtilities.MESSAGE: utilities.getMessageLabel().setText(" <" + source + ">: " + message); break; } } } }