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

plot gridline visibility, got rid of IHideable

parent 5c42ea51
No related branches found
No related tags found
No related merge requests found
Showing
with 52 additions and 73 deletions
......@@ -254,18 +254,6 @@ public class Chart {
this.axisPair.yAxis.axisTitle.setText(title);
}
// ChartPart visibility ////////////////////////////////
/**
* Set the chart grid lines visibility
*
* @param isVisible
*/
public void setGridlinesVisible(boolean isVisible) {
this.plot.plotSurface.setVisible(isVisible);
}
/**
* Set the chart foreground color - the part the series are drawn on
*
......
......@@ -26,13 +26,12 @@ import java.util.TimeZone;
import com.xeiam.xchart.internal.chartpart.Axis.AxisType;
import com.xeiam.xchart.internal.chartpart.Axis.Direction;
import com.xeiam.xchart.internal.interfaces.IChartPart;
import com.xeiam.xchart.internal.interfaces.IHideable;
import com.xeiam.xchart.internal.misc.AxisValueFormatterUtil;
/**
* An axis tick
*/
public class AxisTick implements IChartPart, IHideable {
public class AxisTick implements IChartPart {
/** the default tick mark step hint for x axis */
private static final int DEFAULT_TICK_MARK_STEP_HINT_X = 74;
......@@ -265,9 +264,4 @@ public class AxisTick implements IChartPart, IHideable {
}
@Override
public void setVisible(boolean isVisible) {
// this.isVisible = isVisible;
}
}
......@@ -22,12 +22,11 @@ import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import com.xeiam.xchart.internal.interfaces.IChartPart;
import com.xeiam.xchart.internal.interfaces.IHideable;
/**
* AxisTitle
*/
public class AxisTitle implements IChartPart, IHideable {
public class AxisTitle implements IChartPart {
/** parent */
private final Axis axis;
......@@ -58,11 +57,6 @@ public class AxisTitle implements IChartPart, IHideable {
this.text = text;
}
@Override
public void setVisible(boolean isVisible) {
}
@Override
public Rectangle getBounds() {
......
......@@ -22,12 +22,11 @@ import java.awt.font.TextLayout;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.internal.interfaces.IChartPart;
import com.xeiam.xchart.internal.interfaces.IHideable;
/**
* Chart Title
*/
public class ChartTitle implements IChartPart, IHideable {
public class ChartTitle implements IChartPart {
/** parent */
private final Chart chart;
......@@ -58,11 +57,6 @@ public class ChartTitle implements IChartPart, IHideable {
this.text = text;
}
@Override
public void setVisible(boolean isVisible) {
}
@Override
public void paint(Graphics2D g) {
......
......@@ -23,14 +23,13 @@ import java.util.Map;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.internal.interfaces.IChartPart;
import com.xeiam.xchart.internal.interfaces.IHideable;
import com.xeiam.xchart.internal.markers.Marker;
import com.xeiam.xchart.style.Series;
/**
* @author timmolter
*/
public class Legend implements IChartPart, IHideable {
public class Legend implements IChartPart {
/** parent */
private final Chart chart;
......@@ -48,11 +47,6 @@ public class Legend implements IChartPart, IHideable {
this.chart = chart;
}
@Override
public void setVisible(boolean isVisible) {
}
@Override
public void paint(Graphics2D g) {
......
......@@ -22,13 +22,12 @@ import java.awt.Rectangle;
import java.util.List;
import com.xeiam.xchart.internal.interfaces.IChartPart;
import com.xeiam.xchart.internal.interfaces.IHideable;
import com.xeiam.xchart.style.ChartColor;
/**
* @author timmolter
*/
public class PlotSurface implements IChartPart, IHideable {
public class PlotSurface implements IChartPart {
/** parent */
private Plot plot;
......@@ -42,9 +41,6 @@ public class PlotSurface implements IChartPart, IHideable {
/** the line style */
private BasicStroke stroke;
/** the visibility state of PlotSurface */
protected boolean isVisible = true; // default to true
/**
* Constructor
*
......@@ -78,7 +74,7 @@ public class PlotSurface implements IChartPart, IHideable {
g.draw(borderRectangle);
// paint grid lines
if (isVisible) {
if (plot.chart.getStyleManager().isPlotGridLinesVisible()) {
// horizontal
List<Integer> yAxisTickLocations = plot.chart.axisPair.yAxis.axisTick.tickLocations;
for (int i = 0; i < yAxisTickLocations.size(); i++) {
......@@ -106,12 +102,6 @@ public class PlotSurface implements IChartPart, IHideable {
}
}
@Override
public void setVisible(boolean isVisible) {
this.isVisible = isVisible;
}
/**
* @param gridLinesColor the gridLinesColor to set
*/
......
/*******************************************************************************
* Copyright (c) 2008-2011 SWTChart project. All rights reserved.
*
* This code is distributed under the terms of the Eclipse Public License v1.0
* which is available at http://www.eclipse.org/legal/epl-v10.html
*******************************************************************************/
package com.xeiam.xchart.internal.interfaces;
/**
* ChartParts that can be set visible or not should implement this interface
*
* @author timmolter
*/
// TODO get rid of this after theme refactor is done
public interface IHideable extends IChartPart {
public void setVisible(boolean isVisible);
}
\ No newline at end of file
......@@ -35,19 +35,23 @@ public class StyleManager {
/** the default Theme */
private Theme theme = new XChartTheme();
// Chart Style ///////////////////////////////
private Color chartBackgroundColor;
public Color chartBordersColor;
public Color chartFontColor;
private int chartPadding;
// Chart Title ///////////////////////////////
private Font chartTitleFont;
private boolean isChartTitleVisible;
// Chart Legend ///////////////////////////////
private boolean isLegendVisible;
private Color legendBackgroundColor;
private Font legendFont;
private int legendPadding;
// Chart Axes ///////////////////////////////
private boolean xAxisTitleVisible;
private boolean yAxisTitleVisible;
private Font axisTitleFont;
......@@ -60,6 +64,9 @@ public class StyleManager {
private int plotPadding;
private int axisTitlePadding;
// Chart Plot Area ///////////////////////////////
private boolean isPlotGridLinesVisible;
/**
* Constructor
*/
......@@ -70,19 +77,22 @@ public class StyleManager {
private void setAllStyles() {
// chart
// Chart Style ///////////////////////////////
chartBackgroundColor = theme.getChartBackgroundColor();
chartBordersColor = theme.getChartBordersColor();
chartFontColor = theme.getChartFontColor();
chartPadding = theme.getChartPadding();
// chart title
// Chart Title ///////////////////////////////
chartTitleFont = theme.getChartTitleFont();
isChartTitleVisible = theme.isChartTitleVisible();
// legend
isLegendVisible = theme.isLegendVisible();
legendBackgroundColor = theme.getLegendBackgroundColor();
legendFont = theme.getLegendFont();
legendPadding = theme.getLegendPadding();
// axes
xAxisTitleVisible = theme.isXAxisTitleVisible();
yAxisTitleVisible = theme.isYAxisTitleVisible();
......@@ -95,6 +105,9 @@ public class StyleManager {
isAxisTicksLineVisible = theme.isAxisTicksLineVisible();
plotPadding = theme.getPlotPadding();
axisTitlePadding = theme.getAxisTitlePadding();
// Chart Plot Area ///////////////////////////////
isPlotGridLinesVisible = theme.isPlotGridLinesVisible();
}
/**
......@@ -456,4 +469,21 @@ public class StyleManager {
return axisTitlePadding;
}
// Chart Plot Area ///////////////////////////////
/**
* sets the visibility of the gridlines on the plot area
*
* @param isPlotGridLinesVisible
*/
public void setPlotGridLinesVisible(boolean isPlotGridLinesVisible) {
this.isPlotGridLinesVisible = isPlotGridLinesVisible;
}
public boolean isPlotGridLinesVisible() {
return isPlotGridLinesVisible;
}
}
......@@ -79,4 +79,8 @@ public interface Theme {
public int getPlotPadding();
// Chart Plot Area ///////////////////////////////
public boolean isPlotGridLinesVisible();
}
......@@ -97,6 +97,8 @@ public class XChartTheme implements Theme {
return 10;
}
// Chart Axes ///////////////////////////////
@Override
public boolean isXAxisTitleVisible() {
......@@ -162,4 +164,12 @@ public class XChartTheme implements Theme {
return 10;
}
// Chart Plot Area ///////////////////////////////
@Override
public boolean isPlotGridLinesVisible() {
return true;
}
}
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