public class CategorizedStackedBarChart extends org.jfree.ui.ApplicationFrame
// Sample data for a Categorized Bar chart with sub-grouped stacked bars. // the first real line is to define the group titles Fiscal Year,Accounting Category,Project Driver Dollars F2005,SI Sustain,Reliability,12.20 F2005,SI Sustain,Vegetation Management,25.5 F2005,SI Sustain,Asset Replacement,34 F2005,SI Sustain,Wires Maintenance,25.6 F2005,Growth,System,8.4 F2006,SI Sustain,Reliability,13.40 F2006,SI Sustain,Vegetation Management,23.40 F2006,SI Sustain,Asset Replacement,33.00 F2006,SI Sustain,Wires Maintenance,26.90 F2006,Growth,System,21.20 F2007,SI Sustain,Reliability,14.51 F2007,SI Sustain,Vegetation Management,22.20 F2007,SI Sustain,Asset Replacement,38.10 F2007,SI Sustain,Wires Maintenance,26.80 F2007,Growth,System,31.70 F2008,SI Sustain,Reliability,14.51 F2008,SI Sustain,Vegetation Management,23.00 F2008,SI Sustain,Asset Replacement,38.20 F2008,SI Sustain,Wires Maintenance,31.30 F2008,Growth,System,52.50Tom Gutwin
JFrame.AccessibleJFrame
Frame.AccessibleAWTFrame
Window.AccessibleAWTWindow, Window.Type
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
private Vector |
categories |
private double |
categoryMargin_ |
private String |
categoryName |
Color |
chartBackgroundFromColor |
Color |
chartBackgroundToColor |
Color[] |
chartColours |
private int |
chartdX |
private int |
chartdY |
private String |
chartTitle |
static short |
FILETYPE_CSV |
static short |
FILETYPE_SQL |
static short |
FILETYPE_UNKNOWN |
static short |
FILETYPE_XLS |
GradientPaint[] |
gradientpaint |
private org.jfree.chart.renderer.category.GroupedStackedBarRenderer |
groupedstackedbarrenderer |
private String |
groupName |
private Vector |
groups |
Font |
itemLabelFont |
private org.jfree.chart.JFreeChart |
jfreechart_ |
private org.jfree.data.KeyToGroupMap |
keytogroupmap_ |
private boolean |
showLabels |
private boolean |
showToolTips |
private String |
stackedDataName |
private Vector |
stackedGroup |
accessibleContext, EXIT_ON_CLOSE, rootPane, rootPaneCheckingEnabled
CROSSHAIR_CURSOR, DEFAULT_CURSOR, E_RESIZE_CURSOR, HAND_CURSOR, ICONIFIED, MAXIMIZED_BOTH, MAXIMIZED_HORIZ, MAXIMIZED_VERT, MOVE_CURSOR, N_RESIZE_CURSOR, NE_RESIZE_CURSOR, NORMAL, NW_RESIZE_CURSOR, S_RESIZE_CURSOR, SE_RESIZE_CURSOR, SW_RESIZE_CURSOR, TEXT_CURSOR, W_RESIZE_CURSOR, WAIT_CURSOR
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
DISPOSE_ON_CLOSE, DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
CategorizedStackedBarChart()
Constructor for the CategorizedStackedBarChart object.
|
CategorizedStackedBarChart(String chartTitle)
Constructor for the CategorizedStackedBarChart object.
|
CategorizedStackedBarChart(String chartTitle,
String filename)
Constructor for the CategorizedStackedBarChart object
|
Modifier and Type | Method and Description |
---|---|
void |
addSubtitle(String subtitleParm)
Adds/or changes the subtitle.
|
org.jfree.chart.JFreeChart |
createCategoryStackedBarChart(org.jfree.data.category.CategoryDataset categorydataset)
This method does all the work for getting the chart plot set up.
|
org.jfree.chart.JFreeChart |
createCategoryStackedBarChart(String chartTitle,
org.jfree.data.category.CategoryDataset categorydataset)
This method does all the work for getting the chart plot set up.
|
org.jfree.chart.JFreeChart |
createCategoryStackedBarChart(String chartTitle,
String subTitle,
org.jfree.data.category.CategoryDataset categorydataset)
This method does all the work for getting the chart plot set up.
|
JPanel |
createChartPanel(org.jfree.data.category.CategoryDataset ds)
Description of the Method
|
org.jfree.data.category.CategoryDataset |
createDatasetFromCSV(String csv)
Create the dataset from delimited String.
|
org.jfree.data.category.CategoryDataset |
createDatasetFromCSVFile(String csvFilename)
Description of the Method
|
private org.jfree.data.category.CategoryDataset |
createDatasetFromSQL(String sqlFilename)
Queries a db and converts the results into a Dataset that can be used in
a Grouped Stacked Bar Chart.
|
org.jfree.data.category.CategoryDataset |
createDatasetFromXLS(String xlsFilename)
takes an xls file in the proper format into a Dataset useable by the charter.
|
private org.jfree.chart.LegendItemCollection |
createLegendItems()
Sets up the words in the grouped legend.
|
static void |
exportChartAsPDF(OutputStream out,
org.jfree.chart.JFreeChart chart,
int width,
int height)
Writes a chart to an output stream in PDF format.
|
static void |
exportChartAsPDF(OutputStream out,
org.jfree.chart.JFreeChart chart,
int width,
int height,
FontMapper mapper)
Writes a chart to an output stream in PDF format.
|
static void |
exportChartAsPDF(OutputStream out,
org.jfree.chart.JFreeChart chart,
int width,
int height,
FontMapper mapper,
String title)
Writes a chart to an output stream in PDF format.
|
static void |
exportChartAsPDF(OutputStream out,
org.jfree.chart.JFreeChart chart,
int width,
int height,
String title)
Writes a chart to an output stream in PDF format.
|
org.jfree.chart.JFreeChart |
getChart() |
static short |
getFileType(String filename) |
org.jfree.chart.plot.CategoryPlot |
getPlot()
Gets the current jfreechart plot (null if not already initialized).
|
private void |
initColours() |
static void |
main(String[] args)
The main program for the CategorizedStackedBarChart class
|
void |
saveChartToPdf(File pdfFile)
saves the passed chart to a pdf file in the current models yearly dir.
|
void |
saveChartToPdf(org.jfree.chart.JFreeChart chart,
File pdfFile)
saves the passed chart to a pdf file in the current models yearly dir.
|
void |
saveChartToPdf(org.jfree.chart.JFreeChart chart,
String fileName)
saves the passed chart to a pdf file in the current models yearly dir.
|
void |
saveChartToPdf(String fileName)
saves the passed chart to a pdf file in the current models yearly dir.
|
void |
saveChartToPng(File savedFile)
Saves the passed chart to a png file in the specified file.
|
void |
saveChartToPng(org.jfree.chart.JFreeChart chart,
File savedFile)
Saves the passed chart to a png file in the specified file.
|
void |
saveChartToSvg(File svgFile)
saves the passed chart to a svg file in the current models yearly dir.
|
void |
saveChartToSvg(org.jfree.chart.JFreeChart chart,
File svgFile)
saves the passed chart to a svg file in the current models yearly dir.
|
void |
setCategoryMargins(double catMarginPercent)
Changes the spacing between the categories.
|
void |
setDomainMarker(String categoryKey)
Adds a marker for the Domain category.
|
void |
setSubCategoryMargins(double subCatMarginPercent)
Changes the spacing between the sub categories.
|
windowActivated, windowClosed, windowClosing, windowDeactivated, windowDeiconified, windowIconified, windowOpened
addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getFont, postEvent
public static final short FILETYPE_UNKNOWN
public static final short FILETYPE_XLS
public static final short FILETYPE_CSV
public static final short FILETYPE_SQL
private String categoryName
private Vector categories
private String stackedDataName
private Vector stackedGroup
private org.jfree.chart.renderer.category.GroupedStackedBarRenderer groupedstackedbarrenderer
private org.jfree.data.KeyToGroupMap keytogroupmap_
private org.jfree.chart.JFreeChart jfreechart_
private int chartdX
private int chartdY
private double categoryMargin_
private String chartTitle
public Color[] chartColours
public GradientPaint[] gradientpaint
public Color chartBackgroundFromColor
public Color chartBackgroundToColor
public Font itemLabelFont
private boolean showLabels
private boolean showToolTips
public CategorizedStackedBarChart()
public CategorizedStackedBarChart(String chartTitle)
public CategorizedStackedBarChart(String chartTitle, String filename)
chartTitle
- is the title to place at the top of the chart, it also uses this for the exported filenamescsvFilename
- is the name of the csv file to read the data frompublic static short getFileType(String filename)
private void initColours()
public static void main(String[] args)
args
- The command line arguments (1st is the csvFilename, the rest make up a Chart Title)public org.jfree.chart.JFreeChart getChart()
public JPanel createChartPanel(org.jfree.data.category.CategoryDataset ds)
private org.jfree.data.category.CategoryDataset createDatasetFromSQL(String sqlFilename)
public org.jfree.data.category.CategoryDataset createDatasetFromXLS(String xlsFilename)
public org.jfree.data.category.CategoryDataset createDatasetFromCSVFile(String csvFilename)
public org.jfree.data.category.CategoryDataset createDatasetFromCSV(String csv)
public org.jfree.chart.JFreeChart createCategoryStackedBarChart(org.jfree.data.category.CategoryDataset categorydataset)
categorydataset
- the dataset to use in the chartpublic org.jfree.chart.JFreeChart createCategoryStackedBarChart(String chartTitle, org.jfree.data.category.CategoryDataset categorydataset)
chartTitle
- a new title to put at the top of the chartcategorydataset
- the dataset to use in the chartpublic org.jfree.chart.JFreeChart createCategoryStackedBarChart(String chartTitle, String subTitle, org.jfree.data.category.CategoryDataset categorydataset)
chartTitle
- a new title to put at the top of the chartchartSubTitle
- a new subtitle below the titlecategorydataset
- the dataset to use in the chartpublic org.jfree.chart.plot.CategoryPlot getPlot()
public void setDomainMarker(String categoryKey)
catMarginPercent
- The main category spacing in percent (where 0.10 is ten percent).public void setCategoryMargins(double catMarginPercent)
catMarginPercent
- The main category spacing in percent (where 0.10 is ten percent).public void setSubCategoryMargins(double subCatMarginPercent)
subCatMarginPercent
- The sub-category spacing in percent (where 0.10 is ten percent).public void addSubtitle(String subtitleParm)
subtitleParm
- - The new subtitleprivate org.jfree.chart.LegendItemCollection createLegendItems()
public void saveChartToSvg(org.jfree.chart.JFreeChart chart, File svgFile)
public void saveChartToSvg(File svgFile)
public void saveChartToPng(File savedFile)
savedFile
- is the resulting file to save intopublic void saveChartToPng(org.jfree.chart.JFreeChart chart, File savedFile)
chart
- is the chart to render to a filesavedFile
- is the resulting file to save intopublic static void exportChartAsPDF(OutputStream out, org.jfree.chart.JFreeChart chart, int width, int height, String title)
out
- the output stream.chart
- the chart.width
- the chart width.height
- the chart height.title
- duhIOException
- Description of the Exceptionpublic static void exportChartAsPDF(OutputStream out, org.jfree.chart.JFreeChart chart, int width, int height)
out
- the output stream.chart
- the chart.width
- the chart width.height
- the chart height.IOException
- Description of the Exceptionpublic static void exportChartAsPDF(OutputStream out, org.jfree.chart.JFreeChart chart, int width, int height, FontMapper mapper)
out
- the output stream.chart
- the chart.width
- the chart width.height
- the chart height.mapper
- Description of the ParameterIOException
- Description of the Exceptionpublic static void exportChartAsPDF(OutputStream out, org.jfree.chart.JFreeChart chart, int width, int height, FontMapper mapper, String title)
out
- the output stream.chart
- the chart.width
- the chart width.height
- the chart height.mapper
- Description of the Parametertitle
- is the title to assign to the pdfIOException
- Description of the Exceptionpublic void saveChartToPdf(File pdfFile)
public void saveChartToPdf(String fileName)
public void saveChartToPdf(org.jfree.chart.JFreeChart chart, String fileName)
public void saveChartToPdf(org.jfree.chart.JFreeChart chart, File pdfFile)
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses