Skip to content
Snippets Groups Projects
Commit 8c95a987 authored by Chang Che Hao's avatar Chang Che Hao
Browse files

fix communication issue & invisible text issue

parent 4c8f7761
No related branches found
No related tags found
No related merge requests found
......@@ -209,7 +209,7 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
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();
}
......
......@@ -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;
......
......@@ -3,6 +3,7 @@ package server;
import remote.IDrawingController;
import remote.IDrawingUpdate;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.*;
......@@ -29,13 +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.BLACK);
g2.setPaint(color);
g2.drawString(text, startPoint.x, startPoint.y);
g2 = (Graphics2D) bufferedImage.getGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
......
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment