diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b9cb0d669d487ca1e91dbe16c66139f4a8839460..2428861c89790eb3dfff28bbc9c9c4802d530e77 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,30 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> <project version="4"> <component name="ChangeListManager"> - <list default="true" id="688d774d-cfc7-4b0d-b00c-5ca931aba600" name="Default Changelist" comment=""> + <list default="true" id="688d774d-cfc7-4b0d-b00c-5ca931aba600" name="Default Changelist" comment="Changed the join method to send over a reference of the ClientUpdate Interface"> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ChatScreen$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ChatScreen$1.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ChatScreen.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/ChatScreen.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea$1.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea$1.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/DrawingArea.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/META-INF/infinitymonkeys.kotlin_module" beforeDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/client/ChatUpdate.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/client/ChatUpdate.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/client/Client.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/client/Client.class" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/PaintGUI.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/GUI/PaintGUI.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/client/DrawingUpdate.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/client/DrawingUpdate.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/client/EncryptionUpdate.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/client/EncryptionUpdate.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IChatController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IChatController.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IChatUpdate.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IChatUpdate.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IClientController$Action.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IClientController$Action.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IClientController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IClientController.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IDrawingController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IDrawingController.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IDrawingUpdate.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/remote/IDrawingUpdate.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/ChatController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/ChatController.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/ClientController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/ClientController.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/DrawingController.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/DrawingController.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/MySharedKey.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/MySharedKey.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/Server.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/Server.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/User.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/User.class" afterDir="false" /> - <change beforePath="$PROJECT_DIR$/out/production/infinitymonkeys/server/server.policy" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/infinitymonkeys/server/server.policy" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/GUI/ChatScreen.form" beforeDir="false" afterPath="$PROJECT_DIR$/src/GUI/ChatScreen.form" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/GUI/ChatScreen.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GUI/ChatScreen.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/GUI/DrawingArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/GUI/DrawingArea.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/client/DrawingUpdate.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/client/DrawingUpdate.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/remote/IDrawingController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/remote/IDrawingController.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/remote/IDrawingUpdate.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/remote/IDrawingUpdate.java" afterDir="false" /> + <change beforePath="$PROJECT_DIR$/src/server/DrawingController.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/server/DrawingController.java" afterDir="false" /> </list> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="SHOW_DIALOG" value="false" /> @@ -36,19 +31,12 @@ <option name="testRunner" value="GRADLE" /> <option name="delegatedBuild" value="true" /> </component> - <component name="FindInProjectRecents"> - <findStrings> - <find>RMI</find> - <find>Black</find> - <find>colorOptions</find> - <find>Send</find> - <find>message</find> - <find>userSelectComboBox</find> - <find>updateUserList</find> - <find>send</find> - <find>broadcastMessage</find> - <find>sent</find> - </findStrings> + <component name="FileTemplateManagerImpl"> + <option name="RECENT_TEMPLATES"> + <list> + <option value="Class" /> + </list> + </option> </component> <component name="Git.Settings"> <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> @@ -58,19 +46,13 @@ </map> </option> </component> - <component name="ProjectConfigurationFiles"> - <option name="files"> - <list> - <option value="$PROJECT_DIR$/.idea/uiDesigner.xml" /> - </list> - </option> - </component> <component name="ProjectId" id="1SVgnDiSFxSanFbLYY5D9RJaXPS" /> <component name="PropertiesComponent"> <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> <property name="UI_DESIGNER_EDITOR_MODE.UIDesignerToolWindowManager.WIDTH" value="387" /> <property name="WebServerToolWindowFactoryState" value="false" /> <property name="aspect.path.notification.shown" value="true" /> + <property name="extract.method.default.visibility" value="private" /> <property name="last_opened_file_path" value="$PROJECT_DIR$/../Git Projects" /> <property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" /> <property name="nodejs_npm_path_reset_for_default_project" value="true" /> @@ -91,6 +73,45 @@ </option> </component> <component name="RunManager" selected="Application.Client1"> + <configuration name="AlbumTrackTable" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> + <option name="MAIN_CLASS_NAME" value="client.AlbumTrackTable" /> + <module name="infinitymonkeys" /> + <extension name="coverage"> + <pattern> + <option name="PATTERN" value="client.*" /> + <option name="ENABLED" value="true" /> + </pattern> + </extension> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <configuration name="BlinkColorTextField" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> + <option name="MAIN_CLASS_NAME" value="client.BlinkColorTextField" /> + <module name="infinitymonkeys" /> + <extension name="coverage"> + <pattern> + <option name="PATTERN" value="client.*" /> + <option name="ENABLED" value="true" /> + </pattern> + </extension> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <configuration name="BlinkingPrototype" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> + <option name="MAIN_CLASS_NAME" value="client.BlinkingPrototype" /> + <module name="infinitymonkeys" /> + <extension name="coverage"> + <pattern> + <option name="PATTERN" value="client.*" /> + <option name="ENABLED" value="true" /> + </pattern> + </extension> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> <configuration name="Client 3" type="Application" factoryName="Application"> <option name="MAIN_CLASS_NAME" value="client.Client" /> <module name="infinitymonkeys" /> @@ -123,12 +144,52 @@ <option name="Make" enabled="true" /> </method> </configuration> + <configuration name="TestList" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> + <option name="MAIN_CLASS_NAME" value="client.TestList" /> + <module name="infinitymonkeys" /> + <extension name="coverage"> + <pattern> + <option name="PATTERN" value="client.*" /> + <option name="ENABLED" value="true" /> + </pattern> + </extension> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> + <configuration name="WhiteYellow" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true"> + <option name="MAIN_CLASS_NAME" value="client.WhiteYellow" /> + <module name="infinitymonkeys" /> + <extension name="coverage"> + <pattern> + <option name="PATTERN" value="client.*" /> + <option name="ENABLED" value="true" /> + </pattern> + </extension> + <method v="2"> + <option name="Make" enabled="true" /> + </method> + </configuration> <list> <item itemvalue="Application.Server" /> <item itemvalue="Application.Client1" /> <item itemvalue="Application.Client2" /> <item itemvalue="Application.Client 3" /> + <item itemvalue="Application.BlinkingPrototype" /> + <item itemvalue="Application.WhiteYellow" /> + <item itemvalue="Application.AlbumTrackTable" /> + <item itemvalue="Application.TestList" /> + <item itemvalue="Application.BlinkColorTextField" /> </list> + <recent_temporary> + <list> + <item itemvalue="Application.BlinkColorTextField" /> + <item itemvalue="Application.BlinkingPrototype" /> + <item itemvalue="Application.TestList" /> + <item itemvalue="Application.WhiteYellow" /> + <item itemvalue="Application.AlbumTrackTable" /> + </list> + </recent_temporary> </component> <component name="SvnConfiguration"> <configuration /> @@ -143,7 +204,8 @@ <workItem from="1571631723795" duration="17601000" /> <workItem from="1571654347656" duration="25114000" /> <workItem from="1571786278739" duration="3319000" /> - <workItem from="1571915914956" duration="779000" /> + <workItem from="1571915914956" duration="3985000" /> + <workItem from="1571955297053" duration="14839000" /> </task> <task id="LOCAL-00001" summary="Changed the join method to send over a reference of the ClientUpdate Interface"> <created>1571646862883</created> @@ -185,6 +247,17 @@ <MESSAGE value="Changed the join method to send over a reference of the ClientUpdate Interface" /> <option name="LAST_COMMIT_MESSAGE" value="Changed the join method to send over a reference of the ClientUpdate Interface" /> </component> + <component name="XDebuggerManager"> + <breakpoint-manager> + <breakpoints> + <line-breakpoint enabled="true" type="java-line"> + <url>file://$PROJECT_DIR$/src/client/DrawingUpdate.java</url> + <line>25</line> + <option name="timeStamp" value="4" /> + </line-breakpoint> + </breakpoints> + </breakpoint-manager> + </component> <component name="simpleUML.UMLToolWindowPlugin"> <General> <option name="birdViewUpdateDelay" value="2000" /> diff --git a/out/production/infinitymonkeys/GUI/ChatScreen$1.class b/out/production/infinitymonkeys/GUI/ChatScreen$1.class index 42d9676fc3fd2926790b28a8af7cbe4c73b12ce3..f7b34ebeea5f5e36999a8a42185f0fcc303fb5c5 100644 Binary files a/out/production/infinitymonkeys/GUI/ChatScreen$1.class and b/out/production/infinitymonkeys/GUI/ChatScreen$1.class differ diff --git a/out/production/infinitymonkeys/GUI/ChatScreen.class b/out/production/infinitymonkeys/GUI/ChatScreen.class index 32a056b9a56992c4f64b42814b13f21aa01449f8..f7fb6fbd0ce3d32028c88b0c529269fb52274f86 100644 Binary files a/out/production/infinitymonkeys/GUI/ChatScreen.class and b/out/production/infinitymonkeys/GUI/ChatScreen.class differ diff --git a/out/production/infinitymonkeys/GUI/DrawingArea$1.class b/out/production/infinitymonkeys/GUI/DrawingArea$1.class index a5d5ee5210fdb61d23059b9ae70b3b0033f522b0..96a52d48af1a7c92a8da76ff8c9b50aae156600a 100644 Binary files a/out/production/infinitymonkeys/GUI/DrawingArea$1.class and b/out/production/infinitymonkeys/GUI/DrawingArea$1.class differ diff --git a/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class b/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class index 0dfea6014533d4b2402a663f95c2c029f41e7e9e..958e85d742b3479d575c89210af94b1aef0dff56 100644 Binary files a/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class and b/out/production/infinitymonkeys/GUI/DrawingArea$Mode.class differ diff --git a/out/production/infinitymonkeys/GUI/DrawingArea.class b/out/production/infinitymonkeys/GUI/DrawingArea.class index f59ec0f6020a3f2d28f20121419c1de580214cfd..82e1ef02989e61d8f9a79ba875ce9f42d4952ff6 100644 Binary files a/out/production/infinitymonkeys/GUI/DrawingArea.class and b/out/production/infinitymonkeys/GUI/DrawingArea.class differ diff --git a/out/production/infinitymonkeys/GUI/PaintGUI.class b/out/production/infinitymonkeys/GUI/PaintGUI.class index 2f6725da139d32563c716118e1249fad9798d7cc..16c8ae1e2dad8a125f6a77ea5e350b2a62df68b9 100644 Binary files a/out/production/infinitymonkeys/GUI/PaintGUI.class and b/out/production/infinitymonkeys/GUI/PaintGUI.class differ diff --git a/out/production/infinitymonkeys/client/DrawingUpdate.class b/out/production/infinitymonkeys/client/DrawingUpdate.class index 1b8808ca8c461c37713c4830f67eba18fe90cb11..e11afed4f6128429cbdd3af76ea42a2c5f8f0bbd 100644 Binary files a/out/production/infinitymonkeys/client/DrawingUpdate.class and b/out/production/infinitymonkeys/client/DrawingUpdate.class differ diff --git a/out/production/infinitymonkeys/remote/IDrawingController.class b/out/production/infinitymonkeys/remote/IDrawingController.class index 6eb48f6e4a1f829fe87ee73edd8903cfde96c919..d73ef908ad5fa62f7266e623517e188113f3acbe 100644 Binary files a/out/production/infinitymonkeys/remote/IDrawingController.class and b/out/production/infinitymonkeys/remote/IDrawingController.class differ diff --git a/out/production/infinitymonkeys/remote/IDrawingUpdate.class b/out/production/infinitymonkeys/remote/IDrawingUpdate.class index 8c7a899ae52d6a77403dfd541bc7460379d95aa0..23c8094f66b8ddfa3d0d8e5731aed7b68e868582 100644 Binary files a/out/production/infinitymonkeys/remote/IDrawingUpdate.class and b/out/production/infinitymonkeys/remote/IDrawingUpdate.class differ diff --git a/out/production/infinitymonkeys/server/DrawingController.class b/out/production/infinitymonkeys/server/DrawingController.class index 068b85fd1a186b213be1ba4606ae7e60fd82b779..1f5b804eb1d4ab47311e9d0f75a1eac382bf5d97 100644 Binary files a/out/production/infinitymonkeys/server/DrawingController.class and b/out/production/infinitymonkeys/server/DrawingController.class differ diff --git a/src/GUI/ChatScreen.form b/src/GUI/ChatScreen.form index 8d821a823277ef2693243eb5e949cc285b0c8033..140273c130f937107baf67db482203bc8ef15290 100644 --- a/src/GUI/ChatScreen.form +++ b/src/GUI/ChatScreen.form @@ -129,13 +129,17 @@ <properties/> <border type="none" title="Drawing Users"/> <children> - <component id="9aa9f" class="javax.swing.JList" binding="list1" default-binding="true"> + <component id="2214f" class="javax.swing.JList" binding="allUsersList"> <constraints> <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="2" anchor="0" fill="3" indent="0" use-parent-layout="false"> <preferred-size width="150" height="50"/> </grid> </constraints> - <properties/> + <properties> + <model> + <item value="drawingUserList"/> + </model> + </properties> </component> </children> </grid> diff --git a/src/GUI/ChatScreen.java b/src/GUI/ChatScreen.java index e98608ce5139a8e682f05d2117044b29a7e9043c..1ffd49fbd11023d27ec0e09eaf2d679e1c1310fd 100644 --- a/src/GUI/ChatScreen.java +++ b/src/GUI/ChatScreen.java @@ -32,13 +32,13 @@ public class ChatScreen { private JPanel managersPanel; private JPanel chatPanel; private JButton exitThisRoomButton; - private JList list1; + private DefaultListModel defaultListModel; - public JTextArea getActiveDrawingUserBox() { - return activeDrawingUserBox; + public DefaultListModel getAllUserModel() { + return defaultListModel; } - private JTextArea activeDrawingUserBox; + private JList allUsersList; private JFrame frame; public Client getClient() { @@ -50,12 +50,29 @@ public class ChatScreen { public ChatScreen(Client client) { this.client = client; - activeDrawingUserBox = new JTextArea(); yourNameDisplay.setText(client.getUserName()); exitThisRoomButton.addActionListener(actionListener); sendButton.addActionListener(actionListener); kickOutButton.addActionListener(actionListener); promoteToManagerButton.addActionListener(actionListener); + defaultListModel = new DefaultListModel(); + allUsersList.setModel(defaultListModel); + + allUsersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + allUsersList.setSelectedIndex(0); + allUsersList.setVisibleRowCount(5); + + + + + } + + public void addUserToList(){ + + } + + public void removeUserFromList(){ + } public void setUserName(String userName) @@ -180,4 +197,5 @@ public class ChatScreen { } }; + } diff --git a/src/GUI/DrawingArea.java b/src/GUI/DrawingArea.java index 4df0903efa1151b3bbc3042599a995097fb82ce4..227329927351e162be4fa4393a2013d2f73a3327 100644 --- a/src/GUI/DrawingArea.java +++ b/src/GUI/DrawingArea.java @@ -10,7 +10,6 @@ import java.awt.event.*; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import java.awt.geom.Rectangle2D; -import java.awt.geom.RectangularShape; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; @@ -287,7 +286,13 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis try { drawingController.broadcastDrawing(client.getUserName(), drawing, currentMode.toString(), shapeColor, strokeSize); - drawingController.broadcastDrawingUser(client.getUserName()); + if (currentMode == Mode.TEXT){ + notifyUsingTimer(); + } + else { + drawingController.broadcastDrawingUserStopped(client.getUserName()); + } + } catch (RemoteException ex) { ex.printStackTrace(); } @@ -295,6 +300,31 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis drawing = null; } + private void notifyUsingTimer() throws RemoteException { + + Timer timer = new Timer(4000, new ActionListener() + { + + @Override + public void actionPerformed(ActionEvent e) + { + try { + client.getDrawingController().broadcastDrawingUserStopped(client.getDefaultUserName()); + } catch (RemoteException ex) { + ex.printStackTrace(); + } + + } + + }); + try { + client.getDrawingController().broadcastDrawingUser(client.getDefaultUserName()); + } catch (RemoteException ex) { + ex.printStackTrace(); + } + timer.start(); + } + @Override public void mouseEntered(MouseEvent e) { @@ -368,7 +398,11 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis g2.setStroke(lineStroke); repaint(); try { - drawingController.broadcastDraggingDrawing(client.getUserName(), drawing, currentMode.toString(), shapeColor, strokeSize); + if (currentMode != Mode.TEXT){ + drawingController.broadcastDraggingDrawing(client.getUserName(), drawing, currentMode.toString(), shapeColor, strokeSize); + drawingController.broadcastDrawingUser(client.getUserName()); + } + } catch (RemoteException ex) { ex.printStackTrace(); } diff --git a/src/client/DrawingUpdate.java b/src/client/DrawingUpdate.java index 3ba11e49f18d3c1bee431f17fe669ea71a8dbfff..60ea6688da2a1f8f336a70813f61aa45dc9c472d 100644 --- a/src/client/DrawingUpdate.java +++ b/src/client/DrawingUpdate.java @@ -1,8 +1,8 @@ package client; -import GUI.DrawingArea; import remote.IDrawingUpdate; +import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; import java.io.ByteArrayInputStream; @@ -21,10 +21,28 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate } public boolean notifyUserIsDrawing(String fromClient) throws RemoteException { - client.getApplicationMain().getChatScreen().getActiveDrawingUserBox().append(fromClient); + System.out.println("Adding name of user to the list of drawing users"); + DefaultListModel temp = client.getApplicationMain().getChatScreen().getAllUserModel(); + if(temp.contains(fromClient)){ + System.out.println("Already in the list"); + } + else { + temp.addElement(fromClient); + } + return true; } + public void notifyUserStoppedDrawing(String fromClient) throws RemoteException{ + DefaultListModel temp = client.getApplicationMain().getChatScreen().getAllUserModel(); + int elementIndex = -1; + if(temp.contains(fromClient)){ + elementIndex = temp.indexOf(fromClient); + temp.remove(elementIndex); + } + + } + @Override public boolean notifyTextDrawing(String fromClient, String text, Font font, Color color, Point startPoint) throws RemoteException { client.getApplicationMain().getPaintGUI().getDrawingArea().getG2().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); diff --git a/src/remote/IDrawingController.java b/src/remote/IDrawingController.java index 8b2e030b1842076a371d4c5a63c4b0a86ee71e17..571cd2f437c83d5bb8f0eb8897fa5c67d68547cf 100644 --- a/src/remote/IDrawingController.java +++ b/src/remote/IDrawingController.java @@ -23,4 +23,5 @@ public interface IDrawingController extends Remote { boolean updateImage(byte[] rawImage) throws RemoteException; void broadcastDrawingUser (String fromClient) throws RemoteException; void getImage(String fromClient) throws RemoteException; + void broadcastDrawingUserStopped (String fromClient) throws RemoteException; } diff --git a/src/remote/IDrawingUpdate.java b/src/remote/IDrawingUpdate.java index cd066027f26d6395dc372d6f5351c182fc8e6b3e..3509141895adebdf35afe1b9fd9f321ee5e8235a 100644 --- a/src/remote/IDrawingUpdate.java +++ b/src/remote/IDrawingUpdate.java @@ -12,4 +12,5 @@ public interface IDrawingUpdate extends Remote, Serializable { boolean notifyCanvasClearance(String fromClient) throws RemoteException; boolean receiveImage(byte[] rawImage) throws RemoteException; boolean notifyUserIsDrawing(String fromClient) throws RemoteException; + void notifyUserStoppedDrawing(String fromClient) throws RemoteException; } diff --git a/src/server/DrawingController.java b/src/server/DrawingController.java index ce95c36a5236afe4e340c3ffcc934dafeedd5a90..ebbadcacc84bde7256f2f82920f16fd8b5e01b82 100644 --- a/src/server/DrawingController.java +++ b/src/server/DrawingController.java @@ -175,6 +175,16 @@ public class DrawingController extends UnicastRemoteObject implements IDrawingCo } + public void broadcastDrawingUserStopped (String fromClient) throws RemoteException{ + System.out.println("Current user stopped drawing" + fromClient); + IDrawingUpdate client; + for (User u: server.users){ + client = u.getIDrawingUpdate(); + client.notifyUserStoppedDrawing(fromClient); + } + + } + public boolean broadcastUpdateImage(String fromClient) throws RemoteException {