vertical scrroll bar for formulas tab

This commit is contained in:
rusefi 2019-07-20 18:54:04 -04:00
parent d4daaf6181
commit 3a1e5a0329
3 changed files with 24 additions and 17 deletions

View File

@ -12,6 +12,7 @@ import com.rusefi.ui.livedocs.LiveDocPanel;
import com.rusefi.ui.util.UiUtils;
import com.rusefi.ui.widgets.IntGaugeLabel;
import org.jetbrains.annotations.NotNull;
import org.putgemin.VerticalFlowLayout;
import org.scilab.forge.jlatexmath.TeXConstants;
import org.scilab.forge.jlatexmath.TeXFormula;
import org.scilab.forge.jlatexmath.TeXIcon;
@ -35,15 +36,23 @@ public class FormulasPane {
* this is the panel we expose to the outside world
*/
private final JPanel content = new JPanel(new BorderLayout());
private final JPanel centerProxy = new JPanel(new BorderLayout());
private final JPanel formulaProxy = new JPanel(new BorderLayout());
private boolean isPaused;
private JPanel liveDocs = LiveDocPanel.createLiveDocumentationPanel();
public FormulasPane() {
content.add(centerProxy, BorderLayout.CENTER);
centerProxy.add(new JLabel("Waiting for data..."), BorderLayout.CENTER);
JPanel vertical = new JPanel(new VerticalFlowLayout());
vertical.add(formulaProxy);
vertical.add(liveDocs);
JScrollPane scroll = new JScrollPane(vertical, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
content.add(scroll, BorderLayout.CENTER);
formulaProxy.add(new JLabel("Waiting for data..."), BorderLayout.CENTER);
JButton saveImage = UiUtils.createSaveImageButton();
saveImage.addActionListener(new ActionListener() {
@ -51,7 +60,7 @@ public class FormulasPane {
public void actionPerformed(ActionEvent e) {
String fileName = FileLog.getDate() + "_formulas.png";
UiUtils.saveImageWithPrompt(fileName, centerProxy, centerProxy);
UiUtils.saveImageWithPrompt(fileName, formulaProxy, formulaProxy);
}
});
@ -148,14 +157,12 @@ public class FormulasPane {
g2.fillRect(0, 0, formulasTeX.getIconWidth(), formulasTeX.getIconHeight());
JLabel formulaLabel = new JLabel(formulasTeX);
centerProxy.removeAll();
formulaProxy.removeAll();
JLabel warning = new JLabel("These values are for reference only and do not always reflect ECU logic completely. During cranking different logic is applied.");
warning.setForeground(Color.red);
centerProxy.add(warning, BorderLayout.NORTH);
centerProxy.add(formulaLabel, BorderLayout.CENTER);
centerProxy.add(liveDocs, BorderLayout.SOUTH);
formulaProxy.add(warning, BorderLayout.NORTH);
formulaProxy.add(formulaLabel, BorderLayout.CENTER);
}
@NotNull

View File

@ -32,7 +32,7 @@ public class LiveDocPanel {
private static final String CONSTRAINTS = "wrap, grow";
@NotNull
static JPanel getPanel(String title, String instancePrefix, final int id, Field[] values, Request[] content) {
static JPanel createPanel(String title, String instancePrefix, final int id, Field[] values, Request[] content) {
ActionPanel ap = createComponents(title, content, values, instancePrefix);
JPanel panel = ap.getPanel();
@ -171,19 +171,19 @@ public class LiveDocPanel {
public static JPanel createLiveDocumentationPanel() {
JPanel liveDocs = new JPanel(new MigLayout("gap 0, insets 0"));
liveDocs.add(getPanel("Coolant Sensor", "CLT", Fields.LDS_CLT_INDEX,
liveDocs.add(createPanel("Coolant Sensor", "CLT", Fields.LDS_CLT_INDEX,
ThermistorState.VALUES, ThermistorsMeta.CONTENT), CONSTRAINTS);
liveDocs.add(getPanel("Intake Air Sensor", "IAT", Fields.LDS_IAT_INDEX,
liveDocs.add(createPanel("Intake Air Sensor", "IAT", Fields.LDS_IAT_INDEX,
ThermistorState.VALUES, ThermistorsMeta.CONTENT), CONSTRAINTS);
liveDocs.add(getPanel("Throttle Position Sensor", "", Fields.LDS_ENGINE_STATE_INDEX,
liveDocs.add(createPanel("Throttle Position Sensor", "", Fields.LDS_ENGINE_STATE_INDEX,
EngineState.VALUES, TpsMeta.TPS_SECTION), CONSTRAINTS);
liveDocs.add(getPanel("tCharge", "", Fields.LDS_ENGINE_STATE_INDEX,
liveDocs.add(createPanel("tCharge", "", Fields.LDS_ENGINE_STATE_INDEX,
EngineState.VALUES, SpeedDensityMeta.CONTENT), CONSTRAINTS);
liveDocs.add(getPanel("Trigger", "", Fields.LDS_TRIGGER_INDEX,
liveDocs.add(createPanel("Trigger", "", Fields.LDS_TRIGGER_INDEX,
TriggerState.VALUES, TriggerDecoderMeta.CONTENT), CONSTRAINTS);
return liveDocs;

View File

@ -20,8 +20,8 @@ public class LiveDocsSandbox {
comment.setForeground(Color.blue);
JPanel panels = new JPanel(new MigLayout("fillx, gap 0, insets 0"));
panels.add(LiveDocPanel.getPanel("Coolant Sensor", "CLT", LDS_CLT_INDEX, ThermistorState.VALUES, ThermistorsMeta.CONTENT), "wrap");
panels.add(LiveDocPanel.getPanel("Intake Air Sensor", "CLT", LDS_CLT_INDEX, ThermistorState.VALUES, ThermistorsMeta.CONTENT), "wrap");
panels.add(LiveDocPanel.createPanel("Coolant Sensor", "CLT", LDS_CLT_INDEX, ThermistorState.VALUES, ThermistorsMeta.CONTENT), "wrap");
panels.add(LiveDocPanel.createPanel("Intake Air Sensor", "CLT", LDS_CLT_INDEX, ThermistorState.VALUES, ThermistorsMeta.CONTENT), "wrap");
panels.add(getTChargePanel(), "wrap, grow");