diff options
Diffstat (limited to 'src/share')
14 files changed, 243 insertions, 86 deletions
diff --git a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java index 097e6a689..ae33ddd36 100644 --- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java +++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java @@ -424,7 +424,7 @@ public class WindowsComboBoxUI extends BasicComboBoxUI { State rv; rv = super.getState(); if (rv != State.DISABLED - && ! comboBox.isEditable() + && comboBox != null && ! comboBox.isEditable() && XPStyle.getXP().isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT)) { /* diff --git a/src/share/classes/javax/swing/BorderFactory.java b/src/share/classes/javax/swing/BorderFactory.java index d71ed98ab..0f53bed45 100644 --- a/src/share/classes/javax/swing/BorderFactory.java +++ b/src/share/classes/javax/swing/BorderFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package javax.swing; import java.awt.Color; import java.awt.Font; -import javax.swing.JComponent; import javax.swing.border.*; /** @@ -74,10 +73,20 @@ public class BorderFactory return new LineBorder(color, thickness); } -// public static Border createLineBorder(Color color, int thickness, -// boolean drawRounded) { -// return new JLineBorder(color, thickness, drawRounded); -// } + /** + * Creates a line border with the specified color, thickness, and corner shape. + * + * @param color the color of the border + * @param thickness the thickness of the border + * @param rounded whether or not border corners should be round + * @return the {@code Border} object + * + * @see LineBorder#LineBorder(Color, int, boolean) + * @since 1.7 + */ + public static Border createLineBorder(Color color, int thickness, boolean rounded) { + return new LineBorder(color, thickness, rounded); + } //// BevelBorder ///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// @@ -180,7 +189,115 @@ public class BorderFactory } return null; } + +//// SoftBevelBorder /////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////////////////////// + + private static Border sharedSoftRaisedBevel; + private static Border sharedSoftLoweredBevel; + + /** + * Creates a beveled border with a raised edge and softened corners, + * using brighter shades of the component's current background color + * for highlighting, and darker shading for shadows. + * In a raised border, highlights are on top and shadows are underneath. + * + * @return the {@code Border} object + * + * @since 1.7 + */ + public static Border createRaisedSoftBevelBorder() { + if (sharedSoftRaisedBevel == null) { + sharedSoftRaisedBevel = new SoftBevelBorder(BevelBorder.RAISED); + } + return sharedSoftRaisedBevel; + } + + /** + * Creates a beveled border with a lowered edge and softened corners, + * using brighter shades of the component's current background color + * for highlighting, and darker shading for shadows. + * In a lowered border, shadows are on top and highlights are underneath. + * + * @return the {@code Border} object + * + * @since 1.7 + */ + public static Border createLoweredSoftBevelBorder() { + if (sharedSoftLoweredBevel == null) { + sharedSoftLoweredBevel = new SoftBevelBorder(BevelBorder.LOWERED); + } + return sharedSoftLoweredBevel; + } + + /** + * Creates a beveled border of the specified type with softened corners, + * using brighter shades of the component's current background color + * for highlighting, and darker shading for shadows. + * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. + * + * @param type a type of a bevel + * @return the {@code Border} object or {@code null} + * if the specified type is not valid + * + * @see BevelBorder#BevelBorder(int) + * @since 1.7 + */ + public static Border createSoftBevelBorder(int type) { + if (type == BevelBorder.RAISED) { + return createRaisedSoftBevelBorder(); + } + if (type == BevelBorder.LOWERED) { + return createLoweredSoftBevelBorder(); + } + return null; + } + + /** + * Creates a beveled border of the specified type with softened corners, + * using the specified highlighting and shadowing. + * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. + * The outer edge of the highlight area uses + * a brighter shade of the {@code highlight} color. + * The inner edge of the shadow area uses + * a brighter shade of the {@code shadow} color. + * + * @param type a type of a bevel + * @param highlight a basic color of the highlight area + * @param shadow a basic color of the shadow area + * @return the {@code Border} object + * + * @see BevelBorder#BevelBorder(int, Color, Color) + * @since 1.7 + */ + public static Border createSoftBevelBorder(int type, Color highlight, Color shadow) { + return new BevelBorder(type, highlight, shadow); + } + + /** + * Creates a beveled border of the specified type with softened corners, + * using the specified colors for the inner and outer edges + * of the highlight and the shadow areas. + * The type is either {@link BevelBorder#RAISED} or {@link BevelBorder#LOWERED}. + * Note: The shadow inner and outer colors are switched + * for a lowered bevel border. + * + * @param type a type of a bevel + * @param highlightOuter a color of the outer edge of the highlight area + * @param highlightInner a color of the inner edge of the highlight area + * @param shadowOuter a color of the outer edge of the shadow area + * @param shadowInner a color of the inner edge of the shadow area + * @return the {@code Border} object + * + * @see BevelBorder#BevelBorder(int, Color, Color, Color, Color) + * @since 1.7 + */ + public static Border createSoftBevelBorder(int type, Color highlightOuter, Color highlightInner, Color shadowOuter, Color shadowInner) { + return new BevelBorder(type, highlightOuter, highlightInner, shadowOuter, shadowInner); + } + //// EtchedBorder /////////////////////////////////////////////////////////// + static final Border sharedEtchedBorder = new EtchedBorder(); private static Border sharedRaisedEtchedBorder; diff --git a/src/share/classes/javax/swing/plaf/synth/SynthParser.java b/src/share/classes/javax/swing/plaf/synth/SynthParser.java index cfde2fcd6..37a1893e7 100644 --- a/src/share/classes/javax/swing/plaf/synth/SynthParser.java +++ b/src/share/classes/javax/swing/plaf/synth/SynthParser.java @@ -658,8 +658,7 @@ class SynthParser extends DefaultHandler { } try { _colorTypes.add((ColorType)checkCast(typeClass. - getField(typeName.substring(classIndex, - typeName.length() - classIndex)). + getField(typeName.substring(classIndex)). get(typeClass), ColorType.class)); } catch (NoSuchFieldException nsfe) { throw new SAXException("Unable to find color type: " + diff --git a/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java b/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java index 60888f674..0b55a61f0 100644 --- a/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java +++ b/src/share/classes/javax/swing/plaf/synth/SynthToolBarUI.java @@ -363,18 +363,24 @@ public class SynthToolBarUI extends BasicToolBarUI SynthIcon.getIconWidth(handleIcon, context) : 0; Dimension compDim; for (int i = 0; i < tb.getComponentCount(); i++) { - compDim = tb.getComponent(i).getMinimumSize(); - dim.width += compDim.width; - dim.height = Math.max(dim.height, compDim.height); + Component component = tb.getComponent(i); + if (component.isVisible()) { + compDim = component.getMinimumSize(); + dim.width += compDim.width; + dim.height = Math.max(dim.height, compDim.height); + } } } else { dim.height = tb.isFloatable() ? SynthIcon.getIconHeight(handleIcon, context) : 0; Dimension compDim; for (int i = 0; i < tb.getComponentCount(); i++) { - compDim = tb.getComponent(i).getMinimumSize(); - dim.width = Math.max(dim.width, compDim.width); - dim.height += compDim.height; + Component component = tb.getComponent(i); + if (component.isVisible()) { + compDim = component.getMinimumSize(); + dim.width = Math.max(dim.width, compDim.width); + dim.height += compDim.height; + } } } dim.width += insets.left + insets.right; @@ -395,18 +401,24 @@ public class SynthToolBarUI extends BasicToolBarUI SynthIcon.getIconWidth(handleIcon, context) : 0; Dimension compDim; for (int i = 0; i < tb.getComponentCount(); i++) { - compDim = tb.getComponent(i).getPreferredSize(); - dim.width += compDim.width; - dim.height = Math.max(dim.height, compDim.height); + Component component = tb.getComponent(i); + if (component.isVisible()) { + compDim = component.getPreferredSize(); + dim.width += compDim.width; + dim.height = Math.max(dim.height, compDim.height); + } } } else { dim.height = tb.isFloatable() ? SynthIcon.getIconHeight(handleIcon, context) : 0; Dimension compDim; for (int i = 0; i < tb.getComponentCount(); i++) { - compDim = tb.getComponent(i).getPreferredSize(); - dim.width = Math.max(dim.width, compDim.width); - dim.height += compDim.height; + Component component = tb.getComponent(i); + if (component.isVisible()) { + compDim = component.getPreferredSize(); + dim.width = Math.max(dim.width, compDim.width); + dim.height += compDim.height; + } } } dim.width += insets.left + insets.right; @@ -469,22 +481,24 @@ public class SynthToolBarUI extends BasicToolBarUI for (int i = 0; i < tb.getComponentCount(); i++) { c = tb.getComponent(i); - d = c.getPreferredSize(); - int y, h; - if (d.height >= baseH || c instanceof JSeparator) { - // Fill available height - y = baseY; - h = baseH; - } else { - // Center component vertically in the available space - y = baseY + (baseH / 2) - (d.height / 2); - h = d.height; + if (c.isVisible()) { + d = c.getPreferredSize(); + int y, h; + if (d.height >= baseH || c instanceof JSeparator) { + // Fill available height + y = baseY; + h = baseH; + } else { + // Center component vertically in the available space + y = baseY + (baseH / 2) - (d.height / 2); + h = d.height; + } + //if the component is a "glue" component then add to its + //width the extraSpacePerGlue it is due + if (isGlue(c)) d.width += extraSpacePerGlue; + c.setBounds(ltr ? x : x - d.width, y, d.width, h); + x = ltr ? x + d.width : x - d.width; } - //if the component is a "glue" component then add to its - //width the extraSpacePerGlue it is due - if (isGlue(c)) d.width += extraSpacePerGlue; - c.setBounds(ltr ? x : x - d.width, y, d.width, h); - x = ltr ? x + d.width : x - d.width; } } else { int handleHeight = tb.isFloatable() ? @@ -512,29 +526,31 @@ public class SynthToolBarUI extends BasicToolBarUI for (int i = 0; i < tb.getComponentCount(); i++) { c = tb.getComponent(i); - d = c.getPreferredSize(); - int x, w; - if (d.width >= baseW || c instanceof JSeparator) { - // Fill available width - x = baseX; - w = baseW; - } else { - // Center component horizontally in the available space - x = baseX + (baseW / 2) - (d.width / 2); - w = d.width; + if (c.isVisible()) { + d = c.getPreferredSize(); + int x, w; + if (d.width >= baseW || c instanceof JSeparator) { + // Fill available width + x = baseX; + w = baseW; + } else { + // Center component horizontally in the available space + x = baseX + (baseW / 2) - (d.width / 2); + w = d.width; + } + //if the component is a "glue" component then add to its + //height the extraSpacePerGlue it is due + if (isGlue(c)) d.height += extraSpacePerGlue; + c.setBounds(x, y, w, d.height); + y += d.height; } - //if the component is a "glue" component then add to its - //height the extraSpacePerGlue it is due - if (isGlue(c)) d.height += extraSpacePerGlue; - c.setBounds(x, y, w, d.height); - y += d.height; } } context.dispose(); } private boolean isGlue(Component c) { - if (c instanceof Box.Filler) { + if (c.isVisible() && c instanceof Box.Filler) { Box.Filler f = (Box.Filler)c; Dimension min = f.getMinimumSize(); Dimension pref = f.getPreferredSize(); diff --git a/src/share/classes/javax/swing/text/DefaultStyledDocument.java b/src/share/classes/javax/swing/text/DefaultStyledDocument.java index 79da25362..938fd84f2 100644 --- a/src/share/classes/javax/swing/text/DefaultStyledDocument.java +++ b/src/share/classes/javax/swing/text/DefaultStyledDocument.java @@ -25,15 +25,12 @@ package javax.swing.text; import java.awt.Color; -import java.awt.Component; import java.awt.Font; -import java.awt.FontMetrics; import java.awt.font.TextAttribute; import java.lang.ref.ReferenceQueue; import java.lang.ref.WeakReference; import java.util.Enumeration; import java.util.HashMap; -import java.util.Hashtable; import java.util.List; import java.util.Map; import java.util.Stack; @@ -41,15 +38,14 @@ import java.util.Vector; import java.util.ArrayList; import java.io.IOException; import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.Serializable; -import javax.swing.Icon; import javax.swing.event.*; import javax.swing.undo.AbstractUndoableEdit; import javax.swing.undo.CannotRedoException; import javax.swing.undo.CannotUndoException; import javax.swing.undo.UndoableEdit; import javax.swing.SwingUtilities; +import static sun.swing.SwingUtilities2.IMPLIED_CR; /** * A document that can be marked up with character and paragraph @@ -782,9 +778,18 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc // Check for the composed text element. If it is, merge the character attributes // into this element as well. if (Utilities.isComposedTextAttributeDefined(attr)) { - ((MutableAttributeSet)attr).addAttributes(cattr); - ((MutableAttributeSet)attr).addAttribute(AbstractDocument.ElementNameAttribute, - AbstractDocument.ContentElementName); + MutableAttributeSet mattr = (MutableAttributeSet) attr; + mattr.addAttributes(cattr); + mattr.addAttribute(AbstractDocument.ElementNameAttribute, + AbstractDocument.ContentElementName); + + // Assure that the composed text element is named properly + // and doesn't have the CR attribute defined. + mattr.addAttribute(StyleConstants.NameAttribute, + AbstractDocument.ContentElementName); + if (mattr.isDefined(IMPLIED_CR)) { + mattr.removeAttribute(IMPLIED_CR); + } } ElementSpec[] spec = new ElementSpec[parseBuffer.size()]; diff --git a/src/share/classes/javax/swing/text/GlyphView.java b/src/share/classes/javax/swing/text/GlyphView.java index abb46de25..72487eafc 100644 --- a/src/share/classes/javax/swing/text/GlyphView.java +++ b/src/share/classes/javax/swing/text/GlyphView.java @@ -32,6 +32,7 @@ import java.util.Locale; import javax.swing.UIManager; import sun.swing.SwingUtilities2; +import static sun.swing.SwingUtilities2.IMPLIED_CR; /** * A GlyphView is a styled chunk of text that represents a view @@ -1061,7 +1062,6 @@ public class GlyphView extends View implements TabableView, Cloneable { int length; // if it is an implied newline character boolean impliedCR; - private static final String IMPLIED_CR = "CR"; boolean skipWidth; /** diff --git a/src/share/classes/javax/swing/text/Utilities.java b/src/share/classes/javax/swing/text/Utilities.java index bb0f8f3be..394bba3ed 100644 --- a/src/share/classes/javax/swing/text/Utilities.java +++ b/src/share/classes/javax/swing/text/Utilities.java @@ -404,6 +404,24 @@ public class Utilities { } /** + * Adjust text offset so that the length of a resulting string as a whole + * fits into the specified width. + */ + static int adjustOffsetForFractionalMetrics( + Segment s, FontMetrics fm, int offset, int width) { + // Sometimes the offset returned by getTabbedTextOffset is beyond the + // available area, when fractional metrics are enabled. We should + // guard against this. + if (offset < s.count) { + while (offset > 0 && + fm.charsWidth(s.array, s.offset, offset + 1) > width) { + offset--; + } + } + return offset; + } + + /** * Determine where to break the given text to fit * within the given span. This tries to find a word boundary. * @param s the source of the text @@ -425,7 +443,7 @@ public class Utilities { int txtCount = s.count; int index = Utilities.getTabbedTextOffset(s, metrics, x0, x, e, startOffset, false); - + index = adjustOffsetForFractionalMetrics(s, metrics, index, x - x0); if (index >= txtCount - 1) { return txtCount; diff --git a/src/share/classes/javax/swing/text/WrappedPlainView.java b/src/share/classes/javax/swing/text/WrappedPlainView.java index 7d01cd904..abdaf8d5f 100644 --- a/src/share/classes/javax/swing/text/WrappedPlainView.java +++ b/src/share/classes/javax/swing/text/WrappedPlainView.java @@ -108,7 +108,7 @@ public class WrappedPlainView extends BoxView implements TabExpander { try { if (line.isLeaf()) { - drawText(line, p0, p1, g, x, y); + drawText(line, p0, p1, g, x, y); } else { // this line contains the composed text. int idx = line.getElementIndex(p0); @@ -239,9 +239,11 @@ public class WrappedPlainView extends BoxView implements TabExpander { tabBase, tabBase + currentWidth, this, p0); } else { - p = p0 + Utilities.getTabbedTextOffset(segment, metrics, - tabBase, tabBase + currentWidth, - this, p0, false); + int offset = Utilities.getTabbedTextOffset(segment, metrics, + tabBase, tabBase + currentWidth, this, p0, false); + offset = Utilities.adjustOffsetForFractionalMetrics( + segment, metrics, offset, currentWidth); + p = p0 + offset; } SegmentCache.releaseSharedSegment(segment); return p; diff --git a/src/share/classes/javax/swing/text/html/HTMLDocument.java b/src/share/classes/javax/swing/text/html/HTMLDocument.java index 5443ede76..d489b487d 100644 --- a/src/share/classes/javax/swing/text/html/HTMLDocument.java +++ b/src/share/classes/javax/swing/text/html/HTMLDocument.java @@ -24,20 +24,17 @@ */ package javax.swing.text.html; -import java.awt.Color; -import java.awt.Component; import java.awt.font.TextAttribute; import java.util.*; import java.net.URL; -import java.net.URLEncoder; import java.net.MalformedURLException; import java.io.*; import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; import javax.swing.undo.*; -import java.text.Bidi; import sun.swing.SwingUtilities2; +import static sun.swing.SwingUtilities2.IMPLIED_CR; /** * A document that models HTML. The purpose of this model is to @@ -1819,7 +1816,6 @@ public class HTMLDocument extends DefaultStyledDocument { static String MAP_PROPERTY = "__MAP__"; private static char[] NEWLINE; - private static final String IMPLIED_CR = "CR"; /** * I18N property key. diff --git a/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine b/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine index 66b2ae9c6..607ff5905 100644 --- a/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine +++ b/src/share/classes/sun/java2d/pisces/META-INF/services/sun.java2d.pipe.RenderingEngine @@ -1,5 +1,2 @@ -# Jules Rendering Engine module -sun.java2d.jules.JulesRenderingEngine - # Pisces Rendering Engine module -sun.java2d.pisces.PiscesRenderingEngine
\ No newline at end of file +sun.java2d.pisces.PiscesRenderingEngine diff --git a/src/share/classes/sun/swing/SwingUtilities2.java b/src/share/classes/sun/swing/SwingUtilities2.java index 6358d9870..d1385316d 100644 --- a/src/share/classes/sun/swing/SwingUtilities2.java +++ b/src/share/classes/sun/swing/SwingUtilities2.java @@ -109,6 +109,12 @@ public class SwingUtilities2 { new StringBuffer("AATextInfoPropertyKey"); /** + * Attribute key for the content elements. If it is set on an element, the + * element is considered to be a line break. + */ + public static final String IMPLIED_CR = "CR"; + + /** * Used to tell a text component, being used as an editor for table * or tree, how many clicks it took to start editing. */ diff --git a/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java b/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java index 8187fea6f..78207ce1c 100644 --- a/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java +++ b/src/share/classes/sun/swing/table/DefaultTableCellHeaderRenderer.java @@ -127,7 +127,7 @@ public class DefaultTableCellHeaderRenderer extends DefaultTableCellRenderer public static SortOrder getColumnSortOrder(JTable table, int column) { SortOrder rv = null; - if (table.getRowSorter() == null) { + if (table == null || table.getRowSorter() == null) { return rv; } java.util.List<? extends RowSorter.SortKey> sortKeys = diff --git a/src/share/native/sun/awt/splashscreen/splashscreen_png.c b/src/share/native/sun/awt/splashscreen/splashscreen_png.c index 6c4b3a896..7a814d215 100644 --- a/src/share/native/sun/awt/splashscreen/splashscreen_png.c +++ b/src/share/native/sun/awt/splashscreen/splashscreen_png.c @@ -182,7 +182,7 @@ SplashDecodePngStream(Splash * splash, SplashStream * stream) int success = 0; stream->read(stream, sig, SIG_BYTES); - if (!png_check_sig(sig, SIG_BYTES)) { + if (png_sig_cmp(sig, 0, SIG_BYTES)) { goto done; } success = SplashDecodePng(splash, my_png_read_stream, stream); diff --git a/src/share/native/sun/font/freetypeScaler.c b/src/share/native/sun/font/freetypeScaler.c index 39768c467..c132a4a5a 100644 --- a/src/share/native/sun/font/freetypeScaler.c +++ b/src/share/native/sun/font/freetypeScaler.c @@ -490,22 +490,23 @@ Java_sun_font_FreetypeFontScaler_getFontMetricsNative( /* ascent */ ax = 0; - ay = -(jfloat) FT26Dot6ToFloat( - scalerInfo->face->size->metrics.ascender + - bmodifier/2); + ay = -(jfloat) FT26Dot6ToFloat(FT_MulFix( + ((jlong) scalerInfo->face->ascender + bmodifier/2), + (jlong) scalerInfo->face->size->metrics.y_scale)); /* descent */ dx = 0; - dy = -(jfloat) FT26Dot6ToFloat( - scalerInfo->face->size->metrics.descender + - bmodifier/2); + dy = -(jfloat) FT26Dot6ToFloat(FT_MulFix( + ((jlong) scalerInfo->face->descender + bmodifier/2), + (jlong) scalerInfo->face->size->metrics.y_scale)); /* baseline */ bx = by = 0; /* leading */ lx = 0; - ly = (jfloat) FT26Dot6ToFloat( - scalerInfo->face->size->metrics.height + - bmodifier) + ay - dy; + ly = (jfloat) FT26Dot6ToFloat(FT_MulFix( + (jlong) scalerInfo->face->height + bmodifier, + (jlong) scalerInfo->face->size->metrics.y_scale)) + + ay - dy; /* max advance */ mx = (jfloat) FT26Dot6ToFloat( scalerInfo->face->size->metrics.max_advance + |