Skip to content
Snippets Groups Projects
Commit ecfe997e authored by Carlos Lopez-Camey's avatar Carlos Lopez-Camey
Browse files

Merge branch 'master' of github.com:timmolter/XChart into develop

parents 2c12c9e5 0948b824
No related branches found
No related tags found
No related merge requests found
Showing
with 375 additions and 23 deletions
language: java language: java
sudo: false
before_install: "git clone -b travis `git config --get remote.origin.url` target/travis" before_install: "git clone -b travis `git config --get remote.origin.url` target/travis"
script: " script: "
if [ ${TRAVIS_PULL_REQUEST} = 'false' ]; if [ ${TRAVIS_PULL_REQUEST} = 'false' ];
...@@ -8,6 +10,9 @@ else ...@@ -8,6 +10,9 @@ else
mvn clean verify --settings target/travis/settings.xml; mvn clean verify --settings target/travis/settings.xml;
fi" fi"
jdk:
- openjdk6
# whitelist # whitelist
branches: branches:
only: only:
......
...@@ -93,7 +93,7 @@ Add the XChart library as a dependency to your pom.xml file: ...@@ -93,7 +93,7 @@ Add the XChart library as a dependency to your pom.xml file:
<dependency> <dependency>
<groupId>org.knowm.xchart</groupId> <groupId>org.knowm.xchart</groupId>
<artifactId>xchart</artifactId> <artifactId>xchart</artifactId>
<version>2.6.0</version> <version>2.6.1</version>
</dependency> </dependency>
``` ```
...@@ -109,7 +109,7 @@ For snapshots, add the following to your pom.xml file: ...@@ -109,7 +109,7 @@ For snapshots, add the following to your pom.xml file:
<dependency> <dependency>
<groupId>org.knowm.xchart</groupId> <groupId>org.knowm.xchart</groupId>
<artifactId>xchart</artifactId> <artifactId>xchart</artifactId>
<version>2.6.1-SNAPSHOT</version> <version>2.6.2-SNAPSHOT</version>
</dependency> </dependency>
``` ```
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.knowm.xchart</groupId> <groupId>org.knowm.xchart</groupId>
<artifactId>xchart-parent</artifactId> <artifactId>xchart-parent</artifactId>
<version>2.6.1-SNAPSHOT</version> <version>2.6.2-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>XChart Parent</name> <name>XChart Parent</name>
<description>Basic Charts for Java Applications</description> <description>XChart is a light weight Java library for plotting data.</description>
<url>http://knowm.org/open-source/xchart</url> <url>http://knowm.org/open-source/xchart</url>
<inceptionYear>2011</inceptionYear> <inceptionYear>2011</inceptionYear>
...@@ -65,19 +65,12 @@ ...@@ -65,19 +65,12 @@
<downloadUrl>https://oss.sonatype.org/content/groups/public/org/knowm/xchart</downloadUrl> <downloadUrl>https://oss.sonatype.org/content/groups/public/org/knowm/xchart</downloadUrl>
</distributionManagement> </distributionManagement>
<repositories>
<repository>
<id>erichseifert.de</id>
<url>http://mvn.erichseifert.de/maven2</url>
</repository>
</repositories>
<dependencyManagement> <dependencyManagement>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>de.erichseifert.vectorgraphics2d</groupId> <groupId>de.erichseifert.vectorgraphics2d</groupId>
<artifactId>VectorGraphics2D</artifactId> <artifactId>VectorGraphics2D</artifactId>
<version>0.9.2</version> <version>0.9.3</version>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
</dependencies> </dependencies>
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.knowm.xchart</groupId> <groupId>org.knowm.xchart</groupId>
<artifactId>xchart-parent</artifactId> <artifactId>xchart-parent</artifactId>
<version>2.6.1-SNAPSHOT</version> <version>2.6.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>xchart-demo</artifactId> <artifactId>xchart-demo</artifactId>
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<dependency> <dependency>
<groupId>org.knowm.xchart</groupId> <groupId>org.knowm.xchart</groupId>
<artifactId>xchart</artifactId> <artifactId>xchart</artifactId>
<version>2.6.1-SNAPSHOT</version> <version>2.6.2-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
......
/**
* Copyright 2015 Knowm Inc. (http://knowm.org) and contributors.
* Copyright 2011-2015 Xeiam LLC (http://xeiam.com) and contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.knowm.xchart.demo.charts.plot.lines;
import java.util.ArrayList;
import java.util.List;
import org.knowm.xchart.BitmapEncoder;
import org.knowm.xchart.BitmapEncoder.BitmapFormat;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesMarker;
import org.knowm.xchart.SwingWrapper;
import org.knowm.xchart.VectorGraphicsEncoder;
import org.knowm.xchart.VectorGraphicsEncoder.VectorGraphicsFormat;
/**
* Creates a simple Chart and saves it as a PNG and JPEG image file.
*/
public class Example0WithoutHorizontalLines {
public static void main(String[] args) {
int numCharts = 4;
List<Chart> charts = new ArrayList<Chart>();
for (int i = 0; i < numCharts; i++) {
Chart chart = new ChartBuilder().xAxisTitle("X").yAxisTitle("Y").width(600).height(400).build();
chart.getStyleManager().setYAxisMin(-10);
chart.getStyleManager().setYAxisMax(10);
chart.getStyleManager().setPlotGridHorizontalLinesVisible(false);
Series series = chart.addSeries("" + i, null, getRandomWalk(200));
series.setMarker(SeriesMarker.NONE);
charts.add(chart);
}
new SwingWrapper(charts).displayChartMatrix();
}
/**
* Generates a set of random walk data
*
* @param numPoints
* @return
*/
private static double[] getRandomWalk(int numPoints) {
double[] y = new double[numPoints];
y[0] = 0;
for (int i = 1; i < y.length; i++) {
y[i] = y[i - 1] + Math.random() - .5;
}
return y;
}
}
/**
* Copyright 2015 Knowm Inc. (http://knowm.org) and contributors.
* Copyright 2011-2015 Xeiam LLC (http://xeiam.com) and contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.knowm.xchart.demo.charts.plot.lines;
import java.util.ArrayList;
import java.util.List;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesMarker;
import org.knowm.xchart.SwingWrapper;
/**
* Create a Chart matrix
*
* @author timmolter
*/
public class Example0WithoutVerticalAndHorizontalLines {
public static void main(String[] args) {
int numCharts = 4;
List<Chart> charts = new ArrayList<Chart>();
for (int i = 0; i < numCharts; i++) {
Chart chart = new ChartBuilder().xAxisTitle("X").yAxisTitle("Y").width(600).height(400).build();
chart.getStyleManager().setYAxisMin(-10);
chart.getStyleManager().setYAxisMax(10);
chart.getStyleManager().setPlotGridVerticalLinesVisible(false);
chart.getStyleManager().setPlotGridHorizontalLinesVisible(false);
Series series = chart.addSeries("" + i, null, getRandomWalk(200));
series.setMarker(SeriesMarker.NONE);
charts.add(chart);
}
new SwingWrapper(charts).displayChartMatrix();
}
/**
* Generates a set of random walk data
*
* @param numPoints
* @return
*/
private static double[] getRandomWalk(int numPoints) {
double[] y = new double[numPoints];
y[0] = 0;
for (int i = 1; i < y.length; i++) {
y[i] = y[i - 1] + Math.random() - .5;
}
return y;
}
}
/**
* Copyright 2015 Knowm Inc. (http://knowm.org) and contributors.
* Copyright 2011-2015 Xeiam LLC (http://xeiam.com) and contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.knowm.xchart.demo.charts.plot.lines;
import java.util.ArrayList;
import java.util.List;
import org.knowm.xchart.Chart;
import org.knowm.xchart.ChartBuilder;
import org.knowm.xchart.Series;
import org.knowm.xchart.SeriesMarker;
import org.knowm.xchart.SwingWrapper;
/**
* Creates a simple Chart using QuickChart
*/
public class Example0WithoutVerticalLines {
public static void main(String[] args) {
int numCharts = 4;
List<Chart> charts = new ArrayList<Chart>();
for (int i = 0; i < numCharts; i++) {
Chart chart = new ChartBuilder().xAxisTitle("X").yAxisTitle("Y").width(600).height(400).build();
chart.getStyleManager().setYAxisMin(-10);
chart.getStyleManager().setYAxisMax(10);
chart.getStyleManager().setPlotGridVerticalLinesVisible(false);
Series series = chart.addSeries("" + i, null, getRandomWalk(200));
series.setMarker(SeriesMarker.NONE);
charts.add(chart);
}
new SwingWrapper(charts).displayChartMatrix();
}
/**
* Generates a set of random walk data
*
* @param numPoints
* @return
*/
private static double[] getRandomWalk(int numPoints) {
double[] y = new double[numPoints];
y[0] = 0;
for (int i = 1; i < y.length; i++) {
y[i] = y[i - 1] + Math.random() - .5;
}
return y;
}
}
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<parent> <parent>
<groupId>org.knowm.xchart</groupId> <groupId>org.knowm.xchart</groupId>
<artifactId>xchart-parent</artifactId> <artifactId>xchart-parent</artifactId>
<version>2.6.1-SNAPSHOT</version> <version>2.6.2-SNAPSHOT</version>
</parent> </parent>
<artifactId>xchart</artifactId> <artifactId>xchart</artifactId>
......
...@@ -127,7 +127,8 @@ public class StyleManager { ...@@ -127,7 +127,8 @@ public class StyleManager {
private int xAxisLabelRotation = 0; private int xAxisLabelRotation = 0;
// Chart Plot Area /////////////////////////////// // Chart Plot Area ///////////////////////////////
private boolean isPlotGridLinesVisible; private boolean isPlotGridHorizontalLinesVisible;
private boolean isPlotGridVerticalLinesVisible;
private Color plotBackgroundColor; private Color plotBackgroundColor;
private Color plotBorderColor; private Color plotBorderColor;
private boolean isPlotBorderVisible; private boolean isPlotBorderVisible;
...@@ -215,7 +216,8 @@ public class StyleManager { ...@@ -215,7 +216,8 @@ public class StyleManager {
axisTickSpacePercentage = .95; axisTickSpacePercentage = .95;
// Chart Plot Area /////////////////////////////// // Chart Plot Area ///////////////////////////////
isPlotGridLinesVisible = theme.isPlotGridLinesVisible(); isPlotGridVerticalLinesVisible = theme.isPlotGridVerticalLinesVisible();
isPlotGridHorizontalLinesVisible = theme.isPlotGridHorizontalLinesVisible();
plotBackgroundColor = theme.getPlotBackgroundColor(); plotBackgroundColor = theme.getPlotBackgroundColor();
plotBorderColor = theme.getPlotBorderColor(); plotBorderColor = theme.getPlotBorderColor();
isPlotBorderVisible = theme.isPlotBorderVisible(); isPlotBorderVisible = theme.isPlotBorderVisible();
...@@ -927,12 +929,44 @@ public class StyleManager { ...@@ -927,12 +929,44 @@ public class StyleManager {
*/ */
public void setPlotGridLinesVisible(boolean isPlotGridLinesVisible) { public void setPlotGridLinesVisible(boolean isPlotGridLinesVisible) {
this.isPlotGridLinesVisible = isPlotGridLinesVisible; this.isPlotGridHorizontalLinesVisible = isPlotGridLinesVisible;
this.isPlotGridVerticalLinesVisible = isPlotGridLinesVisible;
} }
@Deprecated
public boolean isPlotGridLinesVisible() { public boolean isPlotGridLinesVisible() {
return isPlotGridLinesVisible; return isPlotGridHorizontalLinesVisible && isPlotGridVerticalLinesVisible;
}
/**
* sets the visibility of the horizontal gridlines on the plot area
*
* @param isPlotGridLinesVisible
*/
public void setPlotGridHorizontalLinesVisible(boolean isPlotGridHorizontalLinesVisible) {
this.isPlotGridHorizontalLinesVisible = isPlotGridHorizontalLinesVisible;
}
public boolean isPlotGridHorizontalLinesVisible() {
return isPlotGridHorizontalLinesVisible;
}
/**
* sets the visibility of the vertical gridlines on the plot area
*
* @param isPlotGridLinesVisible
*/
public void setPlotGridVerticalLinesVisible(boolean isPlotGridVerticalLinesVisible) {
this.isPlotGridVerticalLinesVisible = isPlotGridVerticalLinesVisible;
}
public boolean isPlotGridVerticalLinesVisible() {
return isPlotGridVerticalLinesVisible;
} }
/** /**
......
...@@ -68,7 +68,10 @@ public class PlotSurface implements ChartPart { ...@@ -68,7 +68,10 @@ public class PlotSurface implements ChartPart {
} }
// paint grid lines and/or inner plot ticks // paint grid lines and/or inner plot ticks
if (getChartPainter().getStyleManager().isPlotGridLinesVisible() || getChartPainter().getStyleManager().isPlotTicksMarksVisible()) { if (getChartPainter().getStyleManager().isPlotGridHorizontalLinesVisible()
|| getChartPainter().getStyleManager().isPlotGridVerticalLinesVisible()
|| getChartPainter().getStyleManager().isPlotTicksMarksVisible()
) {
// horizontal // horizontal
List<Double> yAxisTickLocations = getChartPainter().getAxisPair().getYAxis().getAxisTickCalculator().getTickLocations(); List<Double> yAxisTickLocations = getChartPainter().getAxisPair().getYAxis().getAxisTickCalculator().getTickLocations();
...@@ -79,7 +82,7 @@ public class PlotSurface implements ChartPart { ...@@ -79,7 +82,7 @@ public class PlotSurface implements ChartPart {
if (yOffset > bounds.getY() && yOffset < bounds.getY() + bounds.getHeight()) { if (yOffset > bounds.getY() && yOffset < bounds.getY() + bounds.getHeight()) {
// draw lines // draw lines
if (getChartPainter().getStyleManager().isPlotGridLinesVisible()) { if (getChartPainter().getStyleManager().isPlotGridHorizontalLinesVisible()) {
g.setColor(getChartPainter().getStyleManager().getPlotGridLinesColor()); g.setColor(getChartPainter().getStyleManager().getPlotGridLinesColor());
g.setStroke(getChartPainter().getStyleManager().getPlotGridLinesStroke()); g.setStroke(getChartPainter().getStyleManager().getPlotGridLinesStroke());
...@@ -103,7 +106,7 @@ public class PlotSurface implements ChartPart { ...@@ -103,7 +106,7 @@ public class PlotSurface implements ChartPart {
// vertical // vertical
if (getChartPainter().getStyleManager().getChartType() != ChartType.Bar if (getChartPainter().getStyleManager().getChartType() != ChartType.Bar
&& (getChartPainter().getStyleManager().isPlotGridLinesVisible() && (getChartPainter().getStyleManager().isPlotGridVerticalLinesVisible()
|| getChartPainter().getStyleManager().isPlotTicksMarksVisible()) || getChartPainter().getStyleManager().isPlotTicksMarksVisible())
...@@ -118,7 +121,7 @@ public class PlotSurface implements ChartPart { ...@@ -118,7 +121,7 @@ public class PlotSurface implements ChartPart {
if (xOffset > bounds.getX() && xOffset < bounds.getX() + bounds.getWidth()) { if (xOffset > bounds.getX() && xOffset < bounds.getX() + bounds.getWidth()) {
// draw lines // draw lines
if (getChartPainter().getStyleManager().isPlotGridLinesVisible()) { if (getChartPainter().getStyleManager().isPlotGridVerticalLinesVisible()) {
g.setColor(getChartPainter().getStyleManager().getPlotGridLinesColor()); g.setColor(getChartPainter().getStyleManager().getPlotGridLinesColor());
g.setStroke(getChartPainter().getStyleManager().getPlotGridLinesStroke()); g.setStroke(getChartPainter().getStyleManager().getPlotGridLinesStroke());
......
...@@ -244,6 +244,20 @@ public class GGPlot2Theme implements Theme { ...@@ -244,6 +244,20 @@ public class GGPlot2Theme implements Theme {
return true; return true;
} }
@Override
public boolean isPlotGridVerticalLinesVisible() {
return true;
}
@Override
public boolean isPlotGridHorizontalLinesVisible() {
return true;
}
@Override @Override
public Color getPlotBackgroundColor() { public Color getPlotBackgroundColor() {
......
...@@ -244,6 +244,18 @@ public class MatlabTheme implements Theme { ...@@ -244,6 +244,18 @@ public class MatlabTheme implements Theme {
return true; return true;
} }
@Override
public boolean isPlotGridVerticalLinesVisible() {
return true;
}
@Override
public boolean isPlotGridHorizontalLinesVisible() {
return true;
}
@Override @Override
public Color getPlotBackgroundColor() { public Color getPlotBackgroundColor() {
......
...@@ -105,6 +105,10 @@ public interface Theme { ...@@ -105,6 +105,10 @@ public interface Theme {
public boolean isPlotGridLinesVisible(); public boolean isPlotGridLinesVisible();
public boolean isPlotGridVerticalLinesVisible();
public boolean isPlotGridHorizontalLinesVisible();
public Color getPlotBackgroundColor(); public Color getPlotBackgroundColor();
public Color getPlotBorderColor(); public Color getPlotBorderColor();
......
...@@ -244,6 +244,18 @@ public class XChartTheme implements Theme { ...@@ -244,6 +244,18 @@ public class XChartTheme implements Theme {
return true; return true;
} }
@Override
public boolean isPlotGridVerticalLinesVisible() {
return true;
}
@Override
public boolean isPlotGridHorizontalLinesVisible() {
return true;
}
@Override @Override
public Color getPlotBackgroundColor() { public Color getPlotBackgroundColor() {
......
package org.knowm.xchart;
import org.junit.Before;
import org.junit.Test;
import static org.fest.assertions.api.Assertions.assertThat;
public class StyleManagerTest {
private StyleManager styleManager;
@Before
public void setUp() {
styleManager = new StyleManager();
}
@SuppressWarnings("deprecation")
@Test
public void setPlotGridLinesVisibleTestWithFalse(){
styleManager.setPlotGridLinesVisible(false);
assertThat(styleManager.isPlotGridLinesVisible()).isFalse();
assertThat(styleManager.isPlotGridHorizontalLinesVisible()).isFalse();
assertThat(styleManager.isPlotGridVerticalLinesVisible()).isFalse();
}
@SuppressWarnings("deprecation")
@Test
public void setPlotGridLinesVisibleTestWithTrue(){
styleManager.setPlotGridHorizontalLinesVisible(true);
assertThat(styleManager.isPlotGridLinesVisible()).isTrue();
assertThat(styleManager.isPlotGridHorizontalLinesVisible()).isTrue();
assertThat(styleManager.isPlotGridVerticalLinesVisible()).isTrue();
}
@SuppressWarnings("deprecation")
@Test
public void setPlotGridHorizontalLinesVisibleTestWithFalse(){
styleManager.setPlotGridHorizontalLinesVisible(false);
assertThat(styleManager.isPlotGridHorizontalLinesVisible()).isFalse();
assertThat(styleManager.isPlotGridLinesVisible()).isFalse();
}
@SuppressWarnings("deprecation")
@Test
public void setPlotGridHorizontalLinesVisibleTestWithTrue(){
styleManager.setPlotGridLinesVisible(true);
assertThat(styleManager.isPlotGridHorizontalLinesVisible()).isTrue();
assertThat(styleManager.isPlotGridLinesVisible()).isTrue();
}
@SuppressWarnings("deprecation")
@Test
public void setPlotGridVerticalLinesVisibleTestWithFalse(){
styleManager.setPlotGridVerticalLinesVisible(false);
assertThat(styleManager.isPlotGridVerticalLinesVisible()).isFalse();
assertThat(styleManager.isPlotGridLinesVisible()).isFalse();
}
@SuppressWarnings("deprecation")
@Test
public void setPlotGridVerticalLinesVisibleTestWithTrue(){
styleManager.setPlotGridVerticalLinesVisible(true);
assertThat(styleManager.isPlotGridVerticalLinesVisible()).isTrue();
assertThat(styleManager.isPlotGridLinesVisible()).isTrue();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment