mmb.content.electric.ElectricalBatteryVisualiser Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of multimachinebuilder Show documentation
Show all versions of multimachinebuilder Show documentation
Dependency for the MultiMachineBuilder, a voxel game about building an industrial empire in a finite world.
THIS RELEASE IS NOT PLAYABLE. To play the game, donwload from >ITCH.IO LINK HERE< or >GH releases link here<
The newest version!
/**
*
*/
package mmb.content.electric;
import java.awt.Graphics;
import javax.swing.JProgressBar;
/**
* A progress bar, which visualizes it electric charge
* @author oskar
*/
public class ElectricalBatteryVisualiser extends JProgressBar {
public ElectricalBatteryVisualiser() {
}
private static final long serialVersionUID = -822042501287883479L;
private Battery battery;
/** @return battery currently visualised */
public Battery getBattery() {
return battery;
}
/** @param battery new battery to visualise */
public void setBattery(Battery battery) {
this.battery = battery;
repaint();
}
@Override
public void paint(@SuppressWarnings("null") Graphics g) {
if(battery != null) {
setMaximum((int) battery.capacity);
setMinimum(0);
setValue((int) battery.stored);
}
super.paint(g);
}
}