SlideShare a Scribd company logo
1 of 18
Moving From JFreeChart To JavaFX Charts
with JavaFX Chart Extensions
JavaOne 2015 Session:
Moving Enterprise Data From JFreeChart To JavaFX Charts
Bruce Schubert, Independent Software Architect and Developer
Emxsys - Emergency Management Expert Systems (emxsys.com)
Projects: https://bitbucket.org/emxsys
Enterprise Data
Shared by the users of an organization; often plotted or graphed with JFreeChart
JFreeChart
• De facto standard, rich, mature
library
• Free, open source; pay for the
Developer Guide
• Forum support by author
• Comprehensive collection of chart
types
• Swing-based
JavaFX Charts
• Cool, new, native
• JavaFX-based
• Missing many key features that are
found in JFreeChart
Case Study: WildfireFX Application
Port the Wildfire Management Tool (WMT) to JavaFX
https://bitbucket.org/emxsys/wildfire-management-tool
https://bitbucket.org/emxsys/wildfirefx
Objective: Use JFree’s ChartViewer for Unique Chart Types
ChartViewer included in the JFreeChart source distribution
// Example: FXMLController snippet
import org.jfree.chart.fx.ChartViewer;
public class FXMLController
implements Initializable {
@FXML
private AnchorPane pane;
// A JFreeChart!
private final SolarChart chart
= new SolarChart("Solar");
@Override
public void initialize(URL location,
ResourceBundle resources) {
pane.getChildren().add(
new ChartViewer(chart));
}
}
Objective: Port the “Haul Chart” to JavaFX
Logarithmic scatter chart depicting wildland fire behavior
• Logarithmic Axis
• Major Gridlines
• Subtitles
• Value Markers
• Annotations
• Text
• Lines
• Polygons
• Images
JavaFX Chart Extensions Library (Free!)
Easier porting of JFreeChart charts to JavaFX Charts
https://bitbucket.org/emxsys/javafx-chart-extensions
LogarithmicAxis
Creates a Logarithmic XYChart
• LogarithmicAxis
• Pass to XYChart axis arguments
• MajorLogGridlines
• Add to XYChart subclass
• Call layoutGridlines()
• CSS:
• chart-major-vertical-grid-lines
• chart-major-horizontal-grid-lines
final double MIN_X = 10d;
final double MAX_X = 1000d;
final double MIN_Y = 1d;
final double MAX_Y = 100d;
LogarithmicAxis xAxis = new LogarithmicAxis("Domain", MIN_X, MAX_X);
LogarithmicAxis yAxis = new LogarithmicAxis("Range", MIN_Y, MAX_Y);
LineChart chart = new LineChart(xAxis, yAxis, dataset);
LogarithmicAxis Implementation
Subtitle Extension
Adds subtitle text to a chart
• Subtitle
• Add to Chart subclass
• Call layoutSubtitle()
• setSubtitle(“…”)
• CSS Style:
• chart-subtitle
// Chart subclass snippet
private Subtitle subtitle;
public void setSubtitle(String text) {
this.subtitle.setSubtitle(text);
this.requestLayout();
}
Subtitle Implementation
subtitleLabel is added to chart.getChildren() collection
• getChildren() returns {titleLabel,chartContent,legend}
• subtitleLabel added to children after titleLabel
• layoutSubtitle() modifies chartContent’s size
• FYI: getChartChildren() returns chartContent
plotBackground
subtitleLabel
legend
plotArea
titleLabel
yAxis
xAxis
chartContent
XYMarker Extension
ValueMarkers highlight values with a line and label
• XYMarkers
• Add to XYChart subclass
• Call layoutMarkers()
• ValueMarker
• Pos controls label layout
• addDomainMarker()
• addRangeMarker()
• CSS Style:
• chart-marker-line
• chart-maker-label
// XYChart subclass snippet
private XYMarkers markers;
public void addMinMaxMarkers(double maxX, double maxY) {
markers.addDomainMarker(new ValueMarker(
maxX, String.format("Max: %1$.1f", maxX), Pos.BOTTOM_RIGHT));
markers.addRangeMarker(new ValueMarker(
maxY, String.format("Max: %1$.1f"", maxY), Pos.TOP_LEFT));
}
XMarkers Implementation
Label placement controlled by Pos enum
• Horizontal (range) marker labels
• Anchored to left/right of graph
• Placed above or below line
• Vertical (domain) marker labels
• Anchored to top/bottom of graph
• Placed left or right of line
• Tip: Create listeners on label’s width
and height properties to trigger text
layout
• Label width and height are initially zero!
BOTTOM_LEFT
TOP_LEFT
BOTTOM_LEFT
TOP_LEFT TOP_RIGHT
TOP_RIGHT
BOTTOM_RIGHT
BOTTOM_RIGHT
XYTextAnnotation
Draws a label on an XYChart
• XYAnnotations
• Add to XYChart subclass
• Call layoutAnnotations()
• XYTextAnnotation(…)
• Layer controls
foreground/background
• Pos controls label layout
• add(XYTextAnnotation)
• CSS: chart-text-annotation
// XYChart subclass snippet...
private XYAnnotations annotations;
public void addTextAnnotation(double x, double y, String text) {
annotations.add(new XYTextAnnotation(
text, x, y, Pos.TOP_LEFT), Layer.FOREGROUND);
}
XYImageAnnotation
Draws an image on an XYChart
• XYAnnotations
• Add to XYChart subclass
• Call layoutAnnotations()
• XYImageAnnotation(…)
• Layer controls
foreground/background
• Pos controls image placement
• add(XYImageAnnotation)
// XYChart subclass snippet...
private XYAnnotations annotations;
public void addImageAnnotation(double x, double y, String path) {
Image image = new Image(getClass().getResourceAsStream(path));
annotations.add(new XYImageAnnotation(
image, x, y, Pos.CENTER), Layer.FOREGROUND);
}
XYLineAnnotation
Draws a line on an XYChart
• XYAnnotations
• Add to XYChart subclass
• Call layoutAnnotations()
• XYLineAnnotation(…)
• Layer foreground/background
• Optional width and color
• add(XYLineAnnotation)
• CSS: chart-line-annotation
// XYChart subclass snippet...
private XYAnnotations annotations;
public void addLineAnnotation(double x, double y, double x2, double y2) {
annotations.add(new XYLineAnnotation(
x1, y1, x2, y2, 2.0, Color.RED), Layer.FOREGROUND);
}
XYPolygonAnnotation
Draws a polygon on an XYChart
• XYAnnotations
• Add to XYChart subclass
• Call layoutAnnotations()
• XYPolygonAnnotation(…)
• Layer foreground/background
• Optional line width and fill colors
• add(XYPolygonAnnotation)
• CSS: chart-polygon-annotation
// XYChart subclass snippet...
private XYAnnotations annotations;
public void addPolygonAnnotation(double[] xyPoints) {
annotations.add(new XYPolygonAnnotation(
xyPoints, 2.0, Color.BLACK, Color.DARKORANGE), Layer.BACKGROUND);
}
background
XYAnnotations Implementation
chart.getPlotChildren() returns plotArea
zero lines, gridlines, row fills
• Annotation layers are Group objects added to plotArea children
• Foreground: last entry in plot area
• Background: first entry in plot area
zero lines, gridlines, row fills
zero lines, gridlines, row fills
zero lines, gridlines, row fills
plotContent
foregroundplotArea
In Closing
• JavaFX Chart Extensions project:
• https://bitbucket.org/emxsys/javafx-chart-extensions
• WildfireFX project:
• https://bitbucket.org/emxsys/wildfirefx
• Wildfire Management Tool project:
• https://bitbucket.org/emxsys/wildfire-management-tool
• Twitter: @Emxsys
• Email: bruce@emxsys.com

More Related Content

What's hot

JavaFX and Scala in the Cloud
JavaFX and Scala in the CloudJavaFX and Scala in the Cloud
JavaFX and Scala in the CloudStephen Chin
 
SenchaCon 2016: Theming the Modern Toolkit - Phil Guerrant
SenchaCon 2016: Theming the Modern Toolkit - Phil Guerrant   SenchaCon 2016: Theming the Modern Toolkit - Phil Guerrant
SenchaCon 2016: Theming the Modern Toolkit - Phil Guerrant Sencha
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesStephen Chin
 
Scala ActiveRecord
Scala ActiveRecordScala ActiveRecord
Scala ActiveRecordscalaconfjp
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scalaXing
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code ExamplesNaresh Chintalcheru
 
Axis2 client memory leak
Axis2 client memory leakAxis2 client memory leak
Axis2 client memory leakfeng lee
 
Demystifying Oak Search
Demystifying Oak SearchDemystifying Oak Search
Demystifying Oak SearchJustin Edelson
 
Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2Ralph Schindler
 
Omnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsOmnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsJustin Edelson
 
Http4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web StackHttp4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web StackGaryCoady
 
Connect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCIConnect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCIstable|kernel
 

What's hot (16)

JavaFX and Scala in the Cloud
JavaFX and Scala in the CloudJavaFX and Scala in the Cloud
JavaFX and Scala in the Cloud
 
SenchaCon 2016: Theming the Modern Toolkit - Phil Guerrant
SenchaCon 2016: Theming the Modern Toolkit - Phil Guerrant   SenchaCon 2016: Theming the Modern Toolkit - Phil Guerrant
SenchaCon 2016: Theming the Modern Toolkit - Phil Guerrant
 
Scala active record
Scala active recordScala active record
Scala active record
 
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative LanguagesJavaFX Your Way: Building JavaFX Applications with Alternative Languages
JavaFX Your Way: Building JavaFX Applications with Alternative Languages
 
Scala ActiveRecord
Scala ActiveRecordScala ActiveRecord
Scala ActiveRecord
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Java7 New Features and Code Examples
Java7 New Features and Code ExamplesJava7 New Features and Code Examples
Java7 New Features and Code Examples
 
Axis2 client memory leak
Axis2 client memory leakAxis2 client memory leak
Axis2 client memory leak
 
Demystifying Oak Search
Demystifying Oak SearchDemystifying Oak Search
Demystifying Oak Search
 
Play vs Rails
Play vs RailsPlay vs Rails
Play vs Rails
 
Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2Zend Framework 1 + Doctrine 2
Zend Framework 1 + Doctrine 2
 
Omnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the ThingsOmnisearch in AEM 6.2 - Search All the Things
Omnisearch in AEM 6.2 - Search All the Things
 
Http4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web StackHttp4s, Doobie and Circe: The Functional Web Stack
Http4s, Doobie and Circe: The Functional Web Stack
 
Spring data requery
Spring data requerySpring data requery
Spring data requery
 
Connect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCIConnect.Tech- Level Up Your Game With TravisCI
Connect.Tech- Level Up Your Game With TravisCI
 
jQuery-1-Ajax
jQuery-1-AjaxjQuery-1-Ajax
jQuery-1-Ajax
 

Similar to Moving from JFreeChart to JavaFX with JavaFX Chart Extensions

Creating Dynamic Charts With JFreeChart
Creating Dynamic Charts With JFreeChartCreating Dynamic Charts With JFreeChart
Creating Dynamic Charts With JFreeChartDavid Keener
 
Deep dive into deeplearn.js
Deep dive into deeplearn.jsDeep dive into deeplearn.js
Deep dive into deeplearn.jsKai Sasaki
 
The Ring programming language version 1.9 book - Part 54 of 210
The Ring programming language version 1.9 book - Part 54 of 210The Ring programming language version 1.9 book - Part 54 of 210
The Ring programming language version 1.9 book - Part 54 of 210Mahmoud Samir Fayed
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJava Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJAX London
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricksdeanhudson
 
Performing Data Science with HBase
Performing Data Science with HBasePerforming Data Science with HBase
Performing Data Science with HBaseWibiData
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video gamedandylion13
 
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docxasmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docxfredharris32
 
Ajax tutorial
Ajax tutorialAjax tutorial
Ajax tutorialKat Roque
 
U5 JAVA.pptx
U5 JAVA.pptxU5 JAVA.pptx
U5 JAVA.pptxmadan r
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...Publicis Sapient Engineering
 
Google tools for webmasters
Google tools for webmastersGoogle tools for webmasters
Google tools for webmastersRujata Patil
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3Droxlu
 

Similar to Moving from JFreeChart to JavaFX with JavaFX Chart Extensions (20)

Creating Dynamic Charts With JFreeChart
Creating Dynamic Charts With JFreeChartCreating Dynamic Charts With JFreeChart
Creating Dynamic Charts With JFreeChart
 
Deep dive into deeplearn.js
Deep dive into deeplearn.jsDeep dive into deeplearn.js
Deep dive into deeplearn.js
 
The Ring programming language version 1.9 book - Part 54 of 210
The Ring programming language version 1.9 book - Part 54 of 210The Ring programming language version 1.9 book - Part 54 of 210
The Ring programming language version 1.9 book - Part 54 of 210
 
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon RitterJava Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
Java Core | JavaFX 2.0: Great User Interfaces in Java | Simon Ritter
 
Jfreechart tutorial
Jfreechart tutorialJfreechart tutorial
Jfreechart tutorial
 
Stupid Canvas Tricks
Stupid Canvas TricksStupid Canvas Tricks
Stupid Canvas Tricks
 
Performing Data Science with HBase
Performing Data Science with HBasePerforming Data Science with HBase
Performing Data Science with HBase
 
How to make a video game
How to make a video gameHow to make a video game
How to make a video game
 
Intro to HTML5
Intro to HTML5Intro to HTML5
Intro to HTML5
 
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docxasmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
 
Ajax tutorial
Ajax tutorialAjax tutorial
Ajax tutorial
 
OpenVX 1.1 Reference Guide
OpenVX 1.1 Reference GuideOpenVX 1.1 Reference Guide
OpenVX 1.1 Reference Guide
 
OpenVX 1.2 Reference Guide
OpenVX 1.2 Reference GuideOpenVX 1.2 Reference Guide
OpenVX 1.2 Reference Guide
 
U5 JAVA.pptx
U5 JAVA.pptxU5 JAVA.pptx
U5 JAVA.pptx
 
Developing a new Epsilon EMC driver
Developing a new Epsilon EMC driverDeveloping a new Epsilon EMC driver
Developing a new Epsilon EMC driver
 
Flex 4 tips
Flex 4 tipsFlex 4 tips
Flex 4 tips
 
【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例【Unity】Scriptable object 入門と活用例
【Unity】Scriptable object 入門と活用例
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
 
Google tools for webmasters
Google tools for webmastersGoogle tools for webmasters
Google tools for webmasters
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 

Recently uploaded

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Moving from JFreeChart to JavaFX with JavaFX Chart Extensions

  • 1. Moving From JFreeChart To JavaFX Charts with JavaFX Chart Extensions JavaOne 2015 Session: Moving Enterprise Data From JFreeChart To JavaFX Charts Bruce Schubert, Independent Software Architect and Developer Emxsys - Emergency Management Expert Systems (emxsys.com) Projects: https://bitbucket.org/emxsys
  • 2. Enterprise Data Shared by the users of an organization; often plotted or graphed with JFreeChart JFreeChart • De facto standard, rich, mature library • Free, open source; pay for the Developer Guide • Forum support by author • Comprehensive collection of chart types • Swing-based JavaFX Charts • Cool, new, native • JavaFX-based • Missing many key features that are found in JFreeChart
  • 3. Case Study: WildfireFX Application Port the Wildfire Management Tool (WMT) to JavaFX https://bitbucket.org/emxsys/wildfire-management-tool https://bitbucket.org/emxsys/wildfirefx
  • 4. Objective: Use JFree’s ChartViewer for Unique Chart Types ChartViewer included in the JFreeChart source distribution // Example: FXMLController snippet import org.jfree.chart.fx.ChartViewer; public class FXMLController implements Initializable { @FXML private AnchorPane pane; // A JFreeChart! private final SolarChart chart = new SolarChart("Solar"); @Override public void initialize(URL location, ResourceBundle resources) { pane.getChildren().add( new ChartViewer(chart)); } }
  • 5. Objective: Port the “Haul Chart” to JavaFX Logarithmic scatter chart depicting wildland fire behavior • Logarithmic Axis • Major Gridlines • Subtitles • Value Markers • Annotations • Text • Lines • Polygons • Images
  • 6. JavaFX Chart Extensions Library (Free!) Easier porting of JFreeChart charts to JavaFX Charts https://bitbucket.org/emxsys/javafx-chart-extensions
  • 7. LogarithmicAxis Creates a Logarithmic XYChart • LogarithmicAxis • Pass to XYChart axis arguments • MajorLogGridlines • Add to XYChart subclass • Call layoutGridlines() • CSS: • chart-major-vertical-grid-lines • chart-major-horizontal-grid-lines final double MIN_X = 10d; final double MAX_X = 1000d; final double MIN_Y = 1d; final double MAX_Y = 100d; LogarithmicAxis xAxis = new LogarithmicAxis("Domain", MIN_X, MAX_X); LogarithmicAxis yAxis = new LogarithmicAxis("Range", MIN_Y, MAX_Y); LineChart chart = new LineChart(xAxis, yAxis, dataset);
  • 9. Subtitle Extension Adds subtitle text to a chart • Subtitle • Add to Chart subclass • Call layoutSubtitle() • setSubtitle(“…”) • CSS Style: • chart-subtitle // Chart subclass snippet private Subtitle subtitle; public void setSubtitle(String text) { this.subtitle.setSubtitle(text); this.requestLayout(); }
  • 10. Subtitle Implementation subtitleLabel is added to chart.getChildren() collection • getChildren() returns {titleLabel,chartContent,legend} • subtitleLabel added to children after titleLabel • layoutSubtitle() modifies chartContent’s size • FYI: getChartChildren() returns chartContent plotBackground subtitleLabel legend plotArea titleLabel yAxis xAxis chartContent
  • 11. XYMarker Extension ValueMarkers highlight values with a line and label • XYMarkers • Add to XYChart subclass • Call layoutMarkers() • ValueMarker • Pos controls label layout • addDomainMarker() • addRangeMarker() • CSS Style: • chart-marker-line • chart-maker-label // XYChart subclass snippet private XYMarkers markers; public void addMinMaxMarkers(double maxX, double maxY) { markers.addDomainMarker(new ValueMarker( maxX, String.format("Max: %1$.1f", maxX), Pos.BOTTOM_RIGHT)); markers.addRangeMarker(new ValueMarker( maxY, String.format("Max: %1$.1f"", maxY), Pos.TOP_LEFT)); }
  • 12. XMarkers Implementation Label placement controlled by Pos enum • Horizontal (range) marker labels • Anchored to left/right of graph • Placed above or below line • Vertical (domain) marker labels • Anchored to top/bottom of graph • Placed left or right of line • Tip: Create listeners on label’s width and height properties to trigger text layout • Label width and height are initially zero! BOTTOM_LEFT TOP_LEFT BOTTOM_LEFT TOP_LEFT TOP_RIGHT TOP_RIGHT BOTTOM_RIGHT BOTTOM_RIGHT
  • 13. XYTextAnnotation Draws a label on an XYChart • XYAnnotations • Add to XYChart subclass • Call layoutAnnotations() • XYTextAnnotation(…) • Layer controls foreground/background • Pos controls label layout • add(XYTextAnnotation) • CSS: chart-text-annotation // XYChart subclass snippet... private XYAnnotations annotations; public void addTextAnnotation(double x, double y, String text) { annotations.add(new XYTextAnnotation( text, x, y, Pos.TOP_LEFT), Layer.FOREGROUND); }
  • 14. XYImageAnnotation Draws an image on an XYChart • XYAnnotations • Add to XYChart subclass • Call layoutAnnotations() • XYImageAnnotation(…) • Layer controls foreground/background • Pos controls image placement • add(XYImageAnnotation) // XYChart subclass snippet... private XYAnnotations annotations; public void addImageAnnotation(double x, double y, String path) { Image image = new Image(getClass().getResourceAsStream(path)); annotations.add(new XYImageAnnotation( image, x, y, Pos.CENTER), Layer.FOREGROUND); }
  • 15. XYLineAnnotation Draws a line on an XYChart • XYAnnotations • Add to XYChart subclass • Call layoutAnnotations() • XYLineAnnotation(…) • Layer foreground/background • Optional width and color • add(XYLineAnnotation) • CSS: chart-line-annotation // XYChart subclass snippet... private XYAnnotations annotations; public void addLineAnnotation(double x, double y, double x2, double y2) { annotations.add(new XYLineAnnotation( x1, y1, x2, y2, 2.0, Color.RED), Layer.FOREGROUND); }
  • 16. XYPolygonAnnotation Draws a polygon on an XYChart • XYAnnotations • Add to XYChart subclass • Call layoutAnnotations() • XYPolygonAnnotation(…) • Layer foreground/background • Optional line width and fill colors • add(XYPolygonAnnotation) • CSS: chart-polygon-annotation // XYChart subclass snippet... private XYAnnotations annotations; public void addPolygonAnnotation(double[] xyPoints) { annotations.add(new XYPolygonAnnotation( xyPoints, 2.0, Color.BLACK, Color.DARKORANGE), Layer.BACKGROUND); }
  • 17. background XYAnnotations Implementation chart.getPlotChildren() returns plotArea zero lines, gridlines, row fills • Annotation layers are Group objects added to plotArea children • Foreground: last entry in plot area • Background: first entry in plot area zero lines, gridlines, row fills zero lines, gridlines, row fills zero lines, gridlines, row fills plotContent foregroundplotArea
  • 18. In Closing • JavaFX Chart Extensions project: • https://bitbucket.org/emxsys/javafx-chart-extensions • WildfireFX project: • https://bitbucket.org/emxsys/wildfirefx • Wildfire Management Tool project: • https://bitbucket.org/emxsys/wildfire-management-tool • Twitter: @Emxsys • Email: bruce@emxsys.com

Editor's Notes

  1. Name Open source software developer. My company, Emxsys, make tools for firefighters to help predict the behavior of wildfires All my open source projects are hosted on Bitbucket - Emxsys
  2. JFreeChart is a great tool for charting complex data Plethora of chart types David Gilbert, the author, has provided a comprehensive treatment for data presenation JavaFX is Cool! Perhaps the siren song of JavaFX has lured you into a “port” Sirens were mythical creatures—mermaids—that lured sailors to their deaths with their beauty. Whatever the reason, I’m here to share my experience porting a complex chart to JavaFX
  3. I want to share my experience porting the WMT to JavaFX WMT is a modular NetBeans Platform application It computes the potential fire behavior of wildland fires from fuel models, terrain, and environmental data Data is presented in dials and charts for easy consumption by firefighters (not scientists!) My goal is to create a lightweight JavaFX application with a fire behavior simulation (a particle system) -- WildfireFX WildfireFX is a NetBeans, Maven-based project
  4. My first objective is to use the Jfree ChartViewer for unique JFreeChart types, e.g.: Compass Plots Dial Plots Warning! The ChartViewer class is not included in the jfreechart-1.0.19.jar file! Thus it is not included in a maven dependency. You must add the source to your project. Example: Here’s typical FXMLController code snippet adding a ChartViewer Control (Node) to an AnchorPane
  5. WMT has a “Haul Chart” used to display fire behavior data. Y-Axis: ROS, X-Axis: Heat Output Intersection: Flame Length and Fireline intensity As flame lengths increase from lower right: Haul men, haul equipment, haul retardant, haul everyone to safety My 2nd Objective in WildfireFX is to port the Haul Chart to JavaFX. Seems simple enough: it’s XY Scatter Chart - JavaFX has one of those… REVIEW SLIDE BULLETS Discovery: None of the listed features were supported by the ScatterChart! So I implemented them!
  6. I created the Chart Extensions library to make porting of JFreeChart charts to JavaFX Charts easier. It adds subset of common JFreeChart functionality to JavaFX Charts It uses concepts and syntax similar (not identical) to JFreeChart The Bitbucket project Includes: Source JavaDoc and Wiki Demo application Issue tracker And this PowerPoint!
  7. To create a logarithmic chart, simply create a logarithmic axis object and add it to an XYChart. To show major gridlines, you must subclass an XYChart and add a MajorLogGridlines object. You override the Chart’s layoutChildren() and call layoutGridlines() REVIEW SNIPPET
  8. Here’s a class diagram depicting LogarithmicAxis implementation. Note the JavaFX NumberAxis class is final… I had to duplicate it as NumericAccess to implement
  9. To add subtitles you must subclass a Chart and add a Subtitle object. You must override the Chart’s layoutChildren() and call layoutSubtitles()
  10. To add value markers, you must subclass an XYChart and add a XYMarkers object You must override layoutPlotChildren() and call layoutMarkers() ValueMarkers are added to the X and Y axes with addDomainMarker() and addRangeMarker() Label placement controlled by Pos enum
  11. Pos enum passed to addRangeMarker() and addDomainMarker() controls placement
  12. To add annotations you must subclass an XYChart and add a XYAnnotations object You must override layoutPlotChildren () and call layoutAnnotations() All XY annotations are added with a call to add() Pos enum controls label placement relative to X,Y Layer enum controls foreground/background REVIEW EXAMPLE SNIPPET
  13. To add annotations you must subclass an XYChart and add a XYAnnotations object You must override layoutPlotChildren () and call layoutAnnotations() All XY annotations are added with a call to add() Pos enum controls image placement relative to X,Y Layer enum controls foreground/background REVIEW EXAMPLE SNIPPET
  14. To add annotations you must subclass an XYChart and add a XYAnnotations object You must override layoutPlotChildren () and call layoutAnnotations() All XY annotations are added with a call to add() Layer enum controls foreground/background REVIEW EXAMPLE SNIPPET
  15. To add annotations you must subclass an XYChart and add a XYAnnotations object You must override layoutPlotChildren () and call layoutAnnotations() All XY annotations are added with a call to add() Layer enum controls foreground/background REVIEW EXAMPLE SNIPPET