Class CompoundIcon

java.lang.Object
jaxx.runtime.swing.CompoundIcon
All Implemented Interfaces:
javax.swing.Icon

public class CompoundIcon
extends java.lang.Object
implements javax.swing.Icon
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 can be laid out
  • Horizontally
  • Vertically
  • Stacked
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  CompoundIcon.Layout  
  • Field Summary

    Fields
    Modifier and Type Field Description
    static float BOTTOM  
    static float CENTER  
    static float LEFT  
    static float RIGHT  
    static float TOP  
  • Constructor Summary

    Constructors
    Constructor Description
    CompoundIcon​(javax.swing.Icon... icons)
    Convenience constructor for creating a CompoundIcon where the icons are laid out horizontally, the gap is 0 and the X/Y alignments will default to CENTER.
    CompoundIcon​(CompoundIcon.Layout layout, int gap, float alignmentX, float alignmentY, javax.swing.Icon... icons)
    Create a CompoundIcon specifying all the properties.
    CompoundIcon​(CompoundIcon.Layout layout, int gap, javax.swing.Icon... icons)
    Convenience constructor for creating a CompoundIcon where the X/Y alignments will default to CENTER.
    CompoundIcon​(CompoundIcon.Layout layout, javax.swing.Icon... icons)
    Convenience constructor for creating a CompoundIcon where the gap is 0 and the X/Y alignments will default to CENTER.
  • Method Summary

    Modifier and Type Method Description
    float getAlignmentX()
    Get the alignment of the icon on the x-layout
    float getAlignmentY()
    Get the alignment of the icon on the y-layout
    int getGap()
    Get the gap between each icon
    javax.swing.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.
    CompoundIcon.Layout getLayout()
    Get the layout along which each icon is painted.
    void paintIcon​(java.awt.Component c, java.awt.Graphics g, int x, int y)
    Paint the icons of this compound icon at the specified location

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CompoundIcon

      public CompoundIcon​(javax.swing.Icon... icons)
      Convenience constructor for creating a CompoundIcon where the icons are laid out horizontally, 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.Layout layout, javax.swing.Icon... icons)
      Convenience constructor for creating a CompoundIcon where the gap is 0 and the X/Y alignments will default to CENTER.
      Parameters:
      layout - the layout used to lay out the icons for painting.
      icons - the Icons to be painted as part of the CompoundIcon
    • CompoundIcon

      public CompoundIcon​(CompoundIcon.Layout layout, int gap, javax.swing.Icon... icons)
      Convenience constructor for creating a CompoundIcon where the X/Y alignments will default to CENTER.
      Parameters:
      layout - the layout used to lay out the icons for painting
      gap - the gap between the icons
      icons - the Icons to be painted as part of the CompoundIcon
    • CompoundIcon

      public CompoundIcon​(CompoundIcon.Layout layout, int gap, float alignmentX, float alignmentY, javax.swing.Icon... icons)
      Create a CompoundIcon specifying all the properties.
      Parameters:
      layout - the layout used to lay out the icons for painting
      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 Details

    • getLayout

      public CompoundIcon.Layout getLayout()
      Get the layout along which each icon is painted.
      Returns:
      the layout
    • getGap

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

      public float getAlignmentX()
      Get the alignment of the icon on the x-layout
      Returns:
      the alignment
    • getAlignmentY

      public float getAlignmentY()
      Get the alignment of the icon on the y-layout
      Returns:
      the alignment
    • getIconCount

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

      public javax.swing.Icon getIcon​(int index)
      Get the Icon at the specified index.
      Parameters:
      index - the index of the Icon to be returned
      Returns:
      the Icon at the specified index
      Throws:
      java.lang.IndexOutOfBoundsException - if the index is out of range
    • getIconWidth

      public int getIconWidth()
      Gets the width of this icon.
      Specified by:
      getIconWidth in interface javax.swing.Icon
      Returns:
      the width of the icon in pixels.
    • getIconHeight

      public int getIconHeight()
      Gets the height of this icon.
      Specified by:
      getIconHeight in interface javax.swing.Icon
      Returns:
      the height of the icon in pixels.
    • paintIcon

      public void paintIcon​(java.awt.Component c, java.awt.Graphics g, int x, int y)
      Paint the icons of this compound icon at the specified location
      Specified by:
      paintIcon in interface javax.swing.Icon
      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