kg.apc.jmeter.gui.CustomNumberRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jmeter-plugins-cmn-jmeter Show documentation
Show all versions of jmeter-plugins-cmn-jmeter Show documentation
Various utility classes to ease development of plugins
The newest version!
package kg.apc.jmeter.gui;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import org.apache.jorphan.gui.NumberRenderer;
public class CustomNumberRenderer extends NumberRenderer {
private NumberFormat customFormatter = null;
public CustomNumberRenderer() {
super();
}
public CustomNumberRenderer(String format) {
super(format);
}
public CustomNumberRenderer(String format, char groupingSeparator) {
super();
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
symbols.setGroupingSeparator(groupingSeparator);
customFormatter = new DecimalFormat(format, symbols);
}
@Override
public void setValue(Object value) {
String str = "";
if(value != null) {
if(customFormatter != null) {
str = customFormatter.format(value);
} else {
str = formatter.format(value);
}
}
setText(str);
}
}