Chart actualized
This commit is contained in:
parent
3632cc765d
commit
9ccdd15adb
Binary file not shown.
@ -65,6 +65,9 @@ public class ApplicationInitializer {
|
|||||||
public static void initLookAndFeel() {
|
public static void initLookAndFeel() {
|
||||||
try {
|
try {
|
||||||
UIManager.setLookAndFeel(new FlatDarkLaf());
|
UIManager.setLookAndFeel(new FlatDarkLaf());
|
||||||
|
UIManager.put("Component.focusWidth", 1);
|
||||||
|
UIManager.put("Button.arc", 8);
|
||||||
|
UIManager.put("TextComponent.arc", 8);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class BinaryEventService {
|
|||||||
persistenceService.store(prediction);
|
persistenceService.store(prediction);
|
||||||
evaluationService.evaluate();
|
evaluationService.evaluate();
|
||||||
|
|
||||||
//Logger.debug("EVENT", "Prediction verarbeitet: " + prediction);
|
Logger.debug("EVENT", "Prediction verarbeitet: " + prediction);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Logger.error("EVENT", "Payload Verarbeitung fehlgeschlagen: " + payload, e);
|
Logger.error("EVENT", "Payload Verarbeitung fehlgeschlagen: " + payload, e);
|
||||||
|
|||||||
@ -3,6 +3,12 @@ package vassistent.ui;
|
|||||||
import org.jfree.chart.ChartFactory;
|
import org.jfree.chart.ChartFactory;
|
||||||
import org.jfree.chart.ChartPanel;
|
import org.jfree.chart.ChartPanel;
|
||||||
import org.jfree.chart.JFreeChart;
|
import org.jfree.chart.JFreeChart;
|
||||||
|
import org.jfree.chart.axis.NumberAxis;
|
||||||
|
import org.jfree.chart.axis.NumberTickUnit;
|
||||||
|
import org.jfree.chart.plot.ValueMarker;
|
||||||
|
import org.jfree.chart.plot.XYPlot;
|
||||||
|
import org.jfree.chart.ui.RectangleAnchor;
|
||||||
|
import org.jfree.chart.ui.TextAnchor;
|
||||||
import org.jfree.data.category.DefaultCategoryDataset;
|
import org.jfree.data.category.DefaultCategoryDataset;
|
||||||
import org.jfree.data.time.Millisecond;
|
import org.jfree.data.time.Millisecond;
|
||||||
import org.jfree.data.time.TimeSeries;
|
import org.jfree.data.time.TimeSeries;
|
||||||
@ -28,10 +34,31 @@ public class DashboardView extends JPanel {
|
|||||||
|
|
||||||
public DashboardView() {
|
public DashboardView() {
|
||||||
setLayout(new BorderLayout());
|
setLayout(new BorderLayout());
|
||||||
|
setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
|
||||||
|
setOpaque(false);
|
||||||
|
|
||||||
|
JPanel card = new JPanel(new BorderLayout(10,10));
|
||||||
|
card.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
|
||||||
|
|
||||||
|
card.setBackground(UIManager.getColor("Panel.background"));
|
||||||
|
card.setOpaque(true);
|
||||||
|
|
||||||
|
card.setBorder(BorderFactory.createCompoundBorder(
|
||||||
|
BorderFactory.createLineBorder(
|
||||||
|
UIManager.getColor("Component.borderColor")
|
||||||
|
),
|
||||||
|
BorderFactory.createEmptyBorder(12,12,12,12)
|
||||||
|
));
|
||||||
|
|
||||||
// ---------- TOP: Problem Level ----------
|
// ---------- TOP: Problem Level ----------
|
||||||
|
JPanel topWrapper = new JPanel(new BorderLayout());
|
||||||
|
topWrapper.setBorder(BorderFactory.createEmptyBorder(0,0,10,0));
|
||||||
|
topWrapper.setOpaque(false);
|
||||||
|
|
||||||
levelBar = new ProblemLevelBar();
|
levelBar = new ProblemLevelBar();
|
||||||
add(levelBar, BorderLayout.NORTH);
|
topWrapper.add(levelBar, BorderLayout.CENTER);
|
||||||
|
|
||||||
|
card.add(topWrapper, BorderLayout.NORTH);
|
||||||
|
|
||||||
// ---------- CENTER: Chart ----------
|
// ---------- CENTER: Chart ----------
|
||||||
|
|
||||||
@ -46,21 +73,45 @@ public class DashboardView extends JPanel {
|
|||||||
dataset
|
dataset
|
||||||
);
|
);
|
||||||
|
|
||||||
add(new ChartPanel(chart), BorderLayout.CENTER);
|
XYPlot plot = chart.getXYPlot();
|
||||||
|
|
||||||
|
// Threshold Lines
|
||||||
|
addThresholdLine(plot, 0.5, "Warning");
|
||||||
|
addThresholdLine(plot, 0.8, "High");
|
||||||
|
addThresholdLine(plot, 0.9, "Disaster");
|
||||||
|
|
||||||
|
chart.getXYPlot().getRangeAxis().setRange(0.0, 1.02);
|
||||||
|
NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis();
|
||||||
|
rangeAxis.setTickUnit(new NumberTickUnit(0.1));
|
||||||
|
|
||||||
|
chart.setAntiAlias(true);
|
||||||
|
chart.getPlot().setBackgroundPaint(new Color(245,245,245));
|
||||||
|
chart.getPlot().setOutlineVisible(false);
|
||||||
|
|
||||||
|
ChartPanel chartPanel = new ChartPanel(chart);
|
||||||
|
chartPanel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||||
|
|
||||||
|
card.add(chartPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
// ---------- SOUTH: Preview + Buttons ----------
|
// ---------- SOUTH: Preview + Buttons ----------
|
||||||
add(createBottomPanel(), BorderLayout.SOUTH);
|
card.add(createBottomPanel(), BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
add(card, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private JPanel createBottomPanel() {
|
private JPanel createBottomPanel() {
|
||||||
|
|
||||||
JPanel panel = new JPanel(new BorderLayout());
|
JPanel panel = new JPanel(new BorderLayout());
|
||||||
|
panel.setBorder(BorderFactory.createEmptyBorder(10,0,0,0));
|
||||||
|
|
||||||
JPanel buttonPanel = new JPanel(new FlowLayout());
|
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT,10,5));
|
||||||
|
|
||||||
reloadPixelStreamingViewButton = new JButton("Reload Preview");
|
reloadPixelStreamingViewButton = new JButton("Reload Preview");
|
||||||
openFullscreenButton = new JButton("Open Fullscreen");
|
openFullscreenButton = new JButton("Open Fullscreen");
|
||||||
|
|
||||||
|
reloadPixelStreamingViewButton.putClientProperty("JButton.buttonType", "roundRect");
|
||||||
|
openFullscreenButton.putClientProperty("JButton.buttonType", "roundRect");
|
||||||
|
|
||||||
buttonPanel.add(reloadPixelStreamingViewButton);
|
buttonPanel.add(reloadPixelStreamingViewButton);
|
||||||
buttonPanel.add(openFullscreenButton);
|
buttonPanel.add(openFullscreenButton);
|
||||||
|
|
||||||
@ -98,4 +149,18 @@ public class DashboardView extends JPanel {
|
|||||||
public JButton getOpenFullscreenButton() {
|
public JButton getOpenFullscreenButton() {
|
||||||
return openFullscreenButton;
|
return openFullscreenButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addThresholdLine(XYPlot plot, double value, String label) {
|
||||||
|
|
||||||
|
ValueMarker marker = new ValueMarker(value);
|
||||||
|
|
||||||
|
marker.setPaint(Color.RED);
|
||||||
|
marker.setStroke(new BasicStroke(1.5f));
|
||||||
|
marker.setLabel(label);
|
||||||
|
marker.setLabelFont(new Font("Segoe UI", Font.PLAIN, 11));
|
||||||
|
marker.setLabelAnchor(RectangleAnchor.LEFT);
|
||||||
|
marker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT);
|
||||||
|
|
||||||
|
plot.addRangeMarker(marker);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,8 @@ public class ProblemLevelBar extends JPanel {
|
|||||||
|
|
||||||
public ProblemLevelBar() {
|
public ProblemLevelBar() {
|
||||||
setPreferredSize(new Dimension(100, 50));
|
setPreferredSize(new Dimension(100, 50));
|
||||||
|
setOpaque(false);
|
||||||
|
setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRatio(double ratio) {
|
public void setRatio(double ratio) {
|
||||||
@ -44,7 +46,12 @@ public class ProblemLevelBar extends JPanel {
|
|||||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||||
|
|
||||||
// --- Hintergrund ---
|
// --- Hintergrund ---
|
||||||
g2.setColor(Color.LIGHT_GRAY);
|
GradientPaint bg = new GradientPaint(
|
||||||
|
0, 0, new Color(235,235,235),
|
||||||
|
0, height, new Color(210,210,210)
|
||||||
|
);
|
||||||
|
|
||||||
|
g2.setPaint(bg);
|
||||||
g2.fillRoundRect(0, 0, width, height, 20, 20);
|
g2.fillRoundRect(0, 0, width, height, 20, 20);
|
||||||
|
|
||||||
// --- Gefüllter Bereich ---
|
// --- Gefüllter Bereich ---
|
||||||
@ -61,12 +68,18 @@ public class ProblemLevelBar extends JPanel {
|
|||||||
g2.setPaint(gradient);
|
g2.setPaint(gradient);
|
||||||
g2.fillRoundRect(0, 0, filledWidth, height, 20, 20);
|
g2.fillRoundRect(0, 0, filledWidth, height, 20, 20);
|
||||||
|
|
||||||
|
g2.setStroke(new BasicStroke(2f));
|
||||||
|
g2.setColor(baseColor.brighter());
|
||||||
|
g2.drawRoundRect(1,1,width-2,height-2,20,20);
|
||||||
|
|
||||||
// --- Text ---
|
// --- Text ---
|
||||||
String text = level.name() + " (" + (int)(ratio * 100) + "%)";
|
String text = level.name() + " (" + (int)(ratio * 100) + "%)";
|
||||||
|
|
||||||
|
g2.setColor(Color.BLACK);
|
||||||
|
|
||||||
FontMetrics fm = g2.getFontMetrics();
|
FontMetrics fm = g2.getFontMetrics();
|
||||||
int textWidth = fm.stringWidth(text);
|
int textWidth = fm.stringWidth(text);
|
||||||
|
|
||||||
g2.setColor(Color.BLACK);
|
|
||||||
g2.drawString(
|
g2.drawString(
|
||||||
text,
|
text,
|
||||||
(width - textWidth) / 2,
|
(width - textWidth) / 2,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user