us.ihmc.simulationconstructionset.gui.TrackCheckBox Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simulation-construction-set
Show all versions of simulation-construction-set
Simulation Construction Set
package us.ihmc.simulationconstructionset.gui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JCheckBox;
import us.ihmc.jMonkeyEngineToolkit.camera.CameraPropertiesHolder;
public class TrackCheckBox extends JCheckBox implements ActionListener
{
private static final String TRACK = "Track";
private static final long serialVersionUID = -9012772363648771937L;
private ActiveCameraHolder cameraHolder;
public TrackCheckBox(ActiveCameraHolder cameraHolder)
{
super(TRACK);
setName(TRACK);
this.cameraHolder = cameraHolder;
CameraPropertiesHolder camera = cameraHolder.getCameraPropertiesForActiveCamera();
setSelected(camera.isTracking());
addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent actionEvent)
{
CameraPropertiesHolder camera = cameraHolder.getCameraPropertiesForActiveCamera();
camera.setTracking(isSelected());
}
public void makeCameraConsistent()
{
EventDispatchThreadHelper.invokeAndWait(new Runnable()
{
@Override
public void run()
{
CameraPropertiesHolder camera = cameraHolder.getCameraPropertiesForActiveCamera();
camera.setTracking(isSelected());
}
});
}
public void makeCheckBoxConsistent()
{
EventDispatchThreadHelper.invokeAndWait(new Runnable()
{
@Override
public void run()
{
CameraPropertiesHolder camera = cameraHolder.getCameraPropertiesForActiveCamera();
if (camera != null)
setSelected(camera.isTracking());
}
});
}
}