diff --git a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/MGuiRMI.java b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/MGuiRMI.java index 83be002..c91de28 100644 --- a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/MGuiRMI.java +++ b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/MGuiRMI.java @@ -26,6 +26,7 @@ import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.JTextField; import javax.swing.border.BevelBorder; +import javax.swing.border.EmptyBorder; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -92,12 +93,20 @@ class RMIMandelbrotCalculationThread extends Thread { public void run() { try { - long timestampStart = System.currentTimeMillis(); + this.view.setIcon(new ImageIcon()); + long timestampStart = System.currentTimeMillis(); - double ULx = this.remoteCalcObj.getULx(); - double ULy = this.remoteCalcObj.getULy(); - double LRx = this.remoteCalcObj.getLRx(); - double LRy = this.remoteCalcObj.getLRy(); + //double ULx = -0.16099999999999995, ULy = -0.9365333333333333, LRx = -0.03533333333333327, LRy = -0.8108666666666666; + + double ULx = -2; + double ULy = 2; + double LRx = 2; + double LRy = -2; + + //double ULx = this.remoteCalcObj.getULx(); + //double ULy = this.remoteCalcObj.getULy(); + //double LRx = this.remoteCalcObj.getLRx(); + //double LRy = this.remoteCalcObj.getLRy(); System.out.println("actual="+ULx + "/" + ULy + "/" + LRx + "/" + LRy); double w = LRx - ULx; double h = LRy - ULy; @@ -124,12 +133,12 @@ class RMIMandelbrotCalculationThread extends Thread { this.boxULy = 0; this.boxW = MGuiRMI.RESX; this.boxH = MGuiRMI.RESY; - this.remoteCalcObj.setView(ULx, ULy, LRx, LRy); + //this.remoteCalcObj.setView(ULx, ULy, LRx, LRy); // end alex int[] colors = null; - this.remoteCalcObj.iterateAllPoints(this.maxIterations * 1000, MGuiRMI.RESX, MGuiRMI.RESY/2); + this.remoteCalcObj.iterateAllPoints(this.maxIterations * 1000, MGuiRMI.RESX, MGuiRMI.RESY/2, ULx, ULy, LRx, LRy); /* int[] lookupTable = generateLookupTable(this.maxIterations.getValue() * 1000); @@ -179,7 +188,8 @@ public class MGuiRMI implements ActionListener, ChangeListener, MouseListener, M JButton endButton; JButton backButton; JButton calcButton; - JTextField hostTextField; + JTextField host1TextField; + JTextField host2TextField; JSlider maxIterations; MyJLabel viewUpper; MyJLabel viewLower; @@ -203,21 +213,25 @@ public class MGuiRMI implements ActionListener, ChangeListener, MouseListener, M // set up GUI this.frame = new JFrame("Mandelbrotmenge"); this.panel = new JPanel(); + this.panel.setBorder(new EmptyBorder(0,0,0,0)); this.endButton = new JButton("Ende"); this.panel.add(this.endButton); this.backButton = new JButton("Zurück"); this.panel.add(this.backButton); this.calcButton = new JButton("Rechnen"); - this.hostTextField = new JTextField(20); - this.hostTextField.setText("localhost"); + this.host1TextField = new JTextField(10); + this.host1TextField.setText("localhost"); + this.host2TextField = new JTextField(10); + this.host2TextField.setText("localhost"); this.panel.add(this.calcButton); - this.panel.add(this.hostTextField); + this.panel.add(this.host1TextField); + this.panel.add(this.host2TextField); this.frame.add(this.panel); this.frame.setSize(700, 720); this.frame.setVisible(true); this.viewUpper = new MyJLabel(); this.viewLower = new MyJLabel(); - this.maxIterations = new JSlider(0, 50, 30); + this.maxIterations = new JSlider(0, 100, 30); this.panel.add(this.maxIterations); this.panel.add(this.viewUpper); this.panel.add(this.viewLower); @@ -267,11 +281,6 @@ public class MGuiRMI implements ActionListener, ChangeListener, MouseListener, M if (ae.getSource() == this.backButton) { System.out.println("Zurueck"); // Zoom und Ausschnitt zurücksetzen - - double ULx = -2; - double ULy = 2; - double LRx = 2; - double LRy = -2; this.boxULx = 0; this.boxULy = 0; this.boxW = MGuiRMI.RESX; @@ -288,12 +297,14 @@ public class MGuiRMI implements ActionListener, ChangeListener, MouseListener, M } else { + /* try { this.remoteCalcObj.setView(ULx, ULy, LRx, LRy); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } + */ this.message.setText("Ausschnitt zurückgesetzt"); } if (this.remoteCalcObj2 == null) @@ -304,23 +315,31 @@ public class MGuiRMI implements ActionListener, ChangeListener, MouseListener, M } else { - try { + /* + try { this.remoteCalcObj2.setView(ULx, ULy, LRx, LRy); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } + */ this.message.setText("Ausschnitt zurückgesetzt"); } } else if (ae.getSource() == this.calcButton) { - String hostname = this.hostTextField.getText(); - System.out.println("Verbinde mit RMI Registry auf Host: " + hostname); + String hostname1 = this.host1TextField.getText(); + String hostname2 = this.host2TextField.getText(); + System.out.println("Verbinde mit RMI Registry auf Host: " + hostname1); try { - Registry registry = LocateRegistry.getRegistry(hostname); + //double ULx = -0.16099999999999995, ULy = -0.9365333333333333, LRx = -0.03533333333333327, LRy = -0.8108666666666666; + //double ULx = -2, ULy = 2, LRx = 2, LRy = -2; + Registry registry = LocateRegistry.getRegistry(hostname1); this.remoteCalcObj = (RMIMandelbrotCalculationsInterface) registry.lookup("RMIMandelbrotCalculationsInterface"); - this.remoteCalcObj2 = (RMIMandelbrotCalculationsInterface) registry.lookup("RMIMandelbrotCalculationsInterface2"); + //this.remoteCalcObj.setView(ULx, ULy, LRx, LRy); + Registry registry2 = LocateRegistry.getRegistry(hostname2); + this.remoteCalcObj2 = (RMIMandelbrotCalculationsInterface) registry2.lookup("RMIMandelbrotCalculationsInterface"); + //this.remoteCalcObj2.setView(ULx, ULy, LRx, LRy); /** CODE SEBASTIAN System.out.println("Rechnen"); @@ -360,6 +379,7 @@ public class MGuiRMI implements ActionListener, ChangeListener, MouseListener, M end */ /* Code Alex */ System.out.println("Rechnen"); + this.message.setText("Rechnen"); RMIMandelbrotCalculationThread rmimct = new RMIMandelbrotCalculationThread(true, this.viewUpper, this.remoteCalcObj, maxIterations.getValue()); new Thread(rmimct).start(); @@ -374,7 +394,7 @@ public class MGuiRMI implements ActionListener, ChangeListener, MouseListener, M } } - // Zoom not wirking for lower... + // Zoom not working for lower... public void mousePressed(MouseEvent e) { this.boxULx = e.getX(); diff --git a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsInterface.java b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsInterface.java index 7b91dc4..706da3d 100644 --- a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsInterface.java +++ b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsInterface.java @@ -4,11 +4,13 @@ import java.rmi.Remote; import java.rmi.RemoteException; public interface RMIMandelbrotCalculationsInterface extends Remote { - void iterateAllPoints(int maxIterations, double nrPointsX, double nrPointsY) throws RemoteException; + void iterateAllPoints(int maxIterations, double nrPointsX, double nrPointsY, double ULx, double ULy, double LRx, double LRy) throws RemoteException; public int[] getResult() throws RemoteException; + /* public double getULx() throws RemoteException; public double getLRx() throws RemoteException; public double getULy() throws RemoteException; public double getLRy() throws RemoteException; public void setView(double ULx, double ULy, double LRx, double LRy) throws RemoteException; + */ } \ No newline at end of file diff --git a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer.java b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer.java index 9997b42..f226f24 100644 --- a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer.java +++ b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer.java @@ -84,7 +84,7 @@ public class RMIMandelbrotCalculationsServer implements RMIMandelbrotCalculation protected int[] result = null; // der augenblicklich gewaehlte Ausschnitt - double ULx = -2, ULy = 2, LRx = 2, LRy = -2; + //double ULx = -2, ULy = 2, LRx = 2, LRy = -2; int iterateOnePoint(Complex c, int maxIterations, double maxModulus) { Complex z = new Complex(0., 0.); @@ -100,16 +100,16 @@ public class RMIMandelbrotCalculationsServer implements RMIMandelbrotCalculation return maxIterations; } - public void iterateAllPoints(int maxIterations, double nrPointsX, double nrPointsY) { + public void iterateAllPoints(int maxIterations, double nrPointsX, double nrPointsY, double ULx, double ULy, double LRx, double LRy) { this.result = new int[(int) (nrPointsX * nrPointsY)]; int counter = 0; - double stepX = (this.LRx - this.ULx) / nrPointsX; - double stepY = (this.LRy - this.ULy) / nrPointsY; - double i = this.ULy; + double stepX = (LRx - ULx) / nrPointsX; + double stepY = (LRy - ULy) / nrPointsY; + double i = ULy; for (int cy = 0; cy < nrPointsY; cy++) { - double r = this.ULx; + double r = ULx; for (int cx = 0; cx < nrPointsX; cx++) { Complex c = new Complex(r, i); this.result[counter] = maxIterations - this.iterateOnePoint(c, maxIterations, 2.0); @@ -124,6 +124,7 @@ public class RMIMandelbrotCalculationsServer implements RMIMandelbrotCalculation return this.result; } + /* public double getULx() { return this.ULx; } @@ -146,5 +147,6 @@ public class RMIMandelbrotCalculationsServer implements RMIMandelbrotCalculation this.LRx = LRx; this.LRy = LRy; } + */ } diff --git a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer2.java b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer2.java index a0feee9..e52094f 100644 --- a/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer2.java +++ b/VerteilteSysteme-Examples/src/verteiltesysteme/mandelbrot/rmi/RMIMandelbrotCalculationsServer2.java @@ -49,7 +49,7 @@ public class RMIMandelbrotCalculationsServer2 implements RMIMandelbrotCalculatio protected int[] result = null; // der augenblicklich gewaehlte Ausschnitt - double ULx = -2, ULy = 2, LRx = 2, LRy = -2; + //double ULx = -2, ULy = 2, LRx = 2, LRy = -2; int iterateOnePoint(Complex c, int maxIterations, double maxModulus) { Complex z = new Complex(0., 0.); @@ -65,16 +65,16 @@ public class RMIMandelbrotCalculationsServer2 implements RMIMandelbrotCalculatio return maxIterations; } - public void iterateAllPoints(int maxIterations, double nrPointsX, double nrPointsY) { + public void iterateAllPoints(int maxIterations, double nrPointsX, double nrPointsY, double ULx, double ULy, double LRx, double LRy) { this.result = new int[(int) (nrPointsX * nrPointsY)]; int counter = 0; - double stepX = (this.LRx - this.ULx) / nrPointsX; - double stepY = (this.LRy - this.ULy) / nrPointsY; - double i = this.ULy; + double stepX = (LRx - ULx) / nrPointsX; + double stepY = (LRy - ULy) / nrPointsY; + double i = ULy; for (int cy = 0; cy < nrPointsY; cy++) { - double r = this.ULx; + double r = ULx; for (int cx = 0; cx < nrPointsX; cx++) { Complex c = new Complex(r, i); this.result[counter] = maxIterations - this.iterateOnePoint(c, maxIterations, 2.0); @@ -89,6 +89,7 @@ public class RMIMandelbrotCalculationsServer2 implements RMIMandelbrotCalculatio return this.result; } + /* public double getULx() { return this.ULx; } @@ -104,12 +105,15 @@ public class RMIMandelbrotCalculationsServer2 implements RMIMandelbrotCalculatio public double getLRy() { return this.LRy; } + */ + /* public void setView(double ULx, double ULy, double LRx, double LRy) { this.ULx = ULx; this.ULy = ULy; this.LRx = LRx; this.LRy = LRy; } + */ }