Putting the 'Free' into JFreeChart

Similar documents
* =========================================================== 0003 * ===========================================================

* =========================================================== 003 * ===========================================================

Generating Charts in PDF Format with JFreeChart and itext

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Dr. Hikmat A. M. AbdelJaber

public void paintcomponent(graphics g) { Graphics2D g2 = (Graphics2D)g;... }

Agenda. Programming Seminar. By: dr. Amal Khalifa. Coordinate systems Colors Fonts Drawing shapes Graphics2D API

What is an Affine Transform?

Format Type Support Thru. vector (with embedded bitmaps)

Software System Components 1 Graphics

Java 2D Graphics. Drawing Primitives, Affine Transformations, Scene Graphs, Hit Tests. Drawing Primitives 2/9/2014. Using it is simple.

Class Meeting 05 (Lecture 04) Objectives for this class meeting. Conduct vote on basic style of game for class project

It's a cross-platform vector graphics package written in JavaScript. Frequently referenced as dojox.gfx or dojo.gfx. Supported backends:

Overview. Java2D. Graphics in Java2D: Colour Images Fonts. The bigger picture of Java Graphics: Java Advanced Imaging (JAI) API Java3D

This reference has been prepared for beginners to help them understand the basic-toadvanced concepts related to JFreeChart library.

INKSCAPE BASICS. 125 S. Prospect Avenue, Elmhurst, IL (630) elmhurstpubliclibrary.org. Create, Make, and Build

Programming graphics

Core Graphics and OpenGL ES. Dr. Sarah Abraham

Graphics and Painting

Adobe Illustrator CS5 Basic. Course Outline. Course Length: 1 Day. Course Overview. Prerequisites/Audience

IS311 Programming Concepts J AVA. Abstract Window Toolkit. (part 2: Graphics2D)

GRAPHIC WEB DESIGNER PROGRAM

Image creation with PHP

Inkscape Tutorial. v2.0. Simon Andrews.

Swing and you are winning

Enhancing Viewability of Images of Text in PDF in Mobile Devices

Applications and Implementations

Package cairodevice. August 29, 2013

Graphics Transformations

III-6Exporting Graphics (Windows)

Graphics. Lecture 18 COP 3252 Summer June 6, 2017

Computer Games 2012 Game Development

BPS 42 Chart Examples View

Server-Side Graphics

Affine Transformations. Transforming shape models Combining affine transformations Scene graphs, interactor trees Hit tests on transformed shapes

ICOM 4015 Advanced Programming Laboratory. Chapter 3 Introduction to Graphical Applications in Java using Swing

Publication-quality figures with Inkscape

CS 4300 Computer Graphics

Presenta(on Tools Adobe Illustrator. November 6, 2017

Introduction p. 1 Java Features p. 2 Java Expansion p. 4 Getting, Setting Up, and Using Java p. 5 The Java Language p. 5 Java Swing Components p.

Basic statistical operations

New features in APLX Version 3

Assignment 2. Application Development

Graphics in Swing. Engineering 5895 Faculty of Engineering & Applied Science Memorial University of Newfoundland

PLoT: Graph Plotting

Guile-GNOME: PangoCairo

XD++ Professional Edition -- it is designed for building professional flow diagramming applications only.

Output models Drawing Rasterization Color models

Merits of QT for developing Imaging Applications UI

Week 4 Part 2. Introduction to 2D Graphics & Java 2D

Object-Oriented Programming Design. Topic : Graphics Programming GUI Part I

Supplementary Materials of canvasdesigner

Topics. Transient vs Persistent Representation of Objects. Object Serialization CSE Lecture 9 Inheritance, III

Some classes and interfaces used in this chapter from Java s original graphics capabilities and from the Java2D API.

Part III: Survey of Internet technologies

2. (10 pts) Which of the following classes implements the Shape interface? Circle all that apply. a) Ellipse2D b) Area c) Stroke d) AffineTransform e)

CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

Introduction to Plot.ly: Customizing a Stacked Bar Chart

CONTENTS IN DETAIL. What s in This Book?... xx Who Is This Book For?... xx

COMP3421 Computer Graphics

Chapter 1 Introduction to Photoshop CS3 1. Exploring the New Interface Opening an Existing File... 24

Introduction To Inkscape Creating Custom Graphics For Websites, Displays & Lessons

JSynoptic. Nicolas Brodu, October /18

Java Coordinate System

CS 160: Lecture 10. Professor John Canny Spring 2004 Feb 25 2/25/2004 1

Advanced Graphics Components Using JavaServer Faces Technology. Christophe Jolif Architect ILOG S.A.

Introduction to Graphical Interface Programming in Java. Introduction to AWT and Swing

Designing effective scientific figures Introduction to Inkscape to finalise figures

CPS109 Lab 7. Source: Big Java, Chapter 7 Preparation: read Chapter 7 and the lecture notes for this week.

IT82: Mul timedia. Practical Graphics Issues 20th Feb Overview. Anti-aliasing. Fonts. What is it How to do it? History Anatomy of a Font

VISUAL ENGINEERING. KavaChart Developer Documentation. KavaChart User Guide

