From 2cb15d51f042d189f8b84b4c4ae67b2d533acf49 Mon Sep 17 00:00:00 2001
From: timmolter <tim.molter@gmail.com>
Date: Tue, 11 Sep 2012 22:50:25 +0200
Subject: [PATCH] colors of everything can be set now

---
 src/main/java/com/xeiam/xchart/Axis.java      | 14 +++----
 src/main/java/com/xeiam/xchart/AxisPair.java  |  6 +--
 src/main/java/com/xeiam/xchart/AxisTick.java  |  6 +--
 .../java/com/xeiam/xchart/AxisTickLabels.java | 28 +++++--------
 .../java/com/xeiam/xchart/AxisTickMarks.java  | 32 ++++++---------
 src/main/java/com/xeiam/xchart/AxisTitle.java |  6 +--
 src/main/java/com/xeiam/xchart/Chart.java     | 39 ++++++++++++++++++-
 .../java/com/xeiam/xchart/ChartColor.java     | 10 ++---
 .../java/com/xeiam/xchart/ChartLegend.java    | 31 ++++++++-------
 .../java/com/xeiam/xchart/ChartTitle.java     |  6 +--
 src/main/java/com/xeiam/xchart/Plot.java      |  2 +-
 .../java/com/xeiam/xchart/PlotContent.java    |  2 +-
 .../java/com/xeiam/xchart/PlotSurface.java    | 34 ++++++++++++----
 .../com/xeiam/xchart/example/Example9.java    | 22 +++++++++--
 14 files changed, 142 insertions(+), 96 deletions(-)

diff --git a/src/main/java/com/xeiam/xchart/Axis.java b/src/main/java/com/xeiam/xchart/Axis.java
index dc704cd3..765091ed 100644
--- a/src/main/java/com/xeiam/xchart/Axis.java
+++ b/src/main/java/com/xeiam/xchart/Axis.java
@@ -35,15 +35,12 @@ public class Axis implements IChartPart {
     NUMBER, DATE;
   }
 
-  /** the chart */
-  private Chart chart;
+  /** the axisPair */
+  protected AxisPair axisPair;
 
   /** the seriesType */
   private AxisType axisType;
 
-  /** the axisPair */
-  private AxisPair axisPair;
-
   /** the axis title */
   private AxisTitle axisTitle;
 
