org.pushingpixels.flamingo.api.svg
public class SvgBatikResizableIcon extends org.apache.batik.bridge.UserAgentAdapter implements ResizableIcon, AsynchronousLoading
ResizableIcon
based on Apache Batik
library.Modifier and Type | Class and Description |
---|---|
static class |
org.pushingpixels.flamingo.api.svg.SvgBatikIcon.BufferedImageTranscoder
A transcoder that generates a BufferedImage.
|
Modifier and Type | Field and Description |
---|---|
protected Map<String,BufferedImage> |
cachedImages
Contains all precomputed images.
|
protected int |
height
The height of the rendered image.
|
protected EventListenerList |
listenerList
The listeners.
|
protected List |
listeners
The listeners.
|
protected byte[] |
svgBytes
SVG byte array.
|
protected int |
width
The width of the rendered image.
|
Modifier and Type | Method and Description |
---|---|
void |
addAsynchronousLoadListener(AsynchronousLoadListener l)
Adds listener on the asynchronous loading events.
|
void |
addGVTTreeRendererListener(org.apache.batik.swing.gvt.GVTTreeRendererListener l)
Adds a
GVTTreeRendererListener to this GVTTreeRenderer . |
protected static InputStream |
constructFromZipStream(InputStream zippedStream)
Constructs an input stream with uncompressed contents from the specified
input stream with compressed contents.
|
protected void |
fireAsyncCompleted(Boolean event)
Fires the asynchronous load event.
|
void |
fireEvent(org.apache.batik.util.EventDispatcher.Dispatcher dispatcher,
Object event)
Fires event.
|
int |
getIconHeight() |
int |
getIconWidth() |
byte[] |
getSvgBytes()
Returns the SVG bytes of the loaded SVG image.
|
static SvgBatikResizableIcon |
getSvgIcon(InputStream inputStream,
Dimension initialDim)
Returns the icon for the specified input stream.
|
static SvgBatikResizableIcon |
getSvgIcon(URL location,
Dimension initialDim)
Returns the icon for the specified URL.
|
static SvgBatikResizableIcon |
getSvgzIcon(InputStream inputStream,
Dimension initialDim)
Returns the icon for the specified input stream.
|
static SvgBatikResizableIcon |
getSvgzIcon(URL location,
Dimension initialDim)
Returns the icon for the specified URL.
|
Dimension2D |
getViewportSize()
Returns the default size of this user agent.
|
boolean |
isLoading()
Returns indication whether the content is still loading.
|
void |
paintIcon(Component c,
Graphics g,
int x,
int y) |
void |
removeAsynchronousLoadListener(AsynchronousLoadListener l)
Removes listener on the asynchronous loading events.
|
void |
removeGVTTreeRendererListener(org.apache.batik.swing.gvt.GVTTreeRendererListener l)
Removes a
GVTTreeRendererListener ner from this
GVTTreeRenderer . |
protected boolean |
renderGVTTree(int renderWidth,
int renderHeight)
Renders the GVT tree.
|
void |
setDimension(Dimension dim)
Changes the dimension of
this icon. |
void |
setPreferredSize(Dimension dim)
Sets the preferred size for
this icon. |
addStdFeatures, checkLoadExternalResource, checkLoadScript, deselectAll, displayError, displayError, displayMessage, getAlternateStyleSheet, getBolderFontWeight, getBrokenLinkDocument, getClientAreaLocationOnScreen, getDefaultFontFamily, getEventDispatcher, getExternalResourceSecurity, getLanguages, getLighterFontWeight, getMedia, getMediumFontSize, getPixelToMM, getPixelUnitToMillimeter, getScriptSecurity, getStandardBolderFontWeight, getStandardLighterFontWeight, getTransform, getUserStyleSheetURI, getXMLParserClassName, handleElement, hasFeature, isXMLParserValidating, openLink, registerExtension, runThread, setBridgeContext, setSVGCursor, setTextSelection, setTransform, showAlert, showConfirm, showPrompt, showPrompt, supportExtension
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getIconHeight, getIconWidth, paintIcon
protected EventListenerList listenerList
protected Map<String,BufferedImage> cachedImages
protected int width
protected int height
protected byte[] svgBytes
protected List listeners
protected static InputStream constructFromZipStream(InputStream zippedStream) throws IOException
zippedStream
- Input stream with compressed contents.IOException
- in case any I/O operation failed.public static SvgBatikResizableIcon getSvgIcon(URL location, Dimension initialDim)
location
- Icon URL.initialDim
- Initial dimension of the icon.public static SvgBatikResizableIcon getSvgIcon(InputStream inputStream, Dimension initialDim)
inputStream
- Icon stream.initialDim
- Initial dimension of the icon.public static SvgBatikResizableIcon getSvgzIcon(URL location, Dimension initialDim)
location
- Icon URL.initialDim
- Initial dimension of the icon.public static SvgBatikResizableIcon getSvgzIcon(InputStream inputStream, Dimension initialDim)
inputStream
- Icon stream.initialDim
- Initial dimension of the icon.public void setDimension(Dimension dim)
ResizableIcon
this
icon.setDimension
in interface ResizableIcon
dim
- New dimension for this
icon.public void addAsynchronousLoadListener(AsynchronousLoadListener l)
AsynchronousLoading
addAsynchronousLoadListener
in interface AsynchronousLoading
l
- Listener to add.public void removeAsynchronousLoadListener(AsynchronousLoadListener l)
AsynchronousLoading
removeAsynchronousLoadListener
in interface AsynchronousLoading
l
- Listener to remove.protected boolean renderGVTTree(int renderWidth, int renderHeight)
renderWidth
- Requested rendering width.renderHeight
- Requested rendering height.true
, the image is already computed and cached.protected void fireAsyncCompleted(Boolean event)
event
- Event object.public boolean isLoading()
AsynchronousLoading
isLoading
in interface AsynchronousLoading
true
if the content is still loading,
false
otherwise.public int getIconWidth()
getIconWidth
in interface Icon
public int getIconHeight()
getIconHeight
in interface Icon
public Dimension2D getViewportSize()
getViewportSize
in interface org.apache.batik.bridge.UserAgent
getViewportSize
in class org.apache.batik.bridge.UserAgentAdapter
public void setPreferredSize(Dimension dim)
this
icon. The rendering is
scheduled automatically.dim
- Preferred size.public byte[] getSvgBytes()
public void fireEvent(org.apache.batik.util.EventDispatcher.Dispatcher dispatcher, Object event)
dispatcher
- Event dispatcher.event
- Event data.public void addGVTTreeRendererListener(org.apache.batik.swing.gvt.GVTTreeRendererListener l)
GVTTreeRendererListener
to this GVTTreeRenderer
.l
- Listener to add.public void removeGVTTreeRendererListener(org.apache.batik.swing.gvt.GVTTreeRendererListener l)
GVTTreeRendererListener
ner from this
GVTTreeRenderer
.l
- Listener to remove.