diff --git a/src/com/xeiam/swing/SwingHelper.java b/src/com/xeiam/swing/SwingHelper.java index 09076b7626e86105e06b3ac01cc473edaf11a1ad..c87def482942363e951122f64b440979c6ebb601 100644 --- a/src/com/xeiam/swing/SwingHelper.java +++ b/src/com/xeiam/swing/SwingHelper.java @@ -21,6 +21,7 @@ public class SwingHelper { } public void displayChart() { + // Schedule a job for the event-dispatching thread: // creating and showing this application's GUI. javax.swing.SwingUtilities.invokeLater(new Runnable() { diff --git a/src/com/xeiam/xcharts/AxisTick.java b/src/com/xeiam/xcharts/AxisTick.java index 6a09f1931f83f9424531d8eea30008bca175911a..6259e36031c775de6e1667a5d8b5f38535d5f95a 100644 --- a/src/com/xeiam/xcharts/AxisTick.java +++ b/src/com/xeiam/xcharts/AxisTick.java @@ -38,15 +38,16 @@ public class AxisTick implements IChartPart { private int workingSpace; - // private double[] data; - - // /** the default tick mark step hint */ + /** the default tick mark step hint */ private static final int DEFAULT_TICK_MARK_STEP_HINT = 64; protected final static int AXIS_TICK_PADDING = 4; - /** the format for tick labels */ - private Format format = new DecimalFormat("#.###########"); + /** the normal format for tick labels */ + private Format normalFormat = new DecimalFormat("#.###########"); + + /** the scientific format for tick labels */ + private Format scientificFormat = new DecimalFormat("0.###E0"); /** the bounds */ private Rectangle bounds = new Rectangle(); // default all-zero rectangle @@ -226,7 +227,11 @@ public class AxisTick implements IChartPart { private String format(double value) { - return this.format.format(value); + if (Math.abs(value) < 9999 && Math.abs(value) > .0001) { + return this.normalFormat.format(value); + } else { + return this.scientificFormat.format(value); + } } } diff --git a/src/com/xeiam/xcharts/AxisTickLabels.java b/src/com/xeiam/xcharts/AxisTickLabels.java index 9889408c1f0d6f1e60302efc4dbd6d738464fdf4..649e30fe960a3e8369ae903af77964b59e668fc4 100644 --- a/src/com/xeiam/xcharts/AxisTickLabels.java +++ b/src/com/xeiam/xcharts/AxisTickLabels.java @@ -42,7 +42,6 @@ public class AxisTickLabels implements IChartPart { protected AxisTickLabels(Axis axis, AxisTick axisTick) { this.axis = axis; - this.axisTick = axisTick; } diff --git a/src/com/xeiam/xcharts/example/SwingChart3.java b/src/com/xeiam/xcharts/example/SwingChart3.java index c78652b7f66c15cdf5f59564293168fe11484494..5abaf0b919df8a34587cc2febfad0625f0de54fd 100644 --- a/src/com/xeiam/xcharts/example/SwingChart3.java +++ b/src/com/xeiam/xcharts/example/SwingChart3.java @@ -55,13 +55,7 @@ public class SwingChart3 { public static void main(String[] args) { - // Schedule a job for the event-dispatching thread: - // creating and showing this application's GUI. - javax.swing.SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - createAndShowGUI(); - } - }); + createAndShowGUI(); + } } diff --git a/src/com/xeiam/xcharts/example/SwingChart4.java b/src/com/xeiam/xcharts/example/SwingChart4.java index a294877c29283eacaff62e00e4ee8f9b3ae69ca7..6a0e966461b13b864f05d97e44c539fe4878ab3e 100644 --- a/src/com/xeiam/xcharts/example/SwingChart4.java +++ b/src/com/xeiam/xcharts/example/SwingChart4.java @@ -54,13 +54,7 @@ public class SwingChart4 { public static void main(String[] args) { - // Schedule a job for the event-dispatching thread: - // creating and showing this application's GUI. - javax.swing.SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - createAndShowGUI(); - } - }); + createAndShowGUI(); + } }