Skip to content
Snippets Groups Projects
Commit 9afac890 authored by Hai HoDac's avatar Hai HoDac
Browse files

Merged with Ryan's code

parent 5fc735fe
No related branches found
No related tags found
No related merge requests found
......@@ -205,11 +205,11 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
switch (currentMode) {
case TEXT:
g2.setColor(shapeColor);
g2.setFont(new Font("TimesRoman", Font.PLAIN, textSize));
g2.drawString(textString, startPoint.x, startPoint.y);
try {
client.getDrawingController().broadcastText(client.getUserName(), textString, g2.getFont(), startPoint);
client.getDrawingController().broadcastText(client.getUserName(), textString, g2.getFont(), shapeColor, startPoint);
} catch (RemoteException ex) {
ex.printStackTrace();
}
......
......@@ -21,9 +21,10 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
}
@Override
public boolean notifyTextDrawing(String fromClient, String text, Font font, Point startPoint) throws RemoteException {
public boolean notifyTextDrawing(String fromClient, String text, Font font, Color color, Point startPoint) throws RemoteException {
client.getApplicationMain().getPaintGUI().getDrawingArea().getG2().setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
client.getApplicationMain().getPaintGUI().getDrawingArea().getG2().setFont(font);
client.getApplicationMain().getPaintGUI().getDrawingArea().getG2().setColor(color);
client.getApplicationMain().getPaintGUI().getDrawingArea().getG2().drawString(text, startPoint.x, startPoint.y);
client.getApplicationMain().getPaintGUI().getDrawingArea().repaint();
return true;
......
......@@ -15,7 +15,7 @@ import java.rmi.RemoteException;
*/
public interface IDrawingController extends Remote {
boolean broadcastText(String fromClient, String text, Font font, Point startPoint) throws RemoteException;
boolean broadcastText(String fromClient, String text, Font font, Color color, Point startPoint) throws RemoteException;
boolean broadcastDrawing(String fromClient, Shape drawing, String mode, Color color, int strokeSize) throws RemoteException;
boolean broadcastDraggingDrawing(String fromClient, Shape drawing, String mode, Color color, int strokeSize) throws RemoteException;
boolean broadcastClearCanvas(String fromClient) throws RemoteException;
......
......@@ -6,7 +6,7 @@ import java.rmi.Remote;
import java.rmi.RemoteException;
public interface IDrawingUpdate extends Remote, Serializable {
boolean notifyTextDrawing(String fromClient, String text, Font font, Point startPoint) throws RemoteException;
boolean notifyTextDrawing(String fromClient, String text, Font font, Color color, Point startPoint) throws RemoteException;
boolean notifyDrawing(String fromClient, Shape drawing, String mode, Color color, int strokeSize) throws RemoteException;
boolean notifyDraggingDrawing(String fromClient, Shape drawing, String mode, Color color, int strokeSize) throws RemoteException;
boolean notifyCanvasClearance(String fromClient) throws RemoteException;
......
......@@ -30,12 +30,13 @@ public class DrawingController extends UnicastRemoteObject implements IDrawingCo
}
@Override
public boolean broadcastText(String fromClient, String text, Font font, Point startPoint) throws RemoteException {
public boolean broadcastText(String fromClient, String text, Font font, Color color, Point startPoint) throws RemoteException {
System.out.print("Broadcasting drawing to everyone...");
g2 = (Graphics2D) bufferedImage.getGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setFont(font);
g2.setPaint(color);
g2.drawString(text, startPoint.x, startPoint.y);
g2 = (Graphics2D) bufferedImage.getGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
......@@ -47,7 +48,7 @@ public class DrawingController extends UnicastRemoteObject implements IDrawingCo
{
if (!u.getUserName().equals(fromClient)) {
client = u.getIDrawingUpdate();
client.notifyTextDrawing(fromClient, text, font, startPoint);
client.notifyTextDrawing(fromClient, text, font, color, startPoint);
}
}
......
......@@ -60,6 +60,16 @@ public class Server
public void run() throws RemoteException
{
String serverIP = "";
try {
InetAddress inetAddress = InetAddress.getLocalHost();
serverIP = inetAddress.getHostAddress();
} catch (Exception e) {
e.printStackTrace();
}
System.setProperty("java.rmi.server.hostname", serverIP);
LocateRegistry.createRegistry(1099);
Registry registry = LocateRegistry.getRegistry();
// if (System.getSecurityManager() == null) {
......
grant codeBase "file:/Users/haiho/OneDrive - The University of Melbourne/Distributed Systems (COMP90015)/Assignment 2/InfinityMonkeys-remaster/comp90015-dsass2-infinitymonkeys-remaster/out/production/comp90015-dsass2-infinitymonkeys-remaster/" {
permission java.util.PropertyPermission '*', "read,write";
permission java.security.AllPermission;
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment