2016-04-28 16:29:16 +02:00
|
|
|
package org.hwo.ui.diagram;
|
|
|
|
|
2016-04-29 02:38:55 +02:00
|
|
|
import org.hwo.ui.JDiagram;
|
|
|
|
|
2016-04-28 16:29:16 +02:00
|
|
|
public class SimplePlotLabeler implements PlotLabeler {
|
|
|
|
|
|
|
|
private int decimals;
|
|
|
|
private String ordinateFormat;
|
|
|
|
|
|
|
|
|
|
|
|
public SimplePlotLabeler() {
|
|
|
|
this.setDecimals(2);
|
|
|
|
}
|
|
|
|
|
|
|
|
public SimplePlotLabeler(int decimals){
|
|
|
|
this.setDecimals(decimals);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDecimals(int decimals) {
|
|
|
|
this.decimals = decimals;
|
|
|
|
this.ordinateFormat = String.format("%%.%df", decimals);
|
|
|
|
}
|
|
|
|
public int getDecimals() {
|
|
|
|
return decimals;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
2016-04-29 02:38:55 +02:00
|
|
|
public String getOrdinateLabel(JDiagram diagram, Double value) {
|
2016-04-28 16:29:16 +02:00
|
|
|
if (value == null)
|
|
|
|
return "";
|
|
|
|
if (value.isNaN())
|
|
|
|
return "";
|
|
|
|
return String.format(this.ordinateFormat,value);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-04-29 02:38:55 +02:00
|
|
|
public String getAbzisseLabel(JDiagram diagram, Double pos) {
|
|
|
|
return String.format("%.4f", pos);
|
2016-04-28 16:29:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|