Class SubstanceTextUtilities


  • public class SubstanceTextUtilities
    extends Object
    Text-related utilities. This class if for internal use only.
    • Constructor Detail

      • SubstanceTextUtilities

        public SubstanceTextUtilities()
    • Method Detail

      • paintTextWithDropShadow

        public static void paintTextWithDropShadow​(JComponent c,
                                                   Graphics g,
                                                   Color foregroundColor,
                                                   String text,
                                                   int width,
                                                   int height,
                                                   int xOffset,
                                                   int yOffset)
        Paints text with drop shadow.
        Parameters:
        c - Component.
        g - Graphics context.
        foregroundColor - Foreground color.
        text - Text to paint.
        width - Text rectangle width.
        height - Text rectangle height.
        xOffset - Text rectangle X offset.
        yOffset - Text rectangle Y offset.
      • paintText

        public static void paintText​(Graphics g,
                                     JComponent comp,
                                     Rectangle textRect,
                                     String text,
                                     int mnemonicIndex,
                                     Font font,
                                     Color color,
                                     Rectangle clip)
        Paints the specified text.
        Parameters:
        g - Graphics context.
        comp - Component.
        textRect - Text rectangle.
        text - Text to paint.
        mnemonicIndex - Mnemonic index.
        font - Font to use.
        color - Color to use.
        clip - Optional clip. Can be null.
      • paintVerticalText

        public static void paintVerticalText​(Graphics g,
                                             JComponent comp,
                                             Rectangle textRect,
                                             String text,
                                             int mnemonicIndex,
                                             Font font,
                                             Color color,
                                             Rectangle clip,
                                             boolean isFromBottomToTop)
        Paints the specified vertical text.
        Parameters:
        g - Graphics context.
        comp - Component.
        textRect - Text rectangle.
        text - Text to paint.
        mnemonicIndex - Mnemonic index.
        font - Font to use.
        color - Color to use.
        clip - Optional clip. Can be null.
        isFromBottomToTop - If true, the text will be painted from bottom to top, otherwise the text will be painted from top to bottom.
      • paintText

        public static void paintText​(Graphics g,
                                     AbstractButton button,
                                     Rectangle textRect,
                                     String text,
                                     int mnemonicIndex)
        Paints the text of the specified button.
        Parameters:
        g - Graphic context.
        button - Button
        textRect - Text rectangle
        text - Text to paint
        mnemonicIndex - Mnemonic index.
      • paintText

        public static void paintText​(Graphics g,
                                     AbstractButton button,
                                     ButtonModel model,
                                     Rectangle textRect,
                                     String text,
                                     int mnemonicIndex)
        Paints the text of the specified button.
        Parameters:
        g - Graphic context.
        button - Button
        model - Button model.
        textRect - Text rectangle
        text - Text to paint
        mnemonicIndex - Mnemonic index.
      • paintText

        public static void paintText​(Graphics g,
                                     JComponent component,
                                     Rectangle textRect,
                                     String text,
                                     int mnemonicIndex,
                                     ComponentState state,
                                     float textAlpha)
        Paints the specified text.
        Parameters:
        g - Graphics context.
        component - Component.
        textRect - Text rectangle.
        text - Text to paint.
        mnemonicIndex - Mnemonic index.
        state - Component state.
        textAlpha - Alpha channel for painting the text.
      • getForegroundColor

        public static Color getForegroundColor​(JComponent component,
                                               String text,
                                               ComponentState state,
                                               float textAlpha)
        Returns the foreground color for the specified component.
        Parameters:
        component - Component.
        text - Text. If empty or null, the result is null.
        state - Component state.
        textAlpha - Alpha channel for painting the text. If value is less than 1.0, the result is an opaque color which is an interpolation between the "real" foreground color and the background color of the component. This is done to ensure that native text rasterization will be performed on 6u10+ on Windows.
        Returns:
        The foreground color for the specified component.
      • getForegroundColor

        public static Color getForegroundColor​(JComponent component,
                                               String text,
                                               StateTransitionTracker.ModelStateInfo modelStateInfo,
                                               float textAlpha)
        Returns the foreground color for the specified component.
        Parameters:
        component - Component.
        text - Text. If empty or null, the result is null.
        textAlpha - Alpha channel for painting the text. If value is less than 1.0, the result is an opaque color which is an interpolation between the "real" foreground color and the background color of the component. This is done to ensure that native text rasterization will be performed on 6u10 on Windows.
        Returns:
        The foreground color for the specified component.
      • getMenuComponentForegroundColor

        public static Color getMenuComponentForegroundColor​(Component menuComponent,
                                                            String text,
                                                            StateTransitionTracker.ModelStateInfo modelStateInfo,
                                                            float textAlpha)
        Returns the foreground color for the specified menu component.
        Parameters:
        menuComponent - Menu component.
        text - Text. If empty or null, the result is null.
        modelStateInfo - Model state info for the specified component.
        textAlpha - Alpha channel for painting the text. If value is less than 1.0, the result is an opaque color which is an interpolation between the "real" foreground color and the background color of the component. This is done to ensure that native text rasterization will be performed on 6u10 on Windows.
        Returns:
        The foreground color for the specified component.
      • paintTextCompBackground

        public static void paintTextCompBackground​(Graphics g,
                                                   JComponent comp)
        Paints background of the specified text component.
        Parameters:
        g - Graphics context.
        comp - Component.
      • getTextBackgroundFillColor

        public static Color getTextBackgroundFillColor​(JComponent comp)