@@ -79,9 +76,8 @@ public class Axis implements IChartPart {
    * @param direction the axis direction (X or Y)
    * @param chart the chart
    */
-  public Axis(Chart chart, AxisPair axisPair, Direction direction) {
+  public Axis(AxisPair axisPair, Direction direction) {
 
-    this.chart = chart;
     this.axisPair = axisPair;
     this.direction = direction;
 
@@ -214,7 +210,7 @@ public class Axis implements IChartPart {
       int xOffset = Chart.CHART_PADDING;
       int yOffset = (int) (axisPair.getChartTitleBounds().getY() + axisPair.getChartTitleBounds().getHeight() + Chart.CHART_PADDING);
       int width = 80; // arbitrary, final width depends on Axis tick labels
-      int height = chart.getHeight() - yOffset - axisPair.getXAxis().getSizeHint() - Chart.CHART_PADDING;
+      int height = axisPair.chart.getHeight() - yOffset - axisPair.getXAxis().getSizeHint() - Chart.CHART_PADDING;
       Rectangle yAxisRectangle = new Rectangle(xOffset, yOffset, width, height);
       this.paintZone = yAxisRectangle;
       // g.setColor(Color.green);
@@ -239,7 +235,7 @@ public class Axis implements IChartPart {
 
       int xOffset = (int) (axisPair.getYAxis().getBounds().getWidth() + (axisPair.getYAxis().getAxisTick().isVisible ? Plot.PLOT_PADDING : 0) + Chart.CHART_PADDING);
       int yOffset = (int) (axisPair.getYAxis().getBounds().getY() + axisPair.getYAxis().getBounds().getHeight());
-      int width = (int) (chart.getWidth() - axisPair.getYAxis().getBounds().getWidth() - axisPair.getChartLegendBounds().getWidth() - (chart.getLegend().isVisible ? 3 : 2) * Chart.CHART_PADDING);
+      int width = (int) (axisPair.chart.getWidth() - axisPair.getYAxis().getBounds().getWidth() - axisPair.getChartLegendBounds().getWidth() - (axisPair.chart.getLegend().isVisible ? 3 : 2) * Chart.CHART_PADDING);
       int height = this.getSizeHint();
       Rectangle xAxisRectangle = new Rectangle(xOffset, yOffset, width, height);
       this.paintZone = xAxisRectangle;
diff --git a/src/main/java/com/xeiam/xchart/AxisPair.java b/src/main/java/com/xeiam/xchart/AxisPair.java
index 7a6896ff..8a541ab5 100644
--- a/src/main/java/com/xeiam/xchart/AxisPair.java
+++ b/src/main/java/com/xeiam/xchart/AxisPair.java
@@ -34,7 +34,7 @@ import com.xeiam.xchart.series.Series;
 public class AxisPair implements IChartPart {
 
   /** the chart */
-  private Chart chart;
+  protected Chart chart;
 
   private Map<Integer, Series> seriesMap = new LinkedHashMap<Integer, Series>();
 
@@ -53,8 +53,8 @@ public class AxisPair implements IChartPart {
     this.chart = chart;
 
     // add axes
-    xAxis = new Axis(chart, this, Axis.Direction.X);
-    yAxis = new Axis(chart, this, Axis.Direction.Y);
+    xAxis = new Axis(this, Axis.Direction.X);
+    yAxis = new Axis(this, Axis.Direction.Y);
   }
 
   /**
diff --git a/src/main/java/com/xeiam/xchart/AxisTick.java b/src/main/java/com/xeiam/xchart/AxisTick.java
index 03bb98a1..9e59d887 100644
--- a/src/main/java/com/xeiam/xchart/AxisTick.java
+++ b/src/main/java/com/xeiam/xchart/AxisTick.java
@@ -34,7 +34,7 @@ import com.xeiam.xchart.interfaces.IHideable;
 public class AxisTick implements IChartPart, IHideable {
 
   /** the axis */
-  private Axis axis;
+  protected Axis axis;
 
   /** the axisticklabels */
   private AxisTickLabels axisTickLabels;
@@ -80,8 +80,8 @@ public class AxisTick implements IChartPart, IHideable {
   protected AxisTick(Axis axis) {
 
     this.axis = axis;
-    axisTickLabels = new AxisTickLabels(axis, this);
-    axisTickMarks = new AxisTickMarks(axis, this);
+    axisTickLabels = new AxisTickLabels(this);
+    axisTickMarks = new AxisTickMarks(this);
 
   }
 
diff --git a/src/main/java/com/xeiam/xchart/AxisTickLabels.java b/src/main/java/com/xeiam/xchart/AxisTickLabels.java
index 8ddbbd32..3940025d 100644
--- a/src/main/java/com/xeiam/xchart/AxisTickLabels.java
+++ b/src/main/java/com/xeiam/xchart/AxisTickLabels.java
@@ -15,7 +15,6 @@
  */
 package com.xeiam.xchart;
 
-import java.awt.Color;
 import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
@@ -29,17 +28,11 @@ import com.xeiam.xchart.interfaces.IChartPart;
  */
 public class AxisTickLabels implements IChartPart {
 
-  /** the axis */
-  private Axis axis;
-
   private AxisTick axisTick;
 
   /** the font */
   private Font font = new Font(Font.SANS_SERIF, Font.BOLD, 12); // default font
 
-  /** the foreground color */
-  private Color foreground = ChartColor.getAWTColor(ChartColor.DARK_GREY);// default foreground color
-
   /** the bounds */
   private Rectangle bounds;
 
@@ -48,9 +41,8 @@ public class AxisTickLabels implements IChartPart {
    * 
    * @param axis the axis
    */
-  protected AxisTickLabels(Axis axis, AxisTick axisTick) {
+  protected AxisTickLabels(AxisTick axisTick) {
 
-    this.axis = axis;
     this.axisTick = axisTick;
   }
 
@@ -70,12 +62,12 @@ public class AxisTickLabels implements IChartPart {
 
     bounds = new Rectangle();
 
-    g.setColor(foreground);
+    g.setColor(axisTick.axis.axisPair.chart.fontColor);
 
-    if (axis.getDirection() == Axis.Direction.Y) { // Y-Axis
+    if (axisTick.axis.getDirection() == Axis.Direction.Y) { // Y-Axis
 
-      int xOffset = (int) (axis.getAxisTitle().getBounds().getX() + axis.getAxisTitle().getBounds().getWidth());
-      int yOffset = (int) (axis.getPaintZone().getY());
+      int xOffset = (int) (axisTick.axis.getAxisTitle().getBounds().getX() + axisTick.axis.getAxisTitle().getBounds().getWidth());
+      int yOffset = (int) (axisTick.axis.getPaintZone().getY());
       int maxTickLabelWidth = 0;
       for (int i = 0; i < axisTick.getTickLabels().size(); i++) {
 
@@ -86,7 +78,7 @@ public class AxisTickLabels implements IChartPart {
         // TextLayout layout = new TextLayout(tickLabel, font, new FontRenderContext(null, true, false));
         TextLayout layout = new TextLayout(tickLabel, font, frc);
         Rectangle tickLabelBounds = layout.getPixelBounds(null, 0, 0);
-        layout.draw(g, xOffset, (int) (yOffset + axis.getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0));
+        layout.draw(g, xOffset, (int) (yOffset + axisTick.axis.getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0));
 
         if (tickLabelBounds.getWidth() > maxTickLabelWidth) {
           maxTickLabelWidth = (int) tickLabelBounds.getWidth();
@@ -94,14 +86,14 @@ public class AxisTickLabels implements IChartPart {
       }
 
       // bounds
-      bounds = new Rectangle(xOffset, yOffset, maxTickLabelWidth, (int) axis.getPaintZone().getHeight());
+      bounds = new Rectangle(xOffset, yOffset, maxTickLabelWidth, (int) axisTick.axis.getPaintZone().getHeight());
       // g.setColor(Color.blue);
       // g.draw(bounds);
 
     } else { // X-Axis
 
-      int xOffset = (int) (axis.getPaintZone().getX());
-      int yOffset = (int) (axis.getAxisTitle().getBounds().getY());
+      int xOffset = (int) (axisTick.axis.getPaintZone().getX());
+      int yOffset = (int) (axisTick.axis.getAxisTitle().getBounds().getY());
       int maxTickLabelHeight = 0;
       for (int i = 0; i < axisTick.getTickLabels().size(); i++) {
 
@@ -119,7 +111,7 @@ public class AxisTickLabels implements IChartPart {
       }
 
       // bounds
-      bounds = new Rectangle(xOffset, yOffset - maxTickLabelHeight, (int) axis.getPaintZone().getWidth(), maxTickLabelHeight);
+      bounds = new Rectangle(xOffset, yOffset - maxTickLabelHeight, (int) axisTick.axis.getPaintZone().getWidth(), maxTickLabelHeight);
       // g.setColor(Color.blue);
       // g.draw(bounds);
 
diff --git a/src/main/java/com/xeiam/xchart/AxisTickMarks.java b/src/main/java/com/xeiam/xchart/AxisTickMarks.java
index c8a8eeab..dba274d6 100644
--- a/src/main/java/com/xeiam/xchart/AxisTickMarks.java
+++ b/src/main/java/com/xeiam/xchart/AxisTickMarks.java
@@ -16,7 +16,6 @@
 package com.xeiam.xchart;
 
 import java.awt.BasicStroke;
-import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
 import java.awt.Stroke;
@@ -28,14 +27,8 @@ import com.xeiam.xchart.interfaces.IChartPart;
  */
 public class AxisTickMarks implements IChartPart {
 
-  /** the axis */
-  private Axis axis;
-
   private AxisTick axisTick;
 
-  /** the foreground color */
-  private Color foreground = ChartColor.getAWTColor(ChartColor.DARK_GREY);// default foreground color
-
   /** the line style */
   private Stroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
 
@@ -51,9 +44,8 @@ public class AxisTickMarks implements IChartPart {
    * @param axis
    * @param axisTick
    */
-  public AxisTickMarks(Axis axis, AxisTick axisTick) {
+  public AxisTickMarks(AxisTick axisTick) {
 
-    this.axis = axis;
     this.axisTick = axisTick;
   }
 
@@ -68,35 +60,35 @@ public class AxisTickMarks implements IChartPart {
 
     bounds = new Rectangle();
 
-    g.setColor(foreground);
+    g.setColor(axisTick.axis.axisPair.chart.bordersColor);
 
-    if (axis.getDirection() == Axis.Direction.Y) { // Y-Axis
+    if (axisTick.axis.getDirection() == Axis.Direction.Y) { // Y-Axis
 
       int xOffset = (int) (axisTick.getAxisTickLabels().getBounds().getX() + axisTick.getAxisTickLabels().getBounds().getWidth() + AxisTick.AXIS_TICK_PADDING);
-      int yOffset = (int) (axis.getPaintZone().getY());
+      int yOffset = (int) (axisTick.axis.getPaintZone().getY());
 
       // tick marks
       for (int i = 0; i < axisTick.getTickLabels().size(); i++) {
 
         int tickLocation = axisTick.getTickLocations().get(i);
 
-        g.setColor(foreground);
+        g.setColor(axisTick.axis.axisPair.chart.bordersColor);
         g.setStroke(stroke);
 
-        g.drawLine(xOffset, yOffset + (int) (axis.getPaintZone().getHeight() - tickLocation), xOffset + TICK_LENGTH, yOffset + (int) (axis.getPaintZone().getHeight() - tickLocation));
+        g.drawLine(xOffset, yOffset + (int) (axisTick.axis.getPaintZone().getHeight() - tickLocation), xOffset + TICK_LENGTH, yOffset + (int) (axisTick.axis.getPaintZone().getHeight() - tickLocation));
 
       }
       // Line
-      g.drawLine(xOffset + TICK_LENGTH, yOffset, xOffset + TICK_LENGTH, yOffset + (int) axis.getPaintZone().getHeight());
+      g.drawLine(xOffset + TICK_LENGTH, yOffset, xOffset + TICK_LENGTH, yOffset + (int) axisTick.axis.getPaintZone().getHeight());
 
       // bounds
-      bounds = new Rectangle(xOffset, yOffset, TICK_LENGTH, (int) axis.getPaintZone().getHeight());
+      bounds = new Rectangle(xOffset, yOffset, TICK_LENGTH, (int) axisTick.axis.getPaintZone().getHeight());
       // g.setColor(Color.yellow);
       // g.draw(bounds);
 
     } else { // X-Axis
 
-      int xOffset = (int) (axis.getPaintZone().getX());
+      int xOffset = (int) (axisTick.axis.getPaintZone().getX());
       int yOffset = (int) (axisTick.getAxisTickLabels().getBounds().getY() - AxisTick.AXIS_TICK_PADDING);
 
       // tick marks
@@ -104,16 +96,16 @@ public class AxisTickMarks implements IChartPart {
 
         int tickLocation = axisTick.getTickLocations().get(i);
 
-        g.setColor(foreground);
+        g.setColor(axisTick.axis.axisPair.chart.bordersColor);
         g.setStroke(stroke);
 
         g.drawLine(xOffset + tickLocation, yOffset, xOffset + tickLocation, yOffset - TICK_LENGTH);
       }
       // Line
-      g.drawLine(xOffset, yOffset - TICK_LENGTH, xOffset + (int) axis.getPaintZone().getWidth(), yOffset - TICK_LENGTH);
+      g.drawLine(xOffset, yOffset - TICK_LENGTH, xOffset + (int) axisTick.axis.getPaintZone().getWidth(), yOffset - TICK_LENGTH);
 
       // bounds
-      bounds = new Rectangle(xOffset, yOffset - TICK_LENGTH, (int) axis.getPaintZone().getWidth(), TICK_LENGTH);
+      bounds = new Rectangle(xOffset, yOffset - TICK_LENGTH, (int) axisTick.axis.getPaintZone().getWidth(), TICK_LENGTH);
       // g.setColor(Color.yellow);
       // g.draw(bounds);
     }
diff --git a/src/main/java/com/xeiam/xchart/AxisTitle.java b/src/main/java/com/xeiam/xchart/AxisTitle.java
index fc321637..dd96d2d4 100644
--- a/src/main/java/com/xeiam/xchart/AxisTitle.java
+++ b/src/main/java/com/xeiam/xchart/AxisTitle.java
@@ -15,7 +15,6 @@
  */
 package com.xeiam.xchart;
 
-import java.awt.Color;
 import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
@@ -42,9 +41,6 @@ public class AxisTitle implements IHideable {
   /** the font */
   private Font font = new Font(Font.SANS_SERIF, Font.BOLD, 12); // default font
 
-  /** the foreground color */
-  private Color foreground = ChartColor.getAWTColor(ChartColor.DARK_GREY); // default foreground color
-
   /** the bounds */
   private Rectangle bounds;
 
@@ -97,7 +93,7 @@ public class AxisTitle implements IHideable {
 
     bounds = new Rectangle();
 
-    g.setColor(foreground);
+    g.setColor(axis.axisPair.chart.fontColor);
 
     if (axis.getDirection() == Axis.Direction.Y) {
       if (isVisible) {
diff --git a/src/main/java/com/xeiam/xchart/Chart.java b/src/main/java/com/xeiam/xchart/Chart.java
index 519a6cea..1610097c 100644
--- a/src/main/java/com/xeiam/xchart/Chart.java
+++ b/src/main/java/com/xeiam/xchart/Chart.java
@@ -15,6 +15,7 @@
  */
 package com.xeiam.xchart;
 
+import java.awt.Color;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.util.ArrayList;
@@ -33,6 +34,9 @@ public class Chart {
 
   private int width;
   private int height;
+  private Color backgroundColor;
+  protected Color bordersColor;
+  protected Color fontColor;
 
   protected final static int CHART_PADDING = 10;
 
@@ -51,6 +55,9 @@ public class Chart {
 
     this.width = width;
     this.height = height;
+    backgroundColor = ChartColor.getAWTColor(ChartColor.GREY);
+    bordersColor = ChartColor.getAWTColor(ChartColor.DARK_GREY);
+    fontColor = ChartColor.getAWTColor(ChartColor.BLACK);
   }
 
   /**
@@ -75,7 +82,7 @@ public class Chart {
     }
 
     g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // global rendering hint
-    g.setColor(ChartColor.getAWTColor(ChartColor.GREY));
+    g.setColor(backgroundColor);
     g.fillRect(0, 0, width, height);
 
     chartTitle.paint(g);
@@ -268,4 +275,34 @@ public class Chart {
 
     this.plot.getPlotSurface().setVisible(isVisible);
   }
+
+  public void setChartBackgroundColor(Color color) {
+
+    this.backgroundColor = color;
+  }
+
+  public void setChartForegroundColor(Color color) {
+
+    this.plot.getPlotSurface().setForegroundColor(color);
+  }
+
+  public void setChartGridLinesColor(Color color) {
+
+    this.plot.getPlotSurface().setGridLinesColor(color);
+  }
+
+  public void setChartLegendBackgroundColor(Color color) {
+
+    this.chartLegend.setBackgroundColor(color);
+  }
+
+  public void setChartBordersColor(Color color) {
+
+    this.bordersColor = color;
+  }
+
+  public void setChartFontColor(Color color) {
+
+    this.fontColor = color;
+  }
 }
diff --git a/src/main/java/com/xeiam/xchart/ChartColor.java b/src/main/java/com/xeiam/xchart/ChartColor.java
index 5bfd7b8e..b8c1f419 100644
--- a/src/main/java/com/xeiam/xchart/ChartColor.java
+++ b/src/main/java/com/xeiam/xchart/ChartColor.java
@@ -25,9 +25,6 @@ public enum ChartColor {
   /** BLACK */
   BLACK(new Color(0, 0, 0)),
 
-  /** WHITE */
-  WHITE(new Color(255, 255, 255)),
-
   /** DARK_GREY */
   DARK_GREY(new Color(22, 22, 22)),
 
@@ -35,7 +32,10 @@ public enum ChartColor {
   GREY(new Color(200, 200, 200)),
 
   /** LIGHT_GREY */
-  LIGHT_GREY(new Color(252, 252, 252));
+  LIGHT_GREY(new Color(252, 252, 252)),
+
+  /** WHITE */
+  WHITE(new Color(255, 255, 255));
 
   Color color;
 
@@ -45,7 +45,7 @@ public enum ChartColor {
    * @param chartColor
    * @return
    */
-  protected static Color getAWTColor(ChartColor chartColor) {
+  public static Color getAWTColor(ChartColor chartColor) {
 
     return chartColor.color;
   }
diff --git a/src/main/java/com/xeiam/xchart/ChartLegend.java b/src/main/java/com/xeiam/xchart/ChartLegend.java
index ee6da956..ce807a74 100644
--- a/src/main/java/com/xeiam/xchart/ChartLegend.java
+++ b/src/main/java/com/xeiam/xchart/ChartLegend.java
@@ -32,6 +32,8 @@ import com.xeiam.xchart.series.markers.Marker;
  */
 public class ChartLegend implements IHideable {
 
+  private final int LEGEND_PADDING = 10;
+
   /** the chart */
   private Chart chart;
 
@@ -41,16 +43,8 @@ public class ChartLegend implements IHideable {
   /** the font */
   private Font font = new Font(Font.SANS_SERIF, Font.PLAIN, 11); // default font
 
-  /** the border color */
-  private Color border = ChartColor.getAWTColor(ChartColor.DARK_GREY); // default border color
-
   /** the background color */
-  private Color background = ChartColor.getAWTColor(ChartColor.LIGHT_GREY); // default background color
-
-  /** the foreground color */
-  private Color foreground = ChartColor.getAWTColor(ChartColor.BLACK); // default foreground color
-
-  private final int LEGEND_PADDING = 10;
+  private Color backgroundColor;
 
   /** the bounds */
   private Rectangle bounds;
@@ -58,9 +52,10 @@ public class ChartLegend implements IHideable {
   /**
    * Constructor
    */
-  public ChartLegend(Chart pChart) {
+  public ChartLegend(Chart chart) {
 
-    this.chart = pChart;
+    this.chart = chart;
+    backgroundColor = ChartColor.getAWTColor(ChartColor.LIGHT_GREY); // default background color
   }
 
   @Override
@@ -109,9 +104,9 @@ public class ChartLegend implements IHideable {
       int xOffset = chart.getWidth() - legendBoxWidth - Chart.CHART_PADDING;
       int yOffset = (int) ((chart.getHeight() - legendBoxHeight) / 2.0 + chart.getTitle().getBounds().getY() + chart.getTitle().getBounds().getHeight());
 
-      g.setColor(border);
+      g.setColor(chart.bordersColor);
       g.drawRect(xOffset, yOffset, legendBoxWidth, legendBoxHeight);
-      g.setColor(background);
+      g.setColor(backgroundColor);
       g.fillRect(xOffset + 1, yOffset + 1, legendBoxWidth - 1, legendBoxHeight - 1);
 
       // Draw legend content inside legend box
@@ -132,7 +127,7 @@ public class ChartLegend implements IHideable {
         }
 
         // paint series name
-        g.setColor(foreground);
+        g.setColor(chart.fontColor);
         TextLayout layout = new TextLayout(series.getName(), font, new FontRenderContext(null, true, false));
         layout.draw(g, (float) (startx + Marker.SIZE + (Marker.SIZE * 1.5) + LEGEND_PADDING), (starty + Marker.SIZE));
         starty = starty + legendTextContentMaxHeight + LEGEND_PADDING;
@@ -152,4 +147,12 @@ public class ChartLegend implements IHideable {
     return bounds;
   }
 
+  /**
+   * @param backgroundColor the backgroundColor to set
+   */
+  public void setBackgroundColor(Color backgroundColor) {
+
+    this.backgroundColor = backgroundColor;
+  }
+
 }
diff --git a/src/main/java/com/xeiam/xchart/ChartTitle.java b/src/main/java/com/xeiam/xchart/ChartTitle.java
index 1ec98f64..758509cf 100644
--- a/src/main/java/com/xeiam/xchart/ChartTitle.java
+++ b/src/main/java/com/xeiam/xchart/ChartTitle.java
@@ -15,7 +15,6 @@
  */
 package com.xeiam.xchart;
 
-import java.awt.Color;
 import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
@@ -41,9 +40,6 @@ public class ChartTitle implements IHideable {
   /** the font */
   private Font font = new Font(Font.SANS_SERIF, Font.BOLD, 14); // default font
 
-  /** the foreground color */
-  private Color foreground = ChartColor.getAWTColor(ChartColor.DARK_GREY); // default foreground color
-
   /** the bounds */
   private Rectangle bounds;
 
@@ -88,7 +84,7 @@ public class ChartTitle implements IHideable {
       // g.setColor(Color.green);
       // g.draw(bounds);
 
-      g.setColor(foreground);
+      g.setColor(chart.fontColor);
       textLayout.draw(g, xOffset, yOffset);
     }
 
diff --git a/src/main/java/com/xeiam/xchart/Plot.java b/src/main/java/com/xeiam/xchart/Plot.java
index 37720e38..3934c4ce 100644
--- a/src/main/java/com/xeiam/xchart/Plot.java
+++ b/src/main/java/com/xeiam/xchart/Plot.java
@@ -25,7 +25,7 @@ import com.xeiam.xchart.interfaces.IChartPart;
  */
 public class Plot implements IChartPart {
 
-  private Chart chart;
+  protected Chart chart;
 
   private PlotSurface plotSurface;
 
diff --git a/src/main/java/com/xeiam/xchart/PlotContent.java b/src/main/java/com/xeiam/xchart/PlotContent.java
index 6c24e556..04d27170 100644
--- a/src/main/java/com/xeiam/xchart/PlotContent.java
+++ b/src/main/java/com/xeiam/xchart/PlotContent.java
@@ -142,7 +142,7 @@ public class PlotContent implements IChartPart {
 
         // paint errorbar
         if (errorBars != null) {
-          g.setColor(ChartColor.getAWTColor(ChartColor.DARK_GREY));
+          g.setColor(plot.chart.bordersColor);
           g.setStroke(SeriesLineStyle.getBasicStroke(SeriesLineStyle.SOLID));
           int bottom = (int) (-1 * bounds.getHeight() * eb / (yMax.subtract(yMin).doubleValue()));
           int top = (int) (bounds.getHeight() * eb / (yMax.subtract(yMin).doubleValue()));
diff --git a/src/main/java/com/xeiam/xchart/PlotSurface.java b/src/main/java/com/xeiam/xchart/PlotSurface.java
index 0b1ee3c1..c49a8a07 100644
--- a/src/main/java/com/xeiam/xchart/PlotSurface.java
+++ b/src/main/java/com/xeiam/xchart/PlotSurface.java
@@ -33,11 +33,11 @@ public class PlotSurface implements IChartPart, IHideable {
 
   private Plot plot;
 
-  /** the foreground color */
-  private Color foreground = ChartColor.getAWTColor(ChartColor.GREY); // default foreground color
+  /** the gridLines Color */
+  private Color gridLinesColor;
 
   /** the background color */
-  private Color background = ChartColor.getAWTColor(ChartColor.LIGHT_GREY); // default background color
+  private Color foregroundColor;
 
   /** the line style */
   private BasicStroke stroke = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10.0f, new float[] { 3.0f, 3.0f }, 0.0f);
@@ -55,6 +55,8 @@ public class PlotSurface implements IChartPart, IHideable {
 
     this.chart = chart;
     this.plot = plot;
+    gridLinesColor = ChartColor.getAWTColor(ChartColor.GREY); // default gridLines color
+    foregroundColor = ChartColor.getAWTColor(ChartColor.LIGHT_GREY); // default foreground Color color
   }
 
   @Override
@@ -68,12 +70,12 @@ public class PlotSurface implements IChartPart, IHideable {
 
     Rectangle bounds = plot.getBounds();
 
-    // paint background
+    // paint foreground
     Rectangle backgroundRectangle = new Rectangle((int) bounds.getX() - 1, (int) bounds.getY(), (int) (bounds.getWidth()), (int) bounds.getHeight());
-    g.setColor(background);
+    g.setColor(foregroundColor);
     g.fill(backgroundRectangle);
     Rectangle borderRectangle = new Rectangle((int) bounds.getX() - 1, (int) bounds.getY(), (int) (bounds.getWidth()), (int) bounds.getHeight());
-    g.setColor(ChartColor.getAWTColor(ChartColor.DARK_GREY));
+    g.setColor(chart.bordersColor);
     g.draw(borderRectangle);
 
     // paint grid lines
@@ -84,7 +86,7 @@ public class PlotSurface implements IChartPart, IHideable {
 
         int tickLocation = yAxisTickLocations.get(i);
 
-        g.setColor(foreground);
+        g.setColor(gridLinesColor);
         g.setStroke(stroke);
         // System.out.println("bounds.getY()= " + bounds.getY());
         g.drawLine((int) bounds.getX(), (int) (bounds.getY() + bounds.getHeight() - tickLocation), (int) (bounds.getX() + bounds.getWidth() - 2), (int) (bounds.getY() + bounds.getHeight() - tickLocation));
@@ -96,7 +98,7 @@ public class PlotSurface implements IChartPart, IHideable {
 
         int tickLocation = xAxisTickLocations.get(i);
 
-        g.setColor(foreground);
+        g.setColor(gridLinesColor);
         g.setStroke(stroke);
 
         g.drawLine((int) (bounds.getX() + tickLocation - 1), (int) (bounds.getY() + 1), (int) (bounds.getX() + tickLocation - 1), (int) (bounds.getY() + bounds.getHeight() - 1));
@@ -108,6 +110,22 @@ public class PlotSurface implements IChartPart, IHideable {
   public void setVisible(boolean isVisible) {
 
     this.isVisible = isVisible;
+  }
+
+  /**
+   * @param gridLinesColor the gridLinesColor to set
+   */
+  public void setGridLinesColor(Color gridLinesColor) {
+
+    this.gridLinesColor = gridLinesColor;
+  }
 
+  /**
+   * @param foregroundColor the foregroundColor to set
+   */
+  public void setForegroundColor(Color foregroundColor) {
+
+    this.foregroundColor = foregroundColor;
   }
+
 }
diff --git a/src/test/java/com/xeiam/xchart/example/Example9.java b/src/test/java/com/xeiam/xchart/example/Example9.java
index 03313b36..84e99152 100644
--- a/src/test/java/com/xeiam/xchart/example/Example9.java
+++ b/src/test/java/com/xeiam/xchart/example/Example9.java
@@ -15,6 +15,7 @@
  */
 package com.xeiam.xchart.example;
 
+import java.awt.Color;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -23,10 +24,15 @@ import java.util.Collection;
 import java.util.Date;
 
 import com.xeiam.xchart.Chart;
+import com.xeiam.xchart.ChartColor;
+import com.xeiam.xchart.series.Series;
+import com.xeiam.xchart.series.SeriesColor;
+import com.xeiam.xchart.series.SeriesLineStyle;
+import com.xeiam.xchart.series.SeriesMarker;
 import com.xeiam.xchart.swing.SwingWrapper;
 
 /**
- * Create a chart with a Date x-axis
+ * Create a chart with a Date x-axis and extensive chart customization
  * 
  * @author timmolter
  */
@@ -52,9 +58,19 @@ public class Example9 {
     chart.setChartTitle("Sample Chart with Date X-Axis");
     chart.setXAxisTitle("X");
     chart.setYAxisTitle("Y");
-    chart.setChartGridlinesVisible(false);
     chart.setXAxisTicksVisible(false);
-    chart.addDateSeries("Fake Data", xData, yData);
+    chart.setChartForegroundColor(ChartColor.getAWTColor(ChartColor.GREY));
+    chart.setChartGridLinesColor(new Color(255, 255, 255));
+    chart.setChartBackgroundColor(Color.WHITE);
+    chart.setChartLegendBackgroundColor(Color.PINK);
+    chart.setChartBordersColor(Color.GREEN);
+    chart.setChartFontColor(Color.MAGENTA);
+
+    Series series = chart.addDateSeries("Fake Data", xData, yData);
+    series.setLineColor(SeriesColor.BLUE);
+    series.setMarkerColor(Color.ORANGE);
+    series.setMarker(SeriesMarker.CIRCLE);
+    series.setLineStyle(SeriesLineStyle.SOLID);
 
     new SwingWrapper(chart).displayChart();
   }
-- 
GitLab