Added basic raw structure to monitoring panel.
This commit is contained in:
@@ -19,7 +19,8 @@ public final class GUIConstants {
|
||||
public static enum Panel {
|
||||
MonitoringPanel,
|
||||
ControllingPanel,
|
||||
ConnectToServerPanel
|
||||
ConnectToServerPanel,
|
||||
ConnectionsTablePanel
|
||||
}
|
||||
|
||||
public static enum Status {
|
||||
|
||||
@@ -14,8 +14,9 @@ import gui.src.constants.GUIConstants.Theme;
|
||||
import gui.src.interfaces.Themeable;
|
||||
import gui.src.menubar.MenuBar;
|
||||
import gui.src.panels.ControllingPanel;
|
||||
import gui.src.panels.MonitoringPanel;
|
||||
import gui.src.panels.ConnectToServerPanel.ConnectToServerPanel;
|
||||
import gui.src.panels.ConnectionsTablePanel.ConnectionsTablePanel;
|
||||
import gui.src.panels.MonitoringPanel.MonitoringPanel;
|
||||
import gui.src.panels.StatusPanel;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -65,6 +66,8 @@ public final class MainFrame extends JFrame implements Themeable {
|
||||
mainConstraints.weighty = 0.1;
|
||||
this.getContentPane().add(panel, mainConstraints);
|
||||
|
||||
this.pack();
|
||||
this.setSize(1400, 700);
|
||||
this.getContentPane().update(this.getGraphics());
|
||||
this.update(this.getGraphics());
|
||||
}
|
||||
@@ -82,6 +85,9 @@ public final class MainFrame extends JFrame implements Themeable {
|
||||
case ConnectToServerPanel: {
|
||||
this.setPanel(ConnectToServerPanel.getInstance());
|
||||
}break;
|
||||
case ConnectionsTablePanel: {
|
||||
this.setPanel(ConnectionsTablePanel.getInstance());
|
||||
}break;
|
||||
default: {
|
||||
throw new Exception("Unknown kind of panel.");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package gui.src.panels.ConnectionsTablePanel;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class ConnectionsTablePanel extends JPanel {
|
||||
private static ConnectionsTablePanel instance;
|
||||
|
||||
private ConnectionsTablePanel() {
|
||||
|
||||
}
|
||||
|
||||
public static ConnectionsTablePanel getInstance() {
|
||||
if (null == instance) {
|
||||
instance = new ConnectionsTablePanel();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 31.10.2023
|
||||
*/
|
||||
|
||||
package gui.src.panels;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.Insets;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import gui.src.panels.ConnectionsLineChart.ConnectionsLineChartPanel;
|
||||
|
||||
public final class MonitoringPanel extends JPanel {
|
||||
|
||||
private static MonitoringPanel instance;
|
||||
|
||||
private MonitoringPanel() {
|
||||
GridBagConstraints gridBagConstraints = new GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 0;
|
||||
this.add(ConnectionsLineChartPanel.getInstance(), gridBagConstraints);
|
||||
|
||||
this.setPreferredSize(new Dimension(900,600));
|
||||
}
|
||||
|
||||
public static MonitoringPanel getInstance() {
|
||||
if (null == instance) {
|
||||
instance = new MonitoringPanel();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package gui.src.panels.MonitoringPanel.AlarmPanel;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class Alarm extends JPanel {
|
||||
private JButton button;
|
||||
|
||||
public Alarm(String message) {
|
||||
this.button = new JButton(message);
|
||||
|
||||
this.setLayout(new BorderLayout());
|
||||
this.add(button);
|
||||
}
|
||||
|
||||
public JButton getButton() {
|
||||
return button;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package gui.src.panels.MonitoringPanel.AlarmPanel;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
|
||||
public class AlarmPanel extends JPanel {
|
||||
private static AlarmPanel instance;
|
||||
|
||||
private JPanel alarmsPanel;
|
||||
private LinkedList<Alarm> alarms;
|
||||
private JScrollPane scrollPane;
|
||||
|
||||
private AlarmPanel() {
|
||||
this.alarmsPanel = new JPanel();
|
||||
this.alarmsPanel.setLayout(new BoxLayout(alarmsPanel, BoxLayout.Y_AXIS));
|
||||
|
||||
for (int i = 0; i < 41; i++) {
|
||||
Alarm alarm = new Alarm("Test " + i);
|
||||
this.alarmsPanel.add(alarm);
|
||||
}
|
||||
|
||||
JLabel label = new JLabel("Alarme");
|
||||
|
||||
// Fills the whole rest panel (this) with scroll pane.
|
||||
this.scrollPane = new JScrollPane(alarmsPanel);
|
||||
this.scrollPane.setPreferredSize(new Dimension(300,200));
|
||||
|
||||
this.setLayout(new GridBagLayout());
|
||||
GridBagConstraints labelConstraints = new GridBagConstraints();
|
||||
labelConstraints.anchor = GridBagConstraints.NORTHWEST;
|
||||
labelConstraints.gridx = 0;
|
||||
labelConstraints.gridy = 0;
|
||||
this.add(label, labelConstraints);
|
||||
|
||||
GridBagConstraints scrollPaneConstraints = new GridBagConstraints();
|
||||
scrollPaneConstraints.anchor = GridBagConstraints.NORTHWEST;
|
||||
scrollPaneConstraints.gridx = 0;
|
||||
scrollPaneConstraints.gridy = 1;
|
||||
this.add(scrollPane, scrollPaneConstraints);
|
||||
}
|
||||
|
||||
public static AlarmPanel getInstance() {
|
||||
if (null == instance) {
|
||||
instance = new AlarmPanel();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package gui.src.panels.ConnectionsLineChart;
|
||||
package gui.src.panels.MonitoringPanel.ConnectionsLineChart;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Font;
|
||||
|
||||
import java.awt.event.MouseAdapter;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
@@ -15,10 +18,15 @@ import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.plot.XYPlot;
|
||||
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
|
||||
import org.jfree.chart.title.TextTitle;
|
||||
|
||||
import org.jfree.data.xy.XYDataset;
|
||||
import org.jfree.data.xy.XYSeries;
|
||||
import org.jfree.data.xy.XYSeriesCollection;
|
||||
|
||||
import org.w3c.dom.events.MouseEvent;
|
||||
|
||||
import gui.src.frames.MainFrame;
|
||||
|
||||
public class ConnectionsLineChartPanel extends JPanel {
|
||||
private static ConnectionsLineChartPanel instance;
|
||||
|
||||
@@ -28,7 +36,14 @@ public class ConnectionsLineChartPanel extends JPanel {
|
||||
|
||||
ChartPanel chartPanel = new ChartPanel(chart);
|
||||
chartPanel.setBackground(Color.white);
|
||||
chartPanel.setPreferredSize(new Dimension(400,200));
|
||||
add(chartPanel);
|
||||
|
||||
addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
MainFrame.getInstance().setPanel(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static ConnectionsLineChartPanel getInstance() {
|
||||
@@ -40,11 +55,12 @@ public class ConnectionsLineChartPanel extends JPanel {
|
||||
|
||||
private XYDataset createDataset() {
|
||||
|
||||
var series = new XYSeries("2016");
|
||||
series.add(18, 15);
|
||||
series.add(20, 20);
|
||||
series.add(25, 40);
|
||||
series.add(30, 70);
|
||||
var series = new XYSeries("TCP");
|
||||
series.add(1, 2);
|
||||
series.add(2, 4);
|
||||
series.add(3, 2);
|
||||
series.add(4, 5);
|
||||
series.add(5, 7);
|
||||
|
||||
var dataset = new XYSeriesCollection();
|
||||
dataset.addSeries(series);
|
||||
@@ -55,9 +71,9 @@ public class ConnectionsLineChartPanel extends JPanel {
|
||||
private JFreeChart createChart(XYDataset dataset) {
|
||||
|
||||
JFreeChart chart = ChartFactory.createXYLineChart(
|
||||
"Average salary per age",
|
||||
"Age",
|
||||
"Salary (€)",
|
||||
"Zugriffe in Abh. zur Zeit",
|
||||
"Zeit",
|
||||
"Zugriffe",
|
||||
dataset,
|
||||
PlotOrientation.VERTICAL,
|
||||
true,
|
||||
@@ -0,0 +1,48 @@
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 31.10.2023
|
||||
*/
|
||||
|
||||
package gui.src.panels.MonitoringPanel;
|
||||
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import gui.src.panels.MonitoringPanel.AlarmPanel.AlarmPanel;
|
||||
import gui.src.panels.MonitoringPanel.ConnectionsLineChart.ConnectionsLineChartPanel;
|
||||
import gui.src.panels.MonitoringPanel.SystemInformationPanel.SystemInformationPanel;
|
||||
|
||||
public final class MonitoringPanel extends JPanel {
|
||||
|
||||
private static MonitoringPanel instance;
|
||||
|
||||
private MonitoringPanel() {
|
||||
this.setLayout(new GridBagLayout());
|
||||
|
||||
GridBagConstraints alarmConstraints = new GridBagConstraints();
|
||||
alarmConstraints.gridx = 0;
|
||||
alarmConstraints.gridy = 0;
|
||||
this.add(AlarmPanel.getInstance(), alarmConstraints);
|
||||
|
||||
GridBagConstraints connectionsLineCartConstraints = new GridBagConstraints();
|
||||
connectionsLineCartConstraints.gridx = 1;
|
||||
connectionsLineCartConstraints.gridy = 0;
|
||||
this.add(ConnectionsLineChartPanel.getInstance(), connectionsLineCartConstraints);
|
||||
|
||||
GridBagConstraints systemInformationConstraints = new GridBagConstraints();
|
||||
systemInformationConstraints.gridx = 0;
|
||||
systemInformationConstraints.gridy = 1;
|
||||
this.add(SystemInformationPanel.getInstance(), systemInformationConstraints);
|
||||
}
|
||||
|
||||
public static MonitoringPanel getInstance() {
|
||||
if (null == instance) {
|
||||
instance = new MonitoringPanel();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package gui.src.panels.MonitoringPanel.SystemInformationPanel;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class SystemInformationPanel extends JPanel {
|
||||
private static SystemInformationPanel instance;
|
||||
|
||||
private SystemInformationPanel() {
|
||||
this.setBackground(Color.red);
|
||||
this.setPreferredSize(new Dimension(300,200));
|
||||
|
||||
this.setLayout(new GridBagLayout());
|
||||
GridBagConstraints labelConstraints = new GridBagConstraints();
|
||||
labelConstraints.anchor = GridBagConstraints.NORTHWEST;
|
||||
labelConstraints.gridx = 0;
|
||||
labelConstraints.gridy = 0;
|
||||
this.add(new JLabel("System Information"), labelConstraints);
|
||||
}
|
||||
|
||||
public static SystemInformationPanel getInstance() {
|
||||
if (null == instance) {
|
||||
instance = new SystemInformationPanel();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,10 @@ public final class ConnectionModel {
|
||||
|
||||
private ConnectionStatus connectionStatus;
|
||||
|
||||
private String ipAddress;
|
||||
|
||||
private int port;
|
||||
|
||||
public ConnectionModel() {
|
||||
this.connectionStatus = ConnectionStatus.Disconnected;
|
||||
}
|
||||
@@ -24,4 +28,6 @@ public final class ConnectionModel {
|
||||
public void setConnectionStatus(ConnectionStatus newConnectionStatus) {
|
||||
this.connectionStatus = newConnectionStatus;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,10 +7,24 @@ package model.src;
|
||||
public class ModelRepresentation implements Model {
|
||||
private NetworkModel networkModel;
|
||||
private NFTablesModel nfTablesModel;
|
||||
private ConnectionModel connectionModel;
|
||||
|
||||
public ModelRepresentation() {
|
||||
networkModel = new NetworkModel();
|
||||
nfTablesModel = new NFTablesModel();
|
||||
this.networkModel = new NetworkModel();
|
||||
this.nfTablesModel = new NFTablesModel();
|
||||
this.connectionModel = new ConnectionModel();
|
||||
}
|
||||
|
||||
public NetworkModel getNetworkModel() {
|
||||
return this.networkModel;
|
||||
}
|
||||
|
||||
public NFTablesModel getNFTablesModel() {
|
||||
return this.nfTablesModel;
|
||||
}
|
||||
|
||||
public ConnectionModel getConnectionModel() {
|
||||
return this.connectionModel;
|
||||
}
|
||||
|
||||
public void addNetworkConnection(String networkConnection) {
|
||||
|
||||
Reference in New Issue
Block a user