2470 /**
2471 * Converts the dialog unit argument to pixels along the specified
2472 * axis.
2473 */
2474 private int dluToPixels(int dlu, int direction) {
2475 if (baseUnitX == 0) {
2476 calculateBaseUnits();
2477 }
2478 if (direction == SwingConstants.EAST ||
2479 direction == SwingConstants.WEST) {
2480 return dlu * baseUnitX / 4;
2481 }
2482 assert (direction == SwingConstants.NORTH ||
2483 direction == SwingConstants.SOUTH);
2484 return dlu * baseUnitY / 8;
2485 }
2486
2487 /**
2488 * Calculates the dialog unit mapping.
2489 */
2490 private void calculateBaseUnits() {
2491 // This calculation comes from:
2492 // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681
2493 FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(
2494 UIManager.getFont("Button.font"));
2495 baseUnitX = metrics.stringWidth(
2496 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
2497 baseUnitX = (baseUnitX / 26 + 1) / 2;
2498 // The -1 comes from experimentation.
2499 baseUnitY = metrics.getAscent() + metrics.getDescent() - 1;
2500 }
2501
2502 /**
2503 * {@inheritDoc}
2504 *
2505 * @since 1.6
2506 */
2507 public Icon getDisabledIcon(JComponent component, Icon icon) {
2508 // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
2509 // client property set to Boolean.TRUE, then use the new
|
2470 /**
2471 * Converts the dialog unit argument to pixels along the specified
2472 * axis.
2473 */
2474 private int dluToPixels(int dlu, int direction) {
2475 if (baseUnitX == 0) {
2476 calculateBaseUnits();
2477 }
2478 if (direction == SwingConstants.EAST ||
2479 direction == SwingConstants.WEST) {
2480 return dlu * baseUnitX / 4;
2481 }
2482 assert (direction == SwingConstants.NORTH ||
2483 direction == SwingConstants.SOUTH);
2484 return dlu * baseUnitY / 8;
2485 }
2486
2487 /**
2488 * Calculates the dialog unit mapping.
2489 */
2490 @SuppressWarnings("deprecation")
2491 private void calculateBaseUnits() {
2492 // This calculation comes from:
2493 // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681
2494 FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(
2495 UIManager.getFont("Button.font"));
2496 baseUnitX = metrics.stringWidth(
2497 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
2498 baseUnitX = (baseUnitX / 26 + 1) / 2;
2499 // The -1 comes from experimentation.
2500 baseUnitY = metrics.getAscent() + metrics.getDescent() - 1;
2501 }
2502
2503 /**
2504 * {@inheritDoc}
2505 *
2506 * @since 1.6
2507 */
2508 public Icon getDisabledIcon(JComponent component, Icon icon) {
2509 // if the component has a HI_RES_DISABLED_ICON_CLIENT_KEY
2510 // client property set to Boolean.TRUE, then use the new
|