├── .DS_Store ├── .gitattributes ├── Project1 ├── Assignment1.pdf ├── DictionaryMultithreadSC │ ├── .idea │ │ ├── artifacts │ │ │ ├── DictionaryMultithreadSC_jar.xml │ │ │ └── DictionaryMultithreadSC_jar2.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── DictionaryClient │ │ └── META-INF │ │ │ └── MANIFEST.MF │ ├── DictionaryMultithreadSC.iml │ ├── DictionaryServer │ │ └── META-INF │ │ │ └── MANIFEST.MF │ ├── dic.txt │ ├── out │ │ ├── artifacts │ │ │ ├── DictionaryMultithreadSC_jar │ │ │ │ └── DictionaryMultithreadSC.jar │ │ │ └── DictionaryMultithreadSC_jar2 │ │ │ │ └── DictionaryMultithreadSC.jar │ │ └── production │ │ │ └── DictionaryMultithreadSC │ │ │ ├── DictionaryClient$1.class │ │ │ ├── DictionaryClient$2.class │ │ │ ├── DictionaryClient$3.class │ │ │ ├── DictionaryClient.class │ │ │ ├── DictionaryServer.class │ │ │ └── WordIO │ │ │ └── WordOperation.class │ └── src │ │ ├── DictionaryClient.java │ │ ├── DictionaryServer.java │ │ └── WordIO │ │ └── WordOperation.java ├── Jar Package │ ├── DictionaryClient.jar │ ├── DictionaryServer.jar │ └── dic.txt ├── README.md └── Report.pdf ├── Project2 ├── .DS_Store ├── Project2-2019.pptx ├── README.md ├── Version1.0 DLC │ ├── Chatbox │ │ ├── .idea │ │ │ ├── misc.xml │ │ │ ├── modules.xml │ │ │ └── workspace.xml │ │ ├── Chatbox.iml │ │ ├── dic.txt │ │ ├── out │ │ │ └── production │ │ │ │ └── Chatbox │ │ │ │ ├── ChatboxClient$1.class │ │ │ │ ├── ChatboxClient.class │ │ │ │ ├── ChatboxServer$1.class │ │ │ │ ├── ChatboxServer.class │ │ │ │ ├── dic.txt │ │ │ │ ├── message │ │ │ │ └── MsgOperation.class │ │ │ │ └── server.class │ │ └── src │ │ │ ├── ChatboxClient.java │ │ │ ├── ChatboxServer.java │ │ │ └── message │ │ │ └── MsgOperation.java │ └── README.md ├── Version1.0 │ ├── .classpath │ ├── .idea │ │ ├── misc.xml │ │ ├── modules.xml │ │ ├── uiDesigner.xml │ │ ├── vcs.xml │ │ └── workspace.xml │ ├── .project │ ├── Project2.iml │ ├── README.md │ ├── out │ │ └── production │ │ │ └── Project2 │ │ │ ├── META-INF │ │ │ └── Project2.kotlin_module │ │ │ ├── pic │ │ │ ├── Circle.png │ │ │ ├── Color.png │ │ │ ├── Line.png │ │ │ ├── New.png │ │ │ ├── Open.png │ │ │ ├── Oval.png │ │ │ ├── Pencil.png │ │ │ ├── Rect.png │ │ │ ├── RoundRect.png │ │ │ ├── Rubber.png │ │ │ ├── Save.png │ │ │ ├── Stroke.png │ │ │ ├── Word.png │ │ │ ├── fCircle.png │ │ │ ├── fOval.png │ │ │ ├── fRect.png │ │ │ └── frRect.png │ │ │ └── whiteboard │ │ │ ├── WhiteBoard$1.class │ │ │ ├── WhiteBoard$10.class │ │ │ ├── WhiteBoard$11.class │ │ │ ├── WhiteBoard$2.class │ │ │ ├── WhiteBoard$3.class │ │ │ ├── WhiteBoard$4.class │ │ │ ├── WhiteBoard$5.class │ │ │ ├── WhiteBoard$6.class │ │ │ ├── WhiteBoard$7.class │ │ │ ├── WhiteBoard$8.class │ │ │ ├── WhiteBoard$9.class │ │ │ ├── WhiteBoard$ButtonHandlerx.class │ │ │ ├── WhiteBoard$ButtonHandlery.class │ │ │ ├── WhiteBoard$Circle.class │ │ │ ├── WhiteBoard$DrawPanel.class │ │ │ ├── WhiteBoard$Line.class │ │ │ ├── WhiteBoard$Oval.class │ │ │ ├── WhiteBoard$Pencil.class │ │ │ ├── WhiteBoard$Rect.class │ │ │ ├── WhiteBoard$RoundRect.class │ │ │ ├── WhiteBoard$Rubber.class │ │ │ ├── WhiteBoard$Word.class │ │ │ ├── WhiteBoard$checkBoxHandler.class │ │ │ ├── WhiteBoard$drawings.class │ │ │ ├── WhiteBoard$fillCircle.class │ │ │ ├── WhiteBoard$fillOval.class │ │ │ ├── WhiteBoard$fillRect.class │ │ │ ├── WhiteBoard$fillRoundRect.class │ │ │ ├── WhiteBoard$mouseEvent1.class │ │ │ ├── WhiteBoard$mouseEvent2.class │ │ │ └── WhiteBoard.class │ └── src │ │ ├── chy.java │ │ ├── cli.java │ │ ├── pic │ │ ├── Circle.png │ │ ├── Color.png │ │ ├── Line.png │ │ ├── New.png │ │ ├── Open.png │ │ ├── Oval.png │ │ ├── Pencil.png │ │ ├── Rect.png │ │ ├── RoundRect.png │ │ ├── Rubber.png │ │ ├── Save.png │ │ ├── Stroke.png │ │ ├── Word.png │ │ ├── fCircle.png │ │ ├── fOval.png │ │ ├── fRect.png │ │ └── frRect.png │ │ └── whiteboard │ │ ├── Circle.java │ │ ├── Line.java │ │ ├── Oval.java │ │ ├── Pencil.java │ │ ├── Rect.java │ │ ├── RoundRect.java │ │ ├── Rubber.java │ │ ├── WhiteBoard.java │ │ ├── Word.java │ │ ├── drawings.java │ │ ├── fillCircle.java │ │ ├── fillOval.java │ │ ├── fillRect.java │ │ └── fillRoundRect.java ├── Version2.0 │ ├── .DS_Store │ ├── .classpath │ ├── .gitignore │ ├── .idea │ │ ├── misc.xml │ │ ├── modules.xml │ │ ├── vcs.xml │ │ └── workspace.xml │ ├── .project │ ├── README.md │ ├── Version2.0.iml │ ├── chatmsg.txt │ ├── out │ │ └── production │ │ │ └── Version2.0 │ │ │ ├── ClientServer │ │ │ ├── CreateWhiteBoard$1.class │ │ │ ├── CreateWhiteBoard$ServerThread.class │ │ │ ├── CreateWhiteBoard.class │ │ │ ├── JoinWhiteBoard$1.class │ │ │ └── JoinWhiteBoard.class │ │ │ ├── message │ │ │ └── MsgOperation.class │ │ │ ├── pic │ │ │ ├── ChatBox.png │ │ │ ├── Circle.png │ │ │ ├── Color.png │ │ │ ├── Line.png │ │ │ ├── New.png │ │ │ ├── Open.png │ │ │ ├── Oval.png │ │ │ ├── Pencil.png │ │ │ ├── Rect.png │ │ │ ├── RoundRect.png │ │ │ ├── Rubber.png │ │ │ ├── Save.png │ │ │ ├── Stroke.png │ │ │ ├── Word.png │ │ │ ├── fCircle.png │ │ │ ├── fOval.png │ │ │ ├── fRect.png │ │ │ └── frRect.png │ │ │ └── whiteboard │ │ │ ├── WhiteBoard$1.class │ │ │ ├── WhiteBoard$10.class │ │ │ ├── WhiteBoard$11.class │ │ │ ├── WhiteBoard$12.class │ │ │ ├── WhiteBoard$2.class │ │ │ ├── WhiteBoard$3.class │ │ │ ├── WhiteBoard$4.class │ │ │ ├── WhiteBoard$5.class │ │ │ ├── WhiteBoard$6.class │ │ │ ├── WhiteBoard$7.class │ │ │ ├── WhiteBoard$8.class │ │ │ ├── WhiteBoard$9.class │ │ │ ├── WhiteBoard$ButtonHandlerx.class │ │ │ ├── WhiteBoard$ButtonHandlery.class │ │ │ ├── WhiteBoard$Circle.class │ │ │ ├── WhiteBoard$DrawPanel.class │ │ │ ├── WhiteBoard$Line.class │ │ │ ├── WhiteBoard$Oval.class │ │ │ ├── WhiteBoard$Pencil.class │ │ │ ├── WhiteBoard$Rect.class │ │ │ ├── WhiteBoard$RoundRect.class │ │ │ ├── WhiteBoard$Rubber.class │ │ │ ├── WhiteBoard$Word.class │ │ │ ├── WhiteBoard$checkBoxHandler.class │ │ │ ├── WhiteBoard$drawings.class │ │ │ ├── WhiteBoard$fillCircle.class │ │ │ ├── WhiteBoard$fillOval.class │ │ │ ├── WhiteBoard$fillRect.class │ │ │ ├── WhiteBoard$fillRoundRect.class │ │ │ ├── WhiteBoard$mouseEvent1.class │ │ │ ├── WhiteBoard$mouseEvent2.class │ │ │ └── WhiteBoard.class │ └── src │ │ ├── .DS_Store │ │ ├── ClientServer │ │ ├── CreateWhiteBoard.java │ │ └── JoinWhiteBoard.java │ │ ├── message │ │ └── MsgOperation.java │ │ ├── pic │ │ ├── ChatBox.png │ │ ├── Circle.png │ │ ├── Color.png │ │ ├── Line.png │ │ ├── New.png │ │ ├── Open.png │ │ ├── Oval.png │ │ ├── Pencil.png │ │ ├── Rect.png │ │ ├── RoundRect.png │ │ ├── Rubber.png │ │ ├── Save.png │ │ ├── Stroke.png │ │ ├── Word.png │ │ ├── fCircle.png │ │ ├── fOval.png │ │ ├── fRect.png │ │ └── frRect.png │ │ └── whiteboard │ │ └── WhiteBoard.java ├── Version3.0 │ ├── .idea │ │ ├── artifacts │ │ │ └── out_jar.xml │ │ ├── misc.xml │ │ ├── modules.xml │ │ └── workspace.xml │ ├── README.md │ ├── Version3.0.iml │ ├── out │ │ └── production │ │ │ └── Version3.0 │ │ │ ├── CreateWhiteBoard$1.class │ │ │ ├── CreateWhiteBoard$ServerThread.class │ │ │ ├── CreateWhiteBoard.class │ │ │ ├── JoinWhiteBoard$1.class │ │ │ ├── JoinWhiteBoard.class │ │ │ ├── META-INF │ │ │ └── MANIFEST.MF │ │ │ ├── message │ │ │ └── MsgOperation.class │ │ │ ├── pic │ │ │ ├── ChatBox.png │ │ │ ├── Circle.png │ │ │ ├── Color.png │ │ │ ├── Line.png │ │ │ ├── New.png │ │ │ ├── Open.png │ │ │ ├── Oval.png │ │ │ ├── Pencil.png │ │ │ ├── Rect.png │ │ │ ├── RoundRect.png │ │ │ ├── Rubber.png │ │ │ ├── Save.png │ │ │ ├── Stroke.png │ │ │ ├── Word.png │ │ │ ├── fCircle.png │ │ │ ├── fOval.png │ │ │ ├── fRect.png │ │ │ └── frRect.png │ │ │ └── whiteboard │ │ │ ├── Circle.class │ │ │ ├── Line.class │ │ │ ├── Oval.class │ │ │ ├── Pencil.class │ │ │ ├── Rect.class │ │ │ ├── RoundRect.class │ │ │ ├── Rubber.class │ │ │ ├── WhiteBoard$1.class │ │ │ ├── WhiteBoard$10.class │ │ │ ├── WhiteBoard$11.class │ │ │ ├── WhiteBoard$12.class │ │ │ ├── WhiteBoard$2.class │ │ │ ├── WhiteBoard$3.class │ │ │ ├── WhiteBoard$4.class │ │ │ ├── WhiteBoard$5.class │ │ │ ├── WhiteBoard$6.class │ │ │ ├── WhiteBoard$7.class │ │ │ ├── WhiteBoard$8.class │ │ │ ├── WhiteBoard$9.class │ │ │ ├── WhiteBoard$ButtonHandlerx.class │ │ │ ├── WhiteBoard$ButtonHandlery.class │ │ │ ├── WhiteBoard$DrawPanel.class │ │ │ ├── WhiteBoard$checkBoxHandler.class │ │ │ ├── WhiteBoard$mouseEvent1.class │ │ │ ├── WhiteBoard$mouseEvent2.class │ │ │ ├── WhiteBoard.class │ │ │ ├── Word.class │ │ │ ├── drawings.class │ │ │ ├── fillCircle.class │ │ │ ├── fillOval.class │ │ │ ├── fillRect.class │ │ │ └── fillRoundRect.class │ └── src │ │ ├── CreateWhiteBoard.java │ │ ├── JoinWhiteBoard.java │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ ├── message │ │ └── MsgOperation.java │ │ ├── pic │ │ ├── ChatBox.png │ │ ├── Circle.png │ │ ├── Color.png │ │ ├── Line.png │ │ ├── New.png │ │ ├── Open.png │ │ ├── Oval.png │ │ ├── Pencil.png │ │ ├── Rect.png │ │ ├── RoundRect.png │ │ ├── Rubber.png │ │ ├── Save.png │ │ ├── Stroke.png │ │ ├── Word.png │ │ ├── fCircle.png │ │ ├── fOval.png │ │ ├── fRect.png │ │ └── frRect.png │ │ └── whiteboard │ │ ├── Circle.java │ │ ├── Line.java │ │ ├── Oval.java │ │ ├── Pencil.java │ │ ├── Rect.java │ │ ├── RoundRect.java │ │ ├── Rubber.java │ │ ├── WhiteBoard.java │ │ ├── Word.java │ │ ├── drawings.java │ │ ├── fillCircle.java │ │ ├── fillOval.java │ │ ├── fillRect.java │ │ └── fillRoundRect.java ├── Version4.0 │ ├── .gitignore │ ├── Assignment2-Report-WalidMoustafa.pdf │ ├── LICENSE.md │ ├── README.md │ ├── pom.xml │ └── src │ │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── walidmoustafa │ │ │ │ └── board │ │ │ │ ├── App.java │ │ │ │ └── gui │ │ │ │ ├── BoardEvent.java │ │ │ │ ├── BoardServer.java │ │ │ │ ├── Eraser.java │ │ │ │ ├── EventDispatcher.java │ │ │ │ ├── FreeHand.java │ │ │ │ ├── Line.java │ │ │ │ ├── Oval.java │ │ │ │ ├── Rect.java │ │ │ │ ├── Shape.java │ │ │ │ ├── SharedPanel.java │ │ │ │ ├── Text.java │ │ │ │ ├── UserListRenderer.java │ │ │ │ └── UserPanel.java │ │ └── resources │ │ │ └── log4j.properties │ │ └── test │ │ └── java │ │ └── com │ │ └── walidmoustafa │ │ └── board │ │ └── AppTest.java └── Version5.0 │ ├── .classpath │ ├── .gitattributes │ ├── .gitignore │ ├── .idea │ ├── .name │ ├── compiler.xml │ ├── encodings.xml │ ├── inspectionProfiles │ │ └── Project_Default.xml │ ├── misc.xml │ ├── modules.xml │ └── workspace.xml │ ├── .project │ ├── README.md │ ├── WhiteBoard5.0.iml │ ├── bin │ └── img │ │ ├── 1.gif │ │ ├── 11.gif │ │ ├── 12.gif │ │ ├── 2.gif │ │ ├── 3.gif │ │ ├── 4.gif │ │ ├── 5.gif │ │ ├── 6.gif │ │ ├── 7.gif │ │ ├── 8.gif │ │ ├── 9.gif │ │ └── logo.gif │ └── src │ ├── boardsocket │ ├── OutputList.java │ ├── PanelClient.java │ ├── PanelServer.java │ └── Server.java │ ├── dataSource │ ├── ColorConvert.java │ ├── DataArray.java │ ├── DataSource.java │ ├── ListData.java │ └── User.java │ ├── img │ ├── 1.gif │ ├── 11.gif │ ├── 12.gif │ ├── 2.gif │ ├── 3.gif │ ├── 4.gif │ ├── 5.gif │ ├── 6.gif │ ├── 7.gif │ ├── 8.gif │ ├── 9.gif │ └── logo.gif │ └── whiteboardgui │ ├── ColorPanel.java │ ├── DrawStyle.java │ ├── EraserStroke.java │ ├── GraphicAction.java │ ├── ListData.java │ ├── PaintCanvas.java │ ├── PencileStroke.java │ ├── ServerPanel.java │ ├── TextPanel.java │ ├── User.java │ └── WhiteBoardFrame.java └── README.md /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/.DS_Store -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /Project1/Assignment1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/Assignment1.pdf -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/.idea/artifacts/DictionaryMultithreadSC_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/DictionaryMultithreadSC_jar 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/.idea/artifacts/DictionaryMultithreadSC_jar2.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/DictionaryMultithreadSC_jar2 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/DictionaryClient/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: DictionaryClient 3 | 4 | -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/DictionaryMultithreadSC.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/DictionaryServer/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: DictionaryServer 3 | 4 | -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/dic.txt: -------------------------------------------------------------------------------- 1 | hello : this is a fact tha ! 2 | ello : ssss 3 | dfsello : ssss 4 | asd: asfsasas 5 | uulo : ssss 6 | chy : a name 7 | coo : a name 8 | lol : a game 9 | yyy : pppasd 10 | yyys : pppasd 11 | opop : ppplasd 12 | iii : iausfkshdf 13 | helloa : ggggasd 14 | some : opop 15 | soaame : opop 16 | edc : dddddd 17 | yuyu : ppppppp 18 | qwert : keyborad 19 | ytyt : opop 20 | hgyy : opopop 21 | nun : sdsdfsdf 22 | npp : sdsdfsdf 23 | kkk : sdsdfsdf 24 | chychy : ppp 25 | hous : pppppp 26 | hout : pppppp 27 | houpp : pppppp 28 | yes : one statement of ok 29 | -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/out/artifacts/DictionaryMultithreadSC_jar/DictionaryMultithreadSC.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/DictionaryMultithreadSC/out/artifacts/DictionaryMultithreadSC_jar/DictionaryMultithreadSC.jar -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/out/artifacts/DictionaryMultithreadSC_jar2/DictionaryMultithreadSC.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/DictionaryMultithreadSC/out/artifacts/DictionaryMultithreadSC_jar2/DictionaryMultithreadSC.jar -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryClient$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryClient$1.class -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryClient$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryClient$2.class -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryClient$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryClient$3.class -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryClient.class -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryServer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/DictionaryServer.class -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/WordIO/WordOperation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/DictionaryMultithreadSC/out/production/DictionaryMultithreadSC/WordIO/WordOperation.class -------------------------------------------------------------------------------- /Project1/DictionaryMultithreadSC/src/DictionaryServer.java: -------------------------------------------------------------------------------- 1 | import WordIO.WordOperation; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.DataOutputStream; 5 | import java.io.IOException; 6 | import java.net.ServerSocket; 7 | import java.net.Socket; 8 | import java.net.SocketException; 9 | import javax.net.ServerSocketFactory; 10 | 11 | public class DictionaryServer { 12 | 13 | // Declare the port number 14 | // private static int port = 3005; 15 | // Identifies the user number connected 16 | private static int counter = 0; 17 | static String dicpath = ""; 18 | static String portString = ""; 19 | static int port = 0; 20 | // private static String dicpath = "dic.txt"; 21 | 22 | public static void main(String[] args) { 23 | try { 24 | portString = args[0]; 25 | port = Integer.parseInt(portString); 26 | dicpath = args[1]; 27 | } 28 | catch (ArrayIndexOutOfBoundsException ae) { 29 | // ae.printStackTrace(); 30 | System.out.println("ArrayIndexOutOfBoundsException occurs\nPlease ensure input args in legal form"); 31 | return; 32 | } 33 | catch (NumberFormatException ne) { 34 | // ne.printStackTrace(); 35 | System.out.println("NumberFormatException occurs\nPlease ensure input args in legal form"); 36 | return; 37 | } 38 | 39 | ServerSocketFactory factory = ServerSocketFactory.getDefault(); 40 | 41 | try (ServerSocket server = factory.createServerSocket(port)) { 42 | System.out.println("Waiting for client connection-"); 43 | 44 | // Wait for connections. 45 | while (true) { 46 | Socket client = server.accept(); 47 | counter ++; 48 | System.out.println("Client " + counter + ": Applying for connection!"); 49 | 50 | // Start a new thread for a connection 51 | Thread t = new Thread(() -> serveClient(client, dicpath)); 52 | t.start(); 53 | } 54 | 55 | } 56 | catch (IOException e) { 57 | // e.printStackTrace(); 58 | System.out.println("IOException occurs"); 59 | } 60 | 61 | } 62 | 63 | private static void serveClient(Socket client, String dicpath) { 64 | WordOperation op = new WordOperation(); 65 | 66 | try (Socket clientSocket = client) { 67 | // Input stream 68 | DataInputStream input = new DataInputStream(clientSocket.getInputStream()); 69 | // Output Stream 70 | DataOutputStream output = new DataOutputStream(clientSocket.getOutputStream()); 71 | String msg = input.readUTF(); 72 | System.out.println("CLIENT: " + clientSocket.getInetAddress().getHostName() + " " + clientSocket.getLocalPort() + " " + msg); 73 | 74 | String[] method = msg.split("(\\s)*::(\\s)*"); 75 | if (method.length < 2) { 76 | // output.writeUTF("Server: Hi Client " + counter + " The content is illegal !"); 77 | output.writeUTF(" The content is illegal !"); 78 | throw new Exception ("The content from client is illegal !"); 79 | } 80 | else if (method[0].toLowerCase().equals("query")) { 81 | // output.writeUTF("Server: Hi Client "+ counter +" this is result for u:\n" + op.queryword(dicpath, method[1])); 82 | output.writeUTF(op.queryword(dicpath, method[1])); 83 | System.out.println("query request has been DONE !"); 84 | } 85 | else if (method[0].toLowerCase().equals("add")) { 86 | // output.writeUTF("Server: Hi Client "+ counter +" this is result for u:\n" + op.addword(dicpath, method[1])); 87 | output.writeUTF(op.addword(dicpath, method[1])); 88 | System.out.println("add request has been DONE !"); 89 | } 90 | else if (method[0].toLowerCase().equals("delete")) { 91 | // output.writeUTF("Server: Hi Client "+ counter +" this is result for u:\n" + op.deleteword(dicpath, method[1])); 92 | output.writeUTF(op.deleteword(dicpath, method[1])); 93 | System.out.println("delete request has been DONE !"); 94 | } 95 | 96 | } 97 | catch (SocketException e) { 98 | System.out.println("closed ..."); 99 | } 100 | catch (IOException e) { 101 | e.printStackTrace(); 102 | } 103 | catch (Exception e) { 104 | e.printStackTrace(); 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Project1/Jar Package/DictionaryClient.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/Jar Package/DictionaryClient.jar -------------------------------------------------------------------------------- /Project1/Jar Package/DictionaryServer.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/Jar Package/DictionaryServer.jar -------------------------------------------------------------------------------- /Project1/Jar Package/dic.txt: -------------------------------------------------------------------------------- 1 | yes : a statement of ok 2 | -------------------------------------------------------------------------------- /Project1/README.md: -------------------------------------------------------------------------------- 1 | # Multithread Server-Client Dictionary Service 2 | 3 | This is a project based on Server-Client architecture to implement multi-thread server to handle concurrent requests from several clients to query or operate a dictionary file on server. 4 | 5 | More details about this project and the code can be found in [Assignment1.pdf]() and [Report.pdf]() 6 | 7 | There are two ways to execute this project (Need parameters to run main function): 8 | 9 | - Open `DictionaryMultithreadSC` in IntelliJ IDEA, run the DictionaryServer.java with running parameters in form of ` ` such as `2029 dic.txt` and the DictionaryClient.java with running parameters in the form of ` ` such as `localhost 2029`. 10 | 11 | - Run the `jar` package in `Jar Package as` in cmd/shell as `java –jar DictionaryServer.jar ` and `java –jar DictionaryClient.jar ` 12 | -------------------------------------------------------------------------------- /Project1/Report.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project1/Report.pdf -------------------------------------------------------------------------------- /Project2/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/.DS_Store -------------------------------------------------------------------------------- /Project2/Project2-2019.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Project2-2019.pptx -------------------------------------------------------------------------------- /Project2/README.md: -------------------------------------------------------------------------------- 1 | # Distributed System - Project 2 2 | 3 | ## Details of this project can be found in `Project2-2019.pptx`, required functions are not fully implemented 4 | 5 | ## Different versions in developing process 6 | 7 | - [x] Version 1.0 8 | - [x] Version 2.0 9 | - [x] Version 3.0 10 | 11 | ## Based on Others's Code 12 | 13 | - [x] Version4.0 (RMI) 14 | - [x] Version5.0 (Socket) 15 | -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/Chatbox.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/dic.txt: -------------------------------------------------------------------------------- 1 | 2019-10-10 20-03-32 Root : 士大夫 2 | 2019-10-10 20-03-35 Root : 的烦烦烦 3 | 2019-10-10 20-03-38 Root : 的方法 4 | 2019-10-10 20-03-43 Root : 此此次 5 | 2019-10-10 20-03-49 Root : 的发表 6 | 2019-10-10 20-03-51 Root : 从 7 | 2019-10-10 20-03-55 Root : sd 8 | 2019-10-10 20-03-57 Root : dfgdf 9 | 2019-10-10 20-03-58 Root : ddddddddd 10 | 2019-10-10 20-04-02 Root : sdfsdf 11 | 2019-10-10 20-04-05 Root : sss 12 | 2019-10-10 20-04-07 Root : dfg 13 | 2019-10-10 20-04-09 Root : dfg 14 | 2019-10-10 20-04-14 Root : dfgdd 15 | 2019-10-10 20-04-22 Root : fffff 16 | 2019-10-10 20-04-29 Root : dfgggg 17 | 2019-10-10 20-04-32 Root : ddd 18 | 2019-10-10 20-04-35 Root : ssdf 19 | 2019-10-10 20-06-34 Root : asd 20 | 2019-10-10 20-06-37 Root : sdfff 21 | 2019-10-10 20-06-39 Root : dfg 22 | 2019-10-10 20-06-42 Root : 456 23 | 2019-10-10 20-06-44 Root : 234 24 | 2019-10-10 20-06-47 Root : 6897 25 | 2019-10-10 20-06-51 Root : 1352 26 | 2019-10-10 20-06-54 Root : 34534 27 | 2019-10-10 20-06-58 Root : 4544 28 | 2019-10-10 20-07-05 Root : 444 29 | 2019-10-10 20-07-40 Root : 456 30 | 2019-10-10 20-07-43 Root : 7978 31 | 2019-10-10 20-07-46 Root : e5456 32 | 2019-10-10 20-07-49 Root : 676 33 | 2019-10-10 20-07-51 Root : 345345 34 | 2019-10-10 20-07-53 Root : 56 35 | 2019-10-10 20-07-56 Root : 5788 36 | 2019-10-10 20-07-58 Root : 3453 37 | 2019-10-10 20-08-02 Root : dfgdfgdgh 38 | 2019-10-10 20-08-06 Root : ertttetyrtyrtu 39 | 2019-10-10 20-08-29 Root : 手动阀手动阀 40 | 2019-10-10 20-08-34 Root : 手动阀手动阀 41 | 2019-10-10 20-08-37 Root : sdfsdf 42 | 2019-10-10 20-08-40 Root : werwef 43 | 2019-10-10 20-10-47 Root : as 44 | 2019-10-10 20-10-49 Root : sdfsfd 45 | 2019-10-10 20-10-52 Root : ssdrwefwef 46 | 2019-10-10 20-10-55 Root : werwerwer 47 | 2019-10-10 20-10-59 Root : 2453453 48 | 2019-10-10 20-11-02 Root : sgdsfg 49 | 2019-10-10 20-11-17 Root : 我发士大夫 50 | 2019-10-10 20-11-20 Root : 手动阀手动阀 51 | 2019-10-10 20-11-24 Root : sdfsdf 52 | 2019-10-10 20-11-26 Root : sdfsdf3 53 | 2019-10-10 20-11-29 Root : sdfsdfsd 54 | 2019-10-10 20-11-32 Root : 232fsdf 55 | 2019-10-10 20-13-30 Root : 士大夫 56 | 2019-10-10 20-13-34 Root : 水电费 57 | 2019-10-11 11-19-57 Root : wrtg 58 | 2019-10-11 11-20-04 chy : sdsdf 59 | -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/ChatboxClient$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/ChatboxClient$1.class -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/ChatboxClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/ChatboxClient.class -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/ChatboxServer$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/ChatboxServer$1.class -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/ChatboxServer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/ChatboxServer.class -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/dic.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/dic.txt -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/message/MsgOperation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/message/MsgOperation.class -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/server.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0 DLC/Chatbox/out/production/Chatbox/server.class -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/Chatbox/src/message/MsgOperation.java: -------------------------------------------------------------------------------- 1 | package message; 2 | import java.io.*; 3 | 4 | public class MsgOperation { 5 | 6 | public String getMsg(String pathname, String msg) { 7 | synchronized(MsgOperation.class){ 8 | String result = ""; 9 | try { 10 | /* // This can be used to test concurrency 11 | try { 12 | Thread.currentThread().sleep(4000); 13 | } 14 | catch (InterruptedException e) { 15 | e.printStackTrace(); 16 | } 17 | */ 18 | File filename = new File(pathname); 19 | if (!filename.exists()) { 20 | filename.createNewFile(); 21 | System.out.println("No such file AND it was created now !"); 22 | // return "No such file AND it was created now !"; 23 | } 24 | OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(filename, true)); 25 | BufferedWriter bw = new BufferedWriter(writer); 26 | 27 | String[] content = msg.split("( )*:( )*"); 28 | int clientPos = Integer.parseInt(content[0]); 29 | if (content.length > 2 && content[2].length() != 0){ 30 | bw.write(content[1] + " : " + content[2] + '\n'); 31 | bw.flush(); 32 | bw.close(); 33 | } 34 | 35 | // get lines of the file 36 | FileReader freader = new FileReader(filename); 37 | LineNumberReader lnreader = new LineNumberReader(freader); 38 | lnreader.skip(Long.MAX_VALUE); 39 | int lines = lnreader.getLineNumber(); 40 | lnreader.close(); 41 | 42 | String[] filecontent = new String[lines]; 43 | InputStreamReader reader = new InputStreamReader(new FileInputStream(filename)); 44 | BufferedReader br = new BufferedReader(reader); 45 | 46 | String line = ""; 47 | 48 | int count = 0; 49 | 50 | while (line != null) { 51 | line = br.readLine(); 52 | if (line != null) { 53 | filecontent[count++] = line; 54 | } 55 | } 56 | if (clientPos < count) { 57 | for (int i = clientPos; i < count; i++) { 58 | result += filecontent[i] + "\n"; 59 | } 60 | result = String.valueOf(count) + " :: " + result; 61 | } 62 | else { 63 | result = String.valueOf(count) + " :: " + ""; 64 | } 65 | 66 | } 67 | catch (Exception e) { 68 | // e.printStackTrace(); 69 | return "IOException occurs"; 70 | } 71 | 72 | return result; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Project2/Version1.0 DLC/README.md: -------------------------------------------------------------------------------- 1 | # Distributed_System_Project2_DLC -- Independent ChatBox 2 | 3 | ## Environment 4 | 5 | - `IntelliJ IDEA / cmd` 6 | - `JDK 12.0` 7 | 8 | ## Independent ChatBox 9 | 10 | - Implement of one server-multiple clients chatbox 11 | 12 | - To mitigate the throughput of data, using file position to send message from server to clients 13 | 14 | ## RUN (In cmd) 15 | 16 | - locate in `.../src` 17 | 18 | - run `javac -encoding utf-8 *.java` (compile) 19 | 20 | - run `java ChatboxServer ` such as `java ChatboxServer 2029 dic.txt` 21 | 22 | - run `java ChatboxClient ` such as `java ChatboxClient localhost 2029 client1` -------------------------------------------------------------------------------- /Project2/Version1.0/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Project2/Version1.0/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project2/Version1.0/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Project2/Version1.0/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project2/Version1.0/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Project2 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Project2/Version1.0/Project2.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Project2/Version1.0/README.md: -------------------------------------------------------------------------------- 1 | # Distributed_System_Project2 2 | 3 | ## Environment 4 | 5 | - `IntelliJ IDEA / cmd` 6 | - `JDK 12.0` 7 | 8 | ## Version 1.0 9 | 10 | - Based on socket communication 11 | 12 | - Server & Single Client structure (unilateral communication) 13 | 14 | - Commnication based on `ObjectOutputStream/ObjectInputStream` 15 | 16 | ## Issues 17 | 18 | - When drawing a shape, the object will lag on one step (Not solved yet) 19 | 20 | ## RUN (In cmd) 21 | 22 | - locate in `.../src` 23 | 24 | - run `javac -encoding utf-8 *.java` (compile) 25 | 26 | - run `java chy` 27 | 28 | - run `java cli` -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/META-INF/Project2.kotlin_module: -------------------------------------------------------------------------------- 1 |  -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Circle.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Color.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Line.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/New.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/New.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Open.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Oval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Oval.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Pencil.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Rect.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/RoundRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/RoundRect.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Rubber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Rubber.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Save.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Stroke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Stroke.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/Word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/Word.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/fCircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/fCircle.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/fOval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/fOval.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/fRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/fRect.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/pic/frRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/pic/frRect.png -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$1.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$10.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$10.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$11.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$11.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$2.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$3.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$4.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$5.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$6.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$7.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$7.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$8.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$8.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$9.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$9.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$ButtonHandlerx.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$ButtonHandlerx.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$ButtonHandlery.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$ButtonHandlery.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Circle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Circle.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$DrawPanel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$DrawPanel.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Line.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Line.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Oval.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Oval.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Pencil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Pencil.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Rect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Rect.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$RoundRect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$RoundRect.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Rubber.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Rubber.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Word.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$Word.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$checkBoxHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$checkBoxHandler.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$drawings.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$drawings.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$fillCircle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$fillCircle.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$fillOval.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$fillOval.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$fillRect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$fillRect.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$fillRoundRect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$fillRoundRect.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$mouseEvent1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$mouseEvent1.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$mouseEvent2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard$mouseEvent2.class -------------------------------------------------------------------------------- /Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/out/production/Project2/whiteboard/WhiteBoard.class -------------------------------------------------------------------------------- /Project2/Version1.0/src/chy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-09-20 15:35:02 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-01 15:25:26 6 | */ 7 | import whiteboard.*; 8 | 9 | import java.awt.*; 10 | import java.awt.event.*; 11 | import javax.swing.*; 12 | import java.io.*; 13 | 14 | public class chy { 15 | public static void main(String args[]) { 16 | try { 17 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 18 | } catch (Exception e) { 19 | } 20 | WhiteBoard newPad = new WhiteBoard(); 21 | newPad.setTitle("Server Side"); 22 | newPad.setSize(1800, 200); 23 | newPad.addWindowListener( 24 | new WindowAdapter() { 25 | public void windowClosing(WindowEvent e) { 26 | System.exit(0); 27 | } 28 | }); 29 | } 30 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/cli.java: -------------------------------------------------------------------------------- 1 | import java.awt.Graphics; 2 | import java.io.DataInputStream; 3 | import java.io.ObjectInputStream; 4 | import java.io.IOException; 5 | import java.net.Socket; 6 | import java.net.UnknownHostException; 7 | 8 | import javax.swing.JFrame; 9 | import whiteboard.*; 10 | import java.awt.*; 11 | import java.awt.event.*; 12 | import javax.swing.*; 13 | import java.io.*; 14 | 15 | public class cli extends JFrame implements Runnable{ 16 | int x1,x2,y1,y2,curchoice; 17 | DataInputStream is; 18 | ObjectInputStream iss; 19 | Graphics g; 20 | WhiteBoard newPad; 21 | drawings nb; 22 | 23 | public static void main(String args[]) { 24 | cli CP = new cli(); 25 | CP.creat(); 26 | CP.ShowUI(); 27 | } 28 | 29 | public void creat() { 30 | try { 31 | Socket client =new Socket("localhost", 9090); 32 | iss = new ObjectInputStream( client.getInputStream()); 33 | } catch (UnknownHostException e) { 34 | e.printStackTrace(); 35 | } catch (IOException e) { 36 | e.printStackTrace(); 37 | } 38 | } 39 | 40 | public void ShowUI() { 41 | try { 42 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 43 | } catch (Exception e) { 44 | } 45 | newPad = new WhiteBoard(); 46 | newPad.setTitle("Client Side A"); 47 | newPad.setSize(1800, 200); 48 | newPad.addWindowListener( 49 | new WindowAdapter() { 50 | public void windowClosing(WindowEvent e) { 51 | System.exit(0); 52 | } 53 | }); 54 | 55 | g = newPad.getGraphics(); 56 | Thread t = new Thread(this); 57 | t.start(); 58 | 59 | } 60 | 61 | @Override 62 | public void run() { 63 | while (true) { 64 | try { 65 | nb = (drawings)iss.readObject(); 66 | newPad.createNewItemInClient(nb); 67 | 68 | } catch (IOException e) { 69 | e.printStackTrace(); 70 | } 71 | catch (ClassNotFoundException ee) { 72 | ee.printStackTrace(); 73 | } 74 | } 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Circle.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Color.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Line.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/New.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/New.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Open.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Oval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Oval.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Pencil.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Rect.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/RoundRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/RoundRect.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Rubber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Rubber.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Save.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Stroke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Stroke.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/Word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/Word.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/fCircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/fCircle.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/fOval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/fOval.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/fRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/fRect.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/pic/frRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version1.0/src/pic/frRect.png -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/Circle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:57 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Circle extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.drawOval(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)), 19 | Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2))); 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/Line.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:00 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Line extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke, 17 | BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); 18 | g2d.drawLine(x1, y1, x2, y2); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/Oval.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:24:52 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Oval extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.drawOval(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/Pencil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:24:21 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Pencil extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke, 17 | BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); 18 | g2d.drawLine(x1, y1, x2, y2); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/Rect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:24:02 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Rect extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.drawRect(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2)); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/RoundRect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:23:49 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class RoundRect extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.drawRoundRect(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2), 19 | 50, 35); 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/Rubber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:23:38 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Rubber extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(255, 255, 255)); 16 | g2d.setStroke(new BasicStroke(stroke + 3, 17 | BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); 18 | g2d.drawLine(x1, y1, x2, y2); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/Word.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:23:35 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Word extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setFont(new Font(s2, x2 + y2, ((int) stroke) * 16)); 17 | if (s1 != null) { 18 | g2d.drawString(s1, x1, y1); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/drawings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:23:30 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | import java.io.*; 11 | 12 | import java.awt.Graphics; 13 | 14 | public class drawings implements Serializable { 15 | public int x1, y1, x2, y2; 16 | int R, G, B; 17 | float stroke; 18 | int type; 19 | String s1; 20 | String s2; 21 | void draw(Graphics2D g2d) {}; 22 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/fillCircle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:44 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class fillCircle extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.fillOval(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)), 19 | Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2))); 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/fillOval.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:31 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class fillOval extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.fillOval(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2)); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/fillRect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:20 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class fillRect extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.fillRect(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2)); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version1.0/src/whiteboard/fillRoundRect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:08 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class fillRoundRect extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.fillRoundRect(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2), 19 | 50, 35); 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version2.0/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/.DS_Store -------------------------------------------------------------------------------- /Project2/Version2.0/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Project2/Version2.0/.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | -------------------------------------------------------------------------------- /Project2/Version2.0/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project2/Version2.0/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Project2/Version2.0/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project2/Version2.0/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | Version2.0 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | 15 | org.eclipse.jdt.core.javanature 16 | 17 | 18 | -------------------------------------------------------------------------------- /Project2/Version2.0/README.md: -------------------------------------------------------------------------------- 1 | # Distributed_System_Project2 2 | 3 | ## Environment 4 | 5 | - `IntelliJ IDEA / cmd` 6 | - `JDK 12.0` 7 | 8 | ## Version 2.0 9 | 10 | - Based on socket communication 11 | 12 | - Server & Multiple Client structure 13 | 14 | - Commnication based on `DataOutputStream/DataInputStream` 15 | 16 | - Add 'ChatBox' function 17 | 18 | ## Issues 19 | 20 | - ... 21 | 22 | ## RUN (In cmd) 23 | 24 | - locate in `.../src` 25 | 26 | - run `javac -encoding utf-8 *.java` (compile) 27 | 28 | - run `java CreateWhiteBoard` 29 | 30 | - run `java JoinWhiteBoard` -------------------------------------------------------------------------------- /Project2/Version2.0/Version2.0.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Project2/Version2.0/chatmsg.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/chatmsg.txt -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/ClientServer/CreateWhiteBoard$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/ClientServer/CreateWhiteBoard$1.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/ClientServer/CreateWhiteBoard$ServerThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/ClientServer/CreateWhiteBoard$ServerThread.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/ClientServer/CreateWhiteBoard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/ClientServer/CreateWhiteBoard.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/ClientServer/JoinWhiteBoard$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/ClientServer/JoinWhiteBoard$1.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/ClientServer/JoinWhiteBoard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/ClientServer/JoinWhiteBoard.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/message/MsgOperation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/message/MsgOperation.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/ChatBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/ChatBox.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Circle.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Color.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Line.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/New.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/New.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Open.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Oval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Oval.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Pencil.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Rect.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/RoundRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/RoundRect.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Rubber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Rubber.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Save.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Stroke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Stroke.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/Word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/Word.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/fCircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/fCircle.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/fOval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/fOval.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/fRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/fRect.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/pic/frRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/pic/frRect.png -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$1.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$10.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$10.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$11.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$11.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$12.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$12.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$2.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$3.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$4.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$5.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$6.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$7.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$7.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$8.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$8.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$9.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$9.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$ButtonHandlerx.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$ButtonHandlerx.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$ButtonHandlery.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$ButtonHandlery.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Circle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Circle.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$DrawPanel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$DrawPanel.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Line.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Line.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Oval.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Oval.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Pencil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Pencil.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Rect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Rect.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$RoundRect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$RoundRect.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Rubber.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Rubber.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Word.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$Word.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$checkBoxHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$checkBoxHandler.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$drawings.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$drawings.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$fillCircle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$fillCircle.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$fillOval.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$fillOval.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$fillRect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$fillRect.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$fillRoundRect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$fillRoundRect.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$mouseEvent1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$mouseEvent1.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$mouseEvent2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard$mouseEvent2.class -------------------------------------------------------------------------------- /Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/out/production/Version2.0/whiteboard/WhiteBoard.class -------------------------------------------------------------------------------- /Project2/Version2.0/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/.DS_Store -------------------------------------------------------------------------------- /Project2/Version2.0/src/ClientServer/JoinWhiteBoard.java: -------------------------------------------------------------------------------- 1 | package ClientServer; 2 | import java.awt.Graphics; 3 | import java.net.Socket; 4 | import java.net.UnknownHostException; 5 | 6 | import javax.swing.JFrame; 7 | 8 | import whiteboard.*; 9 | import java.awt.*; 10 | import java.awt.event.*; 11 | import javax.swing.*; 12 | import java.io.*; 13 | import java.util.ArrayList; 14 | 15 | public class JoinWhiteBoard extends JFrame { 16 | public final static int MIN_PORT = 0; 17 | public final static int MAX_PORT = 65535; 18 | public static int port = 9090; 19 | public static String address = "localhost"; 20 | public static final String TYPE = "client"; 21 | public static String userName = "Client"; 22 | DataInputStream is; 23 | DataOutputStream os; 24 | ObjectInputStream iss; 25 | Graphics g; 26 | static WhiteBoard newPad; 27 | Socket client; 28 | 29 | public static void main(String args[]) throws IOException, ClassNotFoundException { 30 | parseArgs(args); 31 | JoinWhiteBoard CP = new JoinWhiteBoard(); 32 | CP.creat(); 33 | CP.ShowUI(); 34 | newPad.receiveData(); 35 | } 36 | 37 | private static void parseArgs(String[] args) { 38 | if (args.length == 3) { 39 | if (isNumeric(args[1]) && MIN_PORT <= Integer.parseInt(args[1]) && Integer.parseInt(args[1]) <= MAX_PORT) { 40 | address = args[0]; 41 | port = Integer.parseInt(args[1]); 42 | userName = args[2]; 43 | } 44 | else { 45 | System.out.println("Port number is invalid"); 46 | System.exit(1); 47 | } 48 | } 49 | else { 50 | System.out.println("Argument input is invalid"); 51 | System.exit(1); 52 | } 53 | } 54 | 55 | private static boolean isNumeric(String strNum) { 56 | try { 57 | double d = Double.parseDouble(strNum); 58 | } catch (NumberFormatException | NullPointerException nfe) { 59 | System.out.println("Invalid port"); 60 | System.exit(1); 61 | } 62 | return true; 63 | } 64 | 65 | //产生一个Socket类用于连接服务器,并得到输入流 66 | public void creat() { 67 | try { 68 | client = new Socket(address, port); 69 | is = new DataInputStream(client.getInputStream()); 70 | iss = new ObjectInputStream(client.getInputStream()); 71 | os = new DataOutputStream(new BufferedOutputStream(client.getOutputStream())); 72 | } catch (UnknownHostException e) { 73 | e.printStackTrace(); 74 | } catch (IOException e) { 75 | e.printStackTrace(); 76 | } 77 | } 78 | //构造客户端界面并启动线程 79 | public void ShowUI() throws IOException, ClassNotFoundException { 80 | try { 81 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 82 | } catch (Exception e) { 83 | e.printStackTrace(); 84 | } 85 | newPad = new WhiteBoard(TYPE, userName, client); 86 | newPad.setTitle(userName); 87 | newPad.addWindowListener( 88 | new WindowAdapter() { 89 | public void windowClosing(WindowEvent e) { 90 | System.exit(0); 91 | } 92 | }); 93 | } 94 | } -------------------------------------------------------------------------------- /Project2/Version2.0/src/message/MsgOperation.java: -------------------------------------------------------------------------------- 1 | package message; 2 | import java.io.*; 3 | 4 | public class MsgOperation { 5 | 6 | public String getMsg(String pathname, String msg) { 7 | synchronized(MsgOperation.class){ 8 | String result = ""; 9 | try { 10 | /* // This can be used to test concurrency 11 | try { 12 | Thread.currentThread().sleep(4000); 13 | } 14 | catch (InterruptedException e) { 15 | e.printStackTrace(); 16 | } 17 | */ 18 | File filename = new File(pathname); 19 | if (!filename.exists()) { 20 | filename.createNewFile(); 21 | System.out.println("No such file AND it was created now !"); 22 | // return "No such file AND it was created now !"; 23 | } 24 | OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(filename, true)); 25 | BufferedWriter bw = new BufferedWriter(writer); 26 | 27 | String[] content = msg.split("( )*:( )*"); 28 | int clientPos = Integer.parseInt(content[0]); 29 | if (content.length > 2 && content[2].length() != 0){ 30 | bw.write(content[1] + " : " + content[2] + '\n'); 31 | bw.flush(); 32 | bw.close(); 33 | } 34 | 35 | // get lines of the file 36 | FileReader freader = new FileReader(filename); 37 | LineNumberReader lnreader = new LineNumberReader(freader); 38 | lnreader.skip(Long.MAX_VALUE); 39 | int lines = lnreader.getLineNumber(); 40 | lnreader.close(); 41 | 42 | String[] filecontent = new String[lines]; 43 | InputStreamReader reader = new InputStreamReader(new FileInputStream(filename)); 44 | BufferedReader br = new BufferedReader(reader); 45 | 46 | String line = ""; 47 | 48 | int count = 0; 49 | 50 | while (line != null) { 51 | line = br.readLine(); 52 | if (line != null) { 53 | filecontent[count++] = line; 54 | } 55 | } 56 | if (clientPos < count) { 57 | for (int i = clientPos; i < count; i++) { 58 | result += filecontent[i] + "\n"; 59 | } 60 | result = String.valueOf(count) + " :: " + result; 61 | } 62 | else { 63 | result = String.valueOf(count) + " :: " + ""; 64 | } 65 | 66 | } 67 | catch (Exception e) { 68 | // e.printStackTrace(); 69 | return "IOException occurs"; 70 | } 71 | 72 | return result; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/ChatBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/ChatBox.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Circle.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Color.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Line.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/New.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/New.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Open.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Oval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Oval.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Pencil.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Rect.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/RoundRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/RoundRect.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Rubber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Rubber.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Save.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Stroke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Stroke.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/Word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/Word.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/fCircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/fCircle.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/fOval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/fOval.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/fRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/fRect.png -------------------------------------------------------------------------------- /Project2/Version2.0/src/pic/frRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version2.0/src/pic/frRect.png -------------------------------------------------------------------------------- /Project2/Version3.0/.idea/artifacts/out_jar.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | $PROJECT_DIR$/out/artifacts/out_jar 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Project2/Version3.0/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project2/Version3.0/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Project2/Version3.0/README.md: -------------------------------------------------------------------------------- 1 | # Distributed_System_Project2 2 | 3 | ## Environment 4 | 5 | - `IntelliJ IDEA / cmd` 6 | - `JDK 12.0` 7 | 8 | ## Version 3.0 9 | 10 | - Based on socket communication 11 | 12 | - Server & Multiple Client structure 13 | 14 | - Commnication based on `ObjectOutputStream/ObjectInputStream` 15 | 16 | 17 | ## Issues 18 | 19 | - shapes still lag on one step 20 | 21 | ## RUN (In cmd) 22 | 23 | - locate in `.../src` 24 | 25 | - run `javac -encoding utf-8 *.java` (compile) 26 | 27 | - run `java CreateWhiteBoard
` such as `java CreateWhiteBoard localhost 9999 Server` 28 | 29 | - run `java CreateWhiteBoard
` such as `java JoinWhiteBoard localhost 9999 Client1` -------------------------------------------------------------------------------- /Project2/Version3.0/Version3.0.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/CreateWhiteBoard$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/CreateWhiteBoard$1.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/CreateWhiteBoard$ServerThread.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/CreateWhiteBoard$ServerThread.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/CreateWhiteBoard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/CreateWhiteBoard.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/JoinWhiteBoard$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/JoinWhiteBoard$1.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/JoinWhiteBoard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/JoinWhiteBoard.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: JoinWhiteBoard 3 | 4 | -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/message/MsgOperation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/message/MsgOperation.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/ChatBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/ChatBox.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Circle.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Color.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Line.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/New.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/New.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Open.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Oval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Oval.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Pencil.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Rect.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/RoundRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/RoundRect.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Rubber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Rubber.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Save.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Stroke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Stroke.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/Word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/Word.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/fCircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/fCircle.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/fOval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/fOval.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/fRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/fRect.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/pic/frRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/pic/frRect.png -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/Circle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/Circle.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/Line.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/Line.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/Oval.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/Oval.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/Pencil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/Pencil.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/Rect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/Rect.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/RoundRect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/RoundRect.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/Rubber.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/Rubber.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$1.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$10.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$10.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$11.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$11.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$12.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$12.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$2.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$3.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$4.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$5.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$6.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$7.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$7.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$8.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$8.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$9.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$9.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$ButtonHandlerx.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$ButtonHandlerx.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$ButtonHandlery.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$ButtonHandlery.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$DrawPanel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$DrawPanel.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$checkBoxHandler.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$checkBoxHandler.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$mouseEvent1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$mouseEvent1.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$mouseEvent2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard$mouseEvent2.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/WhiteBoard.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/Word.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/Word.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/drawings.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/drawings.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/fillCircle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/fillCircle.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/fillOval.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/fillOval.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/fillRect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/fillRect.class -------------------------------------------------------------------------------- /Project2/Version3.0/out/production/Version3.0/whiteboard/fillRoundRect.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/out/production/Version3.0/whiteboard/fillRoundRect.class -------------------------------------------------------------------------------- /Project2/Version3.0/src/JoinWhiteBoard.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 15:32:22 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 18:39:10 6 | */ 7 | import java.awt.Graphics; 8 | import java.net.Socket; 9 | import java.net.UnknownHostException; 10 | 11 | import javax.swing.JFrame; 12 | 13 | import whiteboard.*; 14 | import java.awt.*; 15 | import java.awt.event.*; 16 | import javax.swing.*; 17 | import java.io.*; 18 | import java.util.ArrayList; 19 | 20 | public class JoinWhiteBoard extends JFrame { 21 | int x1,x2,y1,y2,curchoice; 22 | DataInputStream is; 23 | DataOutputStream os; 24 | ObjectInputStream iss; 25 | WhiteBoard newPad; 26 | drawings nb; 27 | static String userName; 28 | static String address; 29 | static int port; 30 | Socket client; 31 | 32 | public static void main(String args[]) throws IOException, ClassNotFoundException { 33 | parseArgs(args); 34 | JoinWhiteBoard CP = new JoinWhiteBoard(); 35 | CP.creat(); 36 | CP.ShowUI(); 37 | } 38 | 39 | private static void parseArgs(String[] args) { 40 | if(args.length == 3) { 41 | if(isNumeric(args[1]) && 1024 <= Integer.parseInt(args[1]) && Integer.parseInt(args[1]) <= 65535) { 42 | address = args[0]; 43 | port = Integer.parseInt(args[1]); 44 | System.out.println(port); 45 | userName = args[2]; 46 | } 47 | else { 48 | System.out.println("Port number is invalid"); 49 | System.exit(1); 50 | } 51 | } 52 | else { 53 | System.out.println("Argument input is invalid"); 54 | System.exit(1); 55 | } 56 | } 57 | 58 | private static boolean isNumeric(String strNum) { 59 | try { 60 | double d = Double.parseDouble(strNum); 61 | } catch (NumberFormatException | NullPointerException nfe) { 62 | System.out.println("Invalid port"); 63 | System.exit(1); 64 | } 65 | return true; 66 | } 67 | 68 | //产生一个Socket类用于连接服务器,并得到输入流 69 | public void creat() { 70 | try { 71 | client = new Socket(address, port); 72 | is = new DataInputStream(client.getInputStream()); 73 | iss = new ObjectInputStream(client.getInputStream()); 74 | os = new DataOutputStream(new BufferedOutputStream(client.getOutputStream())); 75 | } catch (UnknownHostException e) { 76 | System.out.println("UnknownHostException"); 77 | // e.printStackTrace(); 78 | } catch (IOException e) { 79 | System.out.println("IOException"); 80 | // e.printStackTrace(); 81 | } 82 | } 83 | //构造客户端界面并启动线程 84 | public void ShowUI() throws IOException, ClassNotFoundException { 85 | try { 86 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 87 | } catch (Exception e) { 88 | e.printStackTrace(); 89 | } 90 | newPad = new WhiteBoard(userName, client); 91 | newPad.setTitle(userName); 92 | newPad.addWindowListener( 93 | new WindowAdapter() { 94 | public void windowClosing(WindowEvent e) { 95 | System.exit(0); 96 | } 97 | }); 98 | 99 | } 100 | 101 | } 102 | -------------------------------------------------------------------------------- /Project2/Version3.0/src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Main-Class: JoinWhiteBoard 3 | 4 | -------------------------------------------------------------------------------- /Project2/Version3.0/src/message/MsgOperation.java: -------------------------------------------------------------------------------- 1 | package message; 2 | import java.io.*; 3 | 4 | public class MsgOperation { 5 | 6 | public String getMsg(String pathname, String msg) { 7 | synchronized(MsgOperation.class){ 8 | String result = ""; 9 | try { 10 | /* // This can be used to test concurrency 11 | try { 12 | Thread.currentThread().sleep(4000); 13 | } 14 | catch (InterruptedException e) { 15 | e.printStackTrace(); 16 | } 17 | */ 18 | File filename = new File(pathname); 19 | if (!filename.exists()) { 20 | filename.createNewFile(); 21 | System.out.println("No such file AND it was created now !"); 22 | // return "No such file AND it was created now !"; 23 | } 24 | OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(filename, true)); 25 | BufferedWriter bw = new BufferedWriter(writer); 26 | 27 | String[] content = msg.split("( )*:( )*"); 28 | int clientPos = Integer.parseInt(content[0]); 29 | if (content.length > 2 && content[2].length() != 0){ 30 | bw.write(content[1] + " : " + content[2] + '\n'); 31 | bw.flush(); 32 | bw.close(); 33 | } 34 | 35 | // get lines of the file 36 | FileReader freader = new FileReader(filename); 37 | LineNumberReader lnreader = new LineNumberReader(freader); 38 | lnreader.skip(Long.MAX_VALUE); 39 | int lines = lnreader.getLineNumber(); 40 | lnreader.close(); 41 | 42 | String[] filecontent = new String[lines]; 43 | InputStreamReader reader = new InputStreamReader(new FileInputStream(filename)); 44 | BufferedReader br = new BufferedReader(reader); 45 | 46 | String line = ""; 47 | 48 | int count = 0; 49 | 50 | while (line != null) { 51 | line = br.readLine(); 52 | if (line != null) { 53 | filecontent[count++] = line; 54 | } 55 | } 56 | if (clientPos < count) { 57 | for (int i = clientPos; i < count; i++) { 58 | result += filecontent[i] + "\n"; 59 | } 60 | result = String.valueOf(count) + " :: " + result; 61 | } 62 | else { 63 | result = String.valueOf(count) + " :: " + ""; 64 | } 65 | 66 | } 67 | catch (Exception e) { 68 | // e.printStackTrace(); 69 | return "IOException occurs"; 70 | } 71 | 72 | return result; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/ChatBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/ChatBox.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Circle.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Color.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Color.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Line.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Line.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/New.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/New.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Open.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Oval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Oval.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Pencil.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Pencil.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Rect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Rect.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/RoundRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/RoundRect.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Rubber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Rubber.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Save.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Stroke.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Stroke.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/Word.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/Word.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/fCircle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/fCircle.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/fOval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/fOval.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/fRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/fRect.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/pic/frRect.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version3.0/src/pic/frRect.png -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/Circle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:57 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Circle extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.drawOval(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)), 19 | Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2))); 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/Line.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:00 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Line extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke, 17 | BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); 18 | g2d.drawLine(x1, y1, x2, y2); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/Oval.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:24:52 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Oval extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.drawOval(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/Pencil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:24:21 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Pencil extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke, 17 | BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); 18 | g2d.drawLine(x1, y1, x2, y2); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/Rect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:24:02 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Rect extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.drawRect(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2)); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/RoundRect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:23:49 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class RoundRect extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.drawRoundRect(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2), 19 | 50, 35); 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/Rubber.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:23:38 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Rubber extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(255, 255, 255)); 16 | g2d.setStroke(new BasicStroke(stroke + 3, 17 | BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); 18 | g2d.drawLine(x1, y1, x2, y2); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/Word.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:23:35 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class Word extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setFont(new Font(s2, x2 + y2, ((int) stroke) * 16)); 17 | if (s1 != null) { 18 | g2d.drawString(s1, x1, y1); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/drawings.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:23:30 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | import java.io.*; 11 | 12 | import java.awt.Graphics; 13 | 14 | public class drawings implements Serializable { 15 | public int x1, y1, x2, y2; 16 | int R, G, B; 17 | float stroke; 18 | int type; 19 | String s1; 20 | String s2; 21 | void draw(Graphics2D g2d) {}; 22 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/fillCircle.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:44 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class fillCircle extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.fillOval(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2)), 19 | Math.max(Math.abs(x1 - x2), Math.abs(y1 - y2))); 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/fillOval.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:31 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class fillOval extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.fillOval(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2)); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/fillRect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:20 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class fillRect extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.fillRect(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2)); 19 | } 20 | } -------------------------------------------------------------------------------- /Project2/Version3.0/src/whiteboard/fillRoundRect.java: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: Puffrora 3 | * @Date: 2019-10-25 14:56:25 4 | * @Last Modified by: Puffrora 5 | * @Last Modified time: 2019-10-25 15:25:08 6 | */ 7 | package whiteboard; 8 | import java.awt.*; 9 | import javax.swing.*; 10 | 11 | import java.awt.Graphics; 12 | 13 | public class fillRoundRect extends drawings { 14 | void draw(Graphics2D g2d) { 15 | g2d.setPaint(new Color(R, G, B)); 16 | g2d.setStroke(new BasicStroke(stroke)); 17 | g2d.fillRoundRect(Math.min(x1, x2), Math.min(y1, y2), 18 | Math.abs(x1 - x2), Math.abs(y1 - y2), 19 | 50, 35); 20 | } 21 | } -------------------------------------------------------------------------------- /Project2/Version4.0/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /Project2/Version4.0/Assignment2-Report-WalidMoustafa.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version4.0/Assignment2-Report-WalidMoustafa.pdf -------------------------------------------------------------------------------- /Project2/Version4.0/README.md: -------------------------------------------------------------------------------- 1 | Please refer to Assignment2-Report-WalidMoustafa.pdf for more details. 2 | 3 | This assignment is about implementing a distributed Whiteboard application. The whiteboard will be shared by several users connected to a central server using Java RMI (Remote Method Invocation) framework. The implemented architecture is a star schema with a simple messaging server in the centre and several desktop clients exchanging and synchronizing user interface as well as control events via RMI function calls the central server. The first user connects to the server is granted the Admin role which authorizes her to receive following users requests-to-join and decide which requests to accept and grant access to the shared whiteboard and which requests to simply revoke and bounce out of the board. Even authorized board users can be bounced out of the whiteboard at any time by the Admin user. Moreover, when the admin user quits the application, all connected board users are sent a notification message and all are bounced out and the board is cleared out. By the end of a board session (which normally happens when all users quit or the Admin user terminates the running whiteboard session), the board server discards all the session data, but does NOT shutdown. Instead, the board server keeps waiting for the first user to connect to be granted the Admin role and start a brand new whiteboard session. 4 | -------------------------------------------------------------------------------- /Project2/Version4.0/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.walidmoustafa.board 6 | distributed-board 7 | 1.0 8 | jar 9 | 10 | distributed-board 11 | http://maven.apache.org 12 | 13 | 14 | UTF-8 15 | 16 | 17 | 18 | 19 | org.slf4j 20 | slf4j-log4j12 21 | 1.7.5 22 | 23 | 24 | junit 25 | junit 26 | 3.8.1 27 | test 28 | 29 | 30 | 31 | 32 | 33 | 34 | org.apache.maven.plugins 35 | maven-compiler-plugin 36 | 3.2 37 | 38 | 1.8 39 | 1.8 40 | 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-assembly-plugin 46 | 2.4 47 | 48 | 49 | jar-with-dependencies 50 | 51 | 52 | 53 | true 54 | com.walidmoustafa.board.App 55 | 56 | 57 | 58 | 59 | 60 | assemble-all 61 | package 62 | 63 | single 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/BoardEvent.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.gui.BoardServer 7 | * File: com.walidmoustafa.board.gui.BoardEvent.java 8 | */ 9 | 10 | import java.awt.*; 11 | import java.io.Serializable; 12 | import java.util.ArrayList; 13 | 14 | 15 | public class BoardEvent implements Serializable { 16 | 17 | private static final long serialVersionUID = 1L; 18 | public int eventID; 19 | public final String eventType; 20 | public String userID; 21 | public ArrayList userList; 22 | public int currentShape; 23 | public int currentMode; 24 | public Color currentColor; 25 | public boolean erasing; 26 | public int eraserSize; 27 | public Point startPoint; 28 | public Point endPoint; 29 | public ArrayList points; 30 | public ArrayList textInput; 31 | public ArrayList shapes; 32 | 33 | public BoardEvent(String eType) { 34 | eventType = eType; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/BoardServer.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.App 7 | * File: com.walidmoustafa.board.gui.BoardServer.java 8 | */ 9 | 10 | import java.rmi.Remote; 11 | import java.rmi.RemoteException; 12 | import java.util.ArrayList; 13 | 14 | 15 | public interface BoardServer extends Remote { 16 | 17 | String joinBoard(String candidateID) throws RemoteException; 18 | 19 | String getAdmin() throws RemoteException; 20 | 21 | void approveUser(String userID) throws RemoteException; 22 | 23 | void bounceUser(String userID) throws RemoteException; 24 | 25 | void addBoardEvent(BoardEvent event) throws RemoteException; 26 | 27 | ArrayList getBoardEvents(int startFrom) throws RemoteException; 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/Eraser.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.App 7 | * File: com.walidmoustafa.board.gui.Eraser.java 8 | */ 9 | 10 | import java.awt.Color; 11 | import java.awt.Graphics; 12 | import java.awt.Point; 13 | import java.io.Serializable; 14 | import java.util.ArrayList; 15 | 16 | 17 | public class Eraser implements Shape, Serializable { 18 | private static final int seed = 3; 19 | private static final long serialVersionUID = 1L; 20 | private int size = 1; 21 | private ArrayList points = new ArrayList<>(); 22 | 23 | public Eraser(ArrayList pts, int size) { 24 | this.size = size; 25 | points = pts; 26 | } 27 | 28 | private static void erasePoint(Graphics gfx, int size, Point point) { 29 | size = size * seed; 30 | int x = (point.x - size) > 0 ? (point.x - size) : 0; 31 | int y = (point.y - size) > 0 ? (point.y - size) : 0; 32 | int width = size * 2; 33 | int height = size * 2; 34 | 35 | gfx.fillRect(x, y, width, height); 36 | } 37 | 38 | public static void draw(Graphics gfx, int size, ArrayList points) { 39 | Color clr = gfx.getColor(); 40 | gfx.setColor(new Color(240, 240, 240)); 41 | for (Point point : points) { 42 | erasePoint(gfx, size, point); 43 | } 44 | gfx.setColor(clr); 45 | } 46 | 47 | @Override 48 | public void draw(Graphics gfx) { 49 | Color clr = gfx.getColor(); 50 | gfx.setColor(new Color(240, 240, 240)); 51 | for (Point point : points) { 52 | erasePoint(gfx, size, point); 53 | } 54 | gfx.setColor(clr); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/FreeHand.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.App 7 | * File: com.walidmoustafa.board.gui.FreeHand.java 8 | */ 9 | 10 | import java.awt.Graphics; 11 | import java.awt.Point; 12 | import java.io.Serializable; 13 | import java.util.ArrayList; 14 | 15 | 16 | public class FreeHand implements Shape, Serializable { 17 | private static final long serialVersionUID = 1L; 18 | private ArrayList points = new ArrayList<>(); 19 | 20 | public FreeHand(ArrayList pts) { 21 | points = pts; 22 | } 23 | 24 | public static void draw(Graphics gfx, ArrayList points) { 25 | for (int i = 1; i < points.size(); i++) { 26 | Point p1 = points.get(i - 1); 27 | Point p2 = points.get(i); 28 | gfx.drawLine(p1.x, p1.y, p2.x, p2.y); 29 | } 30 | } 31 | 32 | @Override 33 | public void draw(Graphics gfx) { 34 | for (int i = 1; i < points.size(); i++) { 35 | Point p1 = points.get(i - 1); 36 | Point p2 = points.get(i); 37 | gfx.drawLine(p1.x, p1.y, p2.x, p2.y); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/Line.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.App 7 | * File: com.walidmoustafa.board.gui.Line.java 8 | */ 9 | 10 | import java.awt.*; 11 | import java.io.Serializable; 12 | 13 | public class Line implements Shape, Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | private final Point startPoint; 17 | private final Point endPoint; 18 | 19 | public Line(Point sPoint, Point ePoint) { 20 | startPoint = sPoint; 21 | endPoint = ePoint; 22 | } 23 | 24 | public static void draw(Graphics gfx, Point sPoint, Point ePoint) { 25 | gfx.drawLine(sPoint.x, sPoint.y, ePoint.x, ePoint.y); 26 | } 27 | 28 | @Override 29 | public void draw(Graphics gfx) { 30 | gfx.drawLine(startPoint.x, startPoint.y, endPoint.x, endPoint.y); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/Oval.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.App 7 | * File: com.walidmoustafa.board.gui.Oval.java 8 | */ 9 | 10 | import java.awt.*; 11 | import java.io.Serializable; 12 | 13 | public class Oval implements Shape, Serializable { 14 | private static final int UNFILLED = 0; 15 | private static final long serialVersionUID = 1L; 16 | private final Point startPoint; 17 | private final Point endPoint; 18 | private final int mode; 19 | private final Color color; 20 | 21 | public Oval(Point sPoint, Point ePoint, int currentMode, Color currentColor) { 22 | startPoint = sPoint; 23 | endPoint = ePoint; 24 | mode = currentMode; 25 | color = currentColor; 26 | } 27 | 28 | public static void draw(Graphics gfx, Point sPoint, Point ePoint, int currentMode, Color currentColor) { 29 | int x, y, width, height; 30 | 31 | if (sPoint.x < ePoint.x) { 32 | x = sPoint.x; 33 | width = ePoint.x - sPoint.x; 34 | } else { 35 | x = ePoint.x; 36 | width = sPoint.x - ePoint.x; 37 | } 38 | 39 | if (sPoint.y < ePoint.y) { 40 | y = sPoint.y; 41 | height = ePoint.y - sPoint.y; 42 | } else { 43 | y = ePoint.y; 44 | height = sPoint.y - ePoint.y; 45 | } 46 | 47 | if (currentMode == UNFILLED) { 48 | gfx.drawOval(x, y, width, height); 49 | } else { 50 | gfx.setColor(currentColor); 51 | gfx.fillOval(x, y, width, height); 52 | } 53 | } 54 | 55 | @Override 56 | public void draw(Graphics gfx) { 57 | int x, y, width, height; 58 | 59 | if (startPoint.x < endPoint.x) { 60 | x = startPoint.x; 61 | width = endPoint.x - startPoint.x; 62 | } else { 63 | x = endPoint.x; 64 | width = startPoint.x - endPoint.x; 65 | } 66 | 67 | if (startPoint.y < endPoint.y) { 68 | y = startPoint.y; 69 | height = endPoint.y - startPoint.y; 70 | } else { 71 | y = endPoint.y; 72 | height = startPoint.y - endPoint.y; 73 | } 74 | 75 | if (mode == UNFILLED) { 76 | gfx.drawOval(x, y, width, height); 77 | } else { 78 | gfx.setColor(color); 79 | gfx.fillOval(x, y, width, height); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/Rect.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui; 2 | 3 | /* 4 | Name: Walid Moustafa 5 | Student ID: 563080 6 | Subject: COMP90015 - Distributed Systems 7 | Assignment: Assignment 2 - Distributed Whiteboard 8 | Project: com.walidmoustafa.board.App 9 | File: com.walidmoustafa.board.gui.Rect.java 10 | */ 11 | 12 | import java.awt.*; 13 | import java.io.Serializable; 14 | 15 | public class Rect implements Shape, Serializable { 16 | private static final int UNFILLED = 0; 17 | private static final long serialVersionUID = 1L; 18 | private final Point startPoint; 19 | private final Point endPoint; 20 | private final int mode; 21 | private final Color color; 22 | 23 | 24 | public Rect(Point sPoint, Point ePoint, int currentMode, Color currentColor) { 25 | startPoint = sPoint; 26 | endPoint = ePoint; 27 | mode = currentMode; 28 | color = currentColor; 29 | } 30 | 31 | public static void draw(Graphics gfx, Point sPoint, Point ePoint, int currentMode, Color currentColor) { 32 | int x, y, width, height; 33 | 34 | if (sPoint.x < ePoint.x) { 35 | x = sPoint.x; 36 | width = ePoint.x - sPoint.x; 37 | } else { 38 | x = ePoint.x; 39 | width = sPoint.x - ePoint.x; 40 | } 41 | 42 | if (sPoint.y < ePoint.y) { 43 | y = sPoint.y; 44 | height = ePoint.y - sPoint.y; 45 | } else { 46 | y = ePoint.y; 47 | height = sPoint.y - ePoint.y; 48 | } 49 | 50 | if (currentMode == UNFILLED) { 51 | gfx.drawRect(x, y, width, height); 52 | } else { 53 | gfx.setColor(currentColor); 54 | gfx.fillRect(x, y, width, height); 55 | } 56 | } 57 | 58 | @Override 59 | public void draw(Graphics gfx) { 60 | int x, y, width, height; 61 | 62 | if (startPoint.x < endPoint.x) { 63 | x = startPoint.x; 64 | width = endPoint.x - startPoint.x; 65 | } else { 66 | x = endPoint.x; 67 | width = startPoint.x - endPoint.x; 68 | } 69 | 70 | if (startPoint.y < endPoint.y) { 71 | y = startPoint.y; 72 | height = endPoint.y - startPoint.y; 73 | } else { 74 | y = endPoint.y; 75 | height = startPoint.y - endPoint.y; 76 | } 77 | 78 | if (mode == UNFILLED) { 79 | gfx.drawRect(x, y, width, height); 80 | } else { 81 | gfx.setColor(color); 82 | gfx.fillRect(x, y, width, height); 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/Shape.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.App 7 | * File: com.walidmoustafa.board.gui.Shape.java 8 | */ 9 | 10 | import java.awt.*; 11 | 12 | interface Shape { 13 | 14 | void draw(Graphics gfx); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/Text.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.App 7 | * File: com.walidmoustafa.board.gui.Text.java 8 | */ 9 | 10 | import java.awt.Graphics; 11 | import java.awt.Point; 12 | import java.io.Serializable; 13 | import java.util.ArrayList; 14 | 15 | public class Text implements Shape, Serializable { 16 | 17 | private static final long serialVersionUID = 1L; 18 | private final Point startPoint; 19 | private ArrayList lines = new ArrayList<>(); 20 | 21 | public Text(Point sPoint, ArrayList input) { 22 | startPoint = sPoint; 23 | lines = input; 24 | } 25 | 26 | public static void draw(Graphics gfx, Point sPoint, ArrayList lines) { 27 | int spacing = gfx.getFontMetrics().getHeight(); 28 | int n = 0; 29 | for (String line : lines) { 30 | gfx.drawString(line, sPoint.x, sPoint.y + (n * spacing)); 31 | n++; 32 | } 33 | } 34 | 35 | @Override 36 | public void draw(Graphics gfx) { 37 | int spacing = gfx.getFontMetrics().getHeight(); 38 | int n = 0; 39 | for (String line : lines) { 40 | gfx.drawString(line, startPoint.x, startPoint.y + (n * spacing)); 41 | n++; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/UserListRenderer.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.App 7 | * File: com.walidmoustafa.board.gui.UserListRenderer.java 8 | */ 9 | 10 | import com.walidmoustafa.board.App; 11 | 12 | import java.awt.Color; 13 | import java.awt.Component; 14 | 15 | import javax.swing.DefaultListCellRenderer; 16 | import javax.swing.JList; 17 | 18 | class UserListRenderer extends DefaultListCellRenderer { 19 | 20 | private static final long serialVersionUID = 1L; 21 | 22 | @Override 23 | public Component getListCellRendererComponent(JList list, 24 | Object value, int index, boolean isSelected, boolean cellHasFocus) { 25 | 26 | String currentUser = value.toString(); 27 | setText(currentUser); 28 | 29 | Color background; 30 | Color foreground; 31 | 32 | if (currentUser.equals(App.userID)) { 33 | background = Color.WHITE; 34 | foreground = Color.BLUE; 35 | } else if (currentUser.equals(App.adminID)) { 36 | background = Color.WHITE; 37 | foreground = Color.RED; 38 | } else { 39 | if (App.isAdmin) { 40 | if (isSelected) { 41 | background = Color.RED; 42 | foreground = Color.WHITE; 43 | } else { 44 | background = Color.WHITE; 45 | foreground = Color.BLACK; 46 | } 47 | } else { 48 | background = Color.WHITE; 49 | foreground = Color.BLACK; 50 | } 51 | } 52 | 53 | setBackground(background); 54 | setForeground(foreground); 55 | 56 | return this; 57 | 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/java/com/walidmoustafa/board/gui/UserPanel.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board.gui;/* 2 | * Name: Walid Moustafa 3 | * Student ID: 563080 4 | * Subject: COMP90015 - Distributed Systems 5 | * Assignment: Assignment 2 - Distributed Whiteboard 6 | * Project: com.walidmoustafa.board.App 7 | * File: com.walidmoustafa.board.gui.UserPanel.java 8 | */ 9 | 10 | import com.walidmoustafa.board.App; 11 | 12 | import java.awt.*; 13 | import java.awt.event.ActionEvent; 14 | import java.awt.event.ActionListener; 15 | import java.awt.event.KeyEvent; 16 | import java.awt.event.KeyListener; 17 | import java.rmi.RemoteException; 18 | import java.util.Vector; 19 | 20 | import javax.swing.*; 21 | import javax.swing.event.ListSelectionEvent; 22 | import javax.swing.event.ListSelectionListener; 23 | 24 | public class UserPanel extends JPanel implements ActionListener, ListSelectionListener, KeyListener { 25 | 26 | private static final long serialVersionUID = 1L; 27 | private final BoardServer boardServer; 28 | private final String userID; 29 | private final JScrollPane scrollPane; 30 | private final JList usersList; 31 | private JButton bounceButton; 32 | private final Vector userIDs = new Vector<>(); 33 | private String selectedUser; 34 | 35 | public UserPanel(BoardServer bServer, String uID, JScrollPane sPane) { 36 | boardServer = bServer; 37 | userID = uID; 38 | scrollPane = sPane; 39 | setBorder(BorderFactory.createTitledBorder("Board Users")); 40 | setLayout(new BorderLayout()); 41 | 42 | if (App.isAdmin) { 43 | bounceButton = new JButton("Bounce"); 44 | add(bounceButton, BorderLayout.SOUTH); 45 | bounceButton.addActionListener(this); 46 | } 47 | 48 | usersList = new JList<>(userIDs); 49 | UserListRenderer renderer = new UserListRenderer(); 50 | usersList.setCellRenderer(renderer); 51 | add(usersList, BorderLayout.CENTER); 52 | usersList.addListSelectionListener(this); 53 | addKeyListener(this); 54 | } 55 | 56 | public synchronized void refresh(Vector uIDs) { 57 | userIDs.removeAllElements(); 58 | for (String auser : uIDs) { 59 | if (auser.charAt(0) != '#') { 60 | userIDs.add(auser); 61 | } 62 | } 63 | usersList.setListData(userIDs); 64 | if (userIDs.size() >= 2) { 65 | usersList.setSelectedIndex(1); 66 | } else { 67 | usersList.setSelectedIndex(0); 68 | } 69 | scrollPane.revalidate(); 70 | scrollPane.repaint(); 71 | } 72 | 73 | @Override 74 | public void valueChanged(ListSelectionEvent event) { 75 | if (event.getSource() == usersList && !event.getValueIsAdjusting()) { 76 | String stringValue = usersList.getSelectedValue(); 77 | if (stringValue != null) { 78 | selectedUser = stringValue; 79 | if (bounceButton != null) { 80 | if (selectedUser.equalsIgnoreCase(App.adminID)) { 81 | bounceButton.setEnabled(false); 82 | } else { 83 | bounceButton.setEnabled(true); 84 | } 85 | } 86 | } 87 | } 88 | } 89 | 90 | @Override 91 | public void actionPerformed(ActionEvent event) { 92 | if (event.getSource() == bounceButton) { 93 | int selection = usersList.getSelectedIndex(); 94 | if (selection >= 0) { 95 | try { 96 | boardServer.bounceUser(selectedUser); 97 | } catch (RemoteException e) { 98 | e.printStackTrace(); 99 | } 100 | } 101 | } 102 | } 103 | 104 | @Override 105 | public void keyTyped(KeyEvent e) { 106 | App.sharedPanel.keyTyping(e); 107 | } 108 | 109 | @Override 110 | public void keyPressed(KeyEvent e) { 111 | } 112 | 113 | @Override 114 | public void keyReleased(KeyEvent e) { 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /Project2/Version4.0/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #log4j.debug 2 | log4j.threshold=DEBUG 3 | log4j.rootLogger=INFO, file 4 | log4j.logger.au.com.alexsolutions=DEBUG 5 | # Direct log messages to a log file 6 | log4j.appender.file=org.apache.log4j.RollingFileAppender 7 | log4j.appender.file.File=logs/distributedboard.log 8 | log4j.appender.file.MaxFileSize=10MB 9 | log4j.appender.file.MaxBackupIndex=10 10 | log4j.appender.file.layout=org.apache.log4j.PatternLayout 11 | log4j.appender.file.layout.ConversionPattern=%d{yyyy/MM/dd HH:mm:ss,SSS} [%t] %-5p - %m%n -------------------------------------------------------------------------------- /Project2/Version4.0/src/test/java/com/walidmoustafa/board/AppTest.java: -------------------------------------------------------------------------------- 1 | package com.walidmoustafa.board; 2 | 3 | import junit.framework.Test; 4 | import junit.framework.TestCase; 5 | import junit.framework.TestSuite; 6 | 7 | /** 8 | * Unit test for simple App. 9 | */ 10 | public class AppTest 11 | extends TestCase 12 | { 13 | /** 14 | * Create the test case 15 | * 16 | * @param testName name of the test case 17 | */ 18 | public AppTest( String testName ) 19 | { 20 | super( testName ); 21 | } 22 | 23 | /** 24 | * @return the suite of tests being tested 25 | */ 26 | public static Test suite() 27 | { 28 | return new TestSuite( AppTest.class ); 29 | } 30 | 31 | /** 32 | * Rigourous Test :-) 33 | */ 34 | public void testApp() 35 | { 36 | assertTrue( true ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Project2/Version5.0/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Project2/Version5.0/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /Project2/Version5.0/.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | 14 | # ========================= 15 | # Operating System Files 16 | # ========================= 17 | 18 | # OSX 19 | # ========================= 20 | 21 | .DS_Store 22 | .AppleDouble 23 | .LSOverride 24 | 25 | # Thumbnails 26 | ._* 27 | 28 | # Files that might appear on external disk 29 | .Spotlight-V100 30 | .Trashes 31 | 32 | # Directories potentially created on remote AFP share 33 | .AppleDB 34 | .AppleDesktop 35 | Network Trash Folder 36 | Temporary Items 37 | .apdisk 38 | 39 | # Windows 40 | # ========================= 41 | 42 | # Windows image file caches 43 | Thumbs.db 44 | ehthumbs.db 45 | 46 | # Folder config file 47 | Desktop.ini 48 | 49 | # Recycle Bin used on file shares 50 | $RECYCLE.BIN/ 51 | 52 | # Windows Installer files 53 | *.cab 54 | *.msi 55 | *.msm 56 | *.msp 57 | 58 | # Windows shortcuts 59 | *.lnk 60 | -------------------------------------------------------------------------------- /Project2/Version5.0/.idea/.name: -------------------------------------------------------------------------------- 1 | WhiteBoard5.0 -------------------------------------------------------------------------------- /Project2/Version5.0/.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /Project2/Version5.0/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Project2/Version5.0/.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | -------------------------------------------------------------------------------- /Project2/Version5.0/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Project2/Version5.0/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Project2/Version5.0/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | WhiteBoard5.0 4 | 5 | 6 | 7 | 8 | org.eclipse.jdt.core.javabuilder 9 | 10 | 11 | 12 | 13 | org.eclipse.jdt.core.javanature 14 | 15 | 16 | -------------------------------------------------------------------------------- /Project2/Version5.0/README.md: -------------------------------------------------------------------------------- 1 | ## The code is based on this [repo](https://github.com/wybneu/WhiteBoard) 2 | 3 | ## Execution 4 | 5 | - compile 6 | 7 | - run `src\boardsocket\Server.java` 8 | 9 | - run `src\boardsocket\PanelClient.java` -------------------------------------------------------------------------------- /Project2/Version5.0/WhiteBoard5.0.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/1.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/11.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/12.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/2.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/3.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/4.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/5.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/6.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/7.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/8.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/9.gif -------------------------------------------------------------------------------- /Project2/Version5.0/bin/img/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/bin/img/logo.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/boardsocket/OutputList.java: -------------------------------------------------------------------------------- 1 | package boardsocket; 2 | 3 | import java.io.BufferedWriter; 4 | import java.io.IOException; 5 | import java.util.ArrayList; 6 | 7 | class OutputList 8 | { 9 | private ArrayList list; 10 | 11 | public OutputList() { 12 | list = new ArrayList(); 13 | } 14 | 15 | public synchronized void append(BufferedWriter writer) { 16 | list.add(writer); 17 | } 18 | 19 | public synchronized void remove(BufferedWriter writer) { 20 | list.remove(writer); 21 | } 22 | 23 | public synchronized void update(String dataBuffer) throws IOException 24 | { 25 | System.out.println("Sending..."); 26 | for (int i = 0; i < list.size(); ++i) { 27 | BufferedWriter out = (BufferedWriter) list.get(i); 28 | out.write(dataBuffer); 29 | out.newLine(); 30 | out.flush(); 31 | } 32 | System.out.println("Finish sending!"); 33 | } 34 | } -------------------------------------------------------------------------------- /Project2/Version5.0/src/boardsocket/PanelClient.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/boardsocket/PanelClient.java -------------------------------------------------------------------------------- /Project2/Version5.0/src/boardsocket/PanelServer.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/boardsocket/PanelServer.java -------------------------------------------------------------------------------- /Project2/Version5.0/src/boardsocket/Server.java: -------------------------------------------------------------------------------- 1 | package boardsocket; 2 | 3 | import javax.swing.JOptionPane; 4 | import javax.swing.UIManager; 5 | 6 | import whiteboardgui.ServerPanel; 7 | 8 | public class Server { 9 | 10 | public Server(){ 11 | this.initialization(); 12 | } 13 | 14 | private void initialization(){ 15 | try { 16 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 17 | } catch (Exception e) { 18 | e.printStackTrace(); 19 | } 20 | 21 | int portNumber = 0; 22 | boolean legalPort = false; 23 | do { 24 | String input = JOptionPane.showInputDialog(null, 25 | "Enter a port for the server (1024 ~ 65535):", "2029"); 26 | if (input == null) { 27 | System.exit(1); 28 | } 29 | try { 30 | portNumber = Integer.parseInt(input); 31 | if ((portNumber < 1024) || (portNumber > 65535)) { 32 | JOptionPane.showMessageDialog(null, 33 | "Port number should be in 1024 ~ 65535", "Error", JOptionPane.ERROR_MESSAGE); 34 | } else { 35 | legalPort = true; 36 | } 37 | } catch (NumberFormatException e) { 38 | JOptionPane.showMessageDialog(null, 39 | "Please in legal pure number format", "Error", JOptionPane.ERROR_MESSAGE); 40 | 41 | } catch (Exception e) { 42 | JOptionPane.showMessageDialog(null, 43 | "Unkown error occurs", "Error", JOptionPane.ERROR_MESSAGE); 44 | } 45 | 46 | } while (!legalPort); 47 | 48 | System.out.println("Server starts on port: " + portNumber); 49 | 50 | ServerPanel svPanel = new ServerPanel(portNumber); 51 | svPanel.setVisible(true); 52 | 53 | } 54 | 55 | public static void main(String[] args) { 56 | Server server = new Server(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/dataSource/ColorConvert.java: -------------------------------------------------------------------------------- 1 | package dataSource; 2 | 3 | 4 | import java.awt.Color; 5 | 6 | public class ColorConvert { 7 | 8 | public static Color String2Color(String str) { 9 | 10 | int i = Integer.parseInt(str.substring(1),16); 11 | 12 | return new Color(i); 13 | 14 | } 15 | 16 | public static String Color2String(Color color) { 17 | 18 | String R = Integer.toHexString(color.getRed()); 19 | 20 | R = R.length()<2?('0'+R):R; 21 | 22 | String B = Integer.toHexString(color.getBlue()); 23 | 24 | B = B.length()<2?('0'+B):B; 25 | 26 | String G = Integer.toHexString(color.getGreen()); 27 | 28 | G = G.length()<2?('0'+G):G; 29 | 30 | return '#'+R+B+G; 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/dataSource/DataArray.java: -------------------------------------------------------------------------------- 1 | package dataSource; 2 | 3 | 4 | import java.util.ArrayList; 5 | import java.util.Iterator; 6 | 7 | public class DataArray { 8 | 9 | /** 10 | * @param args 11 | */ 12 | public ArrayList array=null; 13 | public DataArray(){ 14 | array=new ArrayList(); 15 | } 16 | public synchronized void addData(DataSource dataSource){ 17 | array.add(dataSource); 18 | } 19 | public Iterator iterator(){ 20 | return array.iterator(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/dataSource/DataSource.java: -------------------------------------------------------------------------------- 1 | package dataSource; 2 | 3 | import java.awt.BasicStroke; 4 | import java.awt.Color; 5 | import java.awt.Font; 6 | import java.awt.Point; 7 | import java.awt.Stroke; 8 | 9 | public class DataSource { 10 | private int id;//user id 11 | private int paintType;//the type of drawing 12 | private Color pencilcolor; 13 | private Color erasercolor; 14 | private Stroke pencilStroke; 15 | private Stroke eraserStroke; 16 | private String text; 17 | private String fonttype; 18 | private int bolder; 19 | private int fontsize; 20 | private Point startPoint; 21 | private Point endPoint; 22 | DataSource(){ 23 | paintType=0; 24 | pencilcolor=Color.black; 25 | erasercolor=Color.white; 26 | pencilStroke = new BasicStroke(1.0f); 27 | eraserStroke = new BasicStroke(5.0f); 28 | fonttype = "Arial"; 29 | bolder = Font.PLAIN; 30 | fontsize=12; 31 | startPoint=new Point(0,0); 32 | endPoint=new Point(0,0); 33 | 34 | } 35 | public DataSource(int id,int paintType,Point startPoint,Point endPoint,Color pencilcolor,Color earsercolor,Stroke pencilStroke, 36 | Stroke eraserStroke,String text,String fonttype,int bolder,int fontsize){ 37 | this.id=id; 38 | this.paintType=paintType; 39 | this.pencilcolor=pencilcolor; 40 | this.erasercolor=earsercolor; 41 | this.pencilStroke=pencilStroke; 42 | this.eraserStroke=eraserStroke; 43 | this.text=text; 44 | this.fonttype=fonttype; 45 | this.bolder=bolder; 46 | this.fontsize=fontsize; 47 | this.startPoint=startPoint; 48 | this.endPoint=endPoint; 49 | 50 | } 51 | 52 | public int getId() { 53 | return id; 54 | } 55 | public int getPaintType() { 56 | return paintType; 57 | } 58 | public Color getPencilcolor() { 59 | return pencilcolor; 60 | } 61 | public Color getEarsercolor() { 62 | return erasercolor; 63 | } 64 | public Stroke getPencilStroke() { 65 | return pencilStroke; 66 | } 67 | public Stroke getEraserStroke() { 68 | return eraserStroke; 69 | } 70 | public String getText() { 71 | return text; 72 | } 73 | public String getFonttype() { 74 | return fonttype; 75 | } 76 | public int getBolder() { 77 | return bolder; 78 | } 79 | public int getFontsize() { 80 | return fontsize; 81 | } 82 | public Point getStartPoint() { 83 | return startPoint; 84 | } 85 | public Point getEndPoint() { 86 | return endPoint; 87 | } 88 | public void setEndPoint(Point endPoint) { 89 | this.endPoint = endPoint; 90 | } 91 | public void setStartPoint(Point startPoint) { 92 | this.startPoint = startPoint; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/dataSource/ListData.java: -------------------------------------------------------------------------------- 1 | package dataSource; 2 | 3 | 4 | import java.io.BufferedWriter; 5 | import java.io.IOException; 6 | import java.io.OutputStreamWriter; 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.Collection; 10 | import java.util.Iterator; 11 | 12 | import javax.swing.AbstractListModel; 13 | 14 | public class ListData extends AbstractListModel { 15 | private ArrayList users; 16 | 17 | public void refresh() { 18 | fireContentsChanged(this, 0, getSize()); 19 | } 20 | 21 | public ListData(ArrayList users) { 22 | this.users = users; 23 | fireContentsChanged(this, 0, getSize()); 24 | } 25 | 26 | public int getSize() { 27 | return users.size(); 28 | 29 | } 30 | 31 | public User getElementAt(int index) { 32 | return users.get(index); 33 | } 34 | 35 | public void add(User element) { 36 | if (users.add(element)) { 37 | fireContentsChanged(this, 0, getSize()); 38 | } 39 | } 40 | 41 | public void addAll(User elements[]) { 42 | Collection c = Arrays.asList(elements); 43 | users.addAll(c); 44 | fireContentsChanged(this, 0, getSize()); 45 | } 46 | 47 | public void clear() { 48 | users.clear(); 49 | fireContentsChanged(this, 0, getSize()); 50 | } 51 | 52 | public boolean contains(User element) { 53 | return users.contains(element); 54 | } 55 | 56 | public User firstElement() { 57 | return users.get(0); 58 | } 59 | 60 | public Iterator iterator() { 61 | return users.iterator(); 62 | } 63 | 64 | public User lastElement() { 65 | return users.get(users.size()); 66 | } 67 | 68 | public boolean removeElement(User element) throws IOException { 69 | boolean removed = users.remove(element); 70 | if (removed) { 71 | fireContentsChanged(this, 0, getSize()); 72 | } 73 | return removed; 74 | } 75 | 76 | public User removeElement(int element) { 77 | try { 78 | BufferedWriter out = new BufferedWriter(new OutputStreamWriter(users.get(element).ip.getOutputStream())); 79 | out.write("KICK"); 80 | out.newLine(); 81 | out.flush(); 82 | users.get(element).ip.close(); 83 | } catch (IOException e) { 84 | System.out.println("IOException"); 85 | } 86 | User del = users.remove(element); 87 | fireContentsChanged(this, 0, getSize()); 88 | return del; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/dataSource/User.java: -------------------------------------------------------------------------------- 1 | package dataSource; 2 | 3 | import java.net.*; 4 | 5 | public class User { 6 | private String name = "Guest"; 7 | private int id = 0; 8 | public Socket ip; 9 | 10 | public User() { 11 | } 12 | 13 | public User(String s) { 14 | this.name = s; 15 | } 16 | 17 | public User(int id, String s, Socket inet) { 18 | this.id=id; 19 | this.name = s; 20 | this.ip = inet; 21 | } 22 | 23 | public User(Socket inet) { 24 | this.ip = inet; 25 | } 26 | 27 | public User(int id, Socket inet) { 28 | this.id=id; 29 | this.ip = inet; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public int getId() { 41 | return id; 42 | } 43 | 44 | public void setId(int id) { 45 | this.id = id; 46 | } 47 | 48 | public Socket getIp() { 49 | return ip; 50 | } 51 | 52 | public void setIp(Socket ip) { 53 | this.ip = ip; 54 | } 55 | 56 | public boolean equals(String s){ 57 | if (name == "Guest") return false; 58 | return this.name == s; 59 | } 60 | public boolean equals(Socket inet){ 61 | if (this.ip==null) return false; 62 | return this.ip==inet; 63 | } 64 | public boolean equals(User user){ 65 | return ((this.name == user.name) && (this.ip == user.ip)); 66 | } 67 | public String toString(){ 68 | return this.id + " " + this.name + " " + this.ip.getInetAddress().getHostAddress(); 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/1.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/11.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/11.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/12.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/12.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/2.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/2.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/3.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/3.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/4.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/4.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/5.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/5.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/6.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/6.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/7.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/7.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/8.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/8.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/9.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/9.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/img/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Forcrush/Distributed_System_Project/d9f826d18abb29857b28d8f2eb13bc4da81fa76c/Project2/Version5.0/src/img/logo.gif -------------------------------------------------------------------------------- /Project2/Version5.0/src/whiteboardgui/DrawStyle.java: -------------------------------------------------------------------------------- 1 | package whiteboardgui; 2 | public interface DrawStyle { 3 | final static int FREE_DRAW = 0; 4 | final static int ERASER = 1; 5 | final static int RECTANGLE = 2; 6 | final static int OVAL = 3; 7 | final static int CURVE = 4; 8 | final static int LINE = 5; 9 | final static int ROUND_RECT = 6; 10 | final static int TEXT = 7; 11 | } 12 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/whiteboardgui/EraserStroke.java: -------------------------------------------------------------------------------- 1 | package whiteboardgui; 2 | 3 | import java.awt.BasicStroke; 4 | import java.awt.Dimension; 5 | import java.awt.GridLayout; 6 | import java.awt.Rectangle; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | import java.awt.event.MouseEvent; 10 | import java.awt.event.MouseListener; 11 | import javax.swing.JLabel; 12 | import javax.swing.JPanel; 13 | import javax.swing.JSlider; 14 | import javax.swing.border.TitledBorder; 15 | import javax.swing.event.ChangeEvent; 16 | import javax.swing.event.ChangeListener; 17 | 18 | public class EraserStroke extends JPanel implements MouseListener, 19 | ActionListener, ChangeListener { 20 | 21 | private static final long serialVersionUID = 1L; 22 | private PaintCanvas area; 23 | JLabel showVal; 24 | 25 | public EraserStroke(PaintCanvas area) { 26 | JPanel wholePanel = new JPanel(null); 27 | wholePanel.setLayout(new GridLayout(2, 1)); 28 | int PanelHeight = 50; 29 | int PanelWidth = 100; 30 | wholePanel.setPreferredSize(new Dimension(PanelWidth, PanelHeight)); 31 | wholePanel.setLayout(new GridLayout(1, 0, 15, 15)); 32 | wholePanel.setBounds(new Rectangle(0, 0, 100, 160)); 33 | wholePanel.setBorder(new TitledBorder(null, "Eraser Stroke", 34 | TitledBorder.LEFT, TitledBorder.TOP)); 35 | 36 | JSlider slider = new JSlider (JSlider.HORIZONTAL,5,40,5); 37 | slider.setMajorTickSpacing(10); 38 | slider.setMinorTickSpacing(2); 39 | slider.setSnapToTicks(true); 40 | slider.setPaintTicks(true); 41 | slider.setOrientation(JSlider.HORIZONTAL); 42 | slider.setBounds(0, 0, 100, 50); 43 | slider.setToolTipText(Long.toString(slider.getValue())); 44 | SliderListener listener = new SliderListener(slider, area); 45 | slider.addChangeListener(listener); 46 | wholePanel.add(slider); 47 | add(wholePanel); 48 | } 49 | 50 | class SliderListener implements ChangeListener { 51 | private JSlider slider; 52 | private PaintCanvas area; 53 | 54 | public SliderListener(JSlider slider, PaintCanvas area) { 55 | super(); 56 | this.slider = slider; 57 | this.area = area; 58 | } 59 | 60 | public void stateChanged(ChangeEvent e) { 61 | if (e.getSource() == slider) { 62 | area.setEraserStroke(new BasicStroke((float) slider.getValue())); 63 | area.setEraserSize(slider.getValue()); 64 | slider.setToolTipText(Long.toString(slider.getValue())); 65 | } 66 | } 67 | } 68 | 69 | @Override 70 | public void mouseClicked(MouseEvent arg0) { 71 | // TODO Auto-generated method stub 72 | 73 | } 74 | 75 | @Override 76 | public void mouseEntered(MouseEvent arg0) { 77 | // TODO Auto-generated method stub 78 | 79 | } 80 | 81 | @Override 82 | public void mouseExited(MouseEvent arg0) { 83 | // TODO Auto-generated method stub 84 | 85 | } 86 | 87 | @Override 88 | public void mousePressed(MouseEvent arg0) { 89 | // TODO Auto-generated method stub 90 | 91 | } 92 | 93 | @Override 94 | public void mouseReleased(MouseEvent arg0) { 95 | // TODO Auto-generated method stub 96 | 97 | } 98 | 99 | @Override 100 | public void actionPerformed(ActionEvent arg0) { 101 | // TODO Auto-generated method stub 102 | 103 | } 104 | 105 | @Override 106 | public void stateChanged(ChangeEvent e) { 107 | // TODO Auto-generated method stub 108 | 109 | } 110 | 111 | } 112 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/whiteboardgui/ListData.java: -------------------------------------------------------------------------------- 1 | package whiteboardgui; 2 | 3 | 4 | import java.io.BufferedWriter; 5 | import java.io.IOException; 6 | import java.io.OutputStreamWriter; 7 | import java.util.ArrayList; 8 | import java.util.Arrays; 9 | import java.util.Collection; 10 | import java.util.Iterator; 11 | 12 | import javax.swing.AbstractListModel; 13 | 14 | public class ListData extends AbstractListModel { 15 | ArrayList users = new ArrayList(); 16 | 17 | public void refresh() { 18 | fireContentsChanged(this, 0, getSize()); 19 | } 20 | 21 | public ListData(ArrayList users) { 22 | this.users = users; 23 | fireContentsChanged(this, 0, getSize()); 24 | } 25 | 26 | public int getSize() { 27 | return users.size(); 28 | 29 | } 30 | 31 | public User getElementAt(int index) { 32 | return users.get(index); 33 | } 34 | 35 | // public void SortedListModel() { 36 | // int i=users.size(); 37 | // String[] temp=new String 38 | // Arrays.sort(users,cmp); 39 | // } 40 | 41 | public void add(User element) { 42 | if (users.add(element)) { 43 | fireContentsChanged(this, 0, getSize()); 44 | } 45 | } 46 | 47 | public void addAll(User elements[]) { 48 | Collection c = Arrays.asList(elements); 49 | users.addAll(c); 50 | fireContentsChanged(this, 0, getSize()); 51 | } 52 | 53 | public void clear() { 54 | users.clear(); 55 | fireContentsChanged(this, 0, getSize()); 56 | } 57 | 58 | public boolean contains(User element) { 59 | return users.contains(element); 60 | } 61 | 62 | public User firstElement() { 63 | return users.get(0); 64 | } 65 | 66 | public Iterator iterator() { 67 | return users.iterator(); 68 | } 69 | 70 | public User lastElement() { 71 | return users.get(users.size()); 72 | } 73 | 74 | public boolean removeElement(User element) throws IOException { 75 | boolean removed = users.remove(element); 76 | if (removed) { 77 | fireContentsChanged(this, 0, getSize()); 78 | } 79 | return removed; 80 | } 81 | 82 | public User removeElement(int element) { 83 | try { 84 | BufferedWriter out = new BufferedWriter(new OutputStreamWriter( 85 | users.get(element).ip.getOutputStream())); 86 | out.write("KICK"); 87 | out.newLine(); 88 | out.flush(); 89 | users.get(element).ip.close(); 90 | } catch (IOException e) { 91 | } 92 | User del = users.remove(element); 93 | fireContentsChanged(this, 0, getSize()); 94 | return del; 95 | } 96 | 97 | } 98 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/whiteboardgui/PencileStroke.java: -------------------------------------------------------------------------------- 1 | package whiteboardgui; 2 | 3 | import java.awt.BasicStroke; 4 | import java.awt.Dimension; 5 | import java.awt.GridLayout; 6 | import java.awt.Rectangle; 7 | import java.awt.event.ActionEvent; 8 | import java.awt.event.ActionListener; 9 | import java.awt.event.MouseEvent; 10 | import java.awt.event.MouseListener; 11 | import javax.swing.JLabel; 12 | import javax.swing.JPanel; 13 | import javax.swing.JSlider; 14 | import javax.swing.border.TitledBorder; 15 | import javax.swing.event.ChangeEvent; 16 | import javax.swing.event.ChangeListener; 17 | 18 | public class PencileStroke extends JPanel implements MouseListener, 19 | ActionListener, ChangeListener { 20 | 21 | private static final long serialVersionUID = 1L; 22 | private PaintCanvas area; 23 | JLabel showVal; 24 | 25 | public PencileStroke(PaintCanvas area) { 26 | JPanel wholePanel = new JPanel(null); 27 | wholePanel.setLayout(new GridLayout(2, 1)); 28 | int PanelHeight = 50; 29 | int PanelWidth = 100; 30 | wholePanel.setPreferredSize(new Dimension(PanelWidth, PanelHeight)); 31 | 32 | wholePanel.setLayout(new GridLayout(1, 0, 15, 15)); 33 | wholePanel.setBounds(new Rectangle(0, 0, 100, 160)); 34 | wholePanel.setBorder(new TitledBorder(null, "Line Stroke", 35 | TitledBorder.LEFT, TitledBorder.TOP)); 36 | JSlider slider = new JSlider (JSlider.HORIZONTAL,1,30,1); 37 | slider.setMajorTickSpacing(10); 38 | slider.setMinorTickSpacing(2); 39 | slider.setSnapToTicks(true); 40 | slider.setPaintTicks(true); 41 | slider.setOrientation(JSlider.HORIZONTAL); 42 | slider.setBounds(0, 0, 100, 50); 43 | slider.setToolTipText(Long.toString(slider.getValue())); 44 | SliderListener listener = new SliderListener(slider, area); 45 | slider.addChangeListener(listener); 46 | wholePanel.add(slider); 47 | add(wholePanel); 48 | } 49 | 50 | class SliderListener implements ChangeListener { 51 | private JSlider slider; 52 | private PaintCanvas area; 53 | 54 | public SliderListener(JSlider slider, PaintCanvas area) { 55 | super(); 56 | this.slider = slider; 57 | this.area = area; 58 | } 59 | 60 | public void stateChanged(ChangeEvent e) { 61 | if (e.getSource() == slider) { 62 | area.setPencilStroke(new BasicStroke((float) slider.getValue())); 63 | area.setPencilSize(slider.getValue()); 64 | slider.setToolTipText(Long.toString(slider.getValue())); 65 | System.out.println(slider.getValue()); 66 | } 67 | } 68 | } 69 | 70 | @Override 71 | public void mouseClicked(MouseEvent arg0) { 72 | // TODO Auto-generated method stub 73 | 74 | } 75 | 76 | @Override 77 | public void mouseEntered(MouseEvent arg0) { 78 | // TODO Auto-generated method stub 79 | 80 | } 81 | 82 | @Override 83 | public void mouseExited(MouseEvent arg0) { 84 | // TODO Auto-generated method stub 85 | 86 | } 87 | 88 | @Override 89 | public void mousePressed(MouseEvent arg0) { 90 | // TODO Auto-generated method stub 91 | } 92 | 93 | @Override 94 | public void mouseReleased(MouseEvent arg0) { 95 | // TODO Auto-generated method stub 96 | } 97 | 98 | @Override 99 | public void actionPerformed(ActionEvent arg0) { 100 | // TODO Auto-generated method stub 101 | } 102 | 103 | @Override 104 | public void stateChanged(ChangeEvent e) { 105 | // TODO Auto-generated method stub 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/whiteboardgui/TextPanel.java: -------------------------------------------------------------------------------- 1 | package whiteboardgui; 2 | 3 | import java.awt.BasicStroke; 4 | import java.awt.Choice; 5 | import java.awt.Dimension; 6 | import java.awt.Font; 7 | import java.awt.GraphicsEnvironment; 8 | import java.awt.GridLayout; 9 | import java.awt.Rectangle; 10 | import java.awt.event.ActionListener; 11 | import java.awt.event.ItemEvent; 12 | import java.awt.event.ItemListener; 13 | import java.awt.event.MouseListener; 14 | 15 | import javax.swing.JLabel; 16 | import javax.swing.JPanel; 17 | import javax.swing.JSlider; 18 | import javax.swing.border.TitledBorder; 19 | import javax.swing.event.ChangeEvent; 20 | import javax.swing.event.ChangeListener; 21 | 22 | public class TextPanel extends JPanel implements ItemListener { 23 | 24 | 25 | private PaintCanvas drawPanel; 26 | private Choice fonttype; 27 | private Choice bolder; 28 | private Choice fontsize; 29 | 30 | public TextPanel(PaintCanvas area) { 31 | this.drawPanel=area; 32 | JPanel wholePanel = new JPanel(null); 33 | wholePanel.setLayout(new GridLayout(2, 1)); 34 | int PanelHeight = 50; 35 | int PanelWidth = 350; 36 | wholePanel.setPreferredSize(new Dimension(PanelWidth, PanelHeight)); 37 | wholePanel.setLayout(new GridLayout(1, 0, 15, 15)); 38 | wholePanel.setBounds(new Rectangle(0, 0, 100, 160)); 39 | wholePanel.setBorder(new TitledBorder(null, "Text", 40 | TitledBorder.LEFT, TitledBorder.TOP)); 41 | fontsize = new Choice(); 42 | { 43 | for (int i = 12; i <= 64; i += 2) { 44 | String size = String.valueOf(i); 45 | fontsize.add(size); 46 | } 47 | } 48 | fonttype = new Choice(); 49 | GraphicsEnvironment fonts = GraphicsEnvironment 50 | .getLocalGraphicsEnvironment(); 51 | String ss[] = fonts.getAvailableFontFamilyNames(); 52 | { 53 | for (int j = 0; j < ss.length; j++) 54 | fonttype.add(ss[j]); 55 | } 56 | 57 | String bold[] = { "Font.PLAIN", "Font.ITALIC", "Font.BOLD" }; 58 | // Font.CENTER_BASELINE,Font.CENTER_BASELINE,Font.ROMAN_BASELINE,Font.TRUETYPE_FONT}; 59 | bolder = new Choice(); 60 | { 61 | for (int i = 0; i < bold.length; i++) { 62 | bolder.add(bold[i]); 63 | } 64 | } 65 | 66 | fonttype.addItemListener(this); 67 | bolder.addItemListener(this); 68 | fontsize.addItemListener(this); 69 | 70 | wholePanel.add(fonttype); 71 | wholePanel.add(bolder); 72 | wholePanel.add(fontsize); 73 | 74 | add(wholePanel); 75 | } 76 | 77 | 78 | public void itemStateChanged(ItemEvent e) { 79 | int i = 0; 80 | 81 | // int i = 0; 82 | if (e.getSource() == fonttype) { 83 | // if (fonttype.getSelectedIndex() == i) { 84 | i = fonttype.getSelectedIndex(); 85 | //drawPanel.setFontType(fonttype.getItem(i)); 86 | // } 87 | } 88 | if (e.getSource() == bolder) { 89 | // if (bolder.getSelectedIndex() == i) { 90 | i = bolder.getSelectedIndex(); 91 | if (i == 0) { 92 | drawPanel.setBolder(Font.PLAIN); 93 | } else if (i == 1) { 94 | drawPanel.setBolder(Font.ITALIC); 95 | } else if (i == 2) { 96 | drawPanel.setBolder(Font.BOLD); 97 | } 98 | // } 99 | } 100 | if (e.getSource() == fontsize) { 101 | // if (fontsize.getSelectedIndex() == i) { 102 | i = fontsize.getSelectedIndex(); 103 | //drawPanel.setFontSize(Integer.valueOf(fontsize.getItem(i))); 104 | // } 105 | } 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /Project2/Version5.0/src/whiteboardgui/User.java: -------------------------------------------------------------------------------- 1 | package whiteboardgui; 2 | 3 | import java.net.*; 4 | 5 | public class User { 6 | private String name = "Guest"; 7 | private int id = 0; 8 | public Socket ip; 9 | 10 | public User() { 11 | } 12 | 13 | public User(String s) { 14 | this.name = s; 15 | } 16 | 17 | public User(int id, String s, Socket inet) { 18 | this.id=id; 19 | this.name = s; 20 | this.ip = inet; 21 | } 22 | 23 | public User(Socket inet) { 24 | this.ip = inet; 25 | } 26 | public User(int id, Socket inet) { 27 | this.id=id; 28 | this.ip = inet; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public int getId() { 40 | return id; 41 | } 42 | 43 | public void setId(int id) { 44 | this.id = id; 45 | } 46 | 47 | public Socket getIp() { 48 | return ip; 49 | } 50 | 51 | public void setIp(Socket ip) { 52 | this.ip = ip; 53 | } 54 | public boolean equals(String s){ 55 | if (name=="Guest"){return false;} 56 | return this.name==s; 57 | } 58 | public boolean equals(Socket inet){ 59 | if (this.ip==null){return false;} 60 | return this.ip==inet; 61 | } 62 | public boolean equals(User user){ 63 | return ((this.name==user.name)&&(this.ip==user.ip)); 64 | } 65 | public String toString(){ 66 | return this.id+ " "+ this.name +" "+this.ip.getInetAddress().getHostAddress(); 67 | } 68 | 69 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Distributed_System_Project 2 | 3 | Two projects of Distributed System of Unimelb (Semester2, 2019) 4 | 5 | - [x] Project1 6 | - [x] Project2 --------------------------------------------------------------------------------