Skip to content

Commit

Permalink
fix dynamics panel borders
Browse files Browse the repository at this point in the history
  • Loading branch information
sirfoga committed Sep 27, 2018
1 parent f697f73 commit 8ab0752
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/src/it/raceup/yolo/Data.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public class Data {
public static final String MOTORS_WINDOW_TITLE = APP_NAME + " | " + "AMK & inverters";
public static final String CAN_WINDOW_TITLE = APP_NAME + " | " + "CAN bus";
public static final String BATTERY_WINDOW_TITLE = APP_NAME + " | " + "Battery";
public static final String IMU_WINDOW_TITLE = APP_NAME + " | " + "IMU";
public static final String IMU_WINDOW_TITLE = APP_NAME + " | " + "Dynamics";
// options
public static final String[] BITRATES = {"10k", "50k", "62k", "83k", "100k", "125k", "250k", "500k", "1m"};
// formats
Expand Down
3 changes: 2 additions & 1 deletion app/src/it/raceup/yolo/app/gui/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import it.raceup.yolo.error.ExceptionType;
import it.raceup.yolo.error.YoloException;
import it.raceup.yolo.models.car.Motors;
import it.raceup.yolo.models.kvaser.BlackBird;
import it.raceup.yolo.models.kvaser.FakeBlackBird;
import it.raceup.yolo.ui.window.MainFrame;

Expand Down Expand Up @@ -82,6 +81,8 @@ protected void setupKvaser() {
protected void setupUpdaters() {
hal.addObserverToMotors(view.getMotorPanels());
hal.addObserverToKvaser(view.getCanMessagesFrame());
// todo hal.addObserverToKvaser(view.getBatteryFrame());
// todo hal.addObserverToKvaser(view.getDynamicsFrame());
}

private void setupLogUpdaters(boolean logMotors, boolean logCan, boolean logBattery, boolean logIMU) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public DriverPanel() {
}

private void setup() {
add(new JLabel("Driver"));
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

add(Box.createRigidArea(new Dimension(0, 10)));
add(steeringPanel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private void setup() {
}

private void setupLayout() {
add(Box.createRigidArea(new Dimension(0, 10)));
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // vertically

add(getTopPanel());
Expand All @@ -50,7 +51,7 @@ private JPanel getTopPanel() {
JPanel panel = new JPanel();

// horizontally
panel.setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

panel.add(xAccelerationLabel);
panel.add(Box.createRigidArea(new Dimension(50, 0)));
Expand Down
6 changes: 4 additions & 2 deletions app/src/it/raceup/yolo/ui/component/imu/ImuPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ public ImuPanel() {
}

private void setup() {
add(accelerationsPanel);
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

add(Box.createRigidArea(new Dimension(0, 10)));
add(Box.createRigidArea(new Dimension(10, 0)));
add(accelerationsPanel);
add(Box.createRigidArea(new Dimension(10, 0)));
add(yawPanel);
}

Expand Down
15 changes: 8 additions & 7 deletions app/src/it/raceup/yolo/ui/component/table/TablePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
import static it.raceup.yolo.models.data.Raw.isBoolean;

public class TablePanel extends JPanel {
private final String[] LABELS;
private final JTable table = getDataTable();
private final String[] labels;
private final JTable table;
public JButton viewButton = null;

public TablePanel(String[] labels, String tag) {
LABELS = labels;
this.labels = labels;
table = getDataTable();

if (tag != null) { // tag null -> do not add button
viewButton = new JButton(tag);
Expand Down Expand Up @@ -60,9 +61,9 @@ private JTable getDataTable() {
}; // headers for the table

// actual data
Object[][] data = new Object[LABELS.length][columns.length];
Object[][] data = new Object[labels.length][columns.length];
for (int row = 0; row < data.length; row++) {
data[row][0] = LABELS[row];
data[row][0] = labels[row];
data[row][1] = DNF;
}

Expand All @@ -72,8 +73,8 @@ private JTable getDataTable() {
}

public void update(String type, Double data, boolean isBool) {
if (Arrays.asList(LABELS).contains(type)) {
int tableRow = Arrays.asList(LABELS).indexOf(type);
if (Arrays.asList(labels).contains(type)) {
int tableRow = Arrays.asList(labels).indexOf(type);
if (tableRow >= 0) {
if (isBool) {
table.setValueAt(data.intValue() == 1, tableRow, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,33 @@
import it.raceup.yolo.error.ExceptionType;
import it.raceup.yolo.error.YoloException;
import it.raceup.yolo.models.kvaser.message.FromKvaserMessage;
import it.raceup.yolo.ui.component.driver.DriverPanel;
import it.raceup.yolo.ui.component.imu.ImuPanel;
import it.raceup.yolo.ui.component.tyres.TyresPanel;

import javax.swing.*;
import java.awt.*;
import java.util.Observable;
import java.util.Observer;

import static it.raceup.yolo.Data.IMU_WINDOW_TITLE;
import static it.raceup.yolo.utils.Os.setNativeLookAndFeelOrFail;

public class ImuFrame extends JFrame implements Observer {
public ImuFrame() {
public class DynamicsFrame extends JFrame implements Observer {
private final ImuPanel imuPanel = new ImuPanel();
private final DriverPanel driverPanel = new DriverPanel();
private final TyresPanel tyresPanel = new TyresPanel();

public DynamicsFrame() {
super(IMU_WINDOW_TITLE);
setup();
}

public void open() {
try {
pack();
setSize(600, 500);
setLocation(625, 550); // under battery
setSize(600, 700);
setLocation(625, 350); // under battery
setResizable(false);
setNativeLookAndFeelOrFail();

Expand All @@ -43,13 +51,28 @@ private void setup() {

private void setupLayout() {
setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));

add(getTopPanel());
add(Box.createRigidArea(new Dimension(10, 0)));
add(tyresPanel);
}

private JPanel getTopPanel() {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

panel.add(imuPanel);
panel.add(Box.createRigidArea(new Dimension(10, 0)));
panel.add(driverPanel);

return panel;
}

@Override
public void update(Observable observable, Object o) {
try {
FromKvaserMessage message = new FromKvaserMessage(o);
// todo updateWith
// todo update panels
} catch (Exception e) {
new YoloException("cannot updateWith CAR", e, ExceptionType.KVASER)
.print();
Expand Down
10 changes: 6 additions & 4 deletions app/src/it/raceup/yolo/ui/window/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class MainFrame extends JFrame {
private final MotorsPanel motorPanels = new MotorsPanel();
private final CanMessagesFrame canMessagesFrame = new CanMessagesFrame();
private final BatteryFrame batteryFrame = new BatteryFrame();
private final ImuFrame imuFrame = new ImuFrame();
private final DynamicsFrame dynamicsFrame = new DynamicsFrame();

public MainFrame() {
super(MOTORS_WINDOW_TITLE);
Expand Down Expand Up @@ -62,7 +62,7 @@ private void open() {
private void openFrames() {
canMessagesFrame.open();
batteryFrame.open();
// todo show this frame imuFrame.open();
dynamicsFrame.open();
}

private void setupLayout() {
Expand All @@ -73,9 +73,7 @@ private void setupLayout() {
); // border

setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS));

add(motorPanels);

setJMenuBar(createMenuBar());
}

Expand Down Expand Up @@ -134,6 +132,10 @@ public BatteryFrame getBatteryFrame() {
return batteryFrame;
}

public DynamicsFrame getDynamicsFrame() {
return dynamicsFrame;
}

private void loadIcon() {
Image icon = new Data().getAppImage();
setIconImage(icon); // set icon
Expand Down
Binary file modified production/app/res/images/logo.png
100755 → 100644
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion production/app/res/strings/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.1 (655095c934b34488bd1bbc1af5708c0af390de5d at 15:55:44 18-09-22 +0200)
1.3.4 (e39e5417078aec0e4d6fb1b387cf26fab4b15363 at 17:39:19 18-09-27 +0200)

0 comments on commit 8ab0752

Please sign in to comment.