Class RadianceMetricsUtilities


  • public class RadianceMetricsUtilities
    extends java.lang.Object
    Utility methods to keep component preferred size and component painting in sync. All update() calls in the UI delegates use RadianceCommonCortex.installDesktopHints(java.awt.Graphics2D, java.awt.Font) on the passed Graphics object. Components that show texts (labels, buttons, etc) should also account for text hinting for computing the preferred size. Otherwise on some JVM versions on specific screens the width of unhinted text is not the same as the width of hinted text, leading to text cut-off.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.awt.Rectangle iconR  
      private static java.awt.Insets insets  
      private static java.util.Map<HashMapKey,​java.awt.FontMetrics> metricsMap  
      private static java.util.Map<java.lang.Double,​java.awt.image.BufferedImage> offscreens  
      private static java.util.Map<HashMapKey,​java.awt.font.FontRenderContext> renderContextMap  
      private static java.awt.Rectangle textR  
      private static java.awt.Rectangle viewR  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.awt.FontMetrics getFontMetrics​(double scale, java.awt.Font font)  
      static java.awt.font.FontRenderContext getFontRenderContext​(double scale, java.awt.Font font)  
      static java.awt.Dimension getLabelPreferredSingleLineDimension​(javax.swing.JComponent component, java.lang.String text, java.awt.Font font)  
      private static java.awt.image.BufferedImage getOffscreenImage​(double scale)  
      static java.awt.Dimension getPreferredButtonSize​(javax.swing.AbstractButton button)  
      static java.awt.Dimension getPreferredCheckButtonSize​(javax.swing.AbstractButton button, javax.swing.Icon defaultIcon)  
      static java.awt.Dimension getPreferredLabelSize​(javax.swing.JLabel label)  
      • Methods inherited from class java.lang.Object

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

      • offscreens

        private static java.util.Map<java.lang.Double,​java.awt.image.BufferedImage> offscreens
      • metricsMap

        private static java.util.Map<HashMapKey,​java.awt.FontMetrics> metricsMap
      • renderContextMap

        private static java.util.Map<HashMapKey,​java.awt.font.FontRenderContext> renderContextMap
      • iconR

        private static java.awt.Rectangle iconR
      • textR

        private static java.awt.Rectangle textR
      • viewR

        private static java.awt.Rectangle viewR
      • insets

        private static java.awt.Insets insets
    • Constructor Detail

      • RadianceMetricsUtilities

        public RadianceMetricsUtilities()
    • Method Detail

      • getOffscreenImage

        private static java.awt.image.BufferedImage getOffscreenImage​(double scale)
      • getFontMetrics

        public static java.awt.FontMetrics getFontMetrics​(double scale,
                                                          java.awt.Font font)
      • getFontRenderContext

        public static java.awt.font.FontRenderContext getFontRenderContext​(double scale,
                                                                           java.awt.Font font)
      • getPreferredLabelSize

        public static java.awt.Dimension getPreferredLabelSize​(javax.swing.JLabel label)
      • getLabelPreferredSingleLineDimension

        public static java.awt.Dimension getLabelPreferredSingleLineDimension​(javax.swing.JComponent component,
                                                                              java.lang.String text,
                                                                              java.awt.Font font)
      • getPreferredButtonSize

        public static java.awt.Dimension getPreferredButtonSize​(javax.swing.AbstractButton button)
      • getPreferredCheckButtonSize

        public static java.awt.Dimension getPreferredCheckButtonSize​(javax.swing.AbstractButton button,
                                                                     javax.swing.Icon defaultIcon)