-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the instrument cluster panel skeleton (#268)
- Loading branch information
1 parent
117e818
commit 8b03963
Showing
5 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
dz3r-swing/src/main/java/net/sf/dz3r/view/swing/dashboard/DashboardCell.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package net.sf.dz3r.view.swing.dashboard; | ||
|
||
import net.sf.dz3r.signal.health.SystemStatus; | ||
import net.sf.dz3r.view.swing.ColorScheme; | ||
import net.sf.dz3r.view.swing.EntityCell; | ||
|
||
import java.awt.Color; | ||
import java.awt.Dimension; | ||
import java.awt.Graphics2D; | ||
import java.awt.Rectangle; | ||
|
||
public class DashboardCell extends EntityCell<SystemStatus, Void> { | ||
|
||
public DashboardCell() { | ||
setPreferredSize(new Dimension(20, 70)); | ||
} | ||
|
||
@Override | ||
protected void paintContent(Graphics2D g2d, Rectangle boundary) { | ||
|
||
if (getSignal() == null) { | ||
g2d.setPaint(ColorScheme.offMap.error); | ||
g2d.fill(boundary); | ||
} | ||
} | ||
|
||
@Override | ||
protected Color getBorderColor() { | ||
// Mode has no say in this case, unlike every other cell | ||
return ColorScheme.offMap.green; | ||
} | ||
|
||
@Override | ||
protected Color getIndicatorColor() { | ||
|
||
if (getSignal() == null || getSignal().isError()) { | ||
return ColorScheme.offMap.error; | ||
} | ||
|
||
return ColorScheme.offMap.green.darker().darker(); | ||
} | ||
|
||
@Override | ||
protected void consumeSignalValue(SystemStatus value) { | ||
// No special handling | ||
} | ||
} |
102 changes: 102 additions & 0 deletions
102
dz3r-swing/src/main/java/net/sf/dz3r/view/swing/dashboard/DashboardPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package net.sf.dz3r.view.swing.dashboard; | ||
|
||
import net.sf.dz3r.instrumentation.InstrumentCluster; | ||
import net.sf.dz3r.signal.health.SystemStatus; | ||
import net.sf.dz3r.view.swing.ColorScheme; | ||
import net.sf.dz3r.view.swing.EntityPanel; | ||
import net.sf.dz3r.view.swing.ScreenDescriptor; | ||
import reactor.core.publisher.Flux; | ||
|
||
import javax.swing.BoxLayout; | ||
import javax.swing.JPanel; | ||
import javax.swing.border.TitledBorder; | ||
import java.awt.Color; | ||
import java.awt.GridBagConstraints; | ||
import java.awt.GridBagLayout; | ||
import java.awt.event.KeyEvent; | ||
|
||
public class DashboardPanel extends EntityPanel<SystemStatus, Void> { | ||
|
||
private final InstrumentCluster ic; | ||
|
||
private final JPanel sensorPanel = new JPanel(); | ||
private final JPanel switchPanel = new JPanel(); | ||
private final JPanel connectorPanel = new JPanel(); | ||
private final JPanel collectorPanel = new JPanel(); | ||
private final JPanel hvacDevicePanel = new JPanel(); | ||
|
||
public DashboardPanel(InstrumentCluster ic, ScreenDescriptor screenDescriptor) { | ||
|
||
this.ic = ic; | ||
|
||
setFontSize(screenDescriptor); | ||
initGraphics(); | ||
} | ||
|
||
private void initGraphics() { | ||
|
||
setBackground(ColorScheme.offMap.background); | ||
setBorder(new TitledBorder("Instrument Cluster")); | ||
((TitledBorder) getBorder()).setTitleColor(Color.WHITE); | ||
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); | ||
|
||
sensorPanel.setBorder(new TitledBorder("Sensors")); | ||
switchPanel.setBorder(new TitledBorder("Switches")); | ||
connectorPanel.setBorder(new TitledBorder("Connectors")); | ||
collectorPanel.setBorder(new TitledBorder("Collectors")); | ||
hvacDevicePanel.setBorder(new TitledBorder("HVAC Devices")); | ||
|
||
Flux | ||
.just( | ||
sensorPanel, | ||
switchPanel, | ||
connectorPanel, | ||
collectorPanel, | ||
hvacDevicePanel) | ||
.doOnNext(panel -> panel.setBackground(ColorScheme.offMap.background)) | ||
.doOnNext(panel -> ((TitledBorder) panel.getBorder()).setTitleColor(Color.WHITE)) | ||
.doOnNext(this::add) | ||
.subscribe(); | ||
} | ||
|
||
@Override | ||
public void keyTyped(KeyEvent e) { | ||
// No special handling | ||
} | ||
|
||
@Override | ||
public void keyPressed(KeyEvent e) { | ||
// No special handling yet | ||
} | ||
|
||
@Override | ||
public void keyReleased(KeyEvent e) { | ||
// No special handling | ||
} | ||
|
||
@Override | ||
protected void consumeSignalValue(SystemStatus status) { | ||
// No special handling | ||
} | ||
|
||
@Override | ||
protected void update() { | ||
|
||
var signal = getSignal(); | ||
} | ||
|
||
@Override | ||
protected void createControls(JPanel controls, GridBagLayout layout, GridBagConstraints cs) { | ||
throw new IllegalStateException("Not Implemented Here"); | ||
} | ||
|
||
@Override | ||
public void setFontSize(ScreenDescriptor screenDescriptor) { | ||
|
||
sensorPanel.setFont(screenDescriptor.fontSetpoint); | ||
switchPanel.setFont(screenDescriptor.fontSetpoint); | ||
connectorPanel.setFont(screenDescriptor.fontSetpoint); | ||
collectorPanel.setFont(screenDescriptor.fontSetpoint); | ||
hvacDevicePanel.setFont(screenDescriptor.fontSetpoint); | ||
} | ||
} |