forked from LupusNobilis/java-org.hwo.ui
AbstractTableMapperListener, JDiagram updates
parent
9f2215eaf4
commit
e727197d6b
|
@ -7,4 +7,10 @@ public abstract class AbstractTableMapperListener implements
|
||||||
public void ValueChanged(int row, int column) {
|
public void ValueChanged(int row, int column) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean editorRequest(TableMapper tableMapper, Object row) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -423,6 +423,14 @@ public class TableMapper extends AbstractTableModel
|
||||||
|
|
||||||
private void openEditor()
|
private void openEditor()
|
||||||
{
|
{
|
||||||
|
System.err.println("TableMapper.openEditor()");
|
||||||
|
for (TableMapperListener listener: this.tableMapperListeners){
|
||||||
|
if (listener.editorRequest(this, getSelectedRow())){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object editorObject = getEditorObject();
|
Object editorObject = getEditorObject();
|
||||||
|
|
||||||
|
|
|
@ -4,4 +4,6 @@ public interface TableMapperListener {
|
||||||
|
|
||||||
public void ValueChanged(int row,int column);
|
public void ValueChanged(int row,int column);
|
||||||
|
|
||||||
|
public boolean editorRequest(TableMapper tableMapper,Object row);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,8 @@ public class JDiagram extends JComponent {
|
||||||
plotProvider;
|
plotProvider;
|
||||||
|
|
||||||
private PlotLabeler
|
private PlotLabeler
|
||||||
defaultLabeler;
|
defaultLabeler,
|
||||||
|
abszissLabeler;
|
||||||
|
|
||||||
// Innenabstand zu Zeichnungselementen
|
// Innenabstand zu Zeichnungselementen
|
||||||
private int bTop,
|
private int bTop,
|
||||||
|
@ -75,7 +76,7 @@ public class JDiagram extends JComponent {
|
||||||
setDoubleBuffered(true);
|
setDoubleBuffered(true);
|
||||||
|
|
||||||
defaultLabeler = new SimplePlotLabeler();
|
defaultLabeler = new SimplePlotLabeler();
|
||||||
|
abszissLabeler = defaultLabeler;
|
||||||
|
|
||||||
bTop = bBottom = bLeft = 10;
|
bTop = bBottom = bLeft = 10;
|
||||||
bRight = 30;
|
bRight = 30;
|
||||||
|
@ -193,6 +194,14 @@ public class JDiagram extends JComponent {
|
||||||
this.autoScaleMargins = autoScaleMargins;
|
this.autoScaleMargins = autoScaleMargins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PlotLabeler getAbszissLabeler() {
|
||||||
|
return abszissLabeler;
|
||||||
|
}
|
||||||
|
public void setAbszissLabeler(PlotLabeler abszissLabeler) {
|
||||||
|
this.abszissLabeler = abszissLabeler;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void autoscale(){
|
public void autoscale(){
|
||||||
int ordinate;
|
int ordinate;
|
||||||
Double[] max,min;
|
Double[] max,min;
|
||||||
|
@ -277,6 +286,9 @@ public class JDiagram extends JComponent {
|
||||||
|
|
||||||
public void paintOrdinates(Graphics2D g){
|
public void paintOrdinates(Graphics2D g){
|
||||||
double[][] labelValues = new double[ ordinateViews.length ][];
|
double[][] labelValues = new double[ ordinateViews.length ][];
|
||||||
|
Integer last_y = null,
|
||||||
|
y = null,
|
||||||
|
d = null;
|
||||||
|
|
||||||
for (int ordinate=0; ordinate < ordinateViews.length; ordinate++){
|
for (int ordinate=0; ordinate < ordinateViews.length; ordinate++){
|
||||||
labelValues[ ordinate ] = getordinateLabelHints(ordinate);
|
labelValues[ ordinate ] = getordinateLabelHints(ordinate);
|
||||||
|
@ -294,6 +306,7 @@ public class JDiagram extends JComponent {
|
||||||
for (int i=0;i<=nMarkers;i++){
|
for (int i=0;i<=nMarkers;i++){
|
||||||
labels[i] = this.defaultLabeler.getOrdinateLabel(
|
labels[i] = this.defaultLabeler.getOrdinateLabel(
|
||||||
this,
|
this,
|
||||||
|
ordinate,
|
||||||
labelValues[ordinate][i]
|
labelValues[ordinate][i]
|
||||||
);
|
);
|
||||||
labelWidths[i] = g.getFontMetrics().stringWidth(labels[i]);
|
labelWidths[i] = g.getFontMetrics().stringWidth(labels[i]);
|
||||||
|
@ -303,13 +316,26 @@ public class JDiagram extends JComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
plotWidth -= maxWidth + 5;
|
plotWidth -= maxWidth + 5;
|
||||||
|
last_y = null;
|
||||||
|
|
||||||
for (int i=0; i<=nMarkers ;i++){
|
for (int i=0; i<=nMarkers ;i++){
|
||||||
|
y = bTop + plotHeight - this.ordinateViews[ ordinate ].scaler.getPosition(labelValues[ordinate][i]) + (fontLineHeight/4);
|
||||||
|
if (last_y == null){
|
||||||
|
d = null;
|
||||||
|
} else {
|
||||||
|
d = y -last_y;
|
||||||
|
if (d<0)
|
||||||
|
d = -d;
|
||||||
|
};
|
||||||
|
|
||||||
|
if ((d == null) || (d > fontLineHeight )) {
|
||||||
g.drawString(
|
g.drawString(
|
||||||
labels[i],
|
labels[i],
|
||||||
getWidth() - bRight - plotWidth - labelWidths[i],
|
getWidth() - bRight - plotWidth - labelWidths[i],
|
||||||
bTop + plotHeight - this.ordinateViews[ ordinate ].scaler.getPosition(labelValues[ordinate][i]) + (fontLineHeight/4)
|
y
|
||||||
);
|
);
|
||||||
|
last_y = y;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
plotWidth -= axMarkerLength;
|
plotWidth -= axMarkerLength;
|
||||||
|
@ -373,6 +399,7 @@ public class JDiagram extends JComponent {
|
||||||
bTop + plotHeight
|
bTop + plotHeight
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (nMarker > 0)
|
||||||
for (int n=0;n <= nMarker; n++){
|
for (int n=0;n <= nMarker; n++){
|
||||||
int xpos = plotWidth * n / nMarker;
|
int xpos = plotWidth * n / nMarker;
|
||||||
double pos = abszissMinimum + (abszissWindow * n / nMarker);
|
double pos = abszissMinimum + (abszissWindow * n / nMarker);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.hwo.ui;
|
||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
|
|
||||||
import org.hwo.models.TableMapper.TableMapper;
|
import org.hwo.models.TableMapper.TableMapper;
|
||||||
|
import org.hwo.models.TableMapper.TableMapperListener;
|
||||||
|
|
||||||
public class JMappedTable extends JTable {
|
public class JMappedTable extends JTable {
|
||||||
|
|
||||||
|
@ -16,4 +17,13 @@ public class JMappedTable extends JTable {
|
||||||
return tableMapper;
|
return tableMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addTableMapperListener(TableMapperListener tableMapperListener){
|
||||||
|
this.tableMapper.addTableMapperListener(tableMapperListener);
|
||||||
|
}
|
||||||
|
public void removeTableMapperListener(TableMapperListener tableMapperListener){
|
||||||
|
this.tableMapper.removeTableMapperListener(tableMapperListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,19 @@ package org.hwo.ui;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
import java.awt.GridBagLayout;
|
import java.awt.GridBagLayout;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
|
import javax.swing.SpinnerNumberModel;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
import java.awt.GridBagConstraints;
|
import java.awt.GridBagConstraints;
|
||||||
import java.awt.Insets;
|
import java.awt.Insets;
|
||||||
|
import java.awt.event.FocusEvent;
|
||||||
|
import java.awt.event.FocusListener;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
|
||||||
public class JTimeSpanEditor extends JComponent {
|
public class JTimeSpanEditor extends JComponent implements FocusListener {
|
||||||
private JSpinner spDays;
|
private JSpinner spDays;
|
||||||
private JSpinner spHours;
|
private JSpinner spHours;
|
||||||
private JSpinner spMinutes;
|
private JSpinner spMinutes;
|
||||||
|
@ -16,10 +24,12 @@ public class JTimeSpanEditor extends JComponent {
|
||||||
private JLabel lblNewLabel;
|
private JLabel lblNewLabel;
|
||||||
private JLabel label;
|
private JLabel label;
|
||||||
|
|
||||||
|
private List<FocusListener> focusListeners;
|
||||||
|
private List<Component> components;
|
||||||
|
|
||||||
public JTimeSpanEditor() {
|
public JTimeSpanEditor() {
|
||||||
|
this.focusListeners = new LinkedList<FocusListener>();
|
||||||
|
|
||||||
GridBagLayout gridBagLayout = new GridBagLayout();
|
GridBagLayout gridBagLayout = new GridBagLayout();
|
||||||
gridBagLayout.columnWidths = new int[] {0, 0, 0, 0, 0, 0, 0};
|
gridBagLayout.columnWidths = new int[] {0, 0, 0, 0, 0, 0, 0};
|
||||||
gridBagLayout.rowHeights = new int[]{0, 0};
|
gridBagLayout.rowHeights = new int[]{0, 0};
|
||||||
|
@ -28,6 +38,9 @@ public class JTimeSpanEditor extends JComponent {
|
||||||
setLayout(gridBagLayout);
|
setLayout(gridBagLayout);
|
||||||
|
|
||||||
spDays = new JSpinner();
|
spDays = new JSpinner();
|
||||||
|
spDays.addFocusListener(this);
|
||||||
|
spDays.getEditor().addFocusListener(this);
|
||||||
|
spDays.setModel(new SpinnerNumberModel(0, 0, 366, 1));
|
||||||
GridBagConstraints gbc_spDays = new GridBagConstraints();
|
GridBagConstraints gbc_spDays = new GridBagConstraints();
|
||||||
gbc_spDays.fill = GridBagConstraints.BOTH;
|
gbc_spDays.fill = GridBagConstraints.BOTH;
|
||||||
gbc_spDays.insets = new Insets(0, 0, 0, 5);
|
gbc_spDays.insets = new Insets(0, 0, 0, 5);
|
||||||
|
@ -43,6 +56,10 @@ public class JTimeSpanEditor extends JComponent {
|
||||||
add(lblD, gbc_lblD);
|
add(lblD, gbc_lblD);
|
||||||
|
|
||||||
spHours = new JSpinner();
|
spHours = new JSpinner();
|
||||||
|
spHours.addFocusListener(this);
|
||||||
|
spHours.setFocusable(true);
|
||||||
|
spHours.getEditor().addFocusListener(this);
|
||||||
|
spHours.setModel(new SpinnerNumberModel(0, 0, 23, 1));
|
||||||
GridBagConstraints gbc_spHours = new GridBagConstraints();
|
GridBagConstraints gbc_spHours = new GridBagConstraints();
|
||||||
gbc_spHours.fill = GridBagConstraints.BOTH;
|
gbc_spHours.fill = GridBagConstraints.BOTH;
|
||||||
gbc_spHours.insets = new Insets(0, 0, 0, 5);
|
gbc_spHours.insets = new Insets(0, 0, 0, 5);
|
||||||
|
@ -58,6 +75,9 @@ public class JTimeSpanEditor extends JComponent {
|
||||||
add(lblNewLabel, gbc_lblNewLabel);
|
add(lblNewLabel, gbc_lblNewLabel);
|
||||||
|
|
||||||
spMinutes = new JSpinner();
|
spMinutes = new JSpinner();
|
||||||
|
spMinutes.addFocusListener(this);
|
||||||
|
spMinutes.getEditor().addFocusListener(this);
|
||||||
|
spMinutes.setModel(new SpinnerNumberModel(0, 0, 59, 1));
|
||||||
GridBagConstraints gbc_spMinutes = new GridBagConstraints();
|
GridBagConstraints gbc_spMinutes = new GridBagConstraints();
|
||||||
gbc_spMinutes.fill = GridBagConstraints.BOTH;
|
gbc_spMinutes.fill = GridBagConstraints.BOTH;
|
||||||
gbc_spMinutes.insets = new Insets(0, 0, 0, 5);
|
gbc_spMinutes.insets = new Insets(0, 0, 0, 5);
|
||||||
|
@ -73,14 +93,49 @@ public class JTimeSpanEditor extends JComponent {
|
||||||
add(label, gbc_label);
|
add(label, gbc_label);
|
||||||
|
|
||||||
spSeconds = new JSpinner();
|
spSeconds = new JSpinner();
|
||||||
|
spSeconds.addFocusListener(this);
|
||||||
|
spSeconds.getEditor().addFocusListener(this);
|
||||||
|
spSeconds.setModel(new SpinnerNumberModel(0, 0, 59, 1));
|
||||||
GridBagConstraints gbc_spSeconds = new GridBagConstraints();
|
GridBagConstraints gbc_spSeconds = new GridBagConstraints();
|
||||||
gbc_spSeconds.fill = GridBagConstraints.BOTH;
|
gbc_spSeconds.fill = GridBagConstraints.BOTH;
|
||||||
gbc_spSeconds.gridx = 6;
|
gbc_spSeconds.gridx = 6;
|
||||||
gbc_spSeconds.gridy = 0;
|
gbc_spSeconds.gridy = 0;
|
||||||
add(spSeconds, gbc_spSeconds);
|
add(spSeconds, gbc_spSeconds);
|
||||||
|
|
||||||
|
components = UIHelper.getComponentsRecursive(this);
|
||||||
|
setupFocusListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setupFocusListeners(){
|
||||||
|
setupFocusListener(UIHelper.getComponentsRecursive(spDays));
|
||||||
|
setupFocusListener(UIHelper.getComponentsRecursive(spHours));
|
||||||
|
setupFocusListener(UIHelper.getComponentsRecursive(spMinutes));
|
||||||
|
setupFocusListener(UIHelper.getComponentsRecursive(spSeconds));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupFocusListener(List<Component> cl){
|
||||||
|
for (Component c: cl)
|
||||||
|
c.addFocusListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public synchronized void addFocusListener(FocusListener l) {
|
||||||
|
focusListeners.add(l);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public synchronized void removeFocusListener(FocusListener l) {
|
||||||
|
focusListeners.remove(l);
|
||||||
|
}
|
||||||
|
private void fireFocusLost(Component other){
|
||||||
|
FocusEvent fe = new FocusEvent(this, FocusEvent.FOCUS_LOST, false, other);
|
||||||
|
for (FocusListener l:focusListeners)
|
||||||
|
l.focusLost(fe);
|
||||||
|
}
|
||||||
|
private void fireFocusGained(Component other){
|
||||||
|
FocusEvent fe = new FocusEvent(this, FocusEvent.FOCUS_GAINED, false, other);
|
||||||
|
for (FocusListener l:focusListeners)
|
||||||
|
l.focusGained(fe);
|
||||||
|
}
|
||||||
|
|
||||||
public Integer getValue(){
|
public Integer getValue(){
|
||||||
if (!spSeconds.isEnabled())
|
if (!spSeconds.isEnabled())
|
||||||
|
@ -107,18 +162,48 @@ public class JTimeSpanEditor extends JComponent {
|
||||||
spHours.setEnabled(true);
|
spHours.setEnabled(true);
|
||||||
spDays.setEnabled(true);
|
spDays.setEnabled(true);
|
||||||
|
|
||||||
|
if (spDays.isVisible())
|
||||||
spDays.setValue(mod / 86400);
|
spDays.setValue(mod / 86400);
|
||||||
|
|
||||||
mod %= 86400;
|
mod %= 86400;
|
||||||
spHours.setValue(mod / 3600);
|
spHours.setValue(mod / 3600);
|
||||||
mod %= 3600;
|
mod %= 3600;
|
||||||
spMinutes.setValue(mod / 60);
|
spMinutes.setValue(mod / 60);
|
||||||
mod %= 60;
|
mod %= 60;
|
||||||
spSeconds.setValue(mod);
|
spSeconds.setValue(mod);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDaysEnabled(){
|
||||||
|
return spDays.isVisible();
|
||||||
|
}
|
||||||
|
public void setDaysEnabled(boolean daysEnabled){
|
||||||
|
if (!daysEnabled){
|
||||||
|
spDays.setValue(new Integer(0));
|
||||||
|
}
|
||||||
|
spDays.setVisible(daysEnabled);
|
||||||
|
spDays.setEnabled(daysEnabled);
|
||||||
|
lblD.setVisible(daysEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void focusLost(FocusEvent e) {
|
||||||
|
if (!components.contains(e.getOppositeComponent())){
|
||||||
|
System.err.println("JTimeSpanEditor: Focus Lost " + this);
|
||||||
|
System.err.println("Source: " + e.getSource());
|
||||||
|
System.err.println("Other: " + e.getOppositeComponent());
|
||||||
|
System.err.println("");
|
||||||
|
fireFocusLost(e.getOppositeComponent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void focusGained(FocusEvent e) {
|
||||||
|
if (!components.contains(e.getOppositeComponent())){
|
||||||
|
System.err.println("JTimeSpanEditor: Focus Gained " + this);
|
||||||
|
System.err.println("Source: " + e.getSource());
|
||||||
|
System.err.println("Other: " + e.getOppositeComponent());
|
||||||
|
System.err.println("");
|
||||||
|
fireFocusGained(e.getOppositeComponent());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,12 +79,17 @@ public class JUITest extends JFrame {
|
||||||
values = p.getPlot(1);
|
values = p.getPlot(1);
|
||||||
for (int i=0;i<p.getLength();i++){
|
for (int i=0;i<p.getLength();i++){
|
||||||
//values[i] = 5 + (float)Math.sin(Math.PI * i / 8) * 4;
|
//values[i] = 5 + (float)Math.sin(Math.PI * i / 8) * 4;
|
||||||
values[i] = (float)(10 + (((float)i/4)*10.0));
|
//values[i] = (float)(10 + (((float)i/4)*10.0));
|
||||||
|
//values[i] = 1.0f + (float)( ((float)i/4) * ((float)i/4));
|
||||||
|
values[i] = (float)Math.exp(i/5.0);
|
||||||
}
|
}
|
||||||
values = p.getPlot(2);
|
values = p.getPlot(2);
|
||||||
for (int i=0;i<p.getLength();i++){
|
for (int i=0;i<p.getLength();i++){
|
||||||
//values[i] = 5 + (float)Math.sin(Math.PI * i / 8) * 4;
|
//values[i] = 5 + (float)Math.sin(Math.PI * i / 8) * 4;
|
||||||
values[i] = (float)(10 + (((float)i/4)*10.0));
|
//values[i] = (float)(10 + (((float)i/4)*10.0));
|
||||||
|
//values[i] = 1.0f + (float)( ((float)i/4) * ((float)i/4));
|
||||||
|
values[i] = (float)Math.exp(i/5.0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p.setOrdinate(1, 1);
|
p.setOrdinate(1, 1);
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package org.hwo.ui;
|
||||||
|
|
||||||
|
import java.awt.Component;
|
||||||
|
import java.awt.Container;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.zip.InflaterInputStream;
|
||||||
|
|
||||||
|
public class UIHelper {
|
||||||
|
|
||||||
|
public static void getComponentsRecursive(Container comp,List<Component> list){
|
||||||
|
for (Component c:comp.getComponents()){
|
||||||
|
list.add(c);
|
||||||
|
if (Container.class.isInstance(c)){
|
||||||
|
getComponentsRecursive((Container)c, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Component> getComponentsRecursive(Container comp){
|
||||||
|
List<Component> components = new LinkedList<Component>();
|
||||||
|
getComponentsRecursive(comp, components);
|
||||||
|
return components;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -35,7 +35,7 @@ public class AnnotatedSortedMapPlotProvider<T> extends AnnotatedPlotProvider imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOrdinateLabel(JDiagram diagram, Double value) {
|
public String getOrdinateLabel(JDiagram diagram, int ordinate, Double value) {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.hwo.ui.diagram;
|
package org.hwo.ui.diagram;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
public class LogarithmicScaler implements Scaler {
|
public class LogarithmicScaler implements Scaler {
|
||||||
|
|
||||||
|
@ -127,6 +129,9 @@ public class LogarithmicScaler implements Scaler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Collections.sort(hints);
|
||||||
|
Collections.reverse(hints);
|
||||||
|
|
||||||
double[] result = new double[ hints.size() ];
|
double[] result = new double[ hints.size() ];
|
||||||
for (int i=0;i<result.length;i++)
|
for (int i=0;i<result.length;i++)
|
||||||
result[i] = hints.get(i);
|
result[i] = hints.get(i);
|
||||||
|
|
|
@ -4,7 +4,7 @@ import org.hwo.ui.JDiagram;
|
||||||
|
|
||||||
public interface PlotLabeler {
|
public interface PlotLabeler {
|
||||||
|
|
||||||
public String getOrdinateLabel(JDiagram diagram,Double value);
|
public String getOrdinateLabel(JDiagram diagram,int ordinate,Double value);
|
||||||
public String getAbzisseLabel(JDiagram diagram,Double pos);
|
public String getAbzisseLabel(JDiagram diagram,Double pos);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,12 +26,27 @@ public class SimplePlotLabeler implements PlotLabeler {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getOrdinateLabel(JDiagram diagram, Double value) {
|
public String getOrdinateLabel(JDiagram diagram,int ordinate,Double value) {
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return "";
|
return "";
|
||||||
if (value.isNaN())
|
if (value.isNaN())
|
||||||
return "";
|
return "";
|
||||||
return String.format(this.ordinateFormat,value);
|
|
||||||
|
Double window = diagram.getScaler(ordinate).getWindow();
|
||||||
|
int digits = ((Double)Math.log10(window)).intValue();
|
||||||
|
digits -= 4;
|
||||||
|
|
||||||
|
if (digits < 0){
|
||||||
|
return String.format(
|
||||||
|
String.format("%%.%df",-digits),
|
||||||
|
value
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return String.format(
|
||||||
|
String.format("%%%d.2f",-digits),
|
||||||
|
value
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue