Added view abstraction for mvc pattern.
This commit is contained in:
9
src/main/java/controller/src/ViewToControllerData.java
Normal file
9
src/main/java/controller/src/ViewToControllerData.java
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 01.12.2023
|
||||
*/
|
||||
package controller.src;
|
||||
|
||||
public class ViewToControllerData {
|
||||
|
||||
}
|
||||
16
src/main/java/gui/src/View.java
Normal file
16
src/main/java/gui/src/View.java
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 01.12.2023
|
||||
*/
|
||||
package gui.src;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
import controller.src.ControllerToViewData;
|
||||
import controller.src.ViewToControllerData;
|
||||
|
||||
public interface View {
|
||||
public void start();
|
||||
public void setControllerToViewQueue(Queue<ControllerToViewData> queueControllerToView);
|
||||
public void setViewToControllerQueue(Queue<ViewToControllerData> queueViewToController);
|
||||
}
|
||||
39
src/main/java/gui/src/ViewThread.java
Normal file
39
src/main/java/gui/src/ViewThread.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 01.12.2023
|
||||
*/
|
||||
package gui.src;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
import controller.src.ControllerToViewData;
|
||||
import controller.src.ViewToControllerData;
|
||||
import gui.src.frames.MainFrame;
|
||||
|
||||
public class ViewThread extends Thread implements View {
|
||||
private static final String className = "ViewThread";
|
||||
|
||||
private Queue<ControllerToViewData> controllerToViewQueue;
|
||||
private Queue<ViewToControllerData> viewToControllerQueue;
|
||||
|
||||
public void run() {
|
||||
MainFrame.start();
|
||||
printMessage("Swing ui thread was started.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints a given message.
|
||||
* @param message to print.
|
||||
*/
|
||||
private static void printMessage(String message) {
|
||||
System.out.println(className + ": " + message);
|
||||
}
|
||||
|
||||
public void setControllerToViewQueue(Queue<ControllerToViewData> controllerToViewQueue) {
|
||||
this.controllerToViewQueue = controllerToViewQueue;
|
||||
}
|
||||
|
||||
public void setViewToControllerQueue(Queue<ViewToControllerData> viewToControllerQueue) {
|
||||
this.viewToControllerQueue = viewToControllerQueue;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
* @author Aaron Moser
|
||||
* @date 31.10.2023
|
||||
*/
|
||||
|
||||
package gui.src.frames;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
@@ -39,7 +38,7 @@ public final class MainFrame extends JFrame implements Themeable {
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
}
|
||||
|
||||
public static MainFrame getInstance() {
|
||||
public static MainFrame start() {
|
||||
if (null == instance) {
|
||||
instance = new MainFrame();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user