提交 a3be12f7 编写于 作者: P prr

7117199: Fix javac warnings in src/share/classes/java/awt/font

Reviewed-by: jgodinez, bae
上级 09e73b9e
......@@ -34,6 +34,7 @@ import java.awt.Toolkit;
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 @@ final class StyledParagraph {
// 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 @@ final class StyledParagraph {
// 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 class StyledParagraph {
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 @@ final class StyledParagraph {
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 @@ final class StyledParagraph {
return decoration;
}
int run = findRunContaining(index, decorationStarts);
return (Decoration) decorations.elementAt(run);
return decorations.elementAt(run);
}
/**
......@@ -339,6 +341,7 @@ final class StyledParagraph {
* 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 @@ final class StyledParagraph {
}
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 @@ final class StyledParagraph {
}
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 @@ final class StyledParagraph {
* 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 @@ final class StyledParagraph {
* 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 @@ final class StyledParagraph {
InputMethodHighlight hl;
hl = (InputMethodHighlight) value;
Map imStyles = null;
Map<? extends Attribute, ?> imStyles = null;
try {
imStyles = hl.getStyle();
} catch (NoSuchMethodError e) {
......@@ -451,7 +456,8 @@ final class StyledParagraph {
}
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 @@ final class StyledParagraph {
* 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) {
......
......@@ -257,7 +257,8 @@ import java.util.HashMap;
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 @@ public final class TextAttribute extends Attribute {
"subclass didn't correctly implement readResolve");
}
TextAttribute instance = (TextAttribute) instanceMap.get(getName());
TextAttribute instance = instanceMap.get(getName());
if (instance != null) {
return instance;
} else {
......
......@@ -55,6 +55,7 @@ import java.awt.geom.Rectangle2D;
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 @@ public final class TextLayout implements Cloneable {
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 @@ public final class TextLayout implements Cloneable {
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 @@ public final class TextLayout implements Cloneable {
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 @@ public final class TextLayout implements Cloneable {
/**
* 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 @@ public final class TextLayout implements Cloneable {
* 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 @@ public final class TextLayout implements Cloneable {
// 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);
......
......@@ -43,6 +43,7 @@ import java.awt.im.InputMethodHighlight;
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 @@ final class TextLine {
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 @@ final class TextLine {
char[] chars,
Font font,
CoreMetrics lm,
Map attributes) {
Map<? extends Attribute, ?> attributes) {
boolean isDirectionLTR = true;
byte[] levels = null;
......@@ -1250,7 +1252,10 @@ final class TextLine {
*/
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;
......
......@@ -43,6 +43,7 @@ package java.awt.font;
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 @@ public final class TextMeasurer implements Cloneable {
throw new Error();
}
if (fComponents != null) {
other.fComponents = (TextLineComponent[]) fComponents.clone();
other.fComponents = fComponents.clone();
}
return other;
}
......@@ -199,7 +200,10 @@ public final class TextMeasurer implements Cloneable {
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 @@ public final class TextMeasurer implements Cloneable {
}
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 @@ public final class TextMeasurer implements Cloneable {
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();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册