Groovy Documentation

com.wordpress.tipsforjava.swing
[Java] Class CompoundIcon

java.lang.Object
  com.wordpress.tipsforjava.swing.CompoundIcon
All Implemented Interfaces:
Icon

public class CompoundIcon
extends Object

The CompoundIcon will paint two, or more, Icons as a single Icon. The Icons are painted in the order in which they are added. The Icons are layed out on the specified axis:

Authors:
Rob Camick
Darryl Burke


Nested Class Summary
enum CompoundIcon.Axis

 
Field Summary
static float BOTTOM

static float CENTER

static float LEFT

static float RIGHT

static float TOP

The CompoundIcon will paint two, or more, Icons as a single Icon.

private float alignmentX

private float alignmentY

private CompoundIcon.Axis axis

private int gap

private Icon[] icons

 
Constructor Summary
CompoundIcon(Icon... icons)

Convenience contructor for creating a CompoundIcon where the icons are layed out on on the X-AXIS, the gap is 0 and the X/Y alignments will default to CENTER.

CompoundIcon(CompoundIcon.Axis axis, Icon... icons)

Convenience contructor for creating a CompoundIcon where the gap is 0 and the X/Y alignments will default to CENTER.

CompoundIcon(CompoundIcon.Axis axis, int gap, Icon... icons)

Convenience contructor for creating a CompoundIcon where the X/Y alignments will default to CENTER.

CompoundIcon(CompoundIcon.Axis axis, int gap, float alignmentX, float alignmentY, Icon... icons)

Create a CompoundIcon specifying all the properties.

 
Method Summary
float getAlignmentX()

Get the alignment of the icon on the x-axis

float getAlignmentY()

Get the alignment of the icon on the y-axis

CompoundIcon.Axis getAxis()

Get the Axis along which each icon is painted.

int getGap()

Get the gap between each icon

Icon getIcon(int index)

Get the Icon at the specified index.

int getIconCount()

Get the number of Icons contained in this CompoundIcon.

int getIconHeight()

Gets the height of this icon.

int getIconWidth()

Gets the width of this icon.

private int getOffset(int maxValue, int iconValue, float alignment)

void paintIcon(Component c, Graphics g, int x, int y)

Paint the icons of this compound icon at the specified location

CompoundIcon valueOf(String name)

Returns the enum constant of this type with the specified name.

CompoundIcon[] values()

Returns an array containing the constants of this enum type, in the order they are declared.

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

BOTTOM

public static final float BOTTOM


CENTER

public static final float CENTER


LEFT

public static final float LEFT


RIGHT

public static final float RIGHT


TOP

public static final float TOP
The CompoundIcon will paint two, or more, Icons as a single Icon. The Icons are painted in the order in which they are added. The Icons are layed out on the specified axis:
Authors:
Rob Camick
Darryl Burke


alignmentX

private float alignmentX


alignmentY

private float alignmentY


axis

private CompoundIcon.Axis axis


gap

private int gap


icons

private Icon[] icons


 
Constructor Detail

CompoundIcon

public CompoundIcon(Icon... icons)
Convenience contructor for creating a CompoundIcon where the icons are layed out on on the X-AXIS, the gap is 0 and the X/Y alignments will default to CENTER.
Parameters:
icons - the Icons to be painted as part of the CompoundIcon


CompoundIcon

public CompoundIcon(CompoundIcon.Axis axis, Icon... icons)
Convenience contructor for creating a CompoundIcon where the gap is 0 and the X/Y alignments will default to CENTER.
Parameters:
axis - the axis used to lay out the icons for painting. Must be one of the Axis enums: X_AXIS, Y_AXIS, Z_Axis.
icons - the Icons to be painted as part of the CompoundIcon


CompoundIcon

public CompoundIcon(CompoundIcon.Axis axis, int gap, Icon... icons)
Convenience contructor for creating a CompoundIcon where the X/Y alignments will default to CENTER.
Parameters:
axis - the axis used to lay out the icons for painting Must be one of the Axis enums: X_AXIS, Y_AXIS, Z_Axis.
gap - the gap between the icons
icons - the Icons to be painted as part of the CompoundIcon


CompoundIcon

public CompoundIcon(CompoundIcon.Axis axis, int gap, float alignmentX, float alignmentY, Icon... icons)
Create a CompoundIcon specifying all the properties.
Parameters:
axis - the axis used to lay out the icons for painting Must be one of the Axis enums: X_AXIS, Y_AXIS, Z_Axis.
gap - the gap between the icons
alignmentX - the X alignment of the icons. Common values are LEFT, CENTER, RIGHT. Can be any value between 0.0 and 1.0
alignmentY - the Y alignment of the icons. Common values are TOP, CENTER, BOTTOM. Can be any value between 0.0 and 1.0
icons - the Icons to be painted as part of the CompoundIcon


 
Method Detail

getAlignmentX

public float getAlignmentX()
Get the alignment of the icon on the x-axis
Returns:
the alignment


getAlignmentY

public float getAlignmentY()
Get the alignment of the icon on the y-axis
Returns:
the alignment


getAxis

public CompoundIcon.Axis getAxis()
Get the Axis along which each icon is painted.
Returns:
the Axis


getGap

public int getGap()
Get the gap between each icon
Returns:
the gap in pixels


getIcon

public Icon getIcon(int index)
Get the Icon at the specified index.
Throws:
IndexOutOfBoundsException if the index is out of range
Parameters:
index - the index of the Icon to be returned
Returns:
the Icon at the specifed index


getIconCount

public int getIconCount()
Get the number of Icons contained in this CompoundIcon.
Returns:
the total number of Icons


getIconHeight

de
public int getIconHeight()
Gets the height of this icon.
Returns:
the height of the icon in pixels.


getIconWidth

de
public int getIconWidth()
Gets the width of this icon.
Returns:
the width of the icon in pixels.


getOffset

private int getOffset(int maxValue, int iconValue, float alignment)


paintIcon

de
public void paintIcon(Component c, Graphics g, int x, int y)
Paint the icons of this compound icon at the specified location
Parameters:
c - The component on which the icon is painted
g - the graphics context
x - the X coordinate of the icon's top-left corner
y - the Y coordinate of the icon's top-left corner


valueOf

CompoundIcon valueOf(String name)
Returns the enum constant of this type with the specified name.


values

CompoundIcon[] values()
Returns an array containing the constants of this enum type, in the order they are declared.


 

Groovy Documentation