< prev index next >

src/java.desktop/share/classes/sun/swing/SwingUtilities2.java

Print this page

        

*** 522,540 **** * more evenly than directly laying out to the screen advances. */ String trimmedText = trimTrailingSpaces(text); if (!trimmedText.isEmpty()) { float screenWidth = (float) g2d.getFont().getStringBounds ! (trimmedText, getFontRenderContext(c)).getWidth(); TextLayout layout = createTextLayout(c, text, g2d.getFont(), g2d.getFontRenderContext()); ! // If text fits the screenWidth, then do not need to justify ! if (SwingUtilities2.stringWidth(c, g2d.getFontMetrics(), ! trimmedText) > screenWidth) { ! layout = layout.getJustifiedLayout(screenWidth); ! } /* Use alternate print color if specified */ Color col = g2d.getColor(); if (col instanceof PrintColorUIResource) { g2d.setColor(((PrintColorUIResource)col).getPrintColor()); } --- 522,536 ---- * more evenly than directly laying out to the screen advances. */ String trimmedText = trimTrailingSpaces(text); if (!trimmedText.isEmpty()) { float screenWidth = (float) g2d.getFont().getStringBounds ! (trimmedText, DEFAULT_FRC).getWidth(); TextLayout layout = createTextLayout(c, text, g2d.getFont(), g2d.getFontRenderContext()); ! layout = layout.getJustifiedLayout(screenWidth); /* Use alternate print color if specified */ Color col = g2d.getColor(); if (col instanceof PrintColorUIResource) { g2d.setColor(((PrintColorUIResource)col).getPrintColor()); }
*** 679,694 **** TextLayout layout = createTextLayout(c, text, g2d.getFont(), g2d.getFontRenderContext()); if (isPrinting) { float screenWidth = (float)g2d.getFont(). ! getStringBounds(text, getFontRenderContext(c)).getWidth(); ! // If text fits the screenWidth, then do not need to justify ! if (SwingUtilities2.stringWidth(c, g2d.getFontMetrics(), ! text) > screenWidth) { ! layout = layout.getJustifiedLayout(screenWidth); ! } } TextHitInfo leading = TextHitInfo.leading(underlinedIndex); TextHitInfo trailing = TextHitInfo.trailing(underlinedIndex); --- 675,686 ---- TextLayout layout = createTextLayout(c, text, g2d.getFont(), g2d.getFontRenderContext()); if (isPrinting) { float screenWidth = (float)g2d.getFont(). ! getStringBounds(text, DEFAULT_FRC).getWidth(); ! layout = layout.getJustifiedLayout(screenWidth); } TextHitInfo leading = TextHitInfo.leading(underlinedIndex); TextHitInfo trailing = TextHitInfo.trailing(underlinedIndex);
*** 869,883 **** deviceFontRenderContext); String trimmedText = trimTrailingSpaces(text); if (!trimmedText.isEmpty()) { float screenWidth = (float)g2d.getFont(). getStringBounds(trimmedText, frc).getWidth(); ! // If text fits the screenWidth, then do not need to justify ! if (SwingUtilities2.stringWidth(c, g2d.getFontMetrics(), ! trimmedText) > screenWidth) { ! layout = layout.getJustifiedLayout(screenWidth); ! } /* Use alternate print color if specified */ Color col = g2d.getColor(); if (col instanceof PrintColorUIResource) { g2d.setColor(((PrintColorUIResource)col).getPrintColor()); --- 861,871 ---- deviceFontRenderContext); String trimmedText = trimTrailingSpaces(text); if (!trimmedText.isEmpty()) { float screenWidth = (float)g2d.getFont(). getStringBounds(trimmedText, frc).getWidth(); ! layout = layout.getJustifiedLayout(screenWidth); /* Use alternate print color if specified */ Color col = g2d.getColor(); if (col instanceof PrintColorUIResource) { g2d.setColor(((PrintColorUIResource)col).getPrintColor());
< prev index next >