From 6501cb859aeee8708978e3302571bf1cb148600e Mon Sep 17 00:00:00 2001
From: Tim Molter <tim.molter@gmail.com>
Date: Sun, 3 Feb 2013 23:23:45 +0100
Subject: [PATCH] chart axis ticks style refactor

---
 pom.xml                                       |   2 +-
 .../xeiam/xchart/demo/charts/Example1.java    |   2 +-
 .../xeiam/xchart/demo/charts/Example10.java   |   2 +-
 .../xeiam/xchart/demo/charts/Example2.java    |   2 +-
 .../xeiam/xchart/demo/charts/Example8.java    |   4 +-
 .../xeiam/xchart/demo/charts/Example9.java    |  11 +-
 .../src/main/java/com/xeiam/xchart/Chart.java | 101 ++--------
 .../java/com/xeiam/xchart/QuickChart.java     |   2 +-
 .../xeiam/xchart/internal/chartpart/Axis.java |  22 +-
 .../xchart/internal/chartpart/AxisTick.java   |  11 +-
 .../internal/chartpart/AxisTickLabels.java    |  11 +-
 .../xchart/internal/chartpart/AxisTitle.java  |  36 +---
 .../{ChartLegend.java => Legend.java}         |  30 +--
 .../xeiam/xchart/internal/chartpart/Plot.java |   2 +-
 .../com/xeiam/xchart/style/StyleManager.java  | 190 +++++++++++++++---
 .../com/xeiam/xchart/style/theme/Theme.java   |  22 +-
 .../xeiam/xchart/style/theme/XChartTheme.java |  44 +++-
 17 files changed, 285 insertions(+), 209 deletions(-)
 rename xchart/src/main/java/com/xeiam/xchart/internal/chartpart/{ChartLegend.java => Legend.java} (81%)

diff --git a/pom.xml b/pom.xml
index fb47c1e2..7ba8227d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
 
 	<groupId>com.xeiam.xchart</groupId>
 	<artifactId>xchart-parent</artifactId>
-	<version>1.3.2-SNAPSHOT</version>
+	<version>2.0.0-SNAPSHOT</version>
 	<packaging>pom</packaging>
 	<name>XChart Parent</name>
 	<description>Basic Charts for Java Applications</description>
