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

bug fixes: date formatter not getting override value, missing plot padding in...

bug fixes: date formatter not getting override value, missing plot padding in plot width calculation
parent 824a708c
Branches
No related tags found
No related merge requests found
Showing
with 55 additions and 44 deletions
......@@ -44,8 +44,8 @@ import com.xeiam.xchart.demo.charts.date.DateChart06;
import com.xeiam.xchart.demo.charts.date.DateChart07;
import com.xeiam.xchart.demo.charts.line.LineChart01;
import com.xeiam.xchart.demo.charts.line.LineChart02;
import com.xeiam.xchart.demo.charts.line.LineChart09;
import com.xeiam.xchart.demo.charts.line.LineChart10;
import com.xeiam.xchart.demo.charts.line.LineChart03;
import com.xeiam.xchart.demo.charts.line.LineChart04;
import com.xeiam.xchart.demo.charts.scatter.ScatterChart01;
import com.xeiam.xchart.demo.charts.scatter.ScatterChart02;
import com.xeiam.xchart.demo.charts.scatter.ScatterChart03;
......@@ -147,10 +147,10 @@ public class XChartDemo extends JPanel implements TreeSelectionListener {
chart = new DefaultMutableTreeNode(new ChartInfo("LineChart02 - Customized Series Style", new LineChart02().getChart()));
category.add(chart);
chart = new DefaultMutableTreeNode(new ChartInfo("LineChart09 - Extensive chart customization", new LineChart09().getChart()));
chart = new DefaultMutableTreeNode(new ChartInfo("LineChart03 - Extensive Chart Customization", new LineChart03().getChart()));
category.add(chart);
chart = new DefaultMutableTreeNode(new ChartInfo("LineChart10 - Plots Hundreds of Series on One Plot", new LineChart10().getChart()));
chart = new DefaultMutableTreeNode(new ChartInfo("LineChart04 - Plots Hundreds of Series on One Plot", new LineChart04().getChart()));
category.add(chart);
// Scatter category
......
......@@ -60,7 +60,7 @@ public class LineChart01 implements ExampleChart {
// Customize Chart
chart.getStyleManager().setChartTitleVisible(false);
chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
chart.getStyleManager().setYAxisLogarithmic(true);
chart.getStyleManager().setyAxisLogarithmic(true);
// Series
Series series = chart.addSeries("10^x", xData1, yData1);
......
......@@ -33,15 +33,16 @@ import com.xeiam.xchart.style.ChartColor;
import com.xeiam.xchart.style.SeriesColor;
import com.xeiam.xchart.style.SeriesLineStyle;
import com.xeiam.xchart.style.SeriesMarker;
import com.xeiam.xchart.style.StyleManager.LegendPosition;
/**
* Extensive chart customization
* Extensive Chart Customization
*/
public class LineChart09 implements ExampleChart {
public class LineChart03 implements ExampleChart {
public static void main(String[] args) {
ExampleChart exampleChart = new LineChart09();
ExampleChart exampleChart = new LineChart03();
Chart chart = exampleChart.getChart();
new SwingWrapper(chart).displayChart();
}
......@@ -70,7 +71,7 @@ public class LineChart09 implements ExampleChart {
}
// Customize Chart
chart.setChartTitle("LineChart09");
chart.setChartTitle("LineChart03");
chart.setXAxisTitle("X");
chart.setYAxisTitle("Y");
chart.getStyleManager().setPlotBackgroundColor(ChartColor.getAWTColor(ChartColor.GREY));
......@@ -78,12 +79,18 @@ public class LineChart09 implements ExampleChart {
chart.getStyleManager().setChartBackgroundColor(Color.WHITE);
chart.getStyleManager().setLegendBackgroundColor(Color.PINK);
chart.getStyleManager().setChartFontColor(Color.MAGENTA);
chart.getStyleManager().setChartTitleBackgroundColor(new Color(0, 222, 0));
chart.getStyleManager().setPlotGridLinesVisible(false);
chart.getStyleManager().setAxisTickPadding(20);
chart.getStyleManager().setAxisTickMarkLength(15);
chart.getStyleManager().setPlotPadding(20);
chart.getStyleManager().setChartTitleFont(new Font(Font.MONOSPACED, Font.BOLD, 24));
chart.getStyleManager().setLegendFont(new Font(Font.SERIF, Font.PLAIN, 18));
chart.getStyleManager().setLegendPosition(LegendPosition.InsideSE);
chart.getStyleManager().setAxisTitleFont(new Font(Font.SANS_SERIF, Font.ITALIC, 18));
chart.getStyleManager().setAxisTickLabelsFont(new Font(Font.SERIF, Font.PLAIN, 11));
chart.getStyleManager().setDatePattern("dd-MMM");
chart.getStyleManager().setNormalDecimalPattern("#.000");
chart.getStyleManager().setNormalDecimalPattern("#0.000");
chart.getStyleManager().setLocale(Locale.GERMAN);
Series series = chart.addDateSeries("Fake Data", xData, yData);
......
......@@ -26,11 +26,11 @@ import com.xeiam.xchart.style.SeriesMarker;
/**
* Plots Hundreds of Series on One Plot
*/
public class LineChart10 implements ExampleChart {
public class LineChart04 implements ExampleChart {
public static void main(String[] args) {
ExampleChart exampleChart = new LineChart10();
ExampleChart exampleChart = new LineChart04();
Chart chart = exampleChart.getChart();
new SwingWrapper(chart).displayChart();
}
......@@ -42,7 +42,7 @@ public class LineChart10 implements ExampleChart {
Chart chart = new Chart(800, 600);
// Customize Chart
chart.setChartTitle("LineChart10");
chart.setChartTitle("LineChart04");
chart.setXAxisTitle("X");
chart.setYAxisTitle("Y");
chart.getStyleManager().setLegendVisible(false);
......
......@@ -62,7 +62,7 @@ public class ScatterChart02 implements ExampleChart {
Chart chart = new Chart(800, 600);
chart.setChartTitle("Logarithmic Data");
chart.getStyleManager().setChartType(ChartType.Scatter);
chart.getStyleManager().setXAxisLogarithmic(true);
chart.getStyleManager().setxAxisLogarithmic(true);
// Customize Chart
chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
......
......@@ -203,7 +203,7 @@ public class Axis implements ChartPart {
}
int width = (int) (getChart().getWidth() - axisPair.getyAxis().getBounds().getWidth() - chartLegendWidth - (getChart().getStyleManager().isLegendVisible() ? 3 : 2)
* getChart().getStyleManager().getChartPadding());
* getChart().getStyleManager().getChartPadding() - getChart().getStyleManager().getPlotPadding());
int height = this.getSizeHint();
Rectangle xAxisRectangle = new Rectangle(xOffset, yOffset, width, height);
this.paintZone = xAxisRectangle;
......
......@@ -88,11 +88,11 @@ public class AxisTick implements ChartPart {
gridStep = new BarChartAxisTickCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChart());
} else if (axis.getDirection() == Axis.Direction.X && getChart().getStyleManager().isXAxisLogarithmic() && axis.getAxisType() != AxisType.Date) {
} else if (axis.getDirection() == Axis.Direction.X && getChart().getStyleManager().isxAxisLogarithmic() && axis.getAxisType() != AxisType.Date) {
gridStep = new LogarithmicAxisTickCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChart().getStyleManager());
} else if (axis.getDirection() == Axis.Direction.Y && getChart().getStyleManager().isYAxisLogarithmic() && axis.getAxisType() != AxisType.Date) {
} else if (axis.getDirection() == Axis.Direction.Y && getChart().getStyleManager().isyAxisLogarithmic() && axis.getAxisType() != AxisType.Date) {
gridStep = new LogarithmicAxisTickCalculator(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChart().getStyleManager());
......
......@@ -64,14 +64,14 @@ public class PlotContentLineChart extends PlotContent {
Collection<?> xData = series.getxData();
BigDecimal xMin = getChart().getAxisPair().getxAxis().getMin();
BigDecimal xMax = getChart().getAxisPair().getxAxis().getMax();
if (getChart().getStyleManager().isXAxisLogarithmic()) {
if (getChart().getStyleManager().isxAxisLogarithmic()) {
xMin = new BigDecimal(Math.log10(xMin.doubleValue()));
xMax = new BigDecimal(Math.log10(xMax.doubleValue()));
}
Collection<Number> yData = series.getyData();
BigDecimal yMin = getChart().getAxisPair().getyAxis().getMin();
BigDecimal yMax = getChart().getAxisPair().getyAxis().getMax();
if (getChart().getStyleManager().isYAxisLogarithmic()) {
if (getChart().getStyleManager().isyAxisLogarithmic()) {
yMin = new BigDecimal(Math.log10(yMin.doubleValue()));
yMax = new BigDecimal(Math.log10(yMax.doubleValue()));
}
......@@ -97,13 +97,13 @@ public class PlotContentLineChart extends PlotContent {
// System.out.println(x);
}
if (getChart().getStyleManager().isXAxisLogarithmic()) {
if (getChart().getStyleManager().isxAxisLogarithmic()) {
x = new BigDecimal(Math.log10(x.doubleValue()));
}
BigDecimal y = new BigDecimal(yItr.next().doubleValue());
if (getChart().getStyleManager().isYAxisLogarithmic()) {
if (getChart().getStyleManager().isyAxisLogarithmic()) {
y = new BigDecimal(Math.log10(y.doubleValue()));
}
......
......@@ -90,21 +90,25 @@ public class DateFormatter {
String datePattern;
// intelligently set date pattern if none is given
if (timeUnit == MILLIS_SCALE) {
datePattern = "ss.SSS";
} else if (timeUnit == SEC_SCALE) {
datePattern = "mm:ss";
} else if (timeUnit == MIN_SCALE) {
datePattern = "HH:mm";
} else if (timeUnit == HOUR_SCALE) {
datePattern = "dd-HH";
} else if (timeUnit == DAY_SCALE) {
datePattern = "MM-dd";
} else if (timeUnit == MONTH_SCALE) {
datePattern = "yyyy-MM";
if (styleManager.getDatePattern() == null) {
// intelligently set date pattern if none is given
if (timeUnit == MILLIS_SCALE) {
datePattern = "ss.SSS";
} else if (timeUnit == SEC_SCALE) {
datePattern = "mm:ss";
} else if (timeUnit == MIN_SCALE) {
datePattern = "HH:mm";
} else if (timeUnit == HOUR_SCALE) {
datePattern = "dd-HH";
} else if (timeUnit == DAY_SCALE) {
datePattern = "MM-dd";
} else if (timeUnit == MONTH_SCALE) {
datePattern = "yyyy-MM";
} else {
datePattern = "yyyy";
}
} else {
datePattern = "yyyy";
datePattern = styleManager.getDatePattern();
}
SimpleDateFormat simpleDateformat = new SimpleDateFormat(datePattern, styleManager.getLocale());
......
......@@ -166,7 +166,7 @@ public class StyleManager {
errorBarsColor = theme.getErrorBarsColor();
// Formatting ////////////////////////////////
datePattern = "HHmmss";
datePattern = null; // if not null, this override pattern will be used
locale = Locale.getDefault();
timezone = TimeZone.getDefault();
normalDecimalPattern = "#.####";
......@@ -656,14 +656,14 @@ public class StyleManager {
/**
* sets the X-Axis to be rendered with a logarithmic scale or not
*
* @param isXAxisLogarithmic
* @param isxAxisLogarithmic
*/
public void setXAxisLogarithmic(boolean isXAxisLogarithmic) {
public void setxAxisLogarithmic(boolean isxAxisLogarithmic) {
this.isXAxisLogarithmic = isXAxisLogarithmic;
this.isXAxisLogarithmic = isxAxisLogarithmic;
}
public boolean isXAxisLogarithmic() {
public boolean isxAxisLogarithmic() {
return isXAxisLogarithmic;
}
......@@ -671,14 +671,14 @@ public class StyleManager {
/**
* sets the Y-Axis to be rendered with a logarithmic scale or not
*
* @param isYAxisLogarithmic
* @param isyAxisLogarithmic
*/
public void setYAxisLogarithmic(boolean isYAxisLogarithmic) {
public void setyAxisLogarithmic(boolean isyAxisLogarithmic) {
this.isYAxisLogarithmic = isYAxisLogarithmic;
this.isYAxisLogarithmic = isyAxisLogarithmic;
}
public boolean isYAxisLogarithmic() {
public boolean isyAxisLogarithmic() {
return isYAxisLogarithmic;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment