Package org.jfree.chart
Class ChartTransferable
- java.lang.Object
-
- org.jfree.chart.ChartTransferable
-
- All Implemented Interfaces:
java.awt.datatransfer.Transferable
public class ChartTransferable extends java.lang.Object implements java.awt.datatransfer.Transferable
A class used to represent a chart on the clipboard.
-
-
Field Summary
Fields Modifier and Type Field Description private JFreeChart
chart
The chart.private int
height
The height of the chart on the clipboard.(package private) java.awt.datatransfer.DataFlavor
imageFlavor
The data flavor.private int
maxDrawHeight
The largest height at which the chart will be drawn (if necessary, the chart will then be scaled up to fit the requested height).private int
maxDrawWidth
The largest width at which the chart will be drawn (if necessary, the chart will then be scaled up to fit the requested width).private int
minDrawHeight
The smallest height at which the chart will be drawn (if necessary, the chart will then be scaled down to fit the requested height).private int
minDrawWidth
The smallest width at which the chart will be drawn (if necessary, the chart will then be scaled down to fit the requested width).private int
width
The width of the chart on the clipboard.
-
Constructor Summary
Constructors Constructor Description ChartTransferable(JFreeChart chart, int width, int height)
Creates a new chart selection.ChartTransferable(JFreeChart chart, int width, int height, boolean cloneData)
Creates a new chart selection.ChartTransferable(JFreeChart chart, int width, int height, int minDrawW, int minDrawH, int maxDrawW, int maxDrawH, boolean cloneData)
Creates a new chart selection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.awt.image.BufferedImage
createBufferedImage(JFreeChart chart, int w, int h, int minDrawW, int minDrawH, int maxDrawW, int maxDrawH)
A utility method that creates an image of a chart, with scaling.java.lang.Object
getTransferData(java.awt.datatransfer.DataFlavor flavor)
Returns the content for the requested flavor, if it is supported.java.awt.datatransfer.DataFlavor[]
getTransferDataFlavors()
Returns the data flavors supported.boolean
isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returnstrue
if the specified flavor is supported.
-
-
-
Field Detail
-
imageFlavor
final java.awt.datatransfer.DataFlavor imageFlavor
The data flavor.
-
chart
private JFreeChart chart
The chart.
-
width
private final int width
The width of the chart on the clipboard.
-
height
private final int height
The height of the chart on the clipboard.
-
minDrawWidth
private final int minDrawWidth
The smallest width at which the chart will be drawn (if necessary, the chart will then be scaled down to fit the requested width).
-
minDrawHeight
private final int minDrawHeight
The smallest height at which the chart will be drawn (if necessary, the chart will then be scaled down to fit the requested height).
-
maxDrawWidth
private final int maxDrawWidth
The largest width at which the chart will be drawn (if necessary, the chart will then be scaled up to fit the requested width).
-
maxDrawHeight
private final int maxDrawHeight
The largest height at which the chart will be drawn (if necessary, the chart will then be scaled up to fit the requested height).
-
-
Constructor Detail
-
ChartTransferable
public ChartTransferable(JFreeChart chart, int width, int height)
Creates a new chart selection.- Parameters:
chart
- the chart.width
- the chart width.height
- the chart height.
-
ChartTransferable
public ChartTransferable(JFreeChart chart, int width, int height, boolean cloneData)
Creates a new chart selection.- Parameters:
chart
- the chart.width
- the chart width.height
- the chart height.cloneData
- clone the dataset(s)?
-
ChartTransferable
public ChartTransferable(JFreeChart chart, int width, int height, int minDrawW, int minDrawH, int maxDrawW, int maxDrawH, boolean cloneData)
Creates a new chart selection. The minimum and maximum drawing dimensions are used to match the scaling behaviour in theChartPanel
class.- Parameters:
chart
- the chart.width
- the chart width.height
- the chart height.minDrawW
- the minimum drawing width.minDrawH
- the minimum drawing height.maxDrawW
- the maximum drawing width.maxDrawH
- the maximum drawing height.cloneData
- clone the dataset(s)?
-
-
Method Detail
-
getTransferDataFlavors
public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Returns the data flavors supported.- Specified by:
getTransferDataFlavors
in interfacejava.awt.datatransfer.Transferable
- Returns:
- The data flavors supported.
-
isDataFlavorSupported
public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Returnstrue
if the specified flavor is supported.- Specified by:
isDataFlavorSupported
in interfacejava.awt.datatransfer.Transferable
- Parameters:
flavor
- the flavor.- Returns:
- A boolean.
-
getTransferData
public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor) throws java.awt.datatransfer.UnsupportedFlavorException, java.io.IOException
Returns the content for the requested flavor, if it is supported.- Specified by:
getTransferData
in interfacejava.awt.datatransfer.Transferable
- Parameters:
flavor
- the requested flavor.- Returns:
- The content.
- Throws:
java.awt.datatransfer.UnsupportedFlavorException
- if the flavor is not supported.java.io.IOException
- if there is an IO problem.
-
createBufferedImage
private java.awt.image.BufferedImage createBufferedImage(JFreeChart chart, int w, int h, int minDrawW, int minDrawH, int maxDrawW, int maxDrawH)
A utility method that creates an image of a chart, with scaling.- Parameters:
chart
- the chart.w
- the image width.h
- the image height.minDrawW
- the minimum width for chart drawing.minDrawH
- the minimum height for chart drawing.maxDrawW
- the maximum width for chart drawing.maxDrawH
- the maximum height for chart drawing.- Returns:
- A chart image.
-
-