Skip to content
Snippets Groups Projects
Commit a0d8a026 authored by Tim Molter's avatar Tim Molter
Browse files

added scientific notation

parent ccea5194
No related branches found
No related tags found
No related merge requests found
......@@ -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() {
......
......@@ -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);
}
}
}
......@@ -42,7 +42,6 @@ public class AxisTickLabels implements IChartPart {
protected AxisTickLabels(Axis axis, AxisTick axisTick) {
this.axis = axis;
this.axisTick = axisTick;
}
......
......@@ -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();
}
}
......@@ -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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment