Skip to content
Snippets Groups Projects
Commit c4a98077 authored by Michael Stummvoll's avatar Michael Stummvoll
Browse files

Obtain the StyleManager from the ChartPainter.

parent b51e94a5
No related branches found
No related tags found
No related merge requests found
......@@ -54,7 +54,7 @@ public class ChartPainter {
chartLegend = new Legend(this);
axisPair = new AxisPair(this);
plot = new Plot(this, styleManager);
plot = new Plot(this);
chartTitle = new ChartTitle(this);
}
......
......@@ -18,7 +18,6 @@ package com.xeiam.xchart.internal.chartpart;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import com.xeiam.xchart.StyleManager;
import com.xeiam.xchart.StyleManager.ChartType;
/**
......@@ -36,18 +35,15 @@ public class Plot implements ChartPart {
private PlotContent plotContent;
private StyleManager styleManager;
/**
* Constructor
*
* @param chartPainter
*/
public Plot(ChartPainter chartPainter, StyleManager styleManager) {
public Plot(ChartPainter chartPainter) {
this.chartPainter = chartPainter;
this.plotSurface = new PlotSurface(this);
this.styleManager = styleManager;
}
......@@ -80,10 +76,10 @@ public class Plot implements ChartPart {
plotSurface.paint(g);
if (getChartPainter().getStyleManager().getChartType() == ChartType.Bar) {
this.plotContent = new PlotContentBarChart(this, styleManager);
this.plotContent = new PlotContentBarChart(this);
}
else {
this.plotContent = new PlotContentLineChart(this, styleManager);
this.plotContent = new PlotContentLineChart(this);
}
plotContent.paint(g);
......
......@@ -32,24 +32,22 @@ import com.xeiam.xchart.internal.Utils;
*/
public class PlotContentBarChart extends PlotContent {
private StyleManager styleManager;
/**
* Constructor
*
* @param plot
*/
protected PlotContentBarChart(Plot plot, StyleManager styleManager) {
protected PlotContentBarChart(Plot plot) {
super(plot);
this.styleManager = styleManager;
}
@Override
public void paint(Graphics2D g) {
Rectangle2D bounds = plot.getBounds();
StyleManager styleManager = plot.getChartPainter().getStyleManager();
// X-Axis
int xTickSpace = (int)(styleManager.getAxisTickSpaceRatio() * bounds.getWidth());
int xLeftMargin = Utils.getTickStartOffset((int) bounds.getWidth(), xTickSpace);
......
......@@ -35,22 +35,21 @@ import com.xeiam.xchart.internal.chartpart.Axis.AxisType;
*/
public class PlotContentLineChart extends PlotContent {
private StyleManager styleManager;
/**
* Constructor
*
* @param plot
*/
protected PlotContentLineChart(Plot plot, StyleManager styleManager) {
protected PlotContentLineChart(Plot plot) {
super(plot);
this.styleManager = styleManager;
}
@Override
public void paint(Graphics2D g) {
Rectangle2D bounds = plot.getBounds();
StyleManager styleManager = plot.getChartPainter().getStyleManager();
// X-Axis
int xTickSpace = (int)(styleManager.getAxisTickSpaceRatio() * bounds.getWidth());
......
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