diff --git a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example1.java b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example1.java
index 086baf75..ea3bf42f 100644
--- a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example1.java
+++ b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example1.java
@@ -76,7 +76,7 @@ public class Example1 implements ExampleChart {
     // Customize Chart
     chart.setTitle("Example1");
     chart.getStyleManager().setChartTitleVisible(false);
-    chart.getStyleManager().setChartLegendVisible(false);
+    chart.getStyleManager().setLegendVisible(false);
 
     // Series 1
     Series series1 = chart.addSeries("data", xData, yData);
diff --git a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example10.java b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example10.java
index cfad83f1..a12b450b 100644
--- a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example10.java
+++ b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example10.java
@@ -46,7 +46,7 @@ public class Example10 implements ExampleChart {
     chart.setTitle("Example10");
     chart.setXAxisTitle("X");
     chart.setYAxisTitle("Y");
-    chart.getStyleManager().setChartLegendVisible(false);
+    chart.getStyleManager().setLegendVisible(false);
 
     for (int i = 0; i < 200; i++) {
       Series series = chart.addSeries("", new double[] { Math.random(), Math.random() }, new double[] { Math.random(), Math.random() });
diff --git a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example2.java b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example2.java
index 4f70acfb..01474ec6 100644
--- a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example2.java
+++ b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example2.java
@@ -57,7 +57,7 @@ public class Example2 implements ExampleChart {
 
     // Customize Chart
     chart.getStyleManager().setChartTitleVisible(false);
-    chart.getStyleManager().setChartLegendVisible(false);
+    chart.getStyleManager().setLegendVisible(false);
 
     // Series 1
     Series series1 = chart.addSeries("y=sin(x)", xData1, yData1);
diff --git a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example8.java b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example8.java
index 3b00784e..ce2a4429 100644
--- a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example8.java
+++ b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example8.java
@@ -58,8 +58,8 @@ public class Example8 implements ExampleChart {
 
     // Customize Chart
     chart.getStyleManager().setChartTitleVisible(false);
-    chart.getStyleManager().setChartLegendVisible(false);
-    chart.setAxisTitlesVisible(false);
+    chart.getStyleManager().setLegendVisible(false);
+    chart.getStyleManager().setAxisTitlesVisible(false);
 
     // Series 1
     Series series1 = chart.addSeries("10^(-x)", xData1, yData1, errorBars);
diff --git a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example9.java b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example9.java
index c8f4a356..be243f17 100644
--- a/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example9.java
+++ b/xchart-demo/src/main/java/com/xeiam/xchart/demo/charts/Example9.java
@@ -77,14 +77,13 @@ public class Example9 implements ExampleChart {
     chart.setForegroundColor(ChartColor.getAWTColor(ChartColor.GREY));
     chart.setGridLinesColor(new Color(255, 255, 255));
     chart.getStyleManager().setChartBackgroundColor(Color.WHITE);
-    chart.getStyleManager().setChartLegendBackgroundColor(Color.PINK);
+    chart.getStyleManager().setLegendBackgroundColor(Color.PINK);
     chart.getStyleManager().setChartBordersColor(Color.GREEN);
     chart.getStyleManager().setChartFontColor(Color.MAGENTA);
-    chart.getStyleManager().setTitleFont(new Font(Font.MONOSPACED, Font.BOLD, 24));
-    chart.getStyleManager().setChartLegendFont(new Font(Font.SERIF, Font.PLAIN, 18));
-    chart.setAxisTitleFont(new Font(Font.SANS_SERIF, Font.ITALIC, 18));
-    chart.setTickLabelFont(new Font(Font.SANS_SERIF, Font.ITALIC, 18));
-    chart.setTickLabelFont(new Font(Font.SERIF, Font.PLAIN, 11));
+    chart.getStyleManager().setChartTitleFont(new Font(Font.MONOSPACED, Font.BOLD, 24));
+    chart.getStyleManager().setLegendFont(new Font(Font.SERIF, Font.PLAIN, 18));
+    chart.getStyleManager().setAxisTitleFont(new Font(Font.SANS_SERIF, Font.ITALIC, 18));
+    chart.getStyleManager().setAxisTicksFont(new Font(Font.SERIF, Font.PLAIN, 11));
     chart.setDateFormatter("dd-MMM");
     chart.setDecmialFormatter("#.000");
     chart.setLocale(Locale.GERMAN);
diff --git a/xchart/src/main/java/com/xeiam/xchart/Chart.java b/xchart/src/main/java/com/xeiam/xchart/Chart.java
index 8af49757..6d4b3064 100644
--- a/xchart/src/main/java/com/xeiam/xchart/Chart.java
+++ b/xchart/src/main/java/com/xeiam/xchart/Chart.java
@@ -16,7 +16,6 @@
 package com.xeiam.xchart;
 
 import java.awt.Color;
-import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
 import java.util.ArrayList;
@@ -26,8 +25,8 @@ import java.util.Locale;
 import java.util.TimeZone;
 
 import com.xeiam.xchart.internal.chartpart.AxisPair;
-import com.xeiam.xchart.internal.chartpart.ChartLegend;
 import com.xeiam.xchart.internal.chartpart.ChartTitle;
+import com.xeiam.xchart.internal.chartpart.Legend;
 import com.xeiam.xchart.internal.chartpart.Plot;
 import com.xeiam.xchart.style.Series;
 import com.xeiam.xchart.style.StyleManager;
@@ -47,7 +46,7 @@ public class Chart {
 
   // Chart Parts
   public ChartTitle chartTitle = new ChartTitle(this);
-  public ChartLegend chartLegend = new ChartLegend(this);
+  public Legend chartLegend = new Legend(this);
   public AxisPair axisPair = new AxisPair(this);
   protected Plot plot = new Plot(this);
 
@@ -75,7 +74,7 @@ public class Chart {
     setTitle(chartBuilder.title);
     setXAxisTitle(chartBuilder.xAxisTitle);
     setYAxisTitle(chartBuilder.yAxisTitle);
-    styleManager.setChartLegendVisible(chartBuilder.isLegendVisible);
+    styleManager.setLegendVisible(chartBuilder.isLegendVisible);
   }
 
   /**
@@ -232,6 +231,11 @@ public class Chart {
    */
   public void setXAxisTitle(String title) {
 
+    if (title == null || title.trim().equalsIgnoreCase("")) {
+      styleManager.setxAxisTitleVisible(false);
+    } else {
+      styleManager.setxAxisTitleVisible(true);
+    }
     this.axisPair.xAxis.axisTitle.setText(title);
   }
 
@@ -242,73 +246,16 @@ public class Chart {
    */
   public void setYAxisTitle(String title) {
 
+    if (title == null || title.trim().equalsIgnoreCase("")) {
+      styleManager.setyAxisTitleVisible(false);
+    } else {
+      styleManager.setyAxisTitleVisible(true);
+    }
     this.axisPair.yAxis.axisTitle.setText(title);
   }
 
   // ChartPart visibility ////////////////////////////////
 
-  /**
-   * Set the x- and y-axis titles visibility
-   * 
-   * @param isVisible
-   */
-  public void setAxisTitlesVisible(boolean isVisible) {
-
-    this.axisPair.xAxis.getAxisTitle().setVisible(isVisible);
-    this.axisPair.yAxis.getAxisTitle().setVisible(isVisible);
-  }
-
-  /**
-   * Set the x-axis title visibility
-   * 
-   * @param isVisible
-   */
-  public void setXAxisTitleVisible(boolean isVisible) {
-
-    this.axisPair.xAxis.getAxisTitle().setVisible(isVisible);
-  }
-
-  /**
-   * Set the y-axis title visibility
-   * 
-   * @param isVisible
-   */
-  public void setYAxisTitleVisible(boolean isVisible) {
-
-    this.axisPair.yAxis.getAxisTitle().setVisible(isVisible);
-  }
-
-  /**
-   * Set the x- and y-axis tick marks and labels visibility
-   * 
-   * @param isVisible
-   */
-  public void setAxisTicksVisible(boolean isVisible) {
-
-    this.axisPair.xAxis.axisTick.setVisible(isVisible);
-    this.axisPair.yAxis.axisTick.setVisible(isVisible);
-  }
-
-  /**
-   * Set the x-axis tick marks and labels visibility
-   * 
-   * @param isVisible
-   */
-  public void setXAxisTicksVisible(boolean isVisible) {
-
-    this.axisPair.xAxis.axisTick.setVisible(isVisible);
-  }
-
-  /**
-   * Set the y-axis tick marks and labels visibility
-   * 
-   * @param isVisible
-   */
-  public void setYAxisTicksVisible(boolean isVisible) {
-
-    this.axisPair.yAxis.axisTick.setVisible(isVisible);
-  }
-
   /**
    * Set the chart grid lines visibility
    * 
@@ -339,28 +286,6 @@ public class Chart {
     this.plot.plotSurface.setGridLinesColor(color);
   }
 
-  /**
-   * Set the x- and y-axis title font
-   * 
-   * @param font
-   */
-  public void setAxisTitleFont(Font font) {
-
-    this.axisPair.xAxis.axisTitle.font = font;
-    this.axisPair.yAxis.axisTitle.font = font;
-  }
-
-  /**
-   * Set the x- and y-axis tick label font
-   * 
-   * @param font
-   */
-  public void setTickLabelFont(Font font) {
-
-    this.axisPair.xAxis.axisTick.axisTickLabels.font = font;
-    this.axisPair.yAxis.axisTick.axisTickLabels.font = font;
-  }
-
   /**
    * Set the String formatter for Data x-axis
    * 
diff --git a/xchart/src/main/java/com/xeiam/xchart/QuickChart.java b/xchart/src/main/java/com/xeiam/xchart/QuickChart.java
index 83405285..4ac80f6c 100644
--- a/xchart/src/main/java/com/xeiam/xchart/QuickChart.java
+++ b/xchart/src/main/java/com/xeiam/xchart/QuickChart.java
@@ -85,7 +85,7 @@ public final class QuickChart {
       if (seriesNames != null) {
         series = chart.addSeries(seriesNames[i], xData, yData[i]);
       } else {
-        chart.getStyleManager().setChartLegendVisible(false);
+        chart.getStyleManager().setLegendVisible(false);
         series = chart.addSeries(" " + i, xData, yData[i]);
       }
       series.setMarker(SeriesMarker.NONE);
diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java
index 5ba21611..3a14963f 100644
--- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java
+++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Axis.java
@@ -80,9 +80,8 @@ public class Axis implements IChartPart {
 
     this.axisPair = axisPair;
     this.direction = direction;
-
-    axisTitle = new AxisTitle(this);
-    axisTick = new AxisTick(this);
+    axisTitle = new AxisTitle(this, direction == Direction.X ? axisPair.chart.getStyleManager().isxAxisTitleVisible() : axisPair.chart.getStyleManager().isyAxisTitleVisible());
+    axisTick = new AxisTick(this, direction == Direction.X ? axisPair.chart.getStyleManager().isxAxisTicksVisible() : axisPair.chart.getStyleManager().isyAxisTicksVisible());
   }
 
   /**
@@ -142,16 +141,16 @@ public class Axis implements IChartPart {
 
       // Axis title
       double titleHeight = 0.0;
-      if (axisTitle.isVisible) {
-        TextLayout textLayout = new TextLayout(axisTitle.getText(), axisTitle.getFont(), new FontRenderContext(null, true, false));
+      if (axisPair.chart.getStyleManager().isxAxisTitleVisible()) {
+        TextLayout textLayout = new TextLayout(axisTitle.getText(), axisTick.axis.axisPair.chart.getStyleManager().getAxisTitleFont(), new FontRenderContext(null, true, false));
         Rectangle rectangle = textLayout.getPixelBounds(null, 0, 0);
         titleHeight = rectangle.getHeight() + AxisTitle.AXIS_TITLE_PADDING;
       }
 
       // Axis tick labels
       double axisTickLabelsHeight = 0.0;
-      if (axisTick.isVisible) {
-        TextLayout textLayout = new TextLayout("0", axisTick.axisTickLabels.font, new FontRenderContext(null, true, false));
+      if (axisPair.chart.getStyleManager().isxAxisTicksVisible()) {
+        TextLayout textLayout = new TextLayout("0", axisTick.axis.axisPair.chart.getStyleManager().getAxisTicksFont(), new FontRenderContext(null, true, false));
         Rectangle rectangle = textLayout.getPixelBounds(null, 0, 0);
         axisTickLabelsHeight = rectangle.getHeight() + AxisTick.AXIS_TICK_PADDING + AxisTickMarks.TICK_LENGTH + Plot.PLOT_PADDING;
       }
@@ -192,7 +191,7 @@ public class Axis implements IChartPart {
 
       xOffset = (int) paintZone.getX();
       yOffset = (int) paintZone.getY();
-      width = (int) (axisTitle.isVisible ? axisTitle.getBounds().getWidth() : 0) + (int) axisTick.getBounds().getWidth();
+      width = (int) (axisPair.chart.getStyleManager().isyAxisTitleVisible() ? axisTitle.getBounds().getWidth() : 0) + (int) axisTick.getBounds().getWidth();
       height = (int) paintZone.getHeight();
       bounds = new Rectangle(xOffset, yOffset, width, height);
       // g.setColor(Color.yellow);
@@ -203,9 +202,10 @@ public class Axis implements IChartPart {
       // calculate paint zone
       // |____________________|
 
-      int xOffset = (int) (axisPair.yAxis.getBounds().getWidth() + (axisPair.yAxis.axisTick.isVisible ? Plot.PLOT_PADDING : 0) + axisPair.chart.getStyleManager().getChartPadding());
+      int xOffset = (int) (axisPair.yAxis.getBounds().getWidth() + (axisPair.chart.getStyleManager().isyAxisTicksVisible() ? Plot.PLOT_PADDING : 0) + axisPair.chart.getStyleManager()
+          .getChartPadding());
       int yOffset = (int) (axisPair.yAxis.getBounds().getY() + axisPair.yAxis.getBounds().getHeight());
-      int width = (int) (axisPair.chart.width - axisPair.yAxis.getBounds().getWidth() - axisPair.getChartLegendBounds().getWidth() - (axisPair.chart.getStyleManager().isChartLegendVisisble() ? 3 : 2)
+      int width = (int) (axisPair.chart.width - axisPair.yAxis.getBounds().getWidth() - axisPair.getChartLegendBounds().getWidth() - (axisPair.chart.getStyleManager().isLegendVisible() ? 3 : 2)
           * axisPair.chart.getStyleManager().getChartPadding());
       int height = this.getSizeHint();
       Rectangle xAxisRectangle = new Rectangle(xOffset, yOffset, width, height);
@@ -219,7 +219,7 @@ public class Axis implements IChartPart {
       xOffset = (int) paintZone.getX();
       yOffset = (int) paintZone.getY();
       width = (int) paintZone.getWidth();
-      height = (int) ((axisTitle.isVisible ? axisTitle.getBounds().getHeight() : 0) + (int) axisTick.getBounds().getHeight());
+      height = (int) ((axisPair.chart.getStyleManager().isxAxisTitleVisible() ? axisTitle.getBounds().getHeight() : 0) + (int) axisTick.getBounds().getHeight());
       bounds = new Rectangle(xOffset, yOffset, width, height);
       bounds = new Rectangle(xOffset, yOffset, width, height);
       // g.setColor(Color.yellow);
diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java
index 74398b44..2d35abb7 100644
--- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java
+++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTick.java
@@ -52,10 +52,10 @@ public class AxisTick implements IChartPart, IHideable {
   /** the axistickmarks */
   protected AxisTickMarks axisTickMarks;
 
-  /** the arraylist of tick label position in pixels */
+  /** the List of tick label position in pixels */
   protected List<Integer> tickLocations;
 
-  /** the arraylist of tick label values */
+  /** the List of tick label values */
   protected List<String> tickLabels;
 
   private int workingSpace;
@@ -74,16 +74,17 @@ public class AxisTick implements IChartPart, IHideable {
   private Rectangle bounds;
 
   /** the visibility state of axistick */
-  protected boolean isVisible = true; // default to true
+  private boolean isVisible = true; // default to true
 
   /**
    * Constructor
    * 
    * @param axis the axis
    */
-  protected AxisTick(Axis axis) {
+  protected AxisTick(Axis axis, boolean isVisible) {
 
     this.axis = axis;
+    this.isVisible = isVisible;
     axisTickLabels = new AxisTickLabels(this);
     axisTickMarks = new AxisTickMarks(this);
 
@@ -270,6 +271,6 @@ public class AxisTick implements IChartPart, IHideable {
   @Override
   public void setVisible(boolean isVisible) {
 
-    this.isVisible = isVisible;
+    // this.isVisible = isVisible;
   }
 }
diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java
index 8087358d..7cdf5312 100644
--- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java
+++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTickLabels.java
@@ -15,7 +15,6 @@
  */
 package com.xeiam.xchart.internal.chartpart;
 
-import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
 import java.awt.font.FontRenderContext;
@@ -31,9 +30,6 @@ public class AxisTickLabels implements IChartPart {
   /** parent */
   private final AxisTick axisTick;
 
-  /** the font */
-  public Font font;
-
   /** the bounds */
   private Rectangle bounds;
 
@@ -45,7 +41,6 @@ public class AxisTickLabels implements IChartPart {
   protected AxisTickLabels(AxisTick axisTick) {
 
     this.axisTick = axisTick;
-    font = new Font(Font.SANS_SERIF, Font.BOLD, 12); // default font
   }
 
   @Override
@@ -58,7 +53,7 @@ public class AxisTickLabels implements IChartPart {
   public void paint(Graphics2D g) {
 
     bounds = new Rectangle();
-    g.setFont(font);
+    g.setFont(axisTick.axis.axisPair.chart.getStyleManager().getAxisTicksFont());
 
     g.setColor(axisTick.axis.axisPair.chart.getStyleManager().getChartFontColor());
 
@@ -75,7 +70,7 @@ public class AxisTickLabels implements IChartPart {
 
         FontRenderContext frc = g.getFontRenderContext();
         // TextLayout layout = new TextLayout(tickLabel, font, new FontRenderContext(null, true, false));
-        TextLayout layout = new TextLayout(tickLabel, font, frc);
+        TextLayout layout = new TextLayout(tickLabel, axisTick.axis.axisPair.chart.getStyleManager().getAxisTicksFont(), frc);
         Rectangle tickLabelBounds = layout.getPixelBounds(null, 0, 0);
         layout.draw(g, xOffset, (int) (yOffset + axisTick.axis.getPaintZone().getHeight() - tickLocation + tickLabelBounds.getHeight() / 2.0));
 
@@ -100,7 +95,7 @@ public class AxisTickLabels implements IChartPart {
         int tickLocation = axisTick.tickLocations.get(i);
 
         FontRenderContext frc = g.getFontRenderContext();
-        TextLayout layout = new TextLayout(tickLabel, font, frc);
+        TextLayout layout = new TextLayout(tickLabel, axisTick.axis.axisPair.chart.getStyleManager().getAxisTicksFont(), frc);
         Rectangle tickLabelBounds = layout.getPixelBounds(null, 0, 0);
         layout.draw(g, (int) (xOffset + tickLocation - tickLabelBounds.getWidth() / 2.0), yOffset);
 
diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java
index 70f0937d..256fb64d 100644
--- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java
+++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/AxisTitle.java
@@ -15,7 +15,6 @@
  */
 package com.xeiam.xchart.internal.chartpart;
 
-import java.awt.Font;
 import java.awt.Graphics2D;
 import java.awt.Rectangle;
 import java.awt.font.FontRenderContext;
@@ -38,12 +37,6 @@ public class AxisTitle implements IChartPart, IHideable {
   /** the title text */
   protected String text = ""; // default to ""
 
-  /** the visibility state of title */
-  protected boolean isVisible = false; // default to false, set true if text is set
-
-  /** the font */
-  public Font font;
-
   /** the bounds */
   private Rectangle bounds;
 
@@ -52,10 +45,9 @@ public class AxisTitle implements IChartPart, IHideable {
    * 
    * @param axis the axis
    */
-  protected AxisTitle(Axis axis) {
+  protected AxisTitle(Axis axis, boolean isVisible) {
 
     this.axis = axis;
-    font = new Font(Font.SANS_SERIF, Font.BOLD, 12); // default font
   }
 
   protected String getText() {
@@ -65,28 +57,12 @@ public class AxisTitle implements IChartPart, IHideable {
 
   public void setText(String text) {
 
-    if (text.trim().equalsIgnoreCase("")) {
-      this.isVisible = false;
-    } else {
-      this.isVisible = true;
-    }
     this.text = text;
   }
 
-  protected Font getFont() {
-
-    return font;
-  }
-
   @Override
   public void setVisible(boolean isVisible) {
 
-    if (!text.trim().equalsIgnoreCase("")) {
-      this.isVisible = isVisible;
-    } else {
-      // don't allow a set to true if text is empty!
-      this.isVisible = false; // set to false for good measure
-    }
   }
 
   @Override
@@ -101,13 +77,13 @@ public class AxisTitle implements IChartPart, IHideable {
     bounds = new Rectangle();
 
     g.setColor(axis.axisPair.chart.getStyleManager().getChartFontColor());
-    g.setFont(font);
+    g.setFont(axis.axisPair.chart.getStyleManager().getAxisTitleFont());
 
     if (axis.direction == Axis.Direction.Y) {
-      if (isVisible) {
+      if (axis.axisPair.chart.getStyleManager().isyAxisTitleVisible()) {
 
         FontRenderContext frc = g.getFontRenderContext();
-        TextLayout nonRotatedTextLayout = new TextLayout(text, font, frc);
+        TextLayout nonRotatedTextLayout = new TextLayout(text, axis.axisPair.chart.getStyleManager().getAxisTitleFont(), frc);
         Rectangle nonRotatedRectangle = nonRotatedTextLayout.getPixelBounds(null, 0, 0);
         // System.out.println(nonRotatedRectangle);
 
@@ -145,10 +121,10 @@ public class AxisTitle implements IChartPart, IHideable {
 
     } else {
 
-      if (isVisible) {
+      if (axis.axisPair.chart.getStyleManager().isxAxisTitleVisible()) {
 
         FontRenderContext frc = g.getFontRenderContext();
-        TextLayout textLayout = new TextLayout(text, font, frc);
+        TextLayout textLayout = new TextLayout(text, axis.axisPair.chart.getStyleManager().getAxisTitleFont(), frc);
         Rectangle rectangle = textLayout.getPixelBounds(null, 0, 0);
         // System.out.println(rectangle);
 
diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartLegend.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java
similarity index 81%
rename from xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartLegend.java
rename to xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java
index bf9aadb8..95c8d3a7 100644
--- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/ChartLegend.java
+++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Legend.java
@@ -30,7 +30,7 @@ import com.xeiam.xchart.style.Series;
 /**
  * @author timmolter
  */
-public class ChartLegend implements IChartPart, IHideable {
+public class Legend implements IChartPart, IHideable {
 
   /** parent */
   private final Chart chart;
@@ -43,7 +43,7 @@ public class ChartLegend implements IChartPart, IHideable {
    * 
    * @param chart
    */
-  public ChartLegend(Chart chart) {
+  public Legend(Chart chart) {
 
     this.chart = chart;
   }
@@ -57,9 +57,9 @@ public class ChartLegend implements IChartPart, IHideable {
   public void paint(Graphics2D g) {
 
     bounds = new Rectangle();
-    g.setFont(chart.getStyleManager().getChartLegendFont());
+    g.setFont(chart.getStyleManager().getLegendFont());
 
-    if (chart.getStyleManager().isChartLegendVisisble()) {
+    if (chart.getStyleManager().isLegendVisible()) {
 
       Map<Integer, Series> seriesMap = chart.axisPair.seriesMap;
 
@@ -69,7 +69,7 @@ public class ChartLegend implements IChartPart, IHideable {
 
       for (Integer seriesId : seriesMap.keySet()) {
         Series series = seriesMap.get(seriesId);
-        TextLayout textLayout = new TextLayout(series.name, chart.getStyleManager().getChartLegendFont(), new FontRenderContext(null, true, false));
+        TextLayout textLayout = new TextLayout(series.name, chart.getStyleManager().getLegendFont(), new FontRenderContext(null, true, false));
         Rectangle rectangle = textLayout.getPixelBounds(null, 0, 0);
         // System.out.println(rectangle);
         if (rectangle.getWidth() > legendTextContentMaxWidth) {
@@ -83,25 +83,25 @@ public class ChartLegend implements IChartPart, IHideable {
       // determine legend content height
       int legendContentHeight = 0;
       int maxContentHeight = Math.max(legendTextContentMaxHeight, Marker.SIZE);
-      legendContentHeight = maxContentHeight * seriesMap.size() + chart.getStyleManager().getChartLegendPadding() * (seriesMap.size() - 1);
+      legendContentHeight = maxContentHeight * seriesMap.size() + chart.getStyleManager().getLegendPadding() * (seriesMap.size() - 1);
 
       // determine legend content width
-      int legendContentWidth = (int) (3.0 * Marker.SIZE + chart.getStyleManager().getChartLegendPadding() + legendTextContentMaxWidth);
+      int legendContentWidth = (int) (3.0 * Marker.SIZE + chart.getStyleManager().getLegendPadding() + legendTextContentMaxWidth);
 
       // Draw Legend Box
-      int legendBoxWidth = legendContentWidth + 2 * chart.getStyleManager().getChartLegendPadding();
-      int legendBoxHeight = legendContentHeight + 2 * chart.getStyleManager().getChartLegendPadding();
+      int legendBoxWidth = legendContentWidth + 2 * chart.getStyleManager().getLegendPadding();
+      int legendBoxHeight = legendContentHeight + 2 * chart.getStyleManager().getLegendPadding();
       int xOffset = chart.width - legendBoxWidth - chart.getStyleManager().getChartPadding();
       int yOffset = (int) ((chart.height - legendBoxHeight) / 2.0 + chart.chartTitle.getBounds().getY() + chart.chartTitle.getBounds().getHeight());
 
       g.setColor(chart.getStyleManager().getChartBordersColor());
       g.drawRect(xOffset, yOffset, legendBoxWidth, legendBoxHeight);
-      g.setColor(chart.getStyleManager().getChartLegendBackgroundColor());
+      g.setColor(chart.getStyleManager().getLegendBackgroundColor());
       g.fillRect(xOffset + 1, yOffset + 1, legendBoxWidth - 1, legendBoxHeight - 1);
 
       // Draw legend content inside legend box
-      int startx = xOffset + chart.getStyleManager().getChartLegendPadding();
-      int starty = yOffset + chart.getStyleManager().getChartLegendPadding();
+      int startx = xOffset + chart.getStyleManager().getLegendPadding();
+      int starty = yOffset + chart.getStyleManager().getLegendPadding();
       for (Integer seriesId : seriesMap.keySet()) {
         Series series = seriesMap.get(seriesId);
         // paint line
@@ -118,9 +118,9 @@ public class ChartLegend implements IChartPart, IHideable {
 
         // paint series name
         g.setColor(chart.getStyleManager().getChartFontColor());
-        TextLayout layout = new TextLayout(series.name, chart.getStyleManager().getChartLegendFont(), new FontRenderContext(null, true, false));
-        layout.draw(g, (float) (startx + Marker.SIZE + (Marker.SIZE * 1.5) + chart.getStyleManager().getChartLegendPadding()), (starty + Marker.SIZE));
-        starty = starty + legendTextContentMaxHeight + chart.getStyleManager().getChartLegendPadding();
+        TextLayout layout = new TextLayout(series.name, chart.getStyleManager().getLegendFont(), new FontRenderContext(null, true, false));
+        layout.draw(g, (float) (startx + Marker.SIZE + (Marker.SIZE * 1.5) + chart.getStyleManager().getLegendPadding()), (starty + Marker.SIZE));
+        starty = starty + legendTextContentMaxHeight + chart.getStyleManager().getLegendPadding();
       }
 
       // bounds
diff --git a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Plot.java b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Plot.java
index ae1c5f11..879adc31 100644
--- a/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Plot.java
+++ b/xchart/src/main/java/com/xeiam/xchart/internal/chartpart/Plot.java
@@ -57,7 +57,7 @@ public class Plot implements IChartPart {
     bounds = new Rectangle();
 
     // calculate bounds
-    int xOffset = (int) (chart.axisPair.yAxis.getBounds().getX() + chart.axisPair.yAxis.getBounds().getWidth() + (chart.axisPair.yAxis.axisTick.isVisible ? (Plot.PLOT_PADDING + 1) : 0));
+    int xOffset = (int) (chart.axisPair.yAxis.getBounds().getX() + chart.axisPair.yAxis.getBounds().getWidth() + (chart.getStyleManager().isyAxisTicksVisible() ? (Plot.PLOT_PADDING + 1) : 0));
     int yOffset = (int) (chart.axisPair.yAxis.getBounds().getY());
     int width = (int) chart.axisPair.xAxis.getBounds().getWidth();
     int height = (int) chart.axisPair.yAxis.getBounds().getHeight();
diff --git a/xchart/src/main/java/com/xeiam/xchart/style/StyleManager.java b/xchart/src/main/java/com/xeiam/xchart/style/StyleManager.java
index bba446df..be84e638 100644
--- a/xchart/src/main/java/com/xeiam/xchart/style/StyleManager.java
+++ b/xchart/src/main/java/com/xeiam/xchart/style/StyleManager.java
@@ -43,10 +43,17 @@ public class StyleManager {
   private Font chartTitleFont;
   private boolean isChartTitleVisible;
 
-  private boolean isChartLegendVisisble;
-  private Color chartLegendBackgroundColor;
-  private Font chartLegendFont;
-  private int chartLegendPadding;
+  private boolean isLegendVisible;
+  private Color legendBackgroundColor;
+  private Font legendFont;
+  private int legendPadding;
+
+  private boolean xAxisTitleVisible;
+  private boolean yAxisTitleVisible;
+  private Font axisTitleFont;
+  private boolean xAxisTicksVisible;
+  private boolean yAxisTicksVisible;
+  private Font axisTicksFont;
 
   /**
    * Constructor
@@ -66,11 +73,18 @@ public class StyleManager {
     // chart title
     chartTitleFont = theme.getChartTitleFont();
     isChartTitleVisible = theme.isChartTitleVisible();
-    // chart legend
-    isChartLegendVisisble = theme.isChartLegendVisible();
-    chartLegendBackgroundColor = theme.getChartLegendBackgroundColor();
-    chartLegendFont = theme.getChartLegendFont();
-    chartLegendPadding = theme.getChartLegendPadding();
+    // legend
+    isLegendVisible = theme.isLegendVisible();
+    legendBackgroundColor = theme.getLegendBackgroundColor();
+    legendFont = theme.getLegendFont();
+    legendPadding = theme.getLegendPadding();
+    // axes
+    xAxisTitleVisible = theme.isXAxisTitleVisible();
+    yAxisTitleVisible = theme.isYAxisTitleVisible();
+    axisTitleFont = theme.getAxisTitleFont();
+    xAxisTicksVisible = theme.isXAxisTicksVisible();
+    yAxisTicksVisible = theme.isYAxisTicksVisible();
+    axisTicksFont = theme.getAxisTicksFont();
   }
 
   /**
@@ -153,9 +167,9 @@ public class StyleManager {
    * 
    * @param font
    */
-  public void setTitleFont(Font font) {
+  public void setChartTitleFont(Font chartTitleFont) {
 
-    this.chartTitleFont = font;
+    this.chartTitleFont = chartTitleFont;
   }
 
   public Font getChartTitleFont() {
@@ -185,14 +199,14 @@ public class StyleManager {
    * 
    * @param color
    */
-  public void setChartLegendBackgroundColor(Color color) {
+  public void setLegendBackgroundColor(Color color) {
 
-    this.chartLegendBackgroundColor = color;
+    this.legendBackgroundColor = color;
   }
 
-  public Color getChartLegendBackgroundColor() {
+  public Color getLegendBackgroundColor() {
 
-    return chartLegendBackgroundColor;
+    return legendBackgroundColor;
   }
 
   /**
@@ -200,46 +214,162 @@ public class StyleManager {
    * 
    * @param font
    */
-  public void setChartLegendFont(Font font) {
+  public void setLegendFont(Font font) {
 
-    this.chartLegendFont = font;
+    this.legendFont = font;
   }
 
-  public Font getChartLegendFont() {
+  public Font getLegendFont() {
 
-    return chartLegendFont;
+    return legendFont;
   }
 
   /**
    * Set the chart legend visibility
    * 
-   * @param isChartLegendVisisble
+   * @param isLegendVisible
    */
-  public void setChartLegendVisible(boolean isChartLegendVisisble) {
+  public void setLegendVisible(boolean isLegendVisible) {
 
-    this.isChartLegendVisisble = isChartLegendVisisble;
+    this.isLegendVisible = isLegendVisible;
   }
 
-  public boolean isChartLegendVisisble() {
+  public boolean isLegendVisible() {
 
-    return isChartLegendVisisble;
+    return isLegendVisible;
   }
 
   /**
    * Set the chart legend padding
    * 
-   * @param chartLegendPadding
+   * @param legendPadding
    */
-  public void setChartLegendPadding(int chartLegendPadding) {
+  public void setLegendPadding(int legendPadding) {
 
-    this.chartLegendPadding = chartLegendPadding;
+    this.legendPadding = legendPadding;
   }
 
-  public int getChartLegendPadding() {
+  public int getLegendPadding() {
 
-    return chartLegendPadding;
+    return legendPadding;
   }
 
-  // Chart Title ///////////////////////////////
+  // Chart Axes ///////////////////////////////
+
+  /**
+   * Set the x-axis title visibility
+   * 
+   * @param isVisible
+   */
+  public void setxAxisTitleVisible(boolean xAxisTitleVisible) {
+
+    this.xAxisTitleVisible = xAxisTitleVisible;
+  }
+
+  public boolean isxAxisTitleVisible() {
+
+    return xAxisTitleVisible;
+  }
+
+  /**
+   * Set the y-axis title visibility
+   * 
+   * @param isVisible
+   */
+  public void setyAxisTitleVisible(boolean yAxisTitleVisible) {
+
+    this.yAxisTitleVisible = yAxisTitleVisible;
+  }
+
+  public boolean isyAxisTitleVisible() {
+
+    return yAxisTitleVisible;
+  }
+
+  /**
+   * Set the x- and y-axis titles visibility
+   * 
+   * @param isVisible
+   */
+  public void setAxisTitlesVisible(boolean isVisible) {
+
+    this.xAxisTitleVisible = isVisible;
+    this.yAxisTitleVisible = isVisible;
+
+  }
+
+  /**
+   * Set the x- and y-axis title font
+   * 
+   * @param axisTitleFont
+   */
+  public void setAxisTitleFont(Font axisTitleFont) {
+
+    this.axisTitleFont = axisTitleFont;
+  }
+
+  public Font getAxisTitleFont() {
+
+    return axisTitleFont;
+  }
+
+  /**
+   * Set the x-axis tick marks and labels visibility
+   * 
+   * @param isVisible
+   */
+
+  public void setxAxisTicksVisible(boolean xAxisTicksVisible) {
+
+    this.xAxisTicksVisible = xAxisTicksVisible;
+  }
+
+  public boolean isxAxisTicksVisible() {
+
+    return xAxisTicksVisible;
+  }
+
+  /**
+   * Set the y-axis tick marks and labels visibility
+   * 
+   * @param isVisible
+   */
+
+  public void setyAxisTicksVisible(boolean yAxisTicksVisible) {
+
+    this.yAxisTicksVisible = yAxisTicksVisible;
+  }
+
+  public boolean isyAxisTicksVisible() {
+
+    return yAxisTicksVisible;
+  }
+
+  /**
+   * Set the x- and y-axis tick marks and labels visibility
+   * 
+   * @param isVisible
+   */
+  public void setAxisTicksVisible(boolean isVisible) {
+
+    this.xAxisTicksVisible = isVisible;
+    this.yAxisTicksVisible = isVisible;
+
+  }
+
+  /**
+   * Set the x- and y-axis tick label font
+   * 
+   * @param foxAxisTicksFontnt
+   */
+  public void setAxisTicksFont(Font axisTicksFont) {
+
+    this.axisTicksFont = axisTicksFont;
+  }
+
+  public Font getAxisTicksFont() {
+
+    return axisTicksFont;
+  }
 
 }
diff --git a/xchart/src/main/java/com/xeiam/xchart/style/theme/Theme.java b/xchart/src/main/java/com/xeiam/xchart/style/theme/Theme.java
index df237837..4066f2d1 100644
--- a/xchart/src/main/java/com/xeiam/xchart/style/theme/Theme.java
+++ b/xchart/src/main/java/com/xeiam/xchart/style/theme/Theme.java
@@ -47,12 +47,26 @@ public interface Theme {
 
   // Chart Legend ///////////////////////////////
 
-  public Font getChartLegendFont();
+  public Font getLegendFont();
 
-  public boolean isChartLegendVisible();
+  public boolean isLegendVisible();
 
-  public Color getChartLegendBackgroundColor();
+  public Color getLegendBackgroundColor();
 
-  public int getChartLegendPadding();
+  public int getLegendPadding();
+
+  // Chart Axes ///////////////////////////////
+
+  public boolean isXAxisTitleVisible();
+
+  public boolean isYAxisTitleVisible();
+
+  public Font getAxisTitleFont();
+
+  public boolean isXAxisTicksVisible();
+
+  public boolean isYAxisTicksVisible();
+
+  public Font getAxisTicksFont();
 
 }
diff --git a/xchart/src/main/java/com/xeiam/xchart/style/theme/XChartTheme.java b/xchart/src/main/java/com/xeiam/xchart/style/theme/XChartTheme.java
index c8438b42..67624290 100644
--- a/xchart/src/main/java/com/xeiam/xchart/style/theme/XChartTheme.java
+++ b/xchart/src/main/java/com/xeiam/xchart/style/theme/XChartTheme.java
@@ -74,27 +74,63 @@ public class XChartTheme implements Theme {
   // Chart Legend ///////////////////////////////
 
   @Override
-  public Font getChartLegendFont() {
+  public Font getLegendFont() {
 
     return new Font(Font.SANS_SERIF, Font.PLAIN, 11);
   }
 
   @Override
-  public boolean isChartLegendVisible() {
+  public boolean isLegendVisible() {
 
     return true;
   }
 
   @Override
-  public Color getChartLegendBackgroundColor() {
+  public Color getLegendBackgroundColor() {
 
     return ChartColor.getAWTColor(ChartColor.LIGHT_GREY);
   }
 
   @Override
-  public int getChartLegendPadding() {
+  public int getLegendPadding() {
 
     return 10;
   }
 
+  @Override
+  public boolean isXAxisTitleVisible() {
+
+    return false;
+  }
+
+  @Override
+  public boolean isYAxisTitleVisible() {
+
+    return false;
+  }
+
+  @Override
+  public Font getAxisTitleFont() {
+
+    return new Font(Font.SANS_SERIF, Font.BOLD, 12);
+  }
+
+  @Override
+  public boolean isXAxisTicksVisible() {
+
+    return true;
+  }
+
+  @Override
+  public boolean isYAxisTicksVisible() {
+
+    return true;
+  }
+
+  @Override
+  public Font getAxisTicksFont() {
+
+    return new Font(Font.SANS_SERIF, Font.BOLD, 12);
+  }
+
 }
-- 
GitLab