jdk/src/share/classes/sun/swing/SwingUtilities2.java
changeset 23281 93c0a5484bb5
parent 23280 df31f522531f
parent 22644 965bba13a5f0
child 23297 2946ef51ee24
equal deleted inserted replaced
23280:df31f522531f 23281:93c0a5484bb5
   125     /* Presently this class assumes default fractional metrics.
   125     /* Presently this class assumes default fractional metrics.
   126      * This may need to change to emulate future platform L&Fs.
   126      * This may need to change to emulate future platform L&Fs.
   127      */
   127      */
   128     public static class AATextInfo {
   128     public static class AATextInfo {
   129 
   129 
   130         private static AATextInfo getAATextInfoFromMap(Map hints) {
   130         private static AATextInfo getAATextInfoFromMap(Map<java.awt.RenderingHints.Key, Object> hints) {
   131 
   131 
   132             Object aaHint   = hints.get(KEY_TEXT_ANTIALIASING);
   132             Object aaHint   = hints.get(KEY_TEXT_ANTIALIASING);
   133             Object contHint = hints.get(KEY_TEXT_LCD_CONTRAST);
   133             Object contHint = hints.get(KEY_TEXT_LCD_CONTRAST);
   134 
   134 
   135             if (aaHint == null ||
   135             if (aaHint == null ||
   139             } else {
   139             } else {
   140                 return new AATextInfo(aaHint, (Integer)contHint);
   140                 return new AATextInfo(aaHint, (Integer)contHint);
   141             }
   141             }
   142         }
   142         }
   143 
   143 
       
   144         @SuppressWarnings("unchecked")
   144         public static AATextInfo getAATextInfo(boolean lafCondition) {
   145         public static AATextInfo getAATextInfo(boolean lafCondition) {
   145             SunToolkit.setAAFontSettingsCondition(lafCondition);
   146             SunToolkit.setAAFontSettingsCondition(lafCondition);
   146             Toolkit tk = Toolkit.getDefaultToolkit();
   147             Toolkit tk = Toolkit.getDefaultToolkit();
   147             Object map = tk.getDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
   148             Object map = tk.getDesktopProperty(SunToolkit.DESKTOPFONTHINTS);
   148             if (map instanceof Map) {
   149             if (map instanceof Map) {
   149                 return getAATextInfoFromMap((Map)map);
   150                 return getAATextInfoFromMap((Map<java.awt.RenderingHints.Key, Object>)map);
   150             } else {
   151             } else {
   151                 return null;
   152                 return null;
   152             }
   153             }
   153         }
   154         }
   154 
   155 
   661      * Point is within the actual bounds of a list item (not just in the cell)
   662      * Point is within the actual bounds of a list item (not just in the cell)
   662      * and if the JList has the "List.isFileList" client property set.
   663      * and if the JList has the "List.isFileList" client property set.
   663      * Otherwise, this method returns -1.
   664      * Otherwise, this method returns -1.
   664      * This is used to make WindowsL&F JFileChooser act like native dialogs.
   665      * This is used to make WindowsL&F JFileChooser act like native dialogs.
   665      */
   666      */
   666     public static int loc2IndexFileList(JList list, Point point) {
   667     public static int loc2IndexFileList(JList<?> list, Point point) {
   667         int index = list.locationToIndex(point);
   668         int index = list.locationToIndex(point);
   668         if (index != -1) {
   669         if (index != -1) {
   669             Object bySize = list.getClientProperty("List.isFileList");
   670             Object bySize = list.getClientProperty("List.isFileList");
   670             if (bySize instanceof Boolean && ((Boolean)bySize).booleanValue() &&
   671             if (bySize instanceof Boolean && ((Boolean)bySize).booleanValue() &&
   671                 !pointIsInActualBounds(list, index, point)) {
   672                 !pointIsInActualBounds(list, index, point)) {
   678 
   679 
   679     /**
   680     /**
   680      * Returns true if the given point is within the actual bounds of the
   681      * Returns true if the given point is within the actual bounds of the
   681      * JList item at index (not just inside the cell).
   682      * JList item at index (not just inside the cell).
   682      */
   683      */
   683     private static boolean pointIsInActualBounds(JList list, int index,
   684     private static <T> boolean pointIsInActualBounds(JList<T> list, int index,
   684                                                 Point point) {
   685                                                 Point point) {
   685         ListCellRenderer renderer = list.getCellRenderer();
   686         ListCellRenderer<? super T> renderer = list.getCellRenderer();
   686         ListModel dataModel = list.getModel();
   687         T value = list.getModel().getElementAt(index);
   687         Object value = dataModel.getElementAt(index);
       
   688         Component item = renderer.getListCellRendererComponent(list,
   688         Component item = renderer.getListCellRendererComponent(list,
   689                           value, index, false, false);
   689                           value, index, false, false);
   690         Dimension itemSize = item.getPreferredSize();
   690         Dimension itemSize = item.getPreferredSize();
   691         Rectangle cellBounds = list.getCellBounds(index, index);
   691         Rectangle cellBounds = list.getCellBounds(index, index);
   692         if (!item.getComponentOrientation().isLeftToRight()) {
   692         if (!item.getComponentOrientation().isLeftToRight()) {