Here is it
progress-bar.xml
<?xml version="1.0" encoding="UTF-8"?>
<nifty-controls>
<controlDefinition name = "progressBar" controller = "kinetrax.nifty.control.progressbar.ProgressBarControl">
<image id="progressBarBorder" filename="Interface/Skins/ProgressBar/border.png" childLayout="horizontal"
imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15">
<image id="progressBarInner" x="0" y="0" filename="$image" width="100%" height="100%"
imageMode="resize:15,2,15,15,15,2,15,2,15,2,15,15" childLayout="" valign="bottom">
</image>
</image>
</controlDefinition>
</nifty-controls>
controls.xml
<?xml version="1.0" encoding="UTF-8"?>
<nifty-controls>
<useControls filename="Interface/Controls/ProgressBar/progress-bar.xml" />
<useControls filename="Interface/Controls/RhythmTrack/rhythm-track.xml" />
<useControls filename="Interface/Controls/MoveBar/move-bar.xml" />
<useControls filename="Interface/Controls/TrackSelect/track-select.xml" />
<useControls filename="Interface/Controls/Track/track.xml" />
</nifty-controls>
ProgressBar.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package kinetrax.nifty.control.progressbar;
import de.lessvoid.nifty.controls.NiftyControl;
/**
*
* @author Glauco Márdano
*/
public interface ProgressBar extends NiftyControl {
public void setProgress(float progress);
public float getProgress();
public void setDirection(String direction);
}
ProgressBarControl.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package kinetrax.nifty.control.progressbar;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.layout.manager.HorizontalLayout;
import de.lessvoid.nifty.layout.manager.VerticalLayout;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.tools.SizeValue;
import de.lessvoid.xml.xpp3.Attributes;
import java.util.Properties;
import kinetrax.nifty.control.KinetraxController;
/**
*
* @author Glauco Márdano
*/
public class ProgressBarControl extends KinetraxController implements ProgressBar {
private float progressParam;
private String directionParam;
private Element progressBarInner;
@Override
public void bind(Nifty nifty, Screen screen, Element element, Properties parameter, Attributes controlDefinitionAttributes) {
super.bind(nifty, screen, element, parameter, controlDefinitionAttributes);
}
@Override
protected void initializeParameters(Properties parameter) {
progressBarInner = getElement().findElementByName("progressBarInner");
setDirection(parameter.getProperty("direction"));
setProgress(Float.parseFloat(parameter.getProperty("progress")));
setChildLayout(directionParam);
progressBarInner.getParent().layoutElements();
}
public void setProgress(float progress) {
assert progress >= 0f && progress <= 1f : "progress out of range " + progress;
progressParam = progress;
final int MIN_WIDTH = 32;
final int MIN_HEIGHT = 32;
if (directionParam.equals("horizontal")) {
int pixelWidth = (int) (MIN_WIDTH + (progressBarInner.getParent().getWidth() - MIN_WIDTH) * progress);
progressBarInner.setConstraintWidth(new SizeValue(pixelWidth + "px"));
}
if (directionParam.equals("vertical")) {
int pixelHeight = (int) (MIN_HEIGHT + (progressBarInner.getParent().getHeight() - MIN_HEIGHT) * progress);
progressBarInner.setConstraintHeight(new SizeValue(pixelHeight + "px"));
}
progressBarInner.getParent().layoutElements();
}
public float getProgress() {
return progressParam;
}
public void setDirection(String direction) {
assert direction.equals("horizontal") || direction.equals("vertical") : "direction unrecognized " + direction;
this.directionParam = direction;
}
private void setChildLayout(String direction) {
if (direction.equals("horizontal")) {
progressBarInner.setLayoutManager(new VerticalLayout());
}
if (direction.equals("vertical")) {
progressBarInner.setLayoutManager(new HorizontalLayout());
}
}
public void update(float tpf) {
}
}
KinetraxController.java
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package kinetrax.nifty.control;
import com.jme3.app.Application;
import com.jme3.app.state.AppState;
import com.jme3.app.state.AppStateManager;
import com.jme3.renderer.RenderManager;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.controls.AbstractController;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.input.NiftyInputEvent;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.xml.xpp3.Attributes;
import java.util.Properties;
import kinetrax.app.KinetraxApp;
import kinetrax.audio.AudioManager;
/**
*
* @author Glauco Márdano
*/
public abstract class KinetraxController extends AbstractController implements AppState {
private Nifty nifty;
private Screen screen;
private Element element;
private Properties parameter;
private Attributes controlDefinitionAttributes;
private KinetraxApp app;
private AppStateManager stateManager;
private boolean initialized;
private boolean enabled = true;
private AudioManager audioManager;
public KinetraxController() {
super();
}
public void bind(Nifty nifty, Screen screen, Element element, Properties parameter, Attributes controlDefinitionAttributes) {
this.nifty = nifty;
this.screen = screen;
this.element = element;
this.parameter = parameter;
this.controlDefinitionAttributes = controlDefinitionAttributes;
initializeParameters(parameter);
}
protected abstract void initializeParameters(Properties parameter);
public void onStartScreen() {
}
public boolean inputEvent(NiftyInputEvent inputEvent) {
return false;
}
public Attributes getControlDefinitionAttributes() {
return controlDefinitionAttributes;
}
public Nifty getNifty() {
return nifty;
}
public void setNifty(Nifty nifty) {
this.nifty = nifty;
}
@Override
public Element getElement() {
return element;
}
public Properties getParameter() {
return parameter;
}
public Screen getScreen() {
return screen;
}
public void setScreen(Screen screen) {
this.screen = screen;
}
public void initialize(AppStateManager stateManager, Application app) {
initialized = true;
this.app = (KinetraxApp) app;
this.stateManager = stateManager;
audioManager = this.app.getAudioManager();
}
public void cleanup() {
initialized = false;
}
public boolean isInitialized() {
return initialized;
}
public void stateAttached(AppStateManager stateManager) {
}
public void stateDetached(AppStateManager stateManager) {
}
public void render(RenderManager rm) {
}
public void postRender() {
}
@Override
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
@Override
public boolean isEnabled() {
return enabled;
}
public KinetraxApp getApp() {
return app;
}
public AppStateManager getStateManager() {
return stateManager;
}
public void setStateManager(AppStateManager stateManager) {
this.stateManager = stateManager;
}
public AudioManager getAudioManager() {
return audioManager;
}
}
Usage in StartScreen.xml
<?xml version="1.0" encoding="UTF-8"?>
<nifty xmlns="http://nifty-gui.sourceforge.net/nifty-1.3.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://nifty-gui.sourceforge.net/nifty-1.3.xsd http://nifty-gui.sourceforge.net/nifty-1.3.xsd">
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<!-- start screen -->
<!-- +++++++++++++++++++++++++++++++++++++++ -->
<useStyles filename="Interface/Styles/styles.xml" />
<useControls filename="nifty-default-controls.xml" />
<useControls filename="Interface/Controls/controls.xml" />
<screen id="startScreen" controller="kinetrax.nifty.control.screen.start.StartScreenControl">
<layer id="startLoadingLayer" childLayout="horizontal">
<panel height="10%"/>
<panel id = "startLoadingPanel" childLayout="vertical" align="center" valign="center" height="32px" width="80%">
<control image="Interface/Skins/ProgressBar/inner-orange.png" id="startLoadingBar" name="progressBar" align="center" valign="center" width="100%" height="100%" progress="0f" direction="horizontal" progresstext="Loading..."/>
</panel>
<panel height="10%"/>
</layer>
<layer id="startLoadingTextLayer" childLayout="horizontal">
<panel height="10%"/>
<panel id = "startLoadingTextPanel" childLayout="center" align="center" valign="center" height="32px" width="80%">
<control id="startLoadingProgressText" text="Loading..." name="label" align="center" valign="center" width="100%"/>
</panel>
<panel height="10%"/>
</layer>
</screen>
</nifty>
-Regards