org.jfree.ui

Class StrokeSample

public class StrokeSample extends JComponent implements ListCellRenderer

A panel that displays a stroke sample.

Author: David Gilbert

Constructor Summary
StrokeSample(Stroke stroke)
Creates a StrokeSample for the specified stroke.
Method Summary
ComponentgetListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
Returns a list cell renderer for the stroke, so the sample can be displayed in a list or combo.
DimensiongetPreferredSize()
Returns the preferred size of the component.
StrokegetStroke()
Returns the current Stroke object being displayed.
voidpaintComponent(Graphics g)
Draws a line using the sample stroke.
voidsetStroke(Stroke stroke)
Sets the stroke object being displayed and repaints the component.

Constructor Detail

StrokeSample

public StrokeSample(Stroke stroke)
Creates a StrokeSample for the specified stroke.

Parameters: stroke the sample stroke (null permitted).

Method Detail

getListCellRendererComponent

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
Returns a list cell renderer for the stroke, so the sample can be displayed in a list or combo.

Parameters: list the list. value the value. index the index. isSelected selected? cellHasFocus focussed?

Returns: the component for rendering.

getPreferredSize

public Dimension getPreferredSize()
Returns the preferred size of the component.

Returns: the preferred size of the component.

getStroke

public Stroke getStroke()
Returns the current Stroke object being displayed.

Returns: The stroke (possibly null).

paintComponent

public void paintComponent(Graphics g)
Draws a line using the sample stroke.

Parameters: g the graphics device.

setStroke

public void setStroke(Stroke stroke)
Sets the stroke object being displayed and repaints the component.

Parameters: stroke the stroke (null permitted).