org.jvnet.lafwidget.preview
Class PreviewPainter

java.lang.Object
  extended by org.jvnet.lafwidget.preview.PreviewPainter
Direct Known Subclasses:
DefaultPreviewPainter

public abstract class PreviewPainter
extends java.lang.Object

Base class for component preview painters.

Author:
Kirill Grouchnikov

Constructor Summary
PreviewPainter()
           
 
Method Summary
 java.awt.Dimension getPreviewWindowDimension(java.awt.Container parent, java.awt.Component component, int componentIndex)
          Returns the dimension for the component preview window.
 int getPreviewWindowExtraDelay(java.awt.Container parent, java.awt.Component component, int componentIndex)
          Returns extra delay (in milliseconds) for showing the component preview window.
 int getUpdateCycle(java.awt.Container parent, java.awt.Component component, int componentIndex)
          If the result of toUpdatePeriodically(Container, Component, int) is true, returns the update cycle length in milliseconds.
 boolean hasPreview(java.awt.Container parent, java.awt.Component component, int componentIndex)
          Checks whether the specified component is previewable.
 boolean hasPreviewWindow(java.awt.Container parent, java.awt.Component component, int componentIndex)
          Checks whether the specified component has a preview window.
 void previewComponent(java.awt.Container parent, java.awt.Component component, int componentIndex, java.awt.Graphics g, int x, int y, int w, int h)
          Draws a component preview on the specified graphics.
 boolean toUpdatePeriodically(java.awt.Container parent, java.awt.Component component, int componentIndex)
          Returns indication whether the thumbnail preview should be updated periodically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PreviewPainter

public PreviewPainter()
Method Detail

previewComponent

public void previewComponent(java.awt.Container parent,
                             java.awt.Component component,
                             int componentIndex,
                             java.awt.Graphics g,
                             int x,
                             int y,
                             int w,
                             int h)
Draws a component preview on the specified graphics.

Parameters:
parent - Component parent. May be null.
component - Component. May be null.
componentIndex - Component index in its parent. May be negative.
g - Graphics context.
x - X coordinate of the preview area.
y - Y coordinate of the preview area.
w - Width of the preview area.
h - Height of the preview area.

hasPreview

public boolean hasPreview(java.awt.Container parent,
                          java.awt.Component component,
                          int componentIndex)
Checks whether the specified component is previewable.

Parameters:
parent - Component parent. May be null.
component - Component. May be null.
componentIndex - Component index in its parent. May be negative.
Returns:
true if the specified component is previewable, false otherwise.

hasPreviewWindow

public boolean hasPreviewWindow(java.awt.Container parent,
                                java.awt.Component component,
                                int componentIndex)
Checks whether the specified component has a preview window.

Parameters:
parent - Component parent. May be null.
component - Component. May be null.
componentIndex - Component index in its parent. May be negative.
Returns:
true if the specified component has a preview window, false otherwise.

getPreviewWindowDimension

public java.awt.Dimension getPreviewWindowDimension(java.awt.Container parent,
                                                    java.awt.Component component,
                                                    int componentIndex)
Returns the dimension for the component preview window.

Parameters:
parent - Component parent. May be null.
component - Component. May be null.
componentIndex - Component index in its parent. May be negative.
Returns:
Dimension of the component preview window.

getPreviewWindowExtraDelay

public int getPreviewWindowExtraDelay(java.awt.Container parent,
                                      java.awt.Component component,
                                      int componentIndex)
Returns extra delay (in milliseconds) for showing the component preview window. The base delay is 2000 milliseconds (2 seconds). This function must return a non-negative value. Note that this method may not be called in some preview scenarios (that require immediate preview functionality).

Parameters:
parent - Component parent. May be null.
component - Component. May be null.
componentIndex - Component index in its parent. May be negative.
Returns:
Non-negative extra delay (in milliseconds) for showing the component preview window.

toUpdatePeriodically

public boolean toUpdatePeriodically(java.awt.Container parent,
                                    java.awt.Component component,
                                    int componentIndex)
Returns indication whether the thumbnail preview should be updated periodically. If the return value is true, then the implementation of getUpdateCycle(Container, Component, int) returns the refresh cycle length in milliseconds.

Parameters:
parent - Component parent. May be null.
component - Component. May be null.
componentIndex - Component index in its parent. May be negative.
Returns:
true if the thumbnail preview of the specified component should be updated periodically, false otherwise.

getUpdateCycle

public int getUpdateCycle(java.awt.Container parent,
                          java.awt.Component component,
                          int componentIndex)
If the result of toUpdatePeriodically(Container, Component, int) is true, returns the update cycle length in milliseconds.

Parameters:
parent - Component parent. May be null.
component - Component. May be null.
componentIndex - Component index in its parent. May be negative.
Returns:
Update cycle length in milliseconds for the thumbnail preview of the specified component.