java.lang.Object
org.jfree.chart.plot.Plot
org.jfree.chart.plot.flow.FlowPlot
- All Implemented Interfaces:
Disposable
,Serializable
,Cloneable
,EventListener
,AnnotationChangeListener
,AxisChangeListener
,MarkerChangeListener
,LegendItemSource
,PublicCloneable
,DatasetChangeListener
A plot for visualising flows defined in a
FlowDataset
. This enables
the production of a type of Sankey chart. The example shown here is
produced by the FlowPlotDemo1.java
program included in the JFreeChart
Demo Collection:
- Since:
- 1.5.3
- See Also:
-
Field Summary
Fields inherited from class org.jfree.chart.plot.Plot
DEFAULT_BACKGROUND_ALPHA, DEFAULT_BACKGROUND_PAINT, DEFAULT_FOREGROUND_ALPHA, DEFAULT_INSETS, DEFAULT_LEGEND_ITEM_BOX, DEFAULT_LEGEND_ITEM_CIRCLE, DEFAULT_OUTLINE_PAINT, DEFAULT_OUTLINE_STROKE, MINIMUM_HEIGHT_TO_DRAW, MINIMUM_WIDTH_TO_DRAW, ZERO
-
Constructor Summary
ConstructorDescriptionFlowPlot
(FlowDataset dataset) Creates a new instance that will source data from the specified dataset. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns an independent copy of thisFlowPlot
instance (note, however, that the dataset is NOT cloned).void
dispose()
void
draw
(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) Draws the flow plot within the specified area of the supplied graphics targetg2
.boolean
Tests this plot for equality with an arbitrary object.Returns a reference to the dataset.Returns the default node color.Returns the default font used to display labels for the source and destination nodes.Returns the default paint used to display labels for the source and destination nodes.double
Returns the flow margin.Returns the list of colors that will be used to auto-populate the node colors when they are first rendered.getNodeFillColor
(NodeKey nodeKey) Returns the fill color for the specified node.Returns the vertical alignment of the node labels relative to the node.double
Returns the x-offset for the node labels.double
Returns the y-offset for the node labels.double
Returns the node margin (expressed as a percentage of the available plotting space) which is the gap between nodes (sources or destinations).double
Returns the width of the source and destination nodes, expressed in Java2D user-space units.Returns a string identifying the plot type.Returns the tool tip generator that creates the strings that are displayed as tool tips for the flows displayed in the plot.int
hashCode()
Returns a hashcode for this instance.protected Color
lookupNodeColor
(NodeKey nodeKey) Performs a lookup on the color for the specified node.void
setDataset
(FlowDataset dataset) Sets the dataset for the plot and sends a change notification to all registered listeners.void
setDefaultNodeColor
(Color color) Sets the default node color and sends a change event to registered listeners.void
setDefaultNodeLabelFont
(Font font) Sets the default font used to display labels for the source and destination nodes and sends a change notification to all registered listeners.void
setDefaultNodeLabelPaint
(Paint paint) Sets the default paint used to display labels for the source and destination nodes and sends a change notification to all registered listeners.void
setFlowMargin
(double margin) Sets the flow margin and sends a change notification to all registered listeners.void
setNodeColorSwatch
(List<Color> colors) Sets the color swatch for the plot.void
setNodeFillColor
(NodeKey nodeKey, Color color) Sets the fill color for the specified node and sends a change notification to all registered listeners.void
setNodeLabelAlignment
(VerticalAlignment alignment) Sets the vertical alignment of the node labels and sends a change notification to all registered listeners.void
setNodeLabelOffsetX
(double offsetX) Sets the x-offset for the node labels and sends a change notification to all registered listeners.void
setNodeLabelOffsetY
(double offsetY) Sets the y-offset for the node labels and sends a change notification to all registered listeners.void
setNodeMargin
(double margin) Sets the node margin and sends a change notification to all registered listeners.void
setNodeWidth
(double width) Sets the width for the source and destination nodes and sends a change notification to all registered listeners.void
setToolTipGenerator
(FlowLabelGenerator generator) Sets the tool tip generator and sends a change notification to all registered listeners.Methods inherited from class org.jfree.chart.plot.Plot
addChangeListener, annotationChanged, axisChanged, createAndAddEntity, datasetChanged, drawBackground, drawBackgroundImage, drawNoDataMessage, drawOutline, fetchElementHintingFlag, fillBackground, fillBackground, fireChangeEvent, getBackgroundAlpha, getBackgroundImage, getBackgroundImageAlignment, getBackgroundImageAlpha, getBackgroundPaint, getChart, getDatasetGroup, getDrawingSupplier, getForegroundAlpha, getInsets, getLegendItems, getNoDataMessage, getNoDataMessageFont, getNoDataMessagePaint, getOutlinePaint, getOutlineStroke, getParent, getRectX, getRectY, getRootPlot, handleClick, isNotify, isOutlineVisible, isSubplot, markerChanged, notifyListeners, removeChangeListener, resolveDomainAxisLocation, resolveRangeAxisLocation, setBackgroundAlpha, setBackgroundImage, setBackgroundImageAlignment, setBackgroundImageAlpha, setBackgroundPaint, setChart, setDatasetGroup, setDrawingSupplier, setDrawingSupplier, setForegroundAlpha, setInsets, setInsets, setNoDataMessage, setNoDataMessageFont, setNoDataMessagePaint, setNotify, setOutlinePaint, setOutlineStroke, setOutlineVisible, setParent, zoom
-
Constructor Details
-
FlowPlot
Creates a new instance that will source data from the specified dataset.- Parameters:
dataset
- the dataset.
-
-
Method Details
-
getPlotType
Returns a string identifying the plot type.- Specified by:
getPlotType
in classPlot
- Returns:
- A string identifying the plot type.
-
getDataset
Returns a reference to the dataset.- Returns:
- A reference to the dataset (possibly
null
).
-
setDataset
Sets the dataset for the plot and sends a change notification to all registered listeners.- Parameters:
dataset
- the dataset (null
permitted).
-
getNodeMargin
public double getNodeMargin()Returns the node margin (expressed as a percentage of the available plotting space) which is the gap between nodes (sources or destinations). The initial (default) value is0.01
(1 percent).- Returns:
- The node margin.
-
setNodeMargin
public void setNodeMargin(double margin) Sets the node margin and sends a change notification to all registered listeners.- Parameters:
margin
- the margin (expressed as a percentage).
-
getFlowMargin
public double getFlowMargin()Returns the flow margin. This determines the gap between the graphic representation of the nodes (sources and destinations) and the curved flow representation. This is expressed as a percentage of the plot width so that it remains proportional as the plot is resized. The initial (default) value is0.005
(0.5 percent).- Returns:
- The flow margin.
-
setFlowMargin
public void setFlowMargin(double margin) Sets the flow margin and sends a change notification to all registered listeners.- Parameters:
margin
- the margin (must be 0.0 or higher).
-
getNodeWidth
public double getNodeWidth()Returns the width of the source and destination nodes, expressed in Java2D user-space units. The initial (default) value is20.0
.- Returns:
- The width.
-
setNodeWidth
public void setNodeWidth(double width) Sets the width for the source and destination nodes and sends a change notification to all registered listeners.- Parameters:
width
- the width.
-
getNodeColorSwatch
Returns the list of colors that will be used to auto-populate the node colors when they are first rendered. If the list is empty, no color will be assigned to the node so, unless it is manually set, the default color will apply. This method returns a copy of the list, modifying the returned list will not affect the plot.- Returns:
- The list of colors (possibly empty, but never
null
).
-
setNodeColorSwatch
Sets the color swatch for the plot.- Parameters:
colors
- the list of colors (null
not permitted).
-
getNodeFillColor
Returns the fill color for the specified node.- Parameters:
nodeKey
- the node key (null
not permitted).- Returns:
- The fill color (possibly
null
).
-
setNodeFillColor
Sets the fill color for the specified node and sends a change notification to all registered listeners.- Parameters:
nodeKey
- the node key (null
not permitted).color
- the fill color (null
permitted).
-
getDefaultNodeColor
Returns the default node color. This is used when no specific node color has been specified. The initial (default) value isColor.GRAY
.- Returns:
- The default node color (never
null
).
-
setDefaultNodeColor
Sets the default node color and sends a change event to registered listeners.- Parameters:
color
- the color (null
not permitted).
-
getDefaultNodeLabelFont
Returns the default font used to display labels for the source and destination nodes. The initial (default) value isFont(Font.DIALOG, Font.BOLD, 12)
.- Returns:
- The default font (never
null
).
-
setDefaultNodeLabelFont
Sets the default font used to display labels for the source and destination nodes and sends a change notification to all registered listeners.- Parameters:
font
- the font (null
not permitted).
-
getDefaultNodeLabelPaint
Returns the default paint used to display labels for the source and destination nodes. The initial (default) value isColor.BLACK
.- Returns:
- The default paint (never
null
).
-
setDefaultNodeLabelPaint
Sets the default paint used to display labels for the source and destination nodes and sends a change notification to all registered listeners.- Parameters:
paint
- the paint (null
not permitted).
-
getNodeLabelAlignment
Returns the vertical alignment of the node labels relative to the node. The initial (default) value isVerticalAlignment.CENTER
.- Returns:
- The alignment (never
null
).
-
setNodeLabelAlignment
Sets the vertical alignment of the node labels and sends a change notification to all registered listeners.- Parameters:
alignment
- the new alignment (null
not permitted).
-
getNodeLabelOffsetX
public double getNodeLabelOffsetX()Returns the x-offset for the node labels.- Returns:
- The x-offset for the node labels.
-
setNodeLabelOffsetX
public void setNodeLabelOffsetX(double offsetX) Sets the x-offset for the node labels and sends a change notification to all registered listeners.- Parameters:
offsetX
- the node label x-offset in Java2D units.
-
getNodeLabelOffsetY
public double getNodeLabelOffsetY()Returns the y-offset for the node labels.- Returns:
- The y-offset for the node labels.
-
setNodeLabelOffsetY
public void setNodeLabelOffsetY(double offsetY) Sets the y-offset for the node labels and sends a change notification to all registered listeners.- Parameters:
offsetY
- the node label y-offset in Java2D units.
-
getToolTipGenerator
Returns the tool tip generator that creates the strings that are displayed as tool tips for the flows displayed in the plot.- Returns:
- The tool tip generator (possibly
null
).
-
setToolTipGenerator
Sets the tool tip generator and sends a change notification to all registered listeners. If the generator is set tonull
, no tool tips will be displayed for the flows.- Parameters:
generator
- the new generator (null
permitted).
-
draw
public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, PlotState parentState, PlotRenderingInfo info) Draws the flow plot within the specified area of the supplied graphics targetg2
. -
lookupNodeColor
Performs a lookup on the color for the specified node.- Parameters:
nodeKey
- the node key (null
not permitted).- Returns:
- The node color.
-
equals
Tests this plot for equality with an arbitrary object. Note that, for the purposes of this equality test, the dataset is ignored. -
hashCode
public int hashCode()Returns a hashcode for this instance. -
clone
Returns an independent copy of thisFlowPlot
instance (note, however, that the dataset is NOT cloned).- Specified by:
clone
in interfacePublicCloneable
- Overrides:
clone
in classPlot
- Returns:
- A close of this instance.
- Throws:
CloneNotSupportedException
-
dispose
public void dispose()- Specified by:
dispose
in interfaceDisposable
-