org.jfree.report.util

Class ComponentDrawable

public class ComponentDrawable extends Object

Creation-Date: 11.10.2005, 14:03:15

Author: Thomas Morgner

Constructor Summary
ComponentDrawable()
Default Constructor.
ComponentDrawable(JFrame peerSupply)
Creates a new ComponentDrawable with the given Frame as peer-supply.
Method Summary
protected voidcleanUp()
A helper method that performs some cleanup and disconnects the component from the AWT and the Swing-Framework to avoid memory-leaks.
voiddraw(Graphics2D g2, Rectangle2D area)
Draws the component.
ComponentgetComponent()
Returns the component that should be drawn.
DimensiongetPreferredSize()
Returns the preferred size of the drawable.
DimensiongetSize()
Returns the declared size of the drawable.
protected static WindowgetWindowAncestor(Component component)
A private helper method that locates the Window to which the component is currently added.
booleanisAllowOwnPeer()
Returns, whether components are allowed to provide their own AWT-Window.
protected booleanisOwnPeerConnected()
A private helper method that checks, whether the component provides an own peer.
booleanisPaintSynchronized()
Returns, whether component operations will happen on the Event-Dispatcher threads.
booleanisPreserveAspectRatio()
Returns true, if this drawable will preserve an aspect ratio during the drawing.
voidsetAllowOwnPeer(boolean allowOwnPeer)
Defines, whether components are allowed to provide their own AWT-Window.
voidsetComponent(Component component)
Defines the component that should be drawn.
voidsetPaintSynchronized(boolean paintSynchronized)
Defines, whether component operations will happen on the Event-Dispatcher threads.
voidsetPreserveAspectRatio(boolean preserveAspectRatio)
Defines whether the layouter should preserve the aspect ratio of the component's preferred size.

Constructor Detail

ComponentDrawable

public ComponentDrawable()
Default Constructor.

ComponentDrawable

public ComponentDrawable(JFrame peerSupply)
Creates a new ComponentDrawable with the given Frame as peer-supply.

Parameters: peerSupply the frame that should be used as peer-source.

Method Detail

cleanUp

protected final void cleanUp()
A helper method that performs some cleanup and disconnects the component from the AWT and the Swing-Framework to avoid memory-leaks.

draw

public void draw(Graphics2D g2, Rectangle2D area)
Draws the component.

Parameters: g2 the graphics device. area the area inside which the object should be drawn.

getComponent

public Component getComponent()
Returns the component that should be drawn.

Returns: the component.

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of the drawable. If the drawable is aspect ratio aware, these bounds should be used to compute the preferred aspect ratio for this drawable.

This calls java.awt.Component#getPreferredSize() on the given component.

Returns: the preferred size.

getSize

public Dimension getSize()
Returns the declared size of the drawable. If the drawable is aspect ratio aware, these bounds should be used to compute the declared aspect ratio for this drawable.

This calls java.awt.Component#getSize() on the given component.

Returns: the preferred size.

getWindowAncestor

protected static Window getWindowAncestor(Component component)
A private helper method that locates the Window to which the component is currently added.

Parameters: component the component for which the Window should be returned.

Returns: the AWT-Window that is the (possibly indirect) parent of this component.

isAllowOwnPeer

public boolean isAllowOwnPeer()
Returns, whether components are allowed to provide their own AWT-Window.

Returns: true, if foreign peers are allowed, false otherwise.

isOwnPeerConnected

protected final boolean isOwnPeerConnected()
A private helper method that checks, whether the component provides an own peer.

Returns: true, if the component has an own peer, false otherwise.

isPaintSynchronized

public boolean isPaintSynchronized()
Returns, whether component operations will happen on the Event-Dispatcher threads. As the AWT is not synchronized, weird things can happen if AWT functionality is executed on user threads.

Returns: true, if all operations will be done on the AWT-EventDispatcher thread, false if they should be done in the local thread.

isPreserveAspectRatio

public boolean isPreserveAspectRatio()
Returns true, if this drawable will preserve an aspect ratio during the drawing.

Returns: true, if an aspect ratio is preserved, false otherwise.

setAllowOwnPeer

public void setAllowOwnPeer(boolean allowOwnPeer)
Defines, whether components are allowed to provide their own AWT-Window.

Parameters: allowOwnPeer true, if components can provide their own peers, false otherwise.

setComponent

public void setComponent(Component component)
Defines the component that should be drawn.

Parameters: component the component.

setPaintSynchronized

public void setPaintSynchronized(boolean paintSynchronized)
Defines, whether component operations will happen on the Event-Dispatcher threads. As the AWT is not synchronized, weird things can happen if AWT functionality is executed on user threads.

Parameters: paintSynchronized true, if all operations will be done on the AWT-EventDispatcher thread, false if they should be done in the local thread.

setPreserveAspectRatio

public void setPreserveAspectRatio(boolean preserveAspectRatio)
Defines whether the layouter should preserve the aspect ratio of the component's preferred size.

Parameters: preserveAspectRatio true, if the aspect ratio should be preserved, false otherwise.