org.apache.jorphan.gui.ui

## Class KerningOptimizer

- java.lang.Object
- - org.apache.jorphan.gui.ui.KerningOptimizer

-     @API(since="5.5",
           status=INTERNAL)
      public class KerningOptimizer
      extends Object

  Text rendering might be slow for long lines when kerning is enabled, so it is worth disabling kerning for long texts.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static KerningOptimizer` | `INSTANCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `KerningOptimizer()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `configureKerning(JComponent component, int documentLength)` Configures text kerning according to the expected document length.
    `int` | `getMaxTextLengthWithKerning()`
    `void` | `installKerningListener(JTextComponent textComponent)` Adds a listener that disables kerning if text length reaches a certain threshold.
    `void` | `setMaxTextLengthWithKerning(int length)` Configures the maximum document length for rendering with kerning enabled.
    `void` | `uninstallKerningListener(JTextComponent textComponent)` Removes the listener that disables kerning if text length reaches a certain threshold.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### INSTANCE

          public static final KerningOptimizer INSTANCE

  - ### Constructor Detail

    - #### KerningOptimizer

          public KerningOptimizer()

  - ### Method Detail

    - #### setMaxTextLengthWithKerning

          public void setMaxTextLengthWithKerning(int length)

      Configures the maximum document length for rendering with kerning enabled.
      Parameters:
        `length` - maximum document length for rendering with kerning enabled

    - #### getMaxTextLengthWithKerning

          public int getMaxTextLengthWithKerning()

    - #### configureKerning

          public void configureKerning(JComponent component,
                                       int documentLength)

      Configures text kerning according to the expected document length. This might be useful before setting the document so the kerning is disabled before updating the document.
      Parameters:
        `component` - text component for kerning configuration
        `documentLength` - expected document length

    - #### installKerningListener

          public void installKerningListener(JTextComponent textComponent)

      Adds a listener that disables kerning if text length reaches a certain threshold.
      Parameters:
        `textComponent` - text component for kerning configuration

    - #### uninstallKerningListener

          public void uninstallKerningListener(JTextComponent textComponent)

      Removes the listener that disables kerning if text length reaches a certain threshold.
      Parameters:
        `textComponent` - text component for kerning configuration

Copyright © 1998-2022 Apache Software Foundation. All Rights Reserved.