org.jsoar.debugger.StatusBar Maven / Gradle / Ivy
/*
* Copyright (c) 2008 Dave Ray
*
* Created on Oct 30, 2008
*/
package org.jsoar.debugger;
import java.awt.Color;
import java.awt.Font;
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicReference;
import javax.swing.JLabel;
import javax.swing.Timer;
import org.jdesktop.swingx.JXStatusBar;
import org.jsoar.kernel.Agent;
import org.jsoar.kernel.SoarProperties;
import org.jsoar.kernel.learning.rl.ReinforcementLearning;
import org.jsoar.runtime.CompletionHandler;
import org.jsoar.runtime.ThreadedAgent;
import org.jsoar.util.adaptables.Adaptables;
/**
* @author ray
*/
public class StatusBar extends JXStatusBar implements Refreshable
{
private static final long serialVersionUID = 1501760828755152573L;
private final ThreadedAgent agent;
private final JLabel runState = new JLabel("run state");
private final JLabel phase = new JLabel("phase");
private final JLabel decisions = new JLabel("decisions");
private final JLabel settings = new JLabel("Status");
public StatusBar(ThreadedAgent agent)
{
this.agent = agent;
final Font boldStatusFont = runState.getFont().deriveFont(Font.BOLD);
add(runState, fixed(100));
runState.setFont(boldStatusFont);
runState.setBackground(new Color(102, 242, 96));
add(phase, fixed((int) (140*JSoarDebugger.getFontScale())));
phase.setFont(boldStatusFont);
add(decisions, fixed((int) (120*JSoarDebugger.getFontScale())));
decisions.setFont(boldStatusFont);
add(settings, fill());
// periodically refresh. this is so we get some feedback when the agent
// is running.
final Timer timer = new Timer(1000, e -> refresh(false));
timer.start();
}
/* (non-Javadoc)
* @see org.jsoar.debugger.Refreshable#refresh(boolean)
*/
public void refresh(boolean afterInitSoar)
{
final AtomicReference settingsString = new AtomicReference();
final Agent a = agent.getAgent();
final Callable