com.alee.extended.label
Class StyledLabelUtils

java.lang.Object
  extended by com.alee.extended.label.StyledLabelUtils
All Implemented Interfaces:
javax.swing.SwingConstants

public final class StyledLabelUtils
extends java.lang.Object
implements javax.swing.SwingConstants

This class provides a set of utilities for WebStyledLabel component.

Author:
Mikle Garin

Field Summary
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
StyledLabelUtils()
           
 
Method Summary
static void buildTextRanges(WebStyledLabel label, java.util.List<TextRange> textRanges)
          Parses label style ranges into text ranges.
static int findFirstRowWordEndIndex(java.lang.String string)
           
static int findNextWordStartIndex(java.lang.String string, int firstRowEndIndex)
           
static java.awt.Font getFont(WebStyledLabel label)
          Returns label custom font if exists or default label font otherwise.
static java.lang.String getPlainText(java.lang.String text, java.util.List<StyleRange> styles)
           
static java.lang.String layoutCompoundLabel(java.lang.String text, javax.swing.Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR, int textIconGap)
          Computes compound label icon and text positions relative to viewR rectangle.
static java.lang.String layoutCompoundLabel(WebStyledLabel label, java.lang.String text, javax.swing.Icon icon, int verticalAlignment, int horizontalAlignment, int verticalTextPosition, int horizontalTextPosition, java.awt.Rectangle viewR, java.awt.Rectangle iconR, java.awt.Rectangle textR, int textIconGap)
          Computes compound label icon and text positions relative to viewR rectangle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StyledLabelUtils

public StyledLabelUtils()
Method Detail

buildTextRanges

public static void buildTextRanges(WebStyledLabel label,
                                   java.util.List<TextRange> textRanges)
Parses label style ranges into text ranges. All parsed text ranges are stored within provided list.

Parameters:
label - label to parse text ranges for
textRanges - list to store text ranges into

getFont

public static java.awt.Font getFont(WebStyledLabel label)
Returns label custom font if exists or default label font otherwise.

Parameters:
label - label to retrieve font for
Returns:
label custom font if exists or default label font otherwise

findNextWordStartIndex

public static int findNextWordStartIndex(java.lang.String string,
                                         int firstRowEndIndex)

findFirstRowWordEndIndex

public static int findFirstRowWordEndIndex(java.lang.String string)

layoutCompoundLabel

public static java.lang.String layoutCompoundLabel(WebStyledLabel label,
                                                   java.lang.String text,
                                                   javax.swing.Icon icon,
                                                   int verticalAlignment,
                                                   int horizontalAlignment,
                                                   int verticalTextPosition,
                                                   int horizontalTextPosition,
                                                   java.awt.Rectangle viewR,
                                                   java.awt.Rectangle iconR,
                                                   java.awt.Rectangle textR,
                                                   int textIconGap)
Computes compound label icon and text positions relative to viewR rectangle. Component orientation is also taken into account and properly applied.

Parameters:
label - painted label
text - painted text
icon - painted icon
verticalAlignment - vertical alignment
horizontalAlignment - horizontal alignment
verticalTextPosition - vertical text position
horizontalTextPosition - horizontal text position
viewR - view rectangle
iconR - icon rectangle
textR - text rectangle
textIconGap - gap between text and icon
Returns:
layout string

layoutCompoundLabel

public static java.lang.String layoutCompoundLabel(java.lang.String text,
                                                   javax.swing.Icon icon,
                                                   int verticalAlignment,
                                                   int horizontalAlignment,
                                                   int verticalTextPosition,
                                                   int horizontalTextPosition,
                                                   java.awt.Rectangle viewR,
                                                   java.awt.Rectangle iconR,
                                                   java.awt.Rectangle textR,
                                                   int textIconGap)
Computes compound label icon and text positions relative to viewR rectangle.

Parameters:
text - painted text
icon - painted icon
verticalAlignment - vertical alignment
horizontalAlignment - horizontal alignment
verticalTextPosition - vertical text position
horizontalTextPosition - horizontal text position
viewR - view rectangle
iconR - icon rectangle
textR - text rectangle
textIconGap - gap between text and icon
Returns:
layout string

getPlainText

public static java.lang.String getPlainText(java.lang.String text,
                                            java.util.List<StyleRange> styles)