Draw Guide Chapter 1 Introducing Draw

Transient Stability Analysis with PowerWorld Simulator

Business Intelligence and Reporting Tools

(SSOL) Simple Shape Oriented Language

DASHBOARDPRO & DASHBOARD

CLASSES AND OBJECTS. Fundamentals of Computer Science I

Adobe Illustrator CS4

snocad-x user guide version b

ArcGIS Desktop: Making Maps in ArcMap

CLASSES AND OBJECTS. Fundamentals of Computer Science I

Ai Adobe. Illustrator. Creative Cloud Beginner

A foundation for programming. Classes and objects. Overview. Java primitive types. Primitive types Creating your own data types

Chapter 1 Introduction to Java

HTMLDOC On Line Help

6.092 Introduction to Software Engineering in Java January (IAP) 2009

INTRODUCTION. Computer Graphics

Archi - ArchiMate Modelling. What s New in Archi 4.x

Image Java Foundation Classes (JFC) java.awt.image JFC. Image. Image. Image PNG GIF JPEG

Lecture 5: Java Graphics

ADD URL SEARCH ENGINE SUBMISSION YAHOO

ITEXT. [Document subtitle]

Lecture 3: Java Graphics & Events

Graphing. ReportMill Graphing User Guide. This document describes ReportMill's graph component. Graphs are the best way to present data visually.

HOW TO SAVE YOUR DESIGN FILES

Why Choose Nevron Chart for SQL Server Reporting Services

Section 33: Advanced Charts

What s new in SketchUp Pro?

HIGHCHARTS - QUICK GUIDE HIGHCHARTS - OVERVIEW

Desktop Studio: Charts. Version: 7.3

Transcription:

Putting the 'Free' into JFreeChart 25 February 2006 Dave Gilbert JFreeChart Project Leader

Overview The Java Trap; JFreeChart; Java2D (Graphics2D); The Free Stack: Cairo (CairoGraphics2D); GNU Classpath; samples; A Real World Application: StatCVS;

I. The Java Trap Free But Shackled The Java Trap by Richard Stallman: http://www.gnu.org/philosophy/java trap.html 12 April 2004; Executive Summary: Free software that depends on a non free platform is not 100% free; JFreeChart falls into this category; so does a vast collection of free and open source software; a motivation for GNU Classpath;

II. JFreeChart a free library for creating charts: http://www.jfree.org/jfreechart/ JFreeChart 1.0.0 released in December 2005; can be used for server side (servlet/jsp) or client side development (Swing based applications or applets); requires Java 1.3.1 or later; relies (heavily) on the Java2D API; GNU Lesser General Public Licence (LGPL);

JFreeChart (2) project started December 1999; some statistics: 32 packages; 462 classes/interfaces; 90+ contributors; an estimated 40,000 developers use JFreeChart; funding: JFreeChart Developer Guide; consulting;

Java2D Java's device independent vector graphics API: introduced in JDK 1.2; centers around abstract class Graphics2D; small API, big implementation; core library provides implementations for output to: screen: javax.swing.jcomponent; printers: java.awt.print.printerjob; images: java.awt.bufferedimage;

Java2D User Space (0, 0) x 72 units per inch y

Java2D Geometry Shapes via java.awt.shape interface: points: java.awt.geom.point2d; lines: java.awt.geom.line2d; rectangles: java.awt.geom.rectangle2d; polygons: java.awt.polygon; arcs: java.awt.geom.arc2d; curves: java.awt.geom.quadcurve2d/cubiccurve2d; paths: java.awt.geom.generalpath;

Java2D Constructive Area Geometry java.awt.geom.area class; allows addition and subtraction of arbitrary shapes; for example, a rectangle and an arc:

Graphics2D set current color: public void setpaint(paint); fill shapes public void fill(shape); set pen style: public void setstroke(stroke); draw shapes: public void draw(shape); draw text: public void setfont(font); public void drawstring(string, float, float);

Java2D Transformations java.awt.affinetransform: public Shape createtransformedshape(shape psrc); translation: public static AffineTransform gettranslateinstance(double tx, double ty) rotation: public static AffineTransform getrotateinstance(double theta, double x, double y) scale: public static AffineTransform getscaleinstance(double sx, double sy) shear: public static AffineTransform getshearinstance(double shx, double shy)

Java2D Rendering colors: java.awt.paint; RGB; gradients; alpha transparency; pen style: java.awt.stroke; line width control; line decorations; dashed lines;

Java2D Rendering (2) text: font control; Unicode support; text outlines as shapes; all transformations possible; images: java.awt.bufferedimage hints: speed vs quality, for example antialiasing; java.awt.renderinghints

Java2D Book Recommended: Jonathan Knudsen published by O'Reilly First Edition, May 1999 http://www.oreilly.com/catalog/java2d/

Graphics2D Implementations external implementations available for: Adobe Portable Document Format (PDF): itext MPL; http://www.lowagie.com/itext/ Scalable Vector Graphics (SVG): Batik Apache license; http://xmlgraphics.apache.org/batik/ Encapsulated Postscript (EPS): jibble.org GPL; http://www.jibble.org/epsgraphics/

