I am looking for help with my MVC design where am I going wrong and if at all it makes sense the way that I'm slowly progressing.
I am trying to create something like this:
Many gauges that would work in their own threads, my issue is with properly dividing this program into views and models.
Here is what I came up with so far:
Controllers
DashboardController
Models
BarGaugeModel
CircularGaugeModel
Views
Components
BarGauge
CircularGauge
DashboardView
ViewModels
DashboardViewModel
Main
Main
BarGaugeModel.java
public class BarGaugeModel {
private int speed;
public int getSpeed() {
return speed;
}
public void setSpeed(int speed) {
this.speed = speed;
}
}
DashboardViewModel.java (would consist of all models)
public class DashboardViewModel {
BarGaugeModel fuelGauge = new BarGaugeModel();
public BarGaugeModel getFuelGauge() {
return fuelGauge;
}
}
BarGauge.java
public class BarGauge extends JPanel {
private JLabel speed = new JLabel();
public int getSpeed() {
return Integer.parseInt(speed.getText());
}
public void setSpeed(int speed) {
this.speed.setText(speed+"");
}
}
DashboardView.java (would create all view components and add to this jframe)
public class DashboardView extends JFrame {
BarGauge barGauge = new BarGauge();
public void DashBoardView(){
this.setSize(new Dimension(100,100));
this.add(barGauge);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Main.java
public class Main {
public static void main(String[] args) {
DashboardView dashboardView = new DashboardView();
DashboardViewModel dashboardViewModel = new DashboardViewModel();
DashboardController dashboardController = new DashboardController(dashboardView, dashboardViewModel);
dashboardView.setVisible(true);
}
}
Each of those gauges would also have a manual input for user to type in which I'm also not too sure where should that input be contained in which view or maybe in completely separate one.