live data legend

This commit is contained in:
rusefillc 2022-01-02 01:32:32 -05:00
parent 34cf49ff57
commit b8ad330a37
2 changed files with 33 additions and 11 deletions

View File

@ -29,7 +29,9 @@ public class CodeWalkthrough {
public static final Color ACTIVE_STATEMENT = new Color(102, 255, 102);
// cost past active return statement
public static final Color PASSIVE_CODE = Color.lightGray;
private static final Color BROKEN_CODE = Color.orange;
public static final Color BROKEN_CODE = Color.orange;
public static final Color TRUE_CONDITION = Color.GREEN;
public static final Color FALSE_CONDITION = Color.RED;
static {
log.configureDebugEnabled(false);
@ -74,12 +76,6 @@ public class CodeWalkthrough {
}
}
@Override
public void enterStatement(CPP14Parser.StatementContext ctx) {
String origin = getOrigin(ctx, sourceCode);
// System.out.println("enter statement [" + origin + "]");
}
@Override
public void visitTerminal(TerminalNode node) {
allTerminals.add(node);
@ -99,8 +95,8 @@ public class CodeWalkthrough {
@Override
public void enterCondition(CPP14Parser.ConditionContext ctx) {
String conditionVariable = ctx.getText();
System.out.println("CONDITIONAL: REQUESTING VALUE " + conditionVariable);
// System.out.println("exp " + getOrigin(ctx.expression(), s));
if (log.debugEnabled())
log.debug("CONDITIONAL: REQUESTING VALUE " + conditionVariable);
Boolean state = (Boolean) valueSource.getValue(conditionVariable);
BranchingState branchingState = BranchingState.valueOf(state);
@ -111,9 +107,9 @@ public class CodeWalkthrough {
brokenConditions.add(conditionVariable);
painter.paintBackground(BROKEN_CODE, new Range(ctx));
} else if (branchingState == BranchingState.TRUE) {
painter.paintBackground(Color.GREEN, new Range(ctx));
painter.paintBackground(TRUE_CONDITION, new Range(ctx));
} else {
painter.paintBackground(Color.RED, new Range(ctx));
painter.paintBackground(FALSE_CONDITION, new Range(ctx));
}
}

View File

@ -1,10 +1,12 @@
package com.rusefi.ui;
import com.rusefi.CodeWalkthrough;
import com.rusefi.core.Sensor;
import com.rusefi.livedata.LiveDataParserPanel;
import com.rusefi.livedata.LiveDataView;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.IntGaugeLabel;
import org.jetbrains.annotations.NotNull;
import org.putgemin.VerticalFlowLayout;
import javax.swing.*;
@ -28,6 +30,8 @@ public class LiveDataPane {
JPanel vertical = new JPanel(new VerticalFlowLayout());
JScrollPane scroll = new JScrollPane(vertical, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
JPanel legend = populateLegend();
JPanel leftList = new JPanel(new VerticalFlowLayout());
for (LiveDataView view : LiveDataView.values()) {
@ -47,6 +51,7 @@ public class LiveDataPane {
content.add(leftList, BorderLayout.WEST);
content.add(scroll, BorderLayout.CENTER);
content.add(legend, BorderLayout.EAST);
/*
JButton saveImage = UiUtils.createSaveImageButton();
@ -79,6 +84,27 @@ public class LiveDataPane {
content.add(bottomPanel, BorderLayout.SOUTH);
}
@NotNull
private JPanel populateLegend() {
JPanel legend = new JPanel(new VerticalFlowLayout());
legend.add(new JLabel("Legend:"));
legend.add(createLabel(CodeWalkthrough.TRUE_CONDITION, "'true' condition"));
legend.add(createLabel(CodeWalkthrough.FALSE_CONDITION, "'false' condition"));
legend.add(createLabel(CodeWalkthrough.INACTIVE_BRANCH, "inactive branch"));
legend.add(createLabel(CodeWalkthrough.ACTIVE_STATEMENT, "active branch"));
legend.add(createLabel(CodeWalkthrough.BROKEN_CODE, "No live data"));
return legend;
}
@NotNull
private JLabel createLabel(Color background, String text) {
JLabel label = new JLabel(text);
label.setOpaque(true);
label.setBackground(background);
return label;
}
public JPanel getContent() {
return content;
}