Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
COMP90015-DSAss2-InfinityMonkeys-remaster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RUNZHE WANG
COMP90015-DSAss2-InfinityMonkeys-remaster
Commits
3f069117
Commit
3f069117
authored
Oct 25, 2019
by
Hai HoDac
Browse files
Options
Downloads
Patches
Plain Diff
added blinks
parent
98d50cb0
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/GUI/DrawingArea.java
+27
-27
27 additions, 27 deletions
src/GUI/DrawingArea.java
src/client/DrawingUpdate.java
+55
-0
55 additions, 0 deletions
src/client/DrawingUpdate.java
with
82 additions
and
27 deletions
src/GUI/DrawingArea.java
+
27
−
27
View file @
3f069117
...
@@ -296,9 +296,9 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
...
@@ -296,9 +296,9 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
try
{
try
{
drawingController
.
broadcastDrawing
(
client
.
getUserName
(),
drawing
,
currentMode
.
toString
(),
shapeColor
,
strokeSize
);
drawingController
.
broadcastDrawing
(
client
.
getUserName
(),
drawing
,
currentMode
.
toString
(),
shapeColor
,
strokeSize
);
if
(
currentMode
==
Mode
.
TEXT
){
//
if (currentMode == Mode.TEXT){
notifyUsingTimer
();
//
notifyUsingTimer();
}
//
}
// else {
// else {
// drawingController.broadcastDrawingUserStopped(client.getUserName());
// drawingController.broadcastDrawingUserStopped(client.getUserName());
// }
// }
...
@@ -310,30 +310,30 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
...
@@ -310,30 +310,30 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
drawing
=
null
;
drawing
=
null
;
}
}
private
void
notifyUsingTimer
()
throws
RemoteException
{
//
private void notifyUsingTimer() throws RemoteException {
//
Timer
timer
=
new
Timer
(
4000
,
new
ActionListener
()
//
Timer timer = new Timer(4000, new ActionListener()
{
//
{
//
@Override
//
@Override
public
void
actionPerformed
(
ActionEvent
e
)
//
public void actionPerformed(ActionEvent e)
{
//
{
try
{
//
try {
client
.
getDrawingController
().
broadcastDrawingUserStopped
(
client
.
get
Default
UserName
());
//
client.getDrawingController().broadcastDrawingUserStopped(client.getUserName());
}
catch
(
RemoteException
ex
)
{
//
} catch (RemoteException ex) {
ex
.
printStackTrace
();
//
ex.printStackTrace();
}
//
}
//
}
//
}
//
});
//
});
try
{
//
try {
client
.
getDrawingController
().
broadcastDrawingUser
(
client
.
get
Default
UserName
());
//
client.getDrawingController().broadcastDrawingUser(client.getUserName());
}
catch
(
RemoteException
ex
)
{
//
} catch (RemoteException ex) {
ex
.
printStackTrace
();
//
ex.printStackTrace();
}
//
}
timer
.
start
();
//
timer.start();
}
//
}
@Override
@Override
public
void
mouseEntered
(
MouseEvent
e
)
{
public
void
mouseEntered
(
MouseEvent
e
)
{
...
...
This diff is collapsed.
Click to expand it.
src/client/DrawingUpdate.java
+
55
−
0
View file @
3f069117
...
@@ -4,6 +4,8 @@ import remote.IDrawingUpdate;
...
@@ -4,6 +4,8 @@ import remote.IDrawingUpdate;
import
javax.swing.*
;
import
javax.swing.*
;
import
java.awt.*
;
import
java.awt.*
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.image.BufferedImage
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -50,6 +52,29 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
...
@@ -50,6 +52,29 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
client
.
getApplicationMain
().
getPaintGUI
().
getDrawingArea
().
getG2
().
setColor
(
color
);
client
.
getApplicationMain
().
getPaintGUI
().
getDrawingArea
().
getG2
().
setColor
(
color
);
client
.
getApplicationMain
().
getPaintGUI
().
getDrawingArea
().
getG2
().
drawString
(
text
,
startPoint
.
x
,
startPoint
.
y
);
client
.
getApplicationMain
().
getPaintGUI
().
getDrawingArea
().
getG2
().
drawString
(
text
,
startPoint
.
x
,
startPoint
.
y
);
client
.
getApplicationMain
().
getPaintGUI
().
getDrawingArea
().
repaint
();
client
.
getApplicationMain
().
getPaintGUI
().
getDrawingArea
().
repaint
();
removeClientTimer
removeClient
=
new
removeClientTimer
(
fromClient
,
client
);
removeClient
.
start
();
//
// Timer timer = new Timer(1000, new ActionListener()
// {
// private int i = 0;
// @Override
// public void actionPerformed(ActionEvent e)
// {
// DefaultListModel temp = client.getApplicationMain().getChatScreen().getAllUserModel();
// System.out.println("action performed" + Integer.toString(i));
// int elementIndex = -1;
// if(temp.contains(fromClient)){
// elementIndex = temp.indexOf(fromClient);
// temp.remove(elementIndex);
// System.out.println("removed from list");
// }
// }
// });
// timer.start();
return
true
;
return
true
;
}
}
...
@@ -136,3 +161,33 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
...
@@ -136,3 +161,33 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
return
true
;
return
true
;
}
}
}
}
class
removeClientTimer
extends
Thread
{
private
String
fromClient
;
private
Client
client
;
public
removeClientTimer
(
String
fromClient
,
Client
client
)
{
this
.
fromClient
=
fromClient
;
this
.
client
=
client
;
}
@Override
public
void
run
()
{
try
{
DefaultListModel
temp
=
client
.
getApplicationMain
().
getChatScreen
().
getAllUserModel
();
if
(!
temp
.
contains
(
fromClient
))
temp
.
addElement
(
fromClient
);
sleep
(
1000
);
int
elementIndex
=
-
1
;
if
(
temp
.
contains
(
fromClient
)){
elementIndex
=
temp
.
indexOf
(
fromClient
);
temp
.
remove
(
elementIndex
);
}
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment