Mercurial > hg > icedtea8-forest > jdk
changeset 4947:70b40ea06df0
7117199: Fix javac warnings in src/share/classes/java/awt/font
Reviewed-by: jgodinez, bae
author | prr |
---|---|
date | Sat, 03 Dec 2011 16:26:08 -0800 |
parents | 23acf34c80b0 |
children | 4075d524fa46 |
files | src/share/classes/java/awt/font/StyledParagraph.java src/share/classes/java/awt/font/TextAttribute.java src/share/classes/java/awt/font/TextLayout.java src/share/classes/java/awt/font/TextLine.java src/share/classes/java/awt/font/TextMeasurer.java |
diffstat | 5 files changed, 55 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/java/awt/font/StyledParagraph.java Sat Dec 03 15:40:49 2011 +0100 +++ b/src/share/classes/java/awt/font/StyledParagraph.java Sat Dec 03 16:26:08 2011 -0800 @@ -34,6 +34,7 @@ import java.awt.im.InputMethodHighlight; import java.text.Annotation; import java.text.AttributedCharacterIterator; +import java.text.AttributedCharacterIterator.Attribute; import java.util.Vector; import java.util.HashMap; import java.util.Map; @@ -65,7 +66,7 @@ // If there are multiple Decorations in the paragraph, they are // stored in this Vector, in order. Otherwise this vector and // the decorationStarts array are null. - private Vector decorations; + private Vector<Decoration> decorations; // If there are multiple Decorations in the paragraph, // decorationStarts[i] contains the index where decoration i // starts. For convenience, there is an extra entry at the @@ -76,7 +77,7 @@ // they are // stored in this Vector, in order. Otherwise this vector and // the fontStarts array are null. - private Vector fonts; + private Vector<Object> fonts; // If there are multiple Fonts/GraphicAttributes in the paragraph, // fontStarts[i] contains the index where decoration i // starts. For convenience, there is an extra entry at the @@ -104,7 +105,7 @@ final int nextRunStart = aci.getRunLimit(); final int localIndex = index-start; - Map attributes = aci.getAttributes(); + Map<? extends Attribute, ?> attributes = aci.getAttributes(); attributes = addInputMethodAttrs(attributes); Decoration d = Decoration.getDecoration(attributes); addDecoration(d, localIndex); @@ -168,7 +169,8 @@ char ch = aci.setIndex(insertPos); int relativePos = Math.max(insertPos - aci.getBeginIndex() - 1, 0); - Map attributes = addInputMethodAttrs(aci.getAttributes()); + Map<? extends Attribute, ?> attributes = + addInputMethodAttrs(aci.getAttributes()); Decoration d = Decoration.getDecoration(attributes); if (!oldParagraph.getDecorationAt(relativePos).equals(d)) { return new StyledParagraph(aci, chars); @@ -297,7 +299,7 @@ return decoration; } int run = findRunContaining(index, decorationStarts); - return (Decoration) decorations.elementAt(run); + return decorations.elementAt(run); } /** @@ -339,6 +341,7 @@ * starts array does not have room for the index, a * new array is created and returned. */ + @SuppressWarnings({"rawtypes", "unchecked"}) private static int[] addToVector(Object obj, int index, Vector v, @@ -374,7 +377,7 @@ } else { if (!decoration.equals(d)) { - decorations = new Vector(INITIAL_SIZE); + decorations = new Vector<Decoration>(INITIAL_SIZE); decorations.addElement(decoration); decorations.addElement(d); decorationStarts = new int[INITIAL_SIZE]; @@ -398,7 +401,7 @@ } else { if (!font.equals(f)) { - fonts = new Vector(INITIAL_SIZE); + fonts = new Vector<Object>(INITIAL_SIZE); fonts.addElement(font); fonts.addElement(f); fontStarts = new int[INITIAL_SIZE]; @@ -412,7 +415,8 @@ * Resolve the given chars into Fonts using FontResolver, then add * font runs for each. */ - private void addFonts(char[] chars, Map attributes, int start, int limit) { + private void addFonts(char[] chars, Map<? extends Attribute, ?> attributes, + int start, int limit) { FontResolver resolver = FontResolver.getInstance(); CodePointIterator iter = CodePointIterator.create(chars, start, limit); @@ -426,7 +430,8 @@ * Return a Map with entries from oldStyles, as well as input * method entries, if any. */ - static Map addInputMethodAttrs(Map oldStyles) { + static Map<? extends Attribute, ?> + addInputMethodAttrs(Map<? extends Attribute, ?> oldStyles) { Object value = oldStyles.get(TextAttribute.INPUT_METHOD_HIGHLIGHT); @@ -439,7 +444,7 @@ InputMethodHighlight hl; hl = (InputMethodHighlight) value; - Map imStyles = null; + Map<? extends Attribute, ?> imStyles = null; try { imStyles = hl.getStyle(); } catch (NoSuchMethodError e) { @@ -451,7 +456,8 @@ } if (imStyles != null) { - HashMap newStyles = new HashMap(5, (float)0.9); + HashMap<Attribute, Object> + newStyles = new HashMap<>(5, (float)0.9); newStyles.putAll(oldStyles); newStyles.putAll(imStyles); @@ -471,7 +477,8 @@ * If attributes does not contain a GraphicAttribute, Font, or * Font family entry this method returns null. */ - private static Object getGraphicOrFont(Map attributes) { + private static Object getGraphicOrFont( + Map<? extends Attribute, ?> attributes) { Object value = attributes.get(TextAttribute.CHAR_REPLACEMENT); if (value != null) {
--- a/src/share/classes/java/awt/font/TextAttribute.java Sat Dec 03 15:40:49 2011 +0100 +++ b/src/share/classes/java/awt/font/TextAttribute.java Sat Dec 03 16:26:08 2011 -0800 @@ -257,7 +257,8 @@ public final class TextAttribute extends Attribute { // table of all instances in this class, used by readResolve - private static final Map instanceMap = new HashMap(29); + private static final Map<String, TextAttribute> + instanceMap = new HashMap<String, TextAttribute>(29); /** * Constructs a <code>TextAttribute</code> with the specified name. @@ -280,7 +281,7 @@ "subclass didn't correctly implement readResolve"); } - TextAttribute instance = (TextAttribute) instanceMap.get(getName()); + TextAttribute instance = instanceMap.get(getName()); if (instance != null) { return instance; } else {
--- a/src/share/classes/java/awt/font/TextLayout.java Sat Dec 03 15:40:49 2011 +0100 +++ b/src/share/classes/java/awt/font/TextLayout.java Sat Dec 03 16:26:08 2011 -0800 @@ -55,6 +55,7 @@ import java.text.AttributedString; import java.text.AttributedCharacterIterator; import java.text.AttributedCharacterIterator.Attribute; +import java.text.CharacterIterator; import java.util.Map; import java.util.HashMap; import java.util.Hashtable; @@ -382,7 +383,7 @@ throw new IllegalArgumentException("Zero length string passed to TextLayout constructor."); } - Map attributes = null; + Map<? extends Attribute, ?> attributes = null; if (font.hasLayoutAttributes()) { attributes = font.getAttributes(); } @@ -451,7 +452,7 @@ private static Font singleFont(char[] text, int start, int limit, - Map attributes) { + Map<? extends Attribute, ?> attributes) { if (attributes.get(TextAttribute.CHAR_REPLACEMENT) != null) { return null; @@ -516,14 +517,17 @@ text.first(); char[] chars = new char[len]; int n = 0; - for (char c = text.first(); c != text.DONE; c = text.next()) { + for (char c = text.first(); + c != CharacterIterator.DONE; + c = text.next()) + { chars[n++] = c; } text.first(); if (text.getRunLimit() == limit) { - Map attributes = text.getAttributes(); + Map<? extends Attribute, ?> attributes = text.getAttributes(); Font font = singleFont(chars, 0, len, attributes); if (font != null) { fastInit(chars, font, attributes, frc); @@ -561,7 +565,9 @@ /** * Initialize the paragraph-specific data. */ - private void paragraphInit(byte aBaseline, CoreMetrics lm, Map paragraphAttrs, char[] text) { + private void paragraphInit(byte aBaseline, CoreMetrics lm, + Map<? extends Attribute, ?> paragraphAttrs, + char[] text) { baseline = aBaseline; @@ -581,7 +587,10 @@ * all renderable by one font (ie no embedded graphics) * all on one baseline */ - private void fastInit(char[] chars, Font font, Map attrs, FontRenderContext frc) { + private void fastInit(char[] chars, Font font, + Map<? extends Attribute, ?> attrs, + FontRenderContext frc) { + // Object vf = attrs.get(TextAttribute.ORIENTATION); // isVerticalLine = TextAttribute.ORIENTATION_VERTICAL.equals(vf); isVerticalLine = false; @@ -619,7 +628,7 @@ // and use it and its font to initialize the paragraph. // If not, use the first graphic to initialize. - Map paragraphAttrs = text.getAttributes(); + Map<? extends Attribute, ?> paragraphAttrs = text.getAttributes(); boolean haveFont = TextLine.advanceToFirstFont(text);
--- a/src/share/classes/java/awt/font/TextLine.java Sat Dec 03 15:40:49 2011 +0100 +++ b/src/share/classes/java/awt/font/TextLine.java Sat Dec 03 16:26:08 2011 -0800 @@ -43,6 +43,7 @@ import java.awt.image.BufferedImage; import java.text.Annotation; import java.text.AttributedCharacterIterator; +import java.text.AttributedCharacterIterator.Attribute; import java.text.Bidi; import java.text.CharacterIterator; import java.util.Hashtable; @@ -318,7 +319,8 @@ for (int i = 0, n = 0; i < fComponents.length; ++i, n += 2) { tlc = fComponents[getComponentLogicalIndex(i)]; AffineTransform at = tlc.getBaselineTransform(); - if (at != null && ((at.getType() & at.TYPE_TRANSLATION) != 0)) { + if (at != null && + ((at.getType() & AffineTransform.TYPE_TRANSLATION) != 0)) { double dx = at.getTranslateX(); double dy = at.getTranslateY(); builder.moveTo(tx += dx, ty += dy); @@ -903,7 +905,7 @@ char[] chars, Font font, CoreMetrics lm, - Map attributes) { + Map<? extends Attribute, ?> attributes) { boolean isDirectionLTR = true; byte[] levels = null; @@ -1250,7 +1252,10 @@ */ static boolean advanceToFirstFont(AttributedCharacterIterator aci) { - for (char ch = aci.first(); ch != aci.DONE; ch = aci.setIndex(aci.getRunLimit())) { + for (char ch = aci.first(); + ch != CharacterIterator.DONE; + ch = aci.setIndex(aci.getRunLimit())) + { if (aci.getAttribute(TextAttribute.CHAR_REPLACEMENT) == null) { return true;
--- a/src/share/classes/java/awt/font/TextMeasurer.java Sat Dec 03 15:40:49 2011 +0100 +++ b/src/share/classes/java/awt/font/TextMeasurer.java Sat Dec 03 16:26:08 2011 -0800 @@ -43,6 +43,7 @@ import java.awt.Font; import java.text.AttributedCharacterIterator; +import java.text.AttributedCharacterIterator.Attribute; import java.text.AttributedString; import java.text.Bidi; import java.text.BreakIterator; @@ -176,7 +177,7 @@ throw new Error(); } if (fComponents != null) { - other.fComponents = (TextLineComponent[]) fComponents.clone(); + other.fComponents = fComponents.clone(); } return other; } @@ -199,7 +200,10 @@ fChars = new char[text.getEndIndex() - fStart]; int n = 0; - for (char c = text.first(); c != text.DONE; c = text.next()) { + for (char c = text.first(); + c != CharacterIterator.DONE; + c = text.next()) + { fChars[n++] = c; } @@ -211,7 +215,7 @@ } text.first(); - Map paragraphAttrs = text.getAttributes(); + Map<? extends Attribute, ?> paragraphAttrs = text.getAttributes(); NumericShaper shaper = AttributeValues.getNumericShaping(paragraphAttrs); if (shaper != null) { shaper.shape(fChars, 0, fChars.length); @@ -243,7 +247,8 @@ GraphicAttribute graphic = (GraphicAttribute) paragraphAttrs.get(TextAttribute.CHAR_REPLACEMENT); fBaseline = TextLayout.getBaselineFromGraphic(graphic); - Font dummyFont = new Font(new Hashtable(5, (float)0.9)); + Hashtable<Attribute, ?> fmap = new Hashtable<>(5, (float)0.9); + Font dummyFont = new Font(fmap); LineMetrics lm = dummyFont.getLineMetrics(" ", 0, 1, fFrc); fBaselineOffsets = lm.getBaselineOffsets(); }