junit.extensions.jfcunit.finder
Class IconMatcher

java.lang.Object
  extended byjunit.extensions.jfcunit.finder.IconMatcher

public class IconMatcher
extends java.lang.Object

Class for comparing that two Icons match.

Author:
Vijay Aravamudhan : ThoughtWorks Inc., Kevin Wilson

Field Summary
private  int m_ich
          Height of the icon.
private  javax.swing.Icon m_icon
          The icon of the first component.
private  int[] m_iconData
          iconData read from the icon given.
private  int m_icw
          width of the icon.
private  int m_incr
          Increment for performing spot checks across the icons to speed performance of not equals comparisons.
private  int m_size
          Size of the icon.
 
Constructor Summary
IconMatcher(javax.swing.Icon icon)
          Constructor accepting all arguments needed to filter the component.
 
Method Summary
 javax.swing.Icon getIcon()
          Get the icon to be matched.
private  int[] iconToArray(javax.swing.Icon icon)
          Paint the icon into an array of int.
 boolean matches(javax.swing.Icon other)
          Method that returns true if the given icon matches the one in this matcher.
 void setIcon(javax.swing.Icon icon)
          Set the Icon to be matched.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_icon

private javax.swing.Icon m_icon
The icon of the first component.


m_iconData

private int[] m_iconData
iconData read from the icon given.


m_ich

private int m_ich
Height of the icon.


m_icw

private int m_icw
width of the icon.


m_incr

private int m_incr
Increment for performing spot checks across the icons to speed performance of not equals comparisons.


m_size

private int m_size
Size of the icon.

Constructor Detail

IconMatcher

public IconMatcher(javax.swing.Icon icon)
            throws java.lang.InterruptedException
Constructor accepting all arguments needed to filter the component.

Parameters:
icon - The desired pattern for the icon of the component.
Throws:
java.lang.InterruptedException - when the PixelGrabber.grabPixels() is interrupted.
Method Detail

setIcon

public final void setIcon(javax.swing.Icon icon)
                   throws java.lang.InterruptedException
Set the Icon to be matched.

Parameters:
icon - Icon icon to match.
Throws:
java.lang.InterruptedException - may be thrown when converting the icon to an array.

getIcon

public final javax.swing.Icon getIcon()
Get the icon to be matched.

Returns:
Icon icon to be matched.

matches

public boolean matches(javax.swing.Icon other)
Method that returns true if the given icon matches the one in this matcher.

Parameters:
other - The other Icon to be compared
Returns:
true if this Icon is a match or the icon which this matcher is created for is null.

iconToArray

private int[] iconToArray(javax.swing.Icon icon)
                   throws java.lang.InterruptedException
Paint the icon into an array of int.

Parameters:
icon - Icon to be painted.
Returns:
int[] containing the painted icon.
Throws:
java.lang.InterruptedException - when PixelGrabber.grabPixels() is interrupted.


Licensed under: GNU Lesser General Public License, Ver 2.1, February 1999