Package com.github.weisj.darklaf.ui
Class BasicTransferable
- java.lang.Object
-
- com.github.weisj.darklaf.ui.BasicTransferable
-
- All Implemented Interfaces:
Transferable
,UIResource
public class BasicTransferable extends Object implements Transferable, UIResource
A transferable implementation for the default data transfer of some Swing components.
-
-
Constructor Summary
Constructors Constructor Description BasicTransferable(String plainData, String htmlData)
-
Method Summary
Modifier and Type Method Description protected String
getHTMLData()
Fetch the data in a text/html formatprotected String
getPlainData()
Fetch the data in a text/plain format.protected Object
getRicherData(DataFlavor flavor)
protected DataFlavor[]
getRicherFlavors()
Some subclasses will have flavors that are more descriptive than HTML or plain text.Object
getTransferData(DataFlavor flavor)
Returns an object which represents the data to be transferred.DataFlavor[]
getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data can be provided in.boolean
isDataFlavorSupported(DataFlavor flavor)
Returns whether the specified data flavor is supported for this object.protected boolean
isHTMLFlavor(DataFlavor flavor)
Returns whether or not the specified data flavor is an HTML flavor that is supported.protected boolean
isHTMLSupported()
Should the HTML flavors be offered? If so, the method getHTMLData should be implemented to provide something reasonable.protected boolean
isPlainFlavor(DataFlavor flavor)
Returns whether or not the specified data flavor is an plain flavor that is supported.protected boolean
isPlainSupported()
Should the plain text flavors be offered? If so, the method getPlainData should be implemented to provide something reasonable.protected boolean
isRicherFlavor(DataFlavor flavor)
protected boolean
isStringFlavor(DataFlavor flavor)
Returns whether or not the specified data flavor is a String flavor that is supported.
-
-
-
Method Detail
-
getTransferDataFlavors
public DataFlavor[] getTransferDataFlavors()
Returns an array of DataFlavor objects indicating the flavors the data can be provided in. The array should be ordered according to preference for providing the data (from most richly descriptive to least descriptive).- Specified by:
getTransferDataFlavors
in interfaceTransferable
- Returns:
- an array of data flavors in which this data can be transferred.
-
isDataFlavorSupported
public boolean isDataFlavorSupported(DataFlavor flavor)
Returns whether the specified data flavor is supported for this object.- Specified by:
isDataFlavorSupported
in interfaceTransferable
- Parameters:
flavor
- the requested flavor for the data- Returns:
- boolean indicating whether the data flavor is supported.
-
getTransferData
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException
Returns an object which represents the data to be transferred. The class of the object returned is defined by the representation class of the flavor.- Specified by:
getTransferData
in interfaceTransferable
- Parameters:
flavor
- the requested flavor for the data- Throws:
UnsupportedFlavorException
- if the requested data flavor is not supported.- See Also:
DataFlavor.getRepresentationClass()
-
isRicherFlavor
protected boolean isRicherFlavor(DataFlavor flavor)
-
getRicherFlavors
protected DataFlavor[] getRicherFlavors()
Some subclasses will have flavors that are more descriptive than HTML or plain text. If this method returns a non-null value, it will be placed at the start of the array of supported flavors.- Returns:
- the supported data flavours as array.
-
getRicherData
protected Object getRicherData(DataFlavor flavor)
-
isHTMLFlavor
protected boolean isHTMLFlavor(DataFlavor flavor)
Returns whether or not the specified data flavor is an HTML flavor that is supported.- Parameters:
flavor
- the requested flavor for the data- Returns:
- boolean indicating whether or not the data flavor is supported
-
isHTMLSupported
protected boolean isHTMLSupported()
Should the HTML flavors be offered? If so, the method getHTMLData should be implemented to provide something reasonable.- Returns:
- true if html is supported.
-
getHTMLData
protected String getHTMLData()
Fetch the data in a text/html format- Returns:
- the html data.
-
isPlainFlavor
protected boolean isPlainFlavor(DataFlavor flavor)
Returns whether or not the specified data flavor is an plain flavor that is supported.- Parameters:
flavor
- the requested flavor for the data- Returns:
- boolean indicating whether or not the data flavor is supported
-
isPlainSupported
protected boolean isPlainSupported()
Should the plain text flavors be offered? If so, the method getPlainData should be implemented to provide something reasonable.- Returns:
- true if plain text is supported.
-
getPlainData
protected String getPlainData()
Fetch the data in a text/plain format.- Returns:
- the plain data.
-
isStringFlavor
protected boolean isStringFlavor(DataFlavor flavor)
Returns whether or not the specified data flavor is a String flavor that is supported.- Parameters:
flavor
- the requested flavor for the data- Returns:
- boolean indicating whether or not the data flavor is supported
-
-