series = new XYZSeries<>("Series 1");
series.add(5, 5, 5);
series.add(15, 5, 5);
series.add(15, 15, 5);
series.add(5, 15, 5);
series.add(5, 5, 5);
series.add(5, 5, 15);
series.add(15, 5, 15);
series.add(15, 15, 15);
series.add(5, 15, 15);
series.add(5, 5, 15);
series.add(5, 15, 15);
series.add(5, 15, 5);
series.add(15, 15, 5);
series.add(15, 15, 15);
series.add(15, 5, 15);
series.add(15, 5, 5);
dataset.add(series);
return dataset;
}
private static Chart3D createChart(XYZDataset dataset) {
Chart3D chart = Chart3DFactory.createXYZLineChart("XYZ Line Chart Demo",
"Orson Charts", dataset, "X", "Y", "Z");
chart.setChartBoxColor(new Color(255, 255, 255, 128));
XYZPlot plot = (XYZPlot) chart.getPlot();
plot.getXAxis().setRange(0, 20);
plot.getYAxis().setRange(0, 20);
plot.getZAxis().setRange(0, 20);
return chart;
}
/**
* Returns a panel containing the content for the demo. This method is
* used across all the individual demo applications to allow aggregation
* into a single "umbrella" demo (OrsonChartsDemo).
*
* @return A panel containing the content for the demo.
*/
public static JPanel createDemoPanel() {
DemoPanel content = new DemoPanel(new BorderLayout());
content.setPreferredSize(OrsonChartsDemo.DEFAULT_CONTENT_SIZE);
XYZDataset dataset = createDataset();
Chart3D chart = createChart(dataset);
Chart3DPanel chartPanel = new Chart3DPanel(chart);
content.setChartPanel(chartPanel);
chartPanel.zoomToFit(OrsonChartsDemo.DEFAULT_CONTENT_SIZE);
content.add(new DisplayPanel3D(chartPanel));
return content;
}
/**
* Starting point for the app.
*
* @param args command line arguments (ignored).
*/
public static void main(String[] args) {
XYZLineChart3DDemo2 app = new XYZLineChart3DDemo2(
"OrsonCharts: XYZLineChart3DDemo2.java");
app.pack();
app.setVisible(true);
}
}
jfree-demos-2.0/src/main/java/com/orsoncharts/demo/package-info.java 0000664 0000000 0000000 00000000152 13776557647 0025476 0 ustar 00root root 0000000 0000000 /**
* Some demo applications to show how Orson Charts works (in Swing).
*/
package com.orsoncharts.demo; jfree-demos-2.0/src/main/java/module-info.java 0000664 0000000 0000000 00000000461 13776557647 0021324 0 ustar 00root root 0000000 0000000 module org.jfree.demos {
requires java.desktop;
requires java.logging;
requires org.jfree.svg;
requires org.jfree.pdf;
requires org.jfree.jfreechart;
requires org.jfree.chart3d;
exports com.orsoncharts.demo;
exports org.jfree.pdf.demo;
exports org.jfree.chart.demo2;
}
jfree-demos-2.0/src/main/java/org/ 0000775 0000000 0000000 00000000000 13776557647 0017031 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/java/org/jfree/ 0000775 0000000 0000000 00000000000 13776557647 0020124 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/java/org/jfree/chart/ 0000775 0000000 0000000 00000000000 13776557647 0021225 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/java/org/jfree/chart/demo2/ 0000775 0000000 0000000 00000000000 13776557647 0022233 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/java/org/jfree/chart/demo2/BarChartDemo1.java 0000664 0000000 0000000 00000012113 13776557647 0025450 0 ustar 00root root 0000000 0000000 /* ==================
* BarChartDemo1.java
* ==================
*
* Copyright (c) 2005-2021, Object Refinery Limited.
* All rights reserved.
*
* http://www.jfree.org/jfreechart/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.jfree.chart.demo2;
import java.awt.Color;
import java.awt.Dimension;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.block.BlockBorder;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.BarRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.UIUtils;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.category.DefaultCategoryDataset;
/**
* A simple demonstration application showing how to create a bar chart.
*/
public class BarChartDemo1 extends ApplicationFrame {
private static final long serialVersionUID = 1L;
/**
* Creates a new demo instance.
*
* @param title the frame title.
*/
public BarChartDemo1(String title) {
super(title);
CategoryDataset dataset = createDataset();
JFreeChart chart = createChart(dataset);
ChartPanel chartPanel = new ChartPanel(chart, false);
chartPanel.setFillZoomRectangle(true);
chartPanel.setMouseWheelEnabled(true);
chartPanel.setPreferredSize(new Dimension(500, 270));
setContentPane(chartPanel);
}
/**
* Returns a sample dataset.
*
* @return The dataset.
*/
private static CategoryDataset createDataset() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(7445, "JFreeSVG", "Warm-up");
dataset.addValue(24448, "Batik", "Warm-up");
dataset.addValue(4297, "JFreeSVG", "Test");
dataset.addValue(21022, "Batik", "Test");
return dataset;
}
/**
* Creates a sample chart.
*
* @param dataset the dataset.
*
* @return The chart.
*/
private static JFreeChart createChart(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createBarChart(
"Performance: JFreeSVG vs Batik", null /* x-axis label*/,
"Milliseconds" /* y-axis label */, dataset);
chart.addSubtitle(new TextTitle("Time to generate 1000 charts in SVG "
+ "format (lower bars = better performance)"));
chart.setBackgroundPaint(Color.WHITE);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
// ******************************************************************
// More than 150 demo applications are included with the JFreeChart
// Developer Guide...for more information, see:
//
// > http://www.object-refinery.com/jfreechart/guide.html
//
// ******************************************************************
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
BarRenderer renderer = (BarRenderer) plot.getRenderer();
renderer.setDrawBarOutline(false);
chart.getLegend().setFrame(BlockBorder.NONE);
return chart;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
BarChartDemo1 demo = new BarChartDemo1("JFreeChart: BarChartDemo1.java");
demo.pack();
UIUtils.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
jfree-demos-2.0/src/main/java/org/jfree/chart/demo2/PieChartDemo1.java 0000664 0000000 0000000 00000017462 13776557647 0025475 0 ustar 00root root 0000000 0000000 /* ==================
* PieChartDemo1.java
* ==================
*
* (C) Copyright 2003-2021, by Object Refinery Limited.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.jfree.chart.demo2;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Point;
import java.awt.RadialGradientPaint;
import java.awt.geom.Point2D;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.title.TextTitle;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.HorizontalAlignment;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.chart.ui.UIUtils;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
/**
* A simple demonstration application showing how to create a pie chart using
* data from a {@link DefaultPieDataset}.
*/
public class PieChartDemo1 extends ApplicationFrame {
private static final long serialVersionUID = 1L;
static {
// set a theme using the new shadow generator feature available in
// 1.0.14 - for backwards compatibility it is not enabled by default
ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow",
true));
}
/**
* Default constructor.
*
* @param title the frame title.
*/
public PieChartDemo1(String title) {
super(title);
setContentPane(createDemoPanel());
}
/**
* Creates a sample dataset.
*
* Source: http://www.bbc.co.uk/news/business-15489523
*
* @return A sample dataset.
*/
private static PieDataset createDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Samsung", new Double(27.8));
dataset.setValue("Others", new Double(55.3));
dataset.setValue("Nokia", new Double(16.8));
dataset.setValue("Apple", new Double(17.1));
return dataset;
}
/**
* Creates a chart.
*
* @param dataset the dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart(
"Smart Phones Manufactured / Q3 2011", // chart title
dataset, // data
false, // no legend
true, // tooltips
false // no URL generation
);
// set a custom background for the chart
chart.setBackgroundPaint(new GradientPaint(new Point(0, 0),
new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));
// customise the title position and font
TextTitle t = chart.getTitle();
t.setHorizontalAlignment(HorizontalAlignment.LEFT);
t.setPaint(new Color(240, 240, 240));
t.setFont(new Font("Arial", Font.BOLD, 26));
PiePlot plot = (PiePlot) chart.getPlot();
plot.setBackgroundPaint(null);
plot.setInteriorGap(0.04);
plot.setOutlineVisible(false);
// use gradients and white borders for the section colours
plot.setSectionPaint("Others",
createGradientPaint(new Color(200, 200, 255), Color.BLUE));
plot.setSectionPaint("Samsung",
createGradientPaint(new Color(255, 200, 200), Color.RED));
plot.setSectionPaint("Apple",
createGradientPaint(new Color(200, 255, 200), Color.GREEN));
plot.setSectionPaint("Nokia",
createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
plot.setDefaultSectionOutlinePaint(Color.WHITE);
plot.setSectionOutlinesVisible(true);
plot.setDefaultSectionOutlineStroke(new BasicStroke(2.0f));
// customise the section label appearance
plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
plot.setLabelLinkPaint(Color.WHITE);
plot.setLabelLinkStroke(new BasicStroke(2.0f));
plot.setLabelOutlineStroke(null);
plot.setLabelPaint(Color.WHITE);
plot.setLabelBackgroundPaint(null);
// add a subtitle giving the data source
TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
new Font("Courier New", Font.PLAIN, 12));
source.setPaint(Color.WHITE);
source.setPosition(RectangleEdge.BOTTOM);
source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
chart.addSubtitle(source);
return chart;
}
/**
* A utility method for creating gradient paints.
*
* @param c1 color 1.
* @param c2 color 2.
*
* @return A radial gradient paint.
*/
private static RadialGradientPaint createGradientPaint(Color c1, Color c2) {
Point2D center = new Point2D.Float(0, 0);
float radius = 200;
float[] dist = {0.0f, 1.0f};
return new RadialGradientPaint(center, radius, dist,
new Color[] {c1, c2});
}
/**
* Creates a panel for the demo (used by SuperDemo.java).
*
* @return A panel.
*/
public static JPanel createDemoPanel() {
JFreeChart chart = createChart(createDataset());
chart.setPadding(new RectangleInsets(4, 8, 2, 2));
ChartPanel panel = new ChartPanel(chart, false);
panel.setMouseWheelEnabled(true);
panel.setPreferredSize(new Dimension(600, 300));
return panel;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
// ******************************************************************
// More than 150 demo applications are included with the JFreeChart
// Developer Guide...for more information, see:
//
// > http://www.object-refinery.com/jfreechart/guide.html
//
// ******************************************************************
PieChartDemo1 demo = new PieChartDemo1("JFreeChart: Pie Chart Demo 1");
demo.pack();
UIUtils.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
jfree-demos-2.0/src/main/java/org/jfree/chart/demo2/TimeSeriesChartDemo1.java 0000664 0000000 0000000 00000017024 13776557647 0027023 0 ustar 00root root 0000000 0000000 /* =========================
* TimeSeriesChartDemo1.java
* =========================
*
* (C) Copyright 2003-2021, by Object Refinery Limited.
*
* Project Info: http://www.jfree.org/jfreechart/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.jfree.chart.demo2;
import java.awt.Color;
import java.text.SimpleDateFormat;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.ui.ApplicationFrame;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.chart.ui.UIUtils;
import org.jfree.data.time.Month;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
/**
* An example of a time series chart create using JFreeChart. For the most
* part, default settings are used, except that the renderer is modified to
* show filled shapes (as well as lines) at each data point.
*/
public class TimeSeriesChartDemo1 extends ApplicationFrame {
private static final long serialVersionUID = 1L;
/**
* A demonstration application showing how to create a simple time series
* chart. This example uses monthly data.
*
* @param title the frame title.
*/
public TimeSeriesChartDemo1(String title) {
super(title);
ChartPanel chartPanel = (ChartPanel) createDemoPanel();
chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
setContentPane(chartPanel);
}
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"Legal & General Unit Trust Prices", // title
"Date", // x-axis label
"Price Per Unit", // y-axis label
dataset);
chart.setBackgroundPaint(Color.WHITE);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setBackgroundPaint(Color.LIGHT_GRAY);
plot.setDomainGridlinePaint(Color.WHITE);
plot.setRangeGridlinePaint(Color.WHITE);
plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setDefaultShapesVisible(true);
renderer.setDefaultShapesFilled(true);
renderer.setDrawSeriesLineAsPath(true);
}
DateAxis axis = (DateAxis) plot.getDomainAxis();
axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy"));
return chart;
}
/**
* Creates a dataset, consisting of two series of monthly data.
*
* @return The dataset.
*/
private static XYDataset createDataset() {
TimeSeries s1 = new TimeSeries("L&G European Index Trust");
s1.add(new Month(2, 2001), 181.8);
s1.add(new Month(3, 2001), 167.3);
s1.add(new Month(4, 2001), 153.8);
s1.add(new Month(5, 2001), 167.6);
s1.add(new Month(6, 2001), 158.8);
s1.add(new Month(7, 2001), 148.3);
s1.add(new Month(8, 2001), 153.9);
s1.add(new Month(9, 2001), 142.7);
s1.add(new Month(10, 2001), 123.2);
s1.add(new Month(11, 2001), 131.8);
s1.add(new Month(12, 2001), 139.6);
s1.add(new Month(1, 2002), 142.9);
s1.add(new Month(2, 2002), 138.7);
s1.add(new Month(3, 2002), 137.3);
s1.add(new Month(4, 2002), 143.9);
s1.add(new Month(5, 2002), 139.8);
s1.add(new Month(6, 2002), 137.0);
s1.add(new Month(7, 2002), 132.8);
TimeSeries s2 = new TimeSeries("L&G UK Index Trust");
s2.add(new Month(2, 2001), 129.6);
s2.add(new Month(3, 2001), 123.2);
s2.add(new Month(4, 2001), 117.2);
s2.add(new Month(5, 2001), 124.1);
s2.add(new Month(6, 2001), 122.6);
s2.add(new Month(7, 2001), 119.2);
s2.add(new Month(8, 2001), 116.5);
s2.add(new Month(9, 2001), 112.7);
s2.add(new Month(10, 2001), 101.5);
s2.add(new Month(11, 2001), 106.1);
s2.add(new Month(12, 2001), 110.3);
s2.add(new Month(1, 2002), 111.7);
s2.add(new Month(2, 2002), 111.0);
s2.add(new Month(3, 2002), 109.6);
s2.add(new Month(4, 2002), 113.2);
s2.add(new Month(5, 2002), 111.6);
s2.add(new Month(6, 2002), 108.8);
s2.add(new Month(7, 2002), 101.6);
// ******************************************************************
// More than 150 demo applications are included with the JFreeChart
// Developer Guide...for more information, see:
//
// > http://www.object-refinery.com/jfreechart/guide.html
//
// ******************************************************************
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
return dataset;
}
/**
* Creates a panel for the demo (used by SuperDemo.java).
*
* @return A panel.
*/
public static JPanel createDemoPanel() {
JFreeChart chart = createChart(createDataset());
ChartPanel panel = new ChartPanel(chart, false);
panel.setFillZoomRectangle(true);
panel.setMouseWheelEnabled(true);
return panel;
}
/**
* Starting point for the demonstration application.
*
* @param args ignored.
*/
public static void main(String[] args) {
TimeSeriesChartDemo1 demo = new TimeSeriesChartDemo1(
"Time Series Chart Demo 1");
demo.pack();
UIUtils.centerFrameOnScreen(demo);
demo.setVisible(true);
}
}
jfree-demos-2.0/src/main/java/org/jfree/chart/demo2/package.html 0000664 0000000 0000000 00000000706 13776557647 0024517 0 ustar 00root root 0000000 0000000
Some basic demos to get you started. A large range of demo applications is
available for download (including source code) with the JFreeChart Developer
Guide. For more information, see:
http://www.object-refinery.com/jfreechart/guide.html
jfree-demos-2.0/src/main/java/org/jfree/graphics2d/ 0000775 0000000 0000000 00000000000 13776557647 0022152 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/java/org/jfree/graphics2d/BufferedImageDemo.java 0000664 0000000 0000000 00000005106 13776557647 0026311 0 ustar 00root root 0000000 0000000 /* ======================
* BufferedImageDemo.java
* ======================
*
* (C)opyright 2013-2017, by Object Refinery Limited. All rights reserved.
*
* Project Info: http://www.jfree.org/jfreesvg/index.html
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*
* [Oracle and Java are registered trademarks of Oracle and/or its affiliates.
* Other names may be trademarks of their respective owners.]
*
* If you do not wish to be bound by the terms of the AGPL, an alternative
* commercial license can be purchased. For details, please see visit the
* JFreeSVG home page:
*
* http://www.jfree.org/jfreesvg
*
*/
package org.jfree.graphics2d;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
/**
* A basic test class for writing to a BufferedImage via Graphics2D. This is
* used as a reference implementation (we can assume that the output is correct
* for Java2D, then compare how it looks when using JFreeSVG or OrsonPDF).
*/
public class BufferedImageDemo {
/**
* Starting point for the demo.
*
* @param args ignored.
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
BufferedImage image = new BufferedImage(600, 400,
BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = image.createGraphics();
ImageIcon icon = new ImageIcon(BufferedImageDemo.class.getResource("jfree_chart_1.jpg"));
g2.rotate(Math.PI / 12);
g2.setStroke(new BasicStroke(2.0f));
g2.setPaint(Color.WHITE);
g2.fill(new Rectangle(0, 0, 600, 400));
g2.setPaint(Color.RED);
g2.draw(new Rectangle(0, 0, 600, 400));
g2.drawImage(icon.getImage(), 10, 20, null);
ImageIO.write(image, "png", new File("image-test.png"));
}
}
jfree-demos-2.0/src/main/java/org/jfree/pdf/ 0000775 0000000 0000000 00000000000 13776557647 0020675 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/java/org/jfree/pdf/demo/ 0000775 0000000 0000000 00000000000 13776557647 0021621 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/java/org/jfree/pdf/demo/PDFBarChartDemo1.java 0000664 0000000 0000000 00000013632 13776557647 0025377 0 ustar 00root root 0000000 0000000 /* =====================================================================
* JFreePDF : a fast, light-weight PDF library for the Java(tm) platform
* =====================================================================
*
* (C)opyright 2013-2021, by Object Refinery Limited. All rights reserved.
*
* Project Info: http://www.object-refinery.com/orsonpdf/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Note that the above terms apply to the demo source only, and not the
* OrsonPDF library.
*
*/
package org.jfree.pdf.demo;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtils;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.StatisticalBarRenderer;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;
import org.jfree.chart.ui.TextAnchor;
import org.jfree.pdf.PDFDocument;
import org.jfree.pdf.PDFGraphics2D;
import org.jfree.pdf.Page;
/**
* A demo for PDF output of a bar chart.
*/
public class PDFBarChartDemo1 {
/**
* Creates a sample dataset.
*
* @return The dataset.
*/
private static CategoryDataset createDataset() {
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
dataset.add(10.0, 2.4, "Row 1", "Column 1");
dataset.add(15.0, 4.4, "Row 1", "Column 2");
dataset.add(13.0, 2.1, "Row 1", "Column 3");
dataset.add(7.0, 1.3, "Row 1", "Column 4");
dataset.add(22.0, 2.4, "Row 2", "Column 1");
dataset.add(18.0, 4.4, "Row 2", "Column 2");
dataset.add(28.0, 2.1, "Row 2", "Column 3");
dataset.add(17.0, 1.3, "Row 2", "Column 4");
return dataset;
}
/**
* Creates a sample chart.
*
* @param dataset a dataset.
*
* @return The chart.
*/
private static JFreeChart createChart(CategoryDataset dataset) {
// create the chart...
JFreeChart chart = ChartFactory.createLineChart(
"Statistical Bar Chart Demo 1", "Type", "Value", dataset);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
// customise the range axis...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
rangeAxis.setAutoRangeIncludesZero(false);
// customise the renderer...
StatisticalBarRenderer renderer = new StatisticalBarRenderer();
renderer.setDrawBarOutline(false);
renderer.setErrorIndicatorPaint(Color.BLACK);
renderer.setIncludeBaseInRange(false);
plot.setRenderer(renderer);
// ensure the current theme is applied to the renderer just added
ChartUtils.applyCurrentTheme(chart);
renderer.setDefaultItemLabelGenerator(
new StandardCategoryItemLabelGenerator());
renderer.setDefaultItemLabelsVisible(true);
renderer.setDefaultItemLabelPaint(Color.YELLOW);
renderer.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER));
// set up gradient paints for series...
GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.BLUE,
0.0f, 0.0f, new Color(0, 0, 64));
GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.GREEN,
0.0f, 0.0f, new Color(0, 64, 0));
renderer.setSeriesPaint(0, gp0);
renderer.setSeriesPaint(1, gp1);
return chart;
}
/**
* Starting point for the demo.
*
* @param args ignored.
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
JFreeChart chart = createChart(createDataset());
PDFDocument pdfDoc = new PDFDocument();
pdfDoc.setTitle("PDFBarChartDemo1");
pdfDoc.setAuthor("Object Refinery Limited");
Page page = pdfDoc.createPage(new Rectangle(612, 468));
PDFGraphics2D g2 = page.getGraphics2D();
chart.draw(g2, new Rectangle(0, 0, 612, 468));
pdfDoc.writeToFile(new File("PDFBarChartDemo1.pdf"));
}
}
jfree-demos-2.0/src/main/java/org/jfree/pdf/demo/PDFPieChartDemo1.java 0000664 0000000 0000000 00000015544 13776557647 0025414 0 ustar 00root root 0000000 0000000 /* =====================================================================
* JFreePDF : a fast, light-weight PDF library for the Java(tm) platform
* =====================================================================
*
* (C)opyright 2013-2021, by Object Refinery Limited. All rights reserved.
*
* Project Info: http://www.object-refinery.com/orsonpdf/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Note that the above terms apply to the demo source only, and not the
* OrsonPDF library.
*
*/
package org.jfree.pdf.demo;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Point;
import java.awt.RadialGradientPaint;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.chart.ui.HorizontalAlignment;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.pdf.PDFDocument;
import org.jfree.pdf.PDFGraphics2D;
import org.jfree.pdf.Page;
/**
* A demo/test for a pie chart.
*/
public class PDFPieChartDemo1 {
/**
* Creates a sample dataset.
*
* Source: http://www.bbc.co.uk/news/business-15489523
*
* @return A sample dataset.
*/
private static PieDataset createDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Samsung", new Double(27.8));
dataset.setValue("Others", new Double(55.3));
dataset.setValue("Nokia", new Double(16.8));
dataset.setValue("Apple", new Double(17.1));
return dataset;
}
/**
* Creates a chart.
*
* @param dataset the dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart(
"Smart Phones Manufactured / Q3 2011", dataset, false, false,
false);
chart.setBackgroundPaint(new GradientPaint(new Point(0, 0),
new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY));
// customise the title position and font
TextTitle t = chart.getTitle();
t.setHorizontalAlignment(HorizontalAlignment.LEFT);
t.setPaint(new Color(240, 240, 240));
t.setFont(new Font("Arial", Font.BOLD, 26));
PiePlot plot = (PiePlot) chart.getPlot();
plot.setBackgroundPaint(null);
plot.setInteriorGap(0.04);
plot.setOutlineVisible(false);
plot.setShadowPaint(null);
plot.setLabelShadowPaint(null);
// use gradients and white borders for the section colours
plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
plot.setDefaultSectionOutlinePaint(Color.WHITE);
plot.setSectionOutlinesVisible(true);
BasicStroke bs = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER, 1.0f);
plot.setDefaultSectionOutlineStroke(new BasicStroke(2.0f));
// customise the section label appearance
plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
plot.setLabelLinkPaint(Color.WHITE);
plot.setLabelLinkStroke(new BasicStroke(2.0f));
plot.setLabelOutlineStroke(null);
plot.setLabelPaint(Color.WHITE);
plot.setLabelBackgroundPaint(null);
// add a subtitle giving the data source
TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
new Font("Courier New", Font.PLAIN, 12));
source.setPaint(Color.WHITE);
source.setPosition(RectangleEdge.BOTTOM);
source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
chart.addSubtitle(source);
return chart;
}
/**
* A utility method for creating gradient paints.
*
* @param c1 color 1.
* @param c2 color 2.
*
* @return A radial gradient paint.
*/
private static RadialGradientPaint createGradientPaint(Color c1, Color c2) {
Point2D center = new Point2D.Float(0, 0);
float radius = 200;
float[] dist = {0.0f, 1.0f};
return new RadialGradientPaint(center, radius, dist,
new Color[] {c1, c2});
}
/**
* Starting point for the demo.
*
* @param args ignored.
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
JFreeChart chart = createChart(createDataset());
PDFDocument pdfDoc = new PDFDocument();
pdfDoc.setTitle("PDFPieChartDemo1");
pdfDoc.setAuthor("Object Refinery Limited");
Page page = pdfDoc.createPage(new Rectangle(612, 468));
PDFGraphics2D g2 = page.getGraphics2D();
g2.setRenderingHint(JFreeChart.KEY_SUPPRESS_SHADOW_GENERATION, true);
chart.draw(g2, new Rectangle(0, 0, 612, 468));
File f = new File("PDFPieChartDemo1.pdf");
pdfDoc.writeToFile(f);
}
}
jfree-demos-2.0/src/main/java/org/jfree/pdf/demo/PDFSwingComponentDemo1.java 0000664 0000000 0000000 00000006535 13776557647 0026667 0 ustar 00root root 0000000 0000000 /* =====================================================================
* JFreePDF : a fast, light-weight PDF library for the Java(tm) platform
* =====================================================================
*
* (C)opyright 2013-2021, by Object Refinery Limited. All rights reserved.
*
* Project Info: http://www.object-refinery.com/orsonpdf/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Note that the above terms apply to the demo source only, and not the
* OrsonPDF library.
*
*/
package org.jfree.pdf.demo;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JComponent;
import org.jfree.pdf.PDFDocument;
import org.jfree.pdf.PDFGraphics2D;
import org.jfree.pdf.PDFHints;
import org.jfree.pdf.Page;
/**
* Renders a Swing component to a PDF file.
*/
public class PDFSwingComponentDemo1 extends JFrame {
public PDFSwingComponentDemo1(String title) {
super(title);
JPanel content = new JPanel(new BorderLayout());
content.add(new JButton("Hello"));
content.add(new JLabel("This is a label"), BorderLayout.EAST);
setContentPane(content);
}
public static void main(String[] args) {
PDFSwingComponentDemo1 demo = new PDFSwingComponentDemo1(
"PDFSwingComponentDemo1.java");
demo.pack();
demo.setVisible(true);
PDFDocument pdf = new PDFDocument();
JComponent c = (JComponent) demo.getContentPane();
Page page = pdf.createPage(new Rectangle(c.getWidth(), c.getHeight()));
PDFGraphics2D g2 = page.getGraphics2D();
g2.setRenderingHint(PDFHints.KEY_DRAW_STRING_TYPE, PDFHints.VALUE_DRAW_STRING_TYPE_VECTOR);
demo.getContentPane().paint(g2);
pdf.writeToFile(new File("PDFSwingComponentDemo1.pdf"));
}
}
jfree-demos-2.0/src/main/java/org/jfree/pdf/demo/PDFSwingComponentDemo2.java 0000664 0000000 0000000 00000007016 13776557647 0026663 0 ustar 00root root 0000000 0000000 /* =====================================================================
* JFreePDF : a fast, light-weight PDF library for the Java(tm) platform
* =====================================================================
*
* (C)opyright 2013-2021, by Object Refinery Limited. All rights reserved.
*
* Project Info: http://www.object-refinery.com/orsonpdf/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Note that the above terms apply to the demo source only, and not the
* OrsonPDF library.
*
*/
package org.jfree.pdf.demo;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JComponent;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import org.jfree.pdf.PDFDocument;
import org.jfree.pdf.PDFGraphics2D;
import org.jfree.pdf.Page;
/**
* Renders a Swing component to a PDF file, but via an image.
*/
public class PDFSwingComponentDemo2 extends JFrame {
public PDFSwingComponentDemo2(String title) {
super(title);
JPanel content = new JPanel(new BorderLayout());
content.add(new JButton("Hello"));
content.add(new JLabel("This is a label"), BorderLayout.EAST);
setContentPane(content);
}
public static void main(String[] args) {
PDFSwingComponentDemo1 demo = new PDFSwingComponentDemo1(
"PDFSwingComponentDemo1.java");
demo.pack();
demo.setVisible(true);
PDFDocument pdf = new PDFDocument();
JComponent c = (JComponent) demo.getContentPane();
int w = c.getWidth();
int h = c.getHeight();
BufferedImage img = new BufferedImage(w, h,
BufferedImage.TYPE_INT_ARGB);
Graphics2D img2 = img.createGraphics();
demo.getContentPane().paint(img2);
Page page = pdf.createPage(new Rectangle(w, h));
PDFGraphics2D g2 = page.getGraphics2D();
g2.drawImage(img, 0, 0, null);
pdf.writeToFile(new File("PDFSwingComponentDemo2.pdf"));
}
}
jfree-demos-2.0/src/main/java/org/jfree/pdf/demo/PDFTimeSeriesChartDemo1.java 0000664 0000000 0000000 00000045214 13776557647 0026745 0 ustar 00root root 0000000 0000000 /* =====================================================================
* JFreePDF : a fast, light-weight PDF library for the Java(tm) platform
* =====================================================================
*
* (C)opyright 2013-2021, by Object Refinery Limited. All rights reserved.
*
* Project Info: http://www.object-refinery.com/orsonpdf/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Note that the above terms apply to the demo source only, and not the
* OrsonPDF library.
*
*/
package org.jfree.pdf.demo;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.block.BlockBorder;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.time.Month;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
import org.jfree.chart.ui.HorizontalAlignment;
import org.jfree.pdf.PDFDocument;
import org.jfree.pdf.PDFGraphics2D;
import org.jfree.pdf.PDFHints;
import org.jfree.pdf.Page;
/**
* A demo for PDF output of a time series chart.
*/
public class PDFTimeSeriesChartDemo1 {
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"International Coffee Organisation : Coffee Prices",
null, "US cents/lb", dataset);
String fontName = "Palatino";
chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
chart.addSubtitle(new TextTitle(
"Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf",
new Font(fontName, Font.PLAIN, 14)));
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(false);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
plot.getDomainAxis().setLowerMargin(0.0);
plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
chart.getLegend().setFrame(BlockBorder.NONE);
chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setDefaultShapesVisible(false);
renderer.setDrawSeriesLineAsPath(true);
// set the default stroke for all series
renderer.setAutoPopulateSeriesStroke(false);
renderer.setDefaultStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_BEVEL), false);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesPaint(1, new Color(24, 123, 58));
renderer.setSeriesPaint(2, new Color(149, 201, 136));
renderer.setSeriesPaint(3, new Color(1, 62, 29));
renderer.setSeriesPaint(4, new Color(81, 176, 86));
renderer.setSeriesPaint(5, new Color(0, 55, 122));
renderer.setSeriesPaint(6, new Color(0, 92, 165));
}
return chart;
}
/**
* Creates a dataset, consisting of two series of monthly data.
*
* @return the dataset.
*/
private static XYDataset createDataset() {
TimeSeries s1 = new TimeSeries("Indicator Price");
s1.add(new Month(1, 2010), 126.80);
s1.add(new Month(2, 2010), 123.37);
s1.add(new Month(3, 2010), 125.30);
s1.add(new Month(4, 2010), 126.89);
s1.add(new Month(5, 2010), 128.10);
s1.add(new Month(6, 2010), 142.20);
s1.add(new Month(7, 2010), 153.41);
s1.add(new Month(8, 2010), 157.46);
s1.add(new Month(9, 2010), 163.61);
s1.add(new Month(10, 2010), 161.56);
s1.add(new Month(11, 2010), 173.90);
s1.add(new Month(12, 2010), 184.26);
s1.add(new Month(1, 2011), 197.35);
s1.add(new Month(2, 2011), 216.03);
s1.add(new Month(3, 2011), 224.33);
s1.add(new Month(4, 2011), 231.24);
s1.add(new Month(5, 2011), 227.97);
s1.add(new Month(6, 2011), 215.58);
s1.add(new Month(7, 2011), 210.36);
s1.add(new Month(8, 2011), 212.19);
s1.add(new Month(9, 2011), 213.04);
s1.add(new Month(10, 2011), 193.90);
s1.add(new Month(11, 2011), 193.66);
s1.add(new Month(12, 2011), 189.02);
s1.add(new Month(1, 2012), 188.90);
s1.add(new Month(2, 2012), 182.29);
s1.add(new Month(3, 2012), 167.77);
s1.add(new Month(4, 2012), 160.46);
s1.add(new Month(5, 2012), 157.68);
s1.add(new Month(6, 2012), 145.31);
s1.add(new Month(7, 2012), 159.07);
s1.add(new Month(8, 2012), 148.50);
s1.add(new Month(9, 2012), 151.28);
s1.add(new Month(10, 2012), 147.12);
s1.add(new Month(11, 2012), 136.35);
s1.add(new Month(12, 2012), 131.31);
s1.add(new Month(1, 2013), 135.38);
s1.add(new Month(2, 2013), 131.51);
s1.add(new Month(3, 2013), 131.38);
TimeSeries s2 = new TimeSeries("Columbian Milds");
s2.add(new Month(1, 2010), 207.51);
s2.add(new Month(2, 2010), 204.71);
s2.add(new Month(3, 2010), 205.71);
s2.add(new Month(4, 2010), 200.00);
s2.add(new Month(5, 2010), 200.54);
s2.add(new Month(6, 2010), 224.49);
s2.add(new Month(7, 2010), 235.52);
s2.add(new Month(8, 2010), 243.98);
s2.add(new Month(9, 2010), 247.77);
s2.add(new Month(10, 2010), 230.02);
s2.add(new Month(11, 2010), 244.02);
s2.add(new Month(12, 2010), 261.97);
s2.add(new Month(1, 2011), 279.88);
s2.add(new Month(2, 2011), 296.44);
s2.add(new Month(3, 2011), 300.68);
s2.add(new Month(4, 2011), 312.95);
s2.add(new Month(5, 2011), 302.17);
s2.add(new Month(6, 2011), 287.95);
s2.add(new Month(7, 2011), 285.21);
s2.add(new Month(8, 2011), 286.97);
s2.add(new Month(9, 2011), 287.54);
s2.add(new Month(10, 2011), 257.66);
s2.add(new Month(11, 2011), 256.99);
s2.add(new Month(12, 2011), 251.60);
s2.add(new Month(1, 2012), 255.91);
s2.add(new Month(2, 2012), 244.14);
s2.add(new Month(3, 2012), 222.84);
s2.add(new Month(4, 2012), 214.46);
s2.add(new Month(5, 2012), 207.32);
s2.add(new Month(6, 2012), 184.67);
s2.add(new Month(7, 2012), 202.56);
s2.add(new Month(8, 2012), 187.14);
s2.add(new Month(9, 2012), 190.10);
s2.add(new Month(10, 2012), 181.39);
s2.add(new Month(11, 2012), 170.08);
s2.add(new Month(12, 2012), 164.40);
s2.add(new Month(1, 2013), 169.19);
s2.add(new Month(2, 2013), 161.70);
s2.add(new Month(3, 2013), 161.53);
TimeSeries s3 = new TimeSeries("Other Milds");
s3.add(new Month(1, 2010), 158.90);
s3.add(new Month(2, 2010), 157.86);
s3.add(new Month(3, 2010), 164.50);
s3.add(new Month(4, 2010), 169.55);
s3.add(new Month(5, 2010), 173.38);
s3.add(new Month(6, 2010), 190.90);
s3.add(new Month(7, 2010), 203.21);
s3.add(new Month(8, 2010), 211.59);
s3.add(new Month(9, 2010), 222.71);
s3.add(new Month(10, 2010), 217.64);
s3.add(new Month(11, 2010), 233.48);
s3.add(new Month(12, 2010), 248.17);
s3.add(new Month(1, 2011), 263.77);
s3.add(new Month(2, 2011), 287.89);
s3.add(new Month(3, 2011), 292.07);
s3.add(new Month(4, 2011), 300.12);
s3.add(new Month(5, 2011), 291.09);
s3.add(new Month(6, 2011), 274.98);
s3.add(new Month(7, 2011), 268.02);
s3.add(new Month(8, 2011), 270.44);
s3.add(new Month(9, 2011), 274.88);
s3.add(new Month(10, 2011), 247.82);
s3.add(new Month(11, 2011), 245.09);
s3.add(new Month(12, 2011), 236.71);
s3.add(new Month(1, 2012), 237.21);
s3.add(new Month(2, 2012), 224.16);
s3.add(new Month(3, 2012), 201.26);
s3.add(new Month(4, 2012), 191.45);
s3.add(new Month(5, 2012), 184.65);
s3.add(new Month(6, 2012), 168.69);
s3.add(new Month(7, 2012), 190.45);
s3.add(new Month(8, 2012), 174.82);
s3.add(new Month(9, 2012), 178.98);
s3.add(new Month(10, 2012), 173.32);
s3.add(new Month(11, 2012), 159.91);
s3.add(new Month(12, 2012), 152.74);
s3.add(new Month(1, 2013), 157.29);
s3.add(new Month(2, 2013), 149.46);
s3.add(new Month(3, 2013), 149.78);
TimeSeries s4 = new TimeSeries("Brazilian Naturals");
s4.add(new Month(1, 2010), 131.67);
s4.add(new Month(2, 2010), 124.57);
s4.add(new Month(3, 2010), 126.21);
s4.add(new Month(4, 2010), 126.07);
s4.add(new Month(5, 2010), 127.45);
s4.add(new Month(6, 2010), 143.20);
s4.add(new Month(7, 2010), 156.87);
s4.add(new Month(8, 2010), 163.21);
s4.add(new Month(9, 2010), 175.15);
s4.add(new Month(10, 2010), 175.38);
s4.add(new Month(11, 2010), 190.62);
s4.add(new Month(12, 2010), 204.25);
s4.add(new Month(1, 2011), 219.77);
s4.add(new Month(2, 2011), 247.00);
s4.add(new Month(3, 2011), 260.98);
s4.add(new Month(4, 2011), 273.40);
s4.add(new Month(5, 2011), 268.66);
s4.add(new Month(6, 2011), 250.59);
s4.add(new Month(7, 2011), 245.69);
s4.add(new Month(8, 2011), 249.83);
s4.add(new Month(9, 2011), 255.64);
s4.add(new Month(10, 2011), 234.28);
s4.add(new Month(11, 2011), 236.75);
s4.add(new Month(12, 2011), 228.79);
s4.add(new Month(1, 2012), 228.21);
s4.add(new Month(2, 2012), 215.40);
s4.add(new Month(3, 2012), 192.03);
s4.add(new Month(4, 2012), 180.90);
s4.add(new Month(5, 2012), 174.17);
s4.add(new Month(6, 2012), 156.17);
s4.add(new Month(7, 2012), 175.98);
s4.add(new Month(8, 2012), 160.05);
s4.add(new Month(9, 2012), 166.53);
s4.add(new Month(10, 2012), 161.20);
s4.add(new Month(11, 2012), 148.25);
s4.add(new Month(12, 2012), 140.69);
s4.add(new Month(1, 2013), 145.17);
s4.add(new Month(2, 2013), 136.63);
s4.add(new Month(3, 2013), 133.61);
TimeSeries s5 = new TimeSeries("Robustas");
s5.add(new Month(1, 2010), 69.92);
s5.add(new Month(2, 2010), 67.88);
s5.add(new Month(3, 2010), 67.25);
s5.add(new Month(4, 2010), 71.59);
s5.add(new Month(5, 2010), 70.70);
s5.add(new Month(6, 2010), 76.92);
s5.add(new Month(7, 2010), 85.27);
s5.add(new Month(8, 2010), 82.68);
s5.add(new Month(9, 2010), 81.28);
s5.add(new Month(10, 2010), 85.27);
s5.add(new Month(11, 2010), 92.04);
s5.add(new Month(12, 2010), 94.09);
s5.add(new Month(1, 2011), 101.09);
s5.add(new Month(2, 2011), 109.35);
s5.add(new Month(3, 2011), 118.13);
s5.add(new Month(4, 2011), 117.37);
s5.add(new Month(5, 2011), 121.98);
s5.add(new Month(6, 2011), 117.95);
s5.add(new Month(7, 2011), 112.73);
s5.add(new Month(8, 2011), 112.07);
s5.add(new Month(9, 2011), 106.06);
s5.add(new Month(10, 2011), 98.10);
s5.add(new Month(11, 2011), 97.24);
s5.add(new Month(12, 2011), 98.41);
s5.add(new Month(1, 2012), 96.72);
s5.add(new Month(2, 2012), 101.93);
s5.add(new Month(3, 2012), 103.57);
s5.add(new Month(4, 2012), 101.80);
s5.add(new Month(5, 2012), 106.88);
s5.add(new Month(6, 2012), 105.70);
s5.add(new Month(7, 2012), 107.06);
s5.add(new Month(8, 2012), 106.52);
s5.add(new Month(9, 2012), 104.95);
s5.add(new Month(10, 2012), 104.47);
s5.add(new Month(11, 2012), 97.67);
s5.add(new Month(12, 2012), 96.59);
s5.add(new Month(1, 2013), 99.69);
s5.add(new Month(2, 2013), 104.03);
s5.add(new Month(3, 2013), 106.26);
TimeSeries s6 = new TimeSeries("Futures (London)");
s6.add(new Month(1, 2010), 62.66);
s6.add(new Month(2, 2010), 60.37);
s6.add(new Month(3, 2010), 58.64);
s6.add(new Month(4, 2010), 62.21);
s6.add(new Month(5, 2010), 62.46);
s6.add(new Month(6, 2010), 69.72);
s6.add(new Month(7, 2010), 78.17);
s6.add(new Month(8, 2010), 78.42);
s6.add(new Month(9, 2010), 75.87);
s6.add(new Month(10, 2010), 80.08);
s6.add(new Month(11, 2010), 86.40);
s6.add(new Month(12, 2010), 88.70);
s6.add(new Month(1, 2011), 96.02);
s6.add(new Month(2, 2011), 104.53);
s6.add(new Month(3, 2011), 111.36);
s6.add(new Month(4, 2011), 111.34);
s6.add(new Month(5, 2011), 116.76);
s6.add(new Month(6, 2011), 110.51);
s6.add(new Month(7, 2011), 103.36);
s6.add(new Month(8, 2011), 102.71);
s6.add(new Month(9, 2011), 96.10);
s6.add(new Month(10, 2011), 88.64);
s6.add(new Month(11, 2011), 85.78);
s6.add(new Month(12, 2011), 87.65);
s6.add(new Month(1, 2012), 84.19);
s6.add(new Month(2, 2012), 88.69);
s6.add(new Month(3, 2012), 91.37);
s6.add(new Month(4, 2012), 91.81);
s6.add(new Month(5, 2012), 96.82);
s6.add(new Month(6, 2012), 94.75);
s6.add(new Month(7, 2012), 96.14);
s6.add(new Month(8, 2012), 96.12);
s6.add(new Month(9, 2012), 94.65);
s6.add(new Month(10, 2012), 94.66);
s6.add(new Month(11, 2012), 87.32);
s6.add(new Month(12, 2012), 85.94);
s6.add(new Month(1, 2013), 88.85);
s6.add(new Month(2, 2013), 94.41);
s6.add(new Month(3, 2013), 97.22);
TimeSeries s7 = new TimeSeries("Futures (New York)");
s7.add(new Month(1, 2010), 142.76);
s7.add(new Month(2, 2010), 134.35);
s7.add(new Month(3, 2010), 134.97);
s7.add(new Month(4, 2010), 135.12);
s7.add(new Month(5, 2010), 135.81);
s7.add(new Month(6, 2010), 152.36);
s7.add(new Month(7, 2010), 165.23);
s7.add(new Month(8, 2010), 175.10);
s7.add(new Month(9, 2010), 187.80);
s7.add(new Month(10, 2010), 190.43);
s7.add(new Month(11, 2010), 206.92);
s7.add(new Month(12, 2010), 221.51);
s7.add(new Month(1, 2011), 238.05);
s7.add(new Month(2, 2011), 261.41);
s7.add(new Month(3, 2011), 274.10);
s7.add(new Month(4, 2011), 285.58);
s7.add(new Month(5, 2011), 277.72);
s7.add(new Month(6, 2011), 262.52);
s7.add(new Month(7, 2011), 255.90);
s7.add(new Month(8, 2011), 260.39);
s7.add(new Month(9, 2011), 261.39);
s7.add(new Month(10, 2011), 236.74);
s7.add(new Month(11, 2011), 235.25);
s7.add(new Month(12, 2011), 227.23);
s7.add(new Month(1, 2012), 227.50);
s7.add(new Month(2, 2012), 212.09);
s7.add(new Month(3, 2012), 188.78);
s7.add(new Month(4, 2012), 181.75);
s7.add(new Month(5, 2012), 176.50);
s7.add(new Month(6, 2012), 159.93);
s7.add(new Month(7, 2012), 183.20);
s7.add(new Month(8, 2012), 169.77);
s7.add(new Month(9, 2012), 175.36);
s7.add(new Month(10, 2012), 170.43);
s7.add(new Month(11, 2012), 155.72);
s7.add(new Month(12, 2012), 149.58);
s7.add(new Month(1, 2013), 154.28);
s7.add(new Month(2, 2013), 144.89);
s7.add(new Month(3, 2013), 141.43);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
dataset.addSeries(s3);
dataset.addSeries(s4);
dataset.addSeries(s5);
dataset.addSeries(s6);
dataset.addSeries(s7);
return dataset;
}
/**
* Starting point for the demo.
*
* @param args ignored.
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
JFreeChart chart = createChart(createDataset());
PDFDocument pdfDoc = new PDFDocument();
pdfDoc.setTitle("PDFTimeSeriesChartDemo1");
pdfDoc.setAuthor("Object Refinery Limited");
Page page = pdfDoc.createPage(new Rectangle(612, 468));
PDFGraphics2D g2 = page.getGraphics2D();
g2.setRenderingHint(PDFHints.KEY_DRAW_STRING_TYPE,
PDFHints.VALUE_DRAW_STRING_TYPE_VECTOR);
chart.draw(g2, new Rectangle(0, 0, 612, 468));
File f = new File("PDFTimeSeriesChartDemo1.pdf");
pdfDoc.writeToFile(f);
}
}
jfree-demos-2.0/src/main/java/org/jfree/pdf/demo/SwingUIToPDFDemo.java 0000664 0000000 0000000 00000010543 13776557647 0025456 0 ustar 00root root 0000000 0000000 /* =====================================================================
* JFreePDF : a fast, light-weight PDF library for the Java(tm) platform
* =====================================================================
*
* (C)opyright 2013-2017, by Object Refinery Limited. All rights reserved.
*
* Project Info: http://www.object-refinery.com/orsonpdf/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Note that the above terms apply to the demo source only, and not the
* OrsonPDF library.
*
*/
package org.jfree.pdf.demo;
import java.awt.BorderLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import org.jfree.pdf.PDFDocument;
import org.jfree.pdf.PDFGraphics2D;
import org.jfree.pdf.PDFHints;
import org.jfree.pdf.Page;
/**
* This demo shows how to export a Swing UI to PDF.
*/
public class SwingUIToPDFDemo extends JFrame implements ActionListener {
public SwingUIToPDFDemo(String title) {
super(title);
add(createContent());
}
private JComponent createContent() {
JPanel content = new JPanel(new BorderLayout());
JTabbedPane tabs = new JTabbedPane();
tabs.add("Tab 1", new JButton("First Tab"));
tabs.add("Tab 2", new JButton("Second Tab"));
JButton button = new JButton("Save to PDF");
button.addActionListener(this);
content.add(tabs);
content.add(button, BorderLayout.SOUTH);
return content;
}
@Override
public void actionPerformed(ActionEvent e) {
JComponent c = (JComponent) getContentPane().getComponent(0);
PDFDocument pdfDoc = new PDFDocument();
pdfDoc.setTitle("SwingUIToPDFDemo.java");
pdfDoc.setAuthor("Object Refinery Limited");
Page page = pdfDoc.createPage(new Rectangle(c.getWidth(), c.getHeight()));
PDFGraphics2D g2 = page.getGraphics2D();
g2.setRenderingHint(PDFHints.KEY_DRAW_STRING_TYPE,
PDFHints.VALUE_DRAW_STRING_TYPE_VECTOR);
c.paint(g2);
File f = new File("SwingUIToPDFDemo.pdf");
pdfDoc.writeToFile(f);
}
public static void main(String[] args) {
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// If Nimbus is not available, you can set the GUI to another look and feel.
}
SwingUIToPDFDemo app = new SwingUIToPDFDemo("SwingUIToPDFDemo.java");
app.pack();
app.setVisible(true);
}
}
jfree-demos-2.0/src/main/java/org/jfree/svg/ 0000775 0000000 0000000 00000000000 13776557647 0020723 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/java/org/jfree/svg/demo/ 0000775 0000000 0000000 00000000000 13776557647 0021647 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/java/org/jfree/svg/demo/ImageTest.java 0000664 0000000 0000000 00000014070 13776557647 0024376 0 ustar 00root root 0000000 0000000 package org.jfree.svg.demo;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.LinearGradientPaint;
import java.awt.MultipleGradientPaint;
import java.awt.MultipleGradientPaint.CycleMethod;
import java.awt.RadialGradientPaint;
import java.awt.Rectangle;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Path2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.jfree.svg.SVGGraphics2D;
import org.jfree.svg.SVGUtils;
/**
*
* @author dgilbert
*/
public class ImageTest {
private static void drawClipTest(Graphics2D g2) {
g2.translate(10, 20);
g2.setColor(Color.RED);
g2.fillRect(10, 10, 100, 100);
g2.clip(new Rectangle(0, 0, 60, 60));
g2.setPaint(Color.BLUE);
g2.fillRect(10, 10, 100, 100);
g2.setClip(null);
g2.setPaint(Color.GREEN);
g2.fillRect(60, 60, 50, 50);
}
private static void drawGradientPaintTest(Graphics2D g2) {
g2.setPaint(new GradientPaint(10f, 10f, Color.RED, 10f, 60f, Color.YELLOW));
g2.fillRect(10, 10, 50, 50);
g2.setPaint(Color.BLUE);
g2.fillRect(60, 10, 50, 50);
}
private static void drawLinearGradientPaintTest(Graphics2D g2) {
// top left
LinearGradientPaint lgp = new LinearGradientPaint(10, 30, 50, 30, new float[] {0.0f, 1.0f}, new Color[] {Color.RED, Color.BLUE});
g2.setPaint(lgp);
g2.fill(new Rectangle2D.Double(10, 10, 40, 40));
// top right
lgp = new LinearGradientPaint(80, 10, 80, 50, new float[] {0.0f, 1.0f}, new Color[] {Color.RED, Color.BLUE});
g2.setPaint(lgp);
g2.fill(new Rectangle2D.Double(60, 10, 40, 40));
// bottom left
lgp = new LinearGradientPaint(10, 100, 50, 60, new float[] {0.0f, 1.0f}, new Color[] {Color.RED, Color.BLUE});
g2.setPaint(lgp);
g2.fill(new Rectangle2D.Double(10, 60, 40, 40));
// bottom right
lgp = new LinearGradientPaint(70, 70, 90, 90, new float[] {0.0f, 0.5f, 1.0f}, new Color[] {Color.RED, Color.YELLOW, Color.BLUE}, CycleMethod.REPEAT);
g2.setPaint(lgp);
g2.fill(new Rectangle2D.Double(60, 60, 40, 40));
}
private static void drawOldLinearGradientPaintTest(Graphics2D g2) {
// top left
GradientPaint lgp = new GradientPaint(10, 30, Color.RED, 50, 30, Color.BLUE);
g2.setPaint(lgp);
g2.fill(new Rectangle2D.Double(10, 10, 40, 40));
// top right
lgp = new GradientPaint(80, 10, Color.RED, 80, 50, Color.BLUE);
g2.setPaint(lgp);
g2.fill(new Rectangle2D.Double(60, 10, 40, 40));
// bottom left
lgp = new GradientPaint(10, 100, Color.RED, 50, 60, Color.BLUE);
g2.setPaint(lgp);
g2.fill(new Rectangle2D.Double(10, 60, 40, 40));
// bottom right
lgp = new GradientPaint(70, 70, Color.RED, 90, 90, Color.BLUE);
g2.setPaint(lgp);
g2.fill(new Rectangle2D.Double(60, 60, 40, 40));
}
private static void drawRadialGradientPaintTest(Graphics2D g2) {
RadialGradientPaint rgp = new RadialGradientPaint(50, 50, 40, 30, 30,
new float[] {0f, 0.75f, 1f}, new Color[] {Color.RED,
Color.GREEN, Color.BLUE},
MultipleGradientPaint.CycleMethod.NO_CYCLE);
g2.setPaint(rgp);
Ellipse2D circle = new Ellipse2D.Double(10, 10, 80, 80);
g2.fill(circle);
}
private static void drawArcTest(Graphics2D g2) {
g2.setPaint(Color.GREEN);
g2.drawRect(0, 20, 70, 50);
g2.setPaint(Color.RED);
Path2D path1 = new Path2D.Double();
double[] pts = calculateReferenceArc(90);
path1.moveTo(pts[0], pts[1]);
path1.curveTo(pts[2], pts[3], pts[4], pts[5], pts[6], pts[7]);
AffineTransform t = new AffineTransform();
t.translate(35, 45);
t.scale(35, 25);
t.rotate(Math.PI / 4);
path1.transform(t);
g2.draw(path1);
Path2D path2 = new Path2D.Double();
path2.moveTo(pts[0], pts[1]);
path2.curveTo(pts[2], pts[3], pts[4], pts[5], pts[6], pts[7]);
AffineTransform t2 = new AffineTransform();
t2.rotate(3 * Math.PI / 4);
t2.scale(35, 25);
t2.translate(35, 35);
path2.transform(t2);
//g2.draw(path2);
Path2D arc = new Path2D.Double();
arc.append(path1, false);
arc.append(path2, false);
//g2.draw(arc);
//g2.draw(path1);
//g2.transform(t);
g2.setPaint(Color.BLUE);
g2.drawArc(0, 20, 70, 50, 0, -270);
//Arc2D arc2d = new Arc2D.Double(0d, 20d, 70d, 50d, 0d, 90, Arc2D.OPEN);
//g2.draw(arc2d);
}
private static double[] calculateReferenceArc(double angle) {
double a = (angle / 180 * Math.PI) / 2.0;
double x0 = Math.cos(a);
double y0 = Math.sin(a);
double x1 = (4 - x0) / 3;
double y1 = (1 - x0) * (3 - x0) / (3 * y0);
double x2 = x1;
double y2 = - y1;
double x3 = x0;
double y3 = -y0;
return new double[] { x0, y0, x1, y1, x2, y2, x3, y3 };
}
/**
* Starting point for the demo.
*
* @param args ignored.
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// BufferedImage image = new BufferedImage(200, 200,
// BufferedImage.TYPE_INT_ARGB);
// Graphics2D g2 = image.createGraphics();
SVGGraphics2D g2 = new SVGGraphics2D(110, 110);
//drawClipTest(g2);
//drawGradientPaintTest(g2);
drawLinearGradientPaintTest(g2);
//drawOldLinearGradientPaintTest(g2);
//drawRadialGradientPaintTest(g2);
//drawArcTest(g2);
// ImageIO.write(image, "png", new File("oldlgp-test.png"));
SVGUtils.writeToSVG(new File("lgp-test.svg"), g2.getSVGElement());
}
}
jfree-demos-2.0/src/main/java/org/jfree/svg/demo/SVGBarChartDemo1.java 0000664 0000000 0000000 00000012704 13776557647 0025452 0 ustar 00root root 0000000 0000000 /* =====================
* SVGBarChartDemo1.java
* =====================
*
* Copyright (c) 2013-2021, Object Refinery Limited.
* All rights reserved.
*
* http://www.jfree.org/jfreechart/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.jfree.svg.demo;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtils;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.renderer.category.StatisticalBarRenderer;
import org.jfree.chart.ui.TextAnchor;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.statistics.DefaultStatisticalCategoryDataset;
import org.jfree.svg.SVGGraphics2D;
import org.jfree.svg.SVGUtils;
/**
* A demo/test for a bar chart.
*/
public class SVGBarChartDemo1 {
/**
* Creates a sample dataset.
*
* @return The dataset.
*/
private static CategoryDataset createDataset() {
DefaultStatisticalCategoryDataset dataset
= new DefaultStatisticalCategoryDataset();
dataset.add(10.0, 2.4, "Row 1", "Column 1");
dataset.add(15.0, 4.4, "Row 1", "Column 2");
dataset.add(13.0, 2.1, "Row 1", "Column 3");
dataset.add(7.0, 1.3, "Row 1", "Column 4");
dataset.add(22.0, 2.4, "Row 2", "Column 1");
dataset.add(18.0, 4.4, "Row 2", "Column 2");
dataset.add(28.0, 2.1, "Row 2", "Column 3");
dataset.add(17.0, 1.3, "Row 2", "Column 4");
return dataset;
}
/**
* Creates a sample chart.
*
* @param dataset a dataset.
*
* @return The chart.
*/
private static JFreeChart createChart(CategoryDataset dataset) {
JFreeChart chart = ChartFactory.createLineChart(
"Statistical Bar Chart Demo 1", "Type", "Value", dataset);
CategoryPlot plot = (CategoryPlot) chart.getPlot();
// customise the range axis...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
rangeAxis.setAutoRangeIncludesZero(false);
// customise the renderer...
StatisticalBarRenderer renderer = new StatisticalBarRenderer();
renderer.setDrawBarOutline(false);
renderer.setErrorIndicatorPaint(Color.black);
renderer.setIncludeBaseInRange(false);
plot.setRenderer(renderer);
// ensure the current theme is applied to the renderer just added
ChartUtils.applyCurrentTheme(chart);
renderer.setDefaultItemLabelGenerator(
new StandardCategoryItemLabelGenerator());
renderer.setDefaultItemLabelsVisible(true);
renderer.setDefaultItemLabelPaint(Color.yellow);
renderer.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER));
// set up gradient paints for series...
GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue,
0.0f, 0.0f, new Color(0, 0, 64));
GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green,
0.0f, 0.0f, new Color(0, 64, 0));
renderer.setSeriesPaint(0, gp0);
renderer.setSeriesPaint(1, gp1);
return chart;
}
/**
* Starting point for the demo.
*
* @param args ignored.
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
JFreeChart chart = createChart(createDataset());
SVGGraphics2D g2 = new SVGGraphics2D(600, 400);
Rectangle r = new Rectangle(0, 0, 600, 400);
chart.draw(g2, r);
File f = new File("SVGBarChartDemo1.svg");
SVGUtils.writeToSVG(f, g2.getSVGElement());
}
}
jfree-demos-2.0/src/main/java/org/jfree/svg/demo/SVGChartWithAnnotationsDemo1.java 0000664 0000000 0000000 00000020656 13776557647 0030104 0 ustar 00root root 0000000 0000000 /* ============================
* SVGChartWithAnnotations.java
* ============================
*
* Copyright (c) 2013-2021, Object Refinery Limited.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.jfree.svg.demo;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.geom.Ellipse2D;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.annotations.XYDrawableAnnotation;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.DateTickUnit;
import org.jfree.chart.axis.DateTickUnitType;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.TickUnitSource;
import org.jfree.chart.axis.TickUnits;
//import org.jfree.chart.drawable.ColorPainter;
import org.jfree.chart.labels.StandardXYToolTipGenerator;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.data.category.DefaultCategoryDataset;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.time.Month;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.time.Year;
import org.jfree.data.xy.XYDataset;
import org.jfree.svg.SVGGraphics2D;
import org.jfree.svg.SVGUtils;
/**
* A demo/test for a pie chart.
*/
public class SVGChartWithAnnotationsDemo1 {
/**
* Creates a sample chart.
*
* @param dataset a dataset for the chart.
*
* @return A sample chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"XYDrawableAnnotationDemo1",
null, "$ million", dataset);
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(true);
DateAxis xAxis = (DateAxis) plot.getDomainAxis();
xAxis.setLowerMargin(0.2);
xAxis.setUpperMargin(0.2);
xAxis.setStandardTickUnits(createStandardDateTickUnits());
NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
yAxis.setLowerMargin(0.2);
yAxis.setUpperMargin(0.2);
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
renderer.setDefaultShapesVisible(true);
renderer.setDefaultLinesVisible(true);
renderer.setSeriesShape(0, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));
renderer.setSeriesShape(1, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0));
renderer.setSeriesStroke(0, new BasicStroke(3.0f));
renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND, 5.0f, new float[] {10.0f, 5.0f}, 0.0f));
renderer.setSeriesFillPaint(0, Color.WHITE);
renderer.setSeriesFillPaint(1, Color.WHITE);
renderer.setUseFillPaint(true);
renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator());
renderer.setDefaultEntityRadius(6);
renderer.addAnnotation(new XYDrawableAnnotation(
new Month(4, 2005).getFirstMillisecond(), 600, 180, 100, 3.0,
createPieChart()));
renderer.addAnnotation(new XYDrawableAnnotation(
new Month(9, 2007).getFirstMillisecond(), 1250, 120, 100, 2.0,
createBarChart()));
plot.setRenderer(renderer);
return chart;
}
/**
* Creates a sample dataset.
*
* @return A dataset.
*/
private static XYDataset createDataset() {
TimeSeries series1 = new TimeSeries("Division A");
series1.add(new Year(2005), 1520);
series1.add(new Year(2006), 1132);
series1.add(new Year(2007), 450);
series1.add(new Year(2008), 620);
TimeSeries series2 = new TimeSeries("Division B");
series2.add(new Year(2005), 1200);
series2.add(new Year(2006), 1300);
series2.add(new Year(2007), 640);
series2.add(new Year(2008), 520);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(series1);
dataset.addSeries(series2);
return dataset;
}
private static JFreeChart createPieChart() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Engineering", 43.2);
dataset.setValue("Research", 13.2);
dataset.setValue("Advertising", 20.9);
PiePlot plot = new PiePlot(dataset);
// plot.setBackgroundPainter(null);
plot.setBackgroundPaint(null);
// plot.setBorderPainter(null);
plot.setOutlineVisible(false);
plot.setDefaultSectionOutlinePaint(Color.WHITE);
plot.setDefaultSectionOutlineStroke(new BasicStroke(2.0f));
plot.setLabelFont(new Font("Dialog", Font.PLAIN, 18));
plot.setMaximumLabelWidth(0.25);
JFreeChart chart = new JFreeChart(plot);
// chart.setBackgroundPainter(null);
chart.setBackgroundPaint(null);
chart.removeLegend();
chart.setPadding(RectangleInsets.ZERO_INSETS);
return chart;
}
private static JFreeChart createBarChart() {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(10.0, "R1", "Q1");
dataset.addValue(7.0, "R1", "Q2");
dataset.addValue(8.0, "R1", "Q3");
dataset.addValue(4.0, "R1", "Q4");
dataset.addValue(10.6, "R2", "Q1");
dataset.addValue(6.1, "R2", "Q2");
dataset.addValue(8.5, "R2", "Q3");
dataset.addValue(4.3, "R2", "Q4");
JFreeChart chart = ChartFactory.createBarChart("Sales 2008", null,
null, dataset);
chart.removeLegend();
// chart.setBackgroundPainter(null);
// chart.getPlot().setBackgroundPainter(new ColorPainter(
// new Color(200, 200, 255, 60)));
return chart;
}
private static TickUnitSource createStandardDateTickUnits() {
TickUnits units = new TickUnits();
DateFormat df = new SimpleDateFormat("yyyy");
units.add(new DateTickUnit(DateTickUnitType.YEAR, 1,
DateTickUnitType.YEAR, 1, df));
units.add(new DateTickUnit(DateTickUnitType.YEAR, 2,
DateTickUnitType.YEAR, 1, df));
units.add(new DateTickUnit(DateTickUnitType.YEAR, 5,
DateTickUnitType.YEAR, 5, df));
return units;
}
/**
* Starting point for the demo.
*
* @param args ignored.
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
JFreeChart chart = createChart(createDataset());
SVGGraphics2D g2 = new SVGGraphics2D(500, 300);
Rectangle r = new Rectangle(0, 0, 500, 300);
chart.draw(g2, r);
File f = new File("SVGChartWithAnnotationsDemo1.svg");
SVGUtils.writeToSVG(f, g2.getSVGElement());
}
}
jfree-demos-2.0/src/main/java/org/jfree/svg/demo/SVGPieChartDemo1.java 0000664 0000000 0000000 00000015211 13776557647 0025457 0 ustar 00root root 0000000 0000000 /* =====================
* SVGPieChartDemo1.java
* =====================
*
* Copyright (c) 2013-2021, Object Refinery Limited.
* All rights reserved.
*
* http://www.jfree.org/jfreesvg/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.jfree.svg.demo;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.RadialGradientPaint;
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.StandardChartTheme;
//import org.jfree.chart.drawable.GradientPainter;
import org.jfree.chart.plot.PiePlot;
import org.jfree.chart.title.TextTitle;
import org.jfree.chart.ui.HorizontalAlignment;
import org.jfree.chart.ui.RectangleEdge;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
import org.jfree.svg.SVGGraphics2D;
import org.jfree.svg.SVGUtils;
/**
* A demo/test for a pie chart.
*/
public class SVGPieChartDemo1 {
static {
// set a theme using the new shadow generator feature available in
// 1.0.14 - for backwards compatibility it is not enabled by default
ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow",
true));
}
/**
* Creates a sample dataset.
*
* Source: http://www.bbc.co.uk/news/business-15489523
*
* @return A sample dataset.
*/
private static PieDataset createDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("Samsung", new Double(27.8));
dataset.setValue("Others", new Double(55.3));
dataset.setValue("Nokia", new Double(16.8));
dataset.setValue("Apple", new Double(17.1));
return dataset;
}
/**
* Creates a chart.
*
* @param dataset the dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart(
"Smart Phones Manufactured / Q3 2011", // chart title
dataset);
chart.removeLegend();
// set a custom background for the chart
// chart.setBackgroundPainter(new GradientPainter(new Color(20, 20, 20),
// RectangleAnchor.TOP_LEFT, Color.DARK_GRAY,
// RectangleAnchor.BOTTOM_RIGHT));
// customise the title position and font
TextTitle t = chart.getTitle();
t.setHorizontalAlignment(HorizontalAlignment.LEFT);
t.setPaint(new Color(240, 240, 240));
t.setFont(new Font("Arial", Font.BOLD, 26));
PiePlot plot = (PiePlot) chart.getPlot();
// plot.setBackgroundPainter(null);
plot.setInteriorGap(0.04);
// plot.setBorderPainter(null);
// use gradients and white borders for the section colours
plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE));
plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED));
plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN));
plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW));
plot.setDefaultSectionOutlinePaint(Color.WHITE);
plot.setSectionOutlinesVisible(true);
plot.setDefaultSectionOutlineStroke(new BasicStroke(2.0f));
// customise the section label appearance
plot.setLabelFont(new Font("Courier New", Font.BOLD, 20));
plot.setLabelLinkPaint(Color.WHITE);
plot.setLabelLinkStroke(new BasicStroke(2.0f));
plot.setLabelOutlineStroke(null);
plot.setLabelPaint(Color.WHITE);
plot.setLabelBackgroundPaint(null);
// add a subtitle giving the data source
TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523",
new Font("Courier New", Font.PLAIN, 12));
source.setPaint(Color.WHITE);
source.setPosition(RectangleEdge.BOTTOM);
source.setHorizontalAlignment(HorizontalAlignment.RIGHT);
chart.addSubtitle(source);
return chart;
}
/**
* A utility method for creating gradient paints.
*
* @param c1 color 1.
* @param c2 color 2.
*
* @return A radial gradient paint.
*/
private static RadialGradientPaint createGradientPaint(Color c1, Color c2) {
Point2D center = new Point2D.Float(0, 0);
float radius = 200;
float[] dist = {0.0f, 1.0f};
return new RadialGradientPaint(center, radius, dist,
new Color[] {c1, c2});
}
/**
* Starting point for the demo.
*
* @param args ignored.
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
JFreeChart chart = createChart(createDataset());
SVGGraphics2D g2 = new SVGGraphics2D(600, 400);
g2.setRenderingHint(JFreeChart.KEY_SUPPRESS_SHADOW_GENERATION, true);
Rectangle r = new Rectangle(0, 0, 600, 400);
chart.draw(g2, r);
File f = new File("SVGPieChartDemo1.svg");
SVGUtils.writeToSVG(f, g2.getSVGElement());
}
}
jfree-demos-2.0/src/main/java/org/jfree/svg/demo/SVGTimeSeriesChartDemo1.java 0000664 0000000 0000000 00000044633 13776557647 0027025 0 ustar 00root root 0000000 0000000 /* ============================
* SVGTimeSeriesChartDemo1.java
* ============================
*
* Copyright (c) 2013-2021, Object Refinery Limited.
* All rights reserved.
*
* http://www.jfree.org/jfreesvg/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.jfree.svg.demo;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Rectangle;
import java.io.File;
import java.io.IOException;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.block.BlockBorder;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.title.TextTitle;
import org.jfree.chart.ui.HorizontalAlignment;
import org.jfree.data.time.Month;
import org.jfree.data.time.TimeSeries;
import org.jfree.data.time.TimeSeriesCollection;
import org.jfree.data.xy.XYDataset;
import org.jfree.svg.SVGGraphics2D;
import org.jfree.svg.SVGUtils;
/**
* A demo for SVG output of a time series chart. Running this application
* will save a file {@code SVGTimeSeriesChartDemo1.svg} to the filesystem - you
* can open this file in a browser to see the resulting chart.
*/
public class SVGTimeSeriesChartDemo1 {
/**
* Creates a chart.
*
* @param dataset a dataset.
*
* @return A chart.
*/
private static JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createTimeSeriesChart(
"International Coffee Organisation : Coffee Prices",
null, "US cents/lb", dataset);
String fontName = "Palatino";
chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18));
chart.addSubtitle(new TextTitle(
"Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf",
new Font(fontName, Font.PLAIN, 14)));
XYPlot plot = (XYPlot) chart.getPlot();
plot.setDomainPannable(true);
plot.setRangePannable(false);
plot.setDomainCrosshairVisible(true);
plot.setRangeCrosshairVisible(true);
plot.getDomainAxis().setLowerMargin(0.0);
plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14));
plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12));
plot.setRangeGridlinePaint(Color.GRAY);
plot.setDomainGridlinePaint(Color.GRAY);
chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14));
chart.getLegend().setFrame(BlockBorder.NONE);
chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER);
XYItemRenderer r = plot.getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r;
renderer.setDefaultShapesVisible(false);
renderer.setDrawSeriesLineAsPath(true);
// set the default stroke for all series
renderer.setAutoPopulateSeriesStroke(false);
renderer.setDefaultStroke(new BasicStroke(3.0f,
BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false);
renderer.setSeriesPaint(0, Color.RED);
renderer.setSeriesPaint(1, new Color(24, 123, 58));
renderer.setSeriesPaint(2, new Color(149, 201, 136));
renderer.setSeriesPaint(3, new Color(1, 62, 29));
renderer.setSeriesPaint(4, new Color(81, 176, 86));
renderer.setSeriesPaint(5, new Color(0, 55, 122));
renderer.setSeriesPaint(6, new Color(0, 92, 165));
}
return chart;
}
/**
* Creates a dataset, consisting of two series of monthly data.
*
* @return the dataset.
*/
private static XYDataset createDataset() {
TimeSeries s1 = new TimeSeries("Indicator Price");
s1.add(new Month(1, 2010), 126.80);
s1.add(new Month(2, 2010), 123.37);
s1.add(new Month(3, 2010), 125.30);
s1.add(new Month(4, 2010), 126.89);
s1.add(new Month(5, 2010), 128.10);
s1.add(new Month(6, 2010), 142.20);
s1.add(new Month(7, 2010), 153.41);
s1.add(new Month(8, 2010), 157.46);
s1.add(new Month(9, 2010), 163.61);
s1.add(new Month(10, 2010), 161.56);
s1.add(new Month(11, 2010), 173.90);
s1.add(new Month(12, 2010), 184.26);
s1.add(new Month(1, 2011), 197.35);
s1.add(new Month(2, 2011), 216.03);
s1.add(new Month(3, 2011), 224.33);
s1.add(new Month(4, 2011), 231.24);
s1.add(new Month(5, 2011), 227.97);
s1.add(new Month(6, 2011), 215.58);
s1.add(new Month(7, 2011), 210.36);
s1.add(new Month(8, 2011), 212.19);
s1.add(new Month(9, 2011), 213.04);
s1.add(new Month(10, 2011), 193.90);
s1.add(new Month(11, 2011), 193.66);
s1.add(new Month(12, 2011), 189.02);
s1.add(new Month(1, 2012), 188.90);
s1.add(new Month(2, 2012), 182.29);
s1.add(new Month(3, 2012), 167.77);
s1.add(new Month(4, 2012), 160.46);
s1.add(new Month(5, 2012), 157.68);
s1.add(new Month(6, 2012), 145.31);
s1.add(new Month(7, 2012), 159.07);
s1.add(new Month(8, 2012), 148.50);
s1.add(new Month(9, 2012), 151.28);
s1.add(new Month(10, 2012), 147.12);
s1.add(new Month(11, 2012), 136.35);
s1.add(new Month(12, 2012), 131.31);
s1.add(new Month(1, 2013), 135.38);
s1.add(new Month(2, 2013), 131.51);
s1.add(new Month(3, 2013), 131.38);
TimeSeries s2 = new TimeSeries("Columbian Milds");
s2.add(new Month(1, 2010), 207.51);
s2.add(new Month(2, 2010), 204.71);
s2.add(new Month(3, 2010), 205.71);
s2.add(new Month(4, 2010), 200.00);
s2.add(new Month(5, 2010), 200.54);
s2.add(new Month(6, 2010), 224.49);
s2.add(new Month(7, 2010), 235.52);
s2.add(new Month(8, 2010), 243.98);
s2.add(new Month(9, 2010), 247.77);
s2.add(new Month(10, 2010), 230.02);
s2.add(new Month(11, 2010), 244.02);
s2.add(new Month(12, 2010), 261.97);
s2.add(new Month(1, 2011), 279.88);
s2.add(new Month(2, 2011), 296.44);
s2.add(new Month(3, 2011), 300.68);
s2.add(new Month(4, 2011), 312.95);
s2.add(new Month(5, 2011), 302.17);
s2.add(new Month(6, 2011), 287.95);
s2.add(new Month(7, 2011), 285.21);
s2.add(new Month(8, 2011), 286.97);
s2.add(new Month(9, 2011), 287.54);
s2.add(new Month(10, 2011), 257.66);
s2.add(new Month(11, 2011), 256.99);
s2.add(new Month(12, 2011), 251.60);
s2.add(new Month(1, 2012), 255.91);
s2.add(new Month(2, 2012), 244.14);
s2.add(new Month(3, 2012), 222.84);
s2.add(new Month(4, 2012), 214.46);
s2.add(new Month(5, 2012), 207.32);
s2.add(new Month(6, 2012), 184.67);
s2.add(new Month(7, 2012), 202.56);
s2.add(new Month(8, 2012), 187.14);
s2.add(new Month(9, 2012), 190.10);
s2.add(new Month(10, 2012), 181.39);
s2.add(new Month(11, 2012), 170.08);
s2.add(new Month(12, 2012), 164.40);
s2.add(new Month(1, 2013), 169.19);
s2.add(new Month(2, 2013), 161.70);
s2.add(new Month(3, 2013), 161.53);
TimeSeries s3 = new TimeSeries("Other Milds");
s3.add(new Month(1, 2010), 158.90);
s3.add(new Month(2, 2010), 157.86);
s3.add(new Month(3, 2010), 164.50);
s3.add(new Month(4, 2010), 169.55);
s3.add(new Month(5, 2010), 173.38);
s3.add(new Month(6, 2010), 190.90);
s3.add(new Month(7, 2010), 203.21);
s3.add(new Month(8, 2010), 211.59);
s3.add(new Month(9, 2010), 222.71);
s3.add(new Month(10, 2010), 217.64);
s3.add(new Month(11, 2010), 233.48);
s3.add(new Month(12, 2010), 248.17);
s3.add(new Month(1, 2011), 263.77);
s3.add(new Month(2, 2011), 287.89);
s3.add(new Month(3, 2011), 292.07);
s3.add(new Month(4, 2011), 300.12);
s3.add(new Month(5, 2011), 291.09);
s3.add(new Month(6, 2011), 274.98);
s3.add(new Month(7, 2011), 268.02);
s3.add(new Month(8, 2011), 270.44);
s3.add(new Month(9, 2011), 274.88);
s3.add(new Month(10, 2011), 247.82);
s3.add(new Month(11, 2011), 245.09);
s3.add(new Month(12, 2011), 236.71);
s3.add(new Month(1, 2012), 237.21);
s3.add(new Month(2, 2012), 224.16);
s3.add(new Month(3, 2012), 201.26);
s3.add(new Month(4, 2012), 191.45);
s3.add(new Month(5, 2012), 184.65);
s3.add(new Month(6, 2012), 168.69);
s3.add(new Month(7, 2012), 190.45);
s3.add(new Month(8, 2012), 174.82);
s3.add(new Month(9, 2012), 178.98);
s3.add(new Month(10, 2012), 173.32);
s3.add(new Month(11, 2012), 159.91);
s3.add(new Month(12, 2012), 152.74);
s3.add(new Month(1, 2013), 157.29);
s3.add(new Month(2, 2013), 149.46);
s3.add(new Month(3, 2013), 149.78);
TimeSeries s4 = new TimeSeries("Brazilian Naturals");
s4.add(new Month(1, 2010), 131.67);
s4.add(new Month(2, 2010), 124.57);
s4.add(new Month(3, 2010), 126.21);
s4.add(new Month(4, 2010), 126.07);
s4.add(new Month(5, 2010), 127.45);
s4.add(new Month(6, 2010), 143.20);
s4.add(new Month(7, 2010), 156.87);
s4.add(new Month(8, 2010), 163.21);
s4.add(new Month(9, 2010), 175.15);
s4.add(new Month(10, 2010), 175.38);
s4.add(new Month(11, 2010), 190.62);
s4.add(new Month(12, 2010), 204.25);
s4.add(new Month(1, 2011), 219.77);
s4.add(new Month(2, 2011), 247.00);
s4.add(new Month(3, 2011), 260.98);
s4.add(new Month(4, 2011), 273.40);
s4.add(new Month(5, 2011), 268.66);
s4.add(new Month(6, 2011), 250.59);
s4.add(new Month(7, 2011), 245.69);
s4.add(new Month(8, 2011), 249.83);
s4.add(new Month(9, 2011), 255.64);
s4.add(new Month(10, 2011), 234.28);
s4.add(new Month(11, 2011), 236.75);
s4.add(new Month(12, 2011), 228.79);
s4.add(new Month(1, 2012), 228.21);
s4.add(new Month(2, 2012), 215.40);
s4.add(new Month(3, 2012), 192.03);
s4.add(new Month(4, 2012), 180.90);
s4.add(new Month(5, 2012), 174.17);
s4.add(new Month(6, 2012), 156.17);
s4.add(new Month(7, 2012), 175.98);
s4.add(new Month(8, 2012), 160.05);
s4.add(new Month(9, 2012), 166.53);
s4.add(new Month(10, 2012), 161.20);
s4.add(new Month(11, 2012), 148.25);
s4.add(new Month(12, 2012), 140.69);
s4.add(new Month(1, 2013), 145.17);
s4.add(new Month(2, 2013), 136.63);
s4.add(new Month(3, 2013), 133.61);
TimeSeries s5 = new TimeSeries("Robustas");
s5.add(new Month(1, 2010), 69.92);
s5.add(new Month(2, 2010), 67.88);
s5.add(new Month(3, 2010), 67.25);
s5.add(new Month(4, 2010), 71.59);
s5.add(new Month(5, 2010), 70.70);
s5.add(new Month(6, 2010), 76.92);
s5.add(new Month(7, 2010), 85.27);
s5.add(new Month(8, 2010), 82.68);
s5.add(new Month(9, 2010), 81.28);
s5.add(new Month(10, 2010), 85.27);
s5.add(new Month(11, 2010), 92.04);
s5.add(new Month(12, 2010), 94.09);
s5.add(new Month(1, 2011), 101.09);
s5.add(new Month(2, 2011), 109.35);
s5.add(new Month(3, 2011), 118.13);
s5.add(new Month(4, 2011), 117.37);
s5.add(new Month(5, 2011), 121.98);
s5.add(new Month(6, 2011), 117.95);
s5.add(new Month(7, 2011), 112.73);
s5.add(new Month(8, 2011), 112.07);
s5.add(new Month(9, 2011), 106.06);
s5.add(new Month(10, 2011), 98.10);
s5.add(new Month(11, 2011), 97.24);
s5.add(new Month(12, 2011), 98.41);
s5.add(new Month(1, 2012), 96.72);
s5.add(new Month(2, 2012), 101.93);
s5.add(new Month(3, 2012), 103.57);
s5.add(new Month(4, 2012), 101.80);
s5.add(new Month(5, 2012), 106.88);
s5.add(new Month(6, 2012), 105.70);
s5.add(new Month(7, 2012), 107.06);
s5.add(new Month(8, 2012), 106.52);
s5.add(new Month(9, 2012), 104.95);
s5.add(new Month(10, 2012), 104.47);
s5.add(new Month(11, 2012), 97.67);
s5.add(new Month(12, 2012), 96.59);
s5.add(new Month(1, 2013), 99.69);
s5.add(new Month(2, 2013), 104.03);
s5.add(new Month(3, 2013), 106.26);
TimeSeries s6 = new TimeSeries("Futures (London)");
s6.add(new Month(1, 2010), 62.66);
s6.add(new Month(2, 2010), 60.37);
s6.add(new Month(3, 2010), 58.64);
s6.add(new Month(4, 2010), 62.21);
s6.add(new Month(5, 2010), 62.46);
s6.add(new Month(6, 2010), 69.72);
s6.add(new Month(7, 2010), 78.17);
s6.add(new Month(8, 2010), 78.42);
s6.add(new Month(9, 2010), 75.87);
s6.add(new Month(10, 2010), 80.08);
s6.add(new Month(11, 2010), 86.40);
s6.add(new Month(12, 2010), 88.70);
s6.add(new Month(1, 2011), 96.02);
s6.add(new Month(2, 2011), 104.53);
s6.add(new Month(3, 2011), 111.36);
s6.add(new Month(4, 2011), 111.34);
s6.add(new Month(5, 2011), 116.76);
s6.add(new Month(6, 2011), 110.51);
s6.add(new Month(7, 2011), 103.36);
s6.add(new Month(8, 2011), 102.71);
s6.add(new Month(9, 2011), 96.10);
s6.add(new Month(10, 2011), 88.64);
s6.add(new Month(11, 2011), 85.78);
s6.add(new Month(12, 2011), 87.65);
s6.add(new Month(1, 2012), 84.19);
s6.add(new Month(2, 2012), 88.69);
s6.add(new Month(3, 2012), 91.37);
s6.add(new Month(4, 2012), 91.81);
s6.add(new Month(5, 2012), 96.82);
s6.add(new Month(6, 2012), 94.75);
s6.add(new Month(7, 2012), 96.14);
s6.add(new Month(8, 2012), 96.12);
s6.add(new Month(9, 2012), 94.65);
s6.add(new Month(10, 2012), 94.66);
s6.add(new Month(11, 2012), 87.32);
s6.add(new Month(12, 2012), 85.94);
s6.add(new Month(1, 2013), 88.85);
s6.add(new Month(2, 2013), 94.41);
s6.add(new Month(3, 2013), 97.22);
TimeSeries s7 = new TimeSeries("Futures (New York)");
s7.add(new Month(1, 2010), 142.76);
s7.add(new Month(2, 2010), 134.35);
s7.add(new Month(3, 2010), 134.97);
s7.add(new Month(4, 2010), 135.12);
s7.add(new Month(5, 2010), 135.81);
s7.add(new Month(6, 2010), 152.36);
s7.add(new Month(7, 2010), 165.23);
s7.add(new Month(8, 2010), 175.10);
s7.add(new Month(9, 2010), 187.80);
s7.add(new Month(10, 2010), 190.43);
s7.add(new Month(11, 2010), 206.92);
s7.add(new Month(12, 2010), 221.51);
s7.add(new Month(1, 2011), 238.05);
s7.add(new Month(2, 2011), 261.41);
s7.add(new Month(3, 2011), 274.10);
s7.add(new Month(4, 2011), 285.58);
s7.add(new Month(5, 2011), 277.72);
s7.add(new Month(6, 2011), 262.52);
s7.add(new Month(7, 2011), 255.90);
s7.add(new Month(8, 2011), 260.39);
s7.add(new Month(9, 2011), 261.39);
s7.add(new Month(10, 2011), 236.74);
s7.add(new Month(11, 2011), 235.25);
s7.add(new Month(12, 2011), 227.23);
s7.add(new Month(1, 2012), 227.50);
s7.add(new Month(2, 2012), 212.09);
s7.add(new Month(3, 2012), 188.78);
s7.add(new Month(4, 2012), 181.75);
s7.add(new Month(5, 2012), 176.50);
s7.add(new Month(6, 2012), 159.93);
s7.add(new Month(7, 2012), 183.20);
s7.add(new Month(8, 2012), 169.77);
s7.add(new Month(9, 2012), 175.36);
s7.add(new Month(10, 2012), 170.43);
s7.add(new Month(11, 2012), 155.72);
s7.add(new Month(12, 2012), 149.58);
s7.add(new Month(1, 2013), 154.28);
s7.add(new Month(2, 2013), 144.89);
s7.add(new Month(3, 2013), 141.43);
TimeSeriesCollection dataset = new TimeSeriesCollection();
dataset.addSeries(s1);
dataset.addSeries(s2);
dataset.addSeries(s3);
dataset.addSeries(s4);
dataset.addSeries(s5);
dataset.addSeries(s6);
dataset.addSeries(s7);
return dataset;
}
/**
* Starting point for the demo.
*
* @param args ignored.
*
* @throws IOException
*/
public static void main(String[] args) throws IOException {
JFreeChart chart = createChart(createDataset());
SVGGraphics2D g2 = new SVGGraphics2D(600, 400);
g2.setRenderingHint(JFreeChart.KEY_SUPPRESS_SHADOW_GENERATION, true);
Rectangle r = new Rectangle(0, 0, 600, 400);
chart.draw(g2, r);
File f = new File("SVGTimeSeriesChartDemo1.svg");
SVGUtils.writeToSVG(f, g2.getSVGElement());
}
}
jfree-demos-2.0/src/main/java/org/jfree/svg/demo/SwingUIToSVGDemo.java 0000664 0000000 0000000 00000007462 13776557647 0025540 0 ustar 00root root 0000000 0000000 /* =====================
* SwingUIToSVGDemo.java
* =====================
*
* Copyright (c) 2013-2021, Object Refinery Limited.
* All rights reserved.
*
* http://www.jfree.org/jfreesvg/index.html
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the Object Refinery Limited nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL OBJECT REFINERY LIMITED BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package org.jfree.svg.demo;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import org.jfree.svg.SVGGraphics2D;
import org.jfree.svg.SVGUtils;
/**
* This demo shows how to export a Swing UI to SVG.
*/
public class SwingUIToSVGDemo extends JFrame implements ActionListener {
public SwingUIToSVGDemo(String title) {
super(title);
add(createContent());
}
private JComponent createContent() {
JPanel content = new JPanel(new BorderLayout());
JTabbedPane tabs = new JTabbedPane();
tabs.add("Tab 1", new JButton("First Tab"));
tabs.add("Tab 2", new JButton("Second Tab"));
JButton button = new JButton("Save to SVG");
button.addActionListener(this);
content.add(tabs);
content.add(button, BorderLayout.SOUTH);
return content;
}
@Override
public void actionPerformed(ActionEvent e) {
JComponent c = (JComponent) getContentPane().getComponent(0);
SVGGraphics2D g2 = new SVGGraphics2D(c.getWidth(), c.getHeight());
c.paint(g2);
File f = new File("SwingUIToSVGDemo.svg");
try {
SVGUtils.writeToSVG(f, g2.getSVGElement());
} catch (IOException ex) {
System.err.println(ex);
}
}
public static void main(String[] args) {
try {
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (Exception e) {
// just take the default look and feel
}
SwingUIToSVGDemo app = new SwingUIToSVGDemo("SwingUIToSVGDemo.java");
app.pack();
app.setVisible(true);
}
}
jfree-demos-2.0/src/main/resources/ 0000775 0000000 0000000 00000000000 13776557647 0017333 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/resources/com/ 0000775 0000000 0000000 00000000000 13776557647 0020111 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/resources/com/orsoncharts/ 0000775 0000000 0000000 00000000000 13776557647 0022456 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/resources/com/orsoncharts/demo/ 0000775 0000000 0000000 00000000000 13776557647 0023402 5 ustar 00root root 0000000 0000000 jfree-demos-2.0/src/main/resources/com/orsoncharts/demo/AreaChart3D1.html 0000664 0000000 0000000 00000001445 13776557647 0026376 0 ustar 00root root 0000000 0000000
AreaChart3DDemo1
An area chart showing the reported quarterly revenues for four
large companies in the IT industry. Note that the dataset on this
chart is identical to that in BarChart3DDemo1
, and
shows how the chart appearance can be changed simply using a
different renderer.
Under the covers, this chart used a CategoryPlot3D
with an AreaRenderer3D
, and displays data from a
StandardCategoryDataset3D
.
jfree-demos-2.0/src/main/resources/com/orsoncharts/demo/AreaChart3D2.html 0000664 0000000 0000000 00000001113 13776557647 0026367 0 ustar 00root root 0000000 0000000
AreaChart3DDemo2
An area chart with some negative data values (this requires special
handling by the renderer).
Under the covers, this chart used a CategoryPlot3D
with an AreaRenderer3D
, and displays data from a
StandardCategoryDataset3D
.
jfree-demos-2.0/src/main/resources/com/orsoncharts/demo/AxisRangeDemo1.html 0000664 0000000 0000000 00000000731 13776557647 0027040 0 ustar 00root root 0000000 0000000
AxisRangeDemo1
An example showing the effect of a restricted axis range on the
chart rendering for an area chart. Use the sliders to modify the
value axis range and observe the effect on the chart rendering.
jfree-demos-2.0/src/main/resources/com/orsoncharts/demo/AxisRangeDemo2.html 0000664 0000000 0000000 00000000727 13776557647 0027046 0 ustar 00root root 0000000 0000000
AxisRangeDemo2
An example showing the effect of a restricted axis range on the
chart rendering for a bar chart. Use the sliders to modify the
value axis range and observe the effect on the chart rendering.
jfree-demos-2.0/src/main/resources/com/orsoncharts/demo/AxisRangeDemo3.html 0000664 0000000 0000000 00000000730 13776557647 0027041 0 ustar 00root root 0000000 0000000
AxisRangeDemo3
An example showing the effect of a restricted axis range on the
chart rendering for a line chart. Use the sliders to modify the
value axis range and observe the effect on the chart rendering.
jfree-demos-2.0/src/main/resources/com/orsoncharts/demo/AxisRangeDemo4.html 0000664 0000000 0000000 00000000735 13776557647 0027047 0 ustar 00root root 0000000 0000000
AxisRangeDemo4
An example showing the effect of a restricted axis range on the
chart rendering for a stacked bar chart. Use the sliders to modify
the value axis range and observe the effect on the chart rendering.