Java2D in GNU Classpath? still a lot of work to be done; an initial implementation, based on Cairo, not yet enabled by default;

III. The Free Stack What is it and what can it do? Cairo; cairo java; CairoGraphics2D; GNU Classpath; a demo application; a range of examples;

Cairo a vector graphics library; written in C; bindings for many programming languages, including Java; http://www.cairographics.org Redhat; widely used: GTK+; Eclipse on Linux (backend for SWT graphics); Mono; GNU Classpath (work in progress);

cairo java Java bindings from the Java Gnome project http://java gnome.sourceforge.net/

CairoGraphics2D need a bridge between: JFreeChart 1.0.0; Cairo; wrote a CairoGraphics2D class: incomplete but functional; maps Graphics2D API calls (by JFreeChart) to Cairo methods (via cairo java); helper class CairoImage to: provide Graphics2D instance; write to PNG file

Sample Program public static void main(string[] args) { CategoryDataset dataset = createdataset(); JFreeChart chart = createchart(dataset); CairoImage image = new CairoImage(600, 400); Graphics2D g2 = image.creategraphics2d(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 600.0, 400.0)); image.savetopng(new File("LineChartTest.png")); }

Sample Program (2) private static CategoryDataset createdataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addvalue(212, "Classes", "JDK 1.0"); dataset.addvalue(504, "Classes", "JDK 1.1"); dataset.addvalue(1520, "Classes", "SDK 1.2"); dataset.addvalue(1842, "Classes", "SDK 1.3"); dataset.addvalue(2991, "Classes", "SDK 1.4"); return dataset; }

Sample Program (3) private static JFreeChart createchart(categorydataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart( "Java Standard Class Library", // chart title "Release", // domain axis label "Class Count", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend false // tooltips false // urls );

Sample Program (4) // title chart.settitle(new TextTitle("Line Chart Demo", new Font("Sans", Font.BOLD, 18))); // subtitle chart.addsubtitle(new TextTitle("Number of Classes By Release", new Font("Sans", Font.BOLD, 14))); TextTitle source = new TextTitle( "Source: Java In A Nutshell (4th Edition) " + "by David Flanagan (O'Reilly)", new Font("Sans", Font.PLAIN, 12)); source.setposition(rectangleedge.bottom); source.sethorizontalalignment(horizontalalignment.right); chart.addsubtitle(source);

Sample Program (5) // colors chart.setbackgroundpaint(color.white); CategoryPlot plot = (CategoryPlot) chart.getplot(); plot.setbackgroundpaint(color.lightgray); plot.setrangegridlinepaint(color.white); // customise the range axis... NumberAxis rangeaxis = (NumberAxis) plot.getrangeaxis(); rangeaxis.setlabelfont(new Font("Sans", Font.BOLD, 14)); rangeaxis.setticklabelfont(new Font("Sans", Font.PLAIN, 12)); rangeaxis.setstandardtickunits( NumberAxis.createIntegerTickUnits());

Sample Program (6) // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getrenderer(); renderer.setshapesvisible(true); renderer.setdrawoutlines(true); renderer.setusefillpaint(true); renderer.setfillpaint(color.white); renderer.setseriesstroke(0, new BasicStroke(4.0f)); renderer.setseriesshape(0, new Ellipse2D.Double(-6, -6, 12, 12)); CategoryAxis domainaxis = plot.getdomainaxis(); domainaxis.setlabelfont(new Font("Sans", Font.BOLD, 14)); domainaxis.setticklabelfont(new Font("Sans", Font.PLAIN, 12)); } return chart;

Sample Program (7)

More Examples all generated with a Free software stack: JamVM 1.4.1; GNU Classpath (recent CVS); Cairo 1.0.2 (via cairo java and custom CairoGraphics2D); JFreeChart 1.0.0; PNG output;

Sample : Pie Chart

Sample : Bar Chart

Sample : Line Chart

Sample: Financial Chart

Sample : Chart with Multiple Axes

Sample : Something different

IV. A Real World Application StatCVS; an analysis for Mauve;

StatCVS generates CVS logfile summary reports; http://statcvs.sourceforge.net/ GNU LGPL output to HTML, including charts generated by JFreeChart;

StatCVS for Mauve (1) use Mauve CVS for an example; Mauve: a free test suite for the standard Java APIs: http://sources.redhat.com/mauve/ GNU General Public Licence (GPL); can be used to test ANY implementation of the Java APIs, but is primarily developed and used by GNU Classpath hackers;

StatCVS for Mauve (2) Use a modified version of StatCVS: http://www.object refinery.com/classpath/statcvs.html Summary of changes: update to use JFreeChart 1.0.0; incorporate small modification to use CairoImage rather than java.awt.bufferedimage; Generate a log file: cvs log > logfile.log Run it...

StatCVS for Mauve (3)

The Future implementation of Graphics2D in GNU Classpath, will enable the use of JFreeChart: in Swing based client applications (ChartPanel extends JPanel); to create and save BufferedImage instances; extend / test external Graphics2D implementations: CairoGraphics2D; EPSGraphics2D (jibble.org); PdfGraphics2D (itext); SWTGraphics2D?

Questions? Questions