Commit ee83d215 authored by NicolaiO's avatar NicolaiO 🐼 Committed by TIGERs GitLab
Browse files

Resolve "Improve visualizer usability"

Closes #1735

See merge request main/Sumatra!1504

sumatra-commit: e59c9f3c8782e59adbc1a7399c386106c4dda659
parent e25b9c69
Pipeline #17755 passed with stage
in 7 minutes and 48 seconds
......@@ -33,7 +33,7 @@ public class ConfigEditorPresenter
@Override
public void onNewConfigClient(final String newClient)
{
viewPanel.addConfigModel(newClient, this);
SwingUtilities.invokeLater(() -> viewPanel.addConfigModel(newClient, this));
}
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.util;
......@@ -55,4 +55,17 @@ public final class ImageScaler
ImageIcon imageIcon = new ImageIcon(ImageScaler.class.getResource(path));
return scaleImageIcon(imageIcon, ScalingUtil.getImageButtonSize(), ScalingUtil.getImageButtonSize());
}
/**
* Scale an image from resources to small button size
*
* @param path
* @return
*/
public static ImageIcon scaleSmallButtonImageIcon(final String path)
{
ImageIcon imageIcon = new ImageIcon(ImageScaler.class.getResource(path));
return scaleImageIcon(imageIcon, ScalingUtil.getImageButtonSmallSize(), ScalingUtil.getImageButtonSmallSize());
}
}
/*
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.util;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
@FunctionalInterface
public interface SimpleDocumentListener extends DocumentListener
{
void update(DocumentEvent e);
@Override
default void insertUpdate(DocumentEvent e)
{
update(e);
}
@Override
default void removeUpdate(DocumentEvent e)
{
update(e);
}
@Override
default void changedUpdate(DocumentEvent e)
{
update(e);
}
}
/*
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.view.toolbar;
......@@ -31,7 +31,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
public class ToolBar
{
private final List<IToolbarObserver> observers = new CopyOnWriteArrayList<>();
private final JButton btnRecSave = new JButton();
private final JToggleButton btnRecSave = new JToggleButton();
@Getter
private final JToolBar jToolBar = new JToolBar();
......@@ -48,7 +48,6 @@ public class ToolBar
log.trace("Create toolbar");
var btnEmergency = new JButton();
btnEmergency.setForeground(Color.red);
btnEmergency.addActionListener(actionEvent -> notifyEmergencyStop());
btnEmergency.setIcon(ImageScaler.scaleDefaultButtonImageIcon("/stop-emergency.png"));
btnEmergency.setToolTipText("Emergency stop [Esc]");
......@@ -57,14 +56,16 @@ public class ToolBar
btnRecSave.addActionListener(actionEvent -> toggleRecord());
btnRecSave.setIcon(ImageScaler.scaleDefaultButtonImageIcon("/record.png"));
btnRecSave.setSelectedIcon(ImageScaler.scaleDefaultButtonImageIcon("/recordActive.gif"));
btnRecSave.setToolTipText("Start/Stop recording");
btnRecSave.setBorder(BorderFactory.createEmptyBorder());
btnRecSave.setBackground(new Color(0, 0, 0, 1));
var btnTournament = new JToggleButton();
btnTournament.addActionListener(this::toggleTournamentMode);
btnTournament.setSelectedIcon(ImageScaler.scaleDefaultButtonImageIcon("/tournament_color.png"));
btnTournament.setIcon(ImageScaler.scaleDefaultButtonImageIcon("/tournament_bw.png"));
btnTournament.setToolTipText("Tournament mode (off)");
btnTournament.setToolTipText("Tournament mode");
btnTournament.setBorder(BorderFactory.createEmptyBorder());
btnTournament.setBackground(new Color(0, 0, 0, 1));
btnTournament.setContentAreaFilled(false);
......@@ -123,15 +124,7 @@ public class ToolBar
*/
public void setRecordingEnabled(final boolean recording)
{
if (recording)
{
btnRecSave.setIcon(ImageScaler.scaleDefaultButtonImageIcon("/recordActive.gif"));
} else
{
btnRecSave.setIcon(ImageScaler.scaleDefaultButtonImageIcon("/record.png"));
}
jToolBar.repaint();
btnRecSave.setSelected(recording);
}
......@@ -145,16 +138,6 @@ public class ToolBar
{
JToggleButton btn = (JToggleButton) e.getSource();
SumatraModel.getInstance().setProductive(btn.isSelected());
if (btn.isSelected())
{
btn.setIcon(ImageScaler.scaleDefaultButtonImageIcon("/tournament_color.png"));
btn.setToolTipText("Tournament mode (on)");
} else
{
btn.setIcon(ImageScaler.scaleDefaultButtonImageIcon("/tournament_bw.png"));
btn.setToolTipText("Tournament mode (off)");
}
jToolBar.repaint();
}
......
/*
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.views;
public abstract class ASumatraPresenter implements ISumatraPresenter
{
private boolean initialized;
@Override
public void onStart()
{
if (!initialized)
{
initialized = true;
onInit();
}
ISumatraPresenter.super.onStart();
}
protected void onInit()
{
// can be overwritten
}
}
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.drawable;
import com.sleepycat.persist.model.Persistent;
import java.awt.Color;
import java.awt.Graphics2D;
import com.sleepycat.persist.model.Persistent;
/**
* Abstract base drawable class.
......@@ -26,6 +26,13 @@ public abstract class ADrawable implements IDrawableShape
}
@Override
public void paintBorder(Graphics2D g, int width, int height)
{
g.setColor(color);
}
@Override
public ADrawable setColor(final Color color)
{
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.drawable;
import com.sleepycat.persist.model.Persistent;
import java.awt.BasicStroke;
import java.awt.Graphics2D;
import java.awt.Stroke;
import com.sleepycat.persist.model.Persistent;
/**
* Abstract base drawable class with stroke width.
......@@ -27,7 +27,7 @@ public abstract class ADrawableWithStroke extends ADrawable
super.paintShape(g, tool, invert);
if (stroke == null)
{
stroke = new BasicStroke(tool.scaleXLength(strokeWidth));
stroke = new BasicStroke(tool.scaleGlobalToGui(strokeWidth));
}
g.setStroke(stroke);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment