src/solaris/classes/sun/awt/X11FontManager.java
Print this page
rev 9830 : 8039642: Fix raw and unchecked warnings in sun.awt.*
Reviewed-by: darcy, prr
@@ -57,11 +57,11 @@
* We use this substring of a full XLFD because the font configuration files
* define the XLFDs in a way that's easier to make into a request.
* E.g., the -0-0-0-0-p-0- reported by X is -*-%d-*-*-p-*- in the font
* configuration files. We need to remove that part for comparisons.
*/
- private static Map fontNameMap = new HashMap();
+ private static Map<String, String> fontNameMap = new HashMap<>();
/*
* xlfdMap is a map from a platform path like
* /usr/openwin/lib/locale/ja/X11/fonts/TT/HG-GothicB.ttf to an XLFD like
* "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0"
@@ -70,11 +70,11 @@
* this map is always a vector where we store all the native names.
* For fonts which we don't understand the key isn't a pathname, its
* the full XLFD string like :-
* "-ricoh-hg gothic b-medium-r-normal--0-0-0-0-m-0-jisx0201.1976-0"
*/
- private static Map xlfdMap = new HashMap();
+ private static Map<String, Vector<String>> xlfdMap = new HashMap<>();
/* xFontDirsMap is also a map from a font ID to a font filepath.
* The difference from fontNameMap is just that it does not have
* resolved symbolic links. Normally this is not interesting except
* that we need to know the directory in which a font was found to
@@ -86,11 +86,11 @@
* dir can be directly derived as its parent directory.
* If a font is used by two XLFDs, each corresponding to a different
* X11 font directory, then precautions must be taken to include both
* directories.
*/
- private static Map xFontDirsMap;
+ private static Map<String, String> xFontDirsMap;
/*
* This is the set of font directories needed to be on the X font path
* to enable AWT heavyweights to find all of the font configuration fonts.
* It is populated by :
@@ -119,11 +119,11 @@
* same directory can then be skipped by checking this Map.
* Access to this map is not synchronised here since creation
* of the singleton GE instance is already synchronised and that is
* the only code path that accesses this map.
*/
- private static HashMap registeredDirs = new HashMap();
+ private static HashMap<String, Object> registeredDirs = new HashMap<>();
/* Array of directories to be added to the X11 font path.
* Used by static method called from Toolkits which use X11 fonts.
* Specifically this means MToolkit
*/
@@ -181,22 +181,22 @@
* different directory.
*
* Add this XLFD (platform name) to the list of known
* ones for this file.
*/
- Vector xVal = (Vector) xlfdMap.get(fileName);
+ Vector<String> xVal = xlfdMap.get(fileName);
if (xVal == null) {
/* Try to be robust on Linux distros which move fonts
* around by verifying that the fileName represents a
* file that exists. If it doesn't, set it to null
* to trigger a search.
*/
if (getFontConfiguration().needToSearchForFile(fileName)) {
fileName = null;
}
if (fileName != null) {
- xVal = new Vector();
+ xVal = new Vector<>();
xVal.add(platName);
xlfdMap.put(fileName, xVal);
}
} else {
if (!xVal.contains(platName)) {
@@ -209,11 +209,11 @@
return fileName;
}
}
if (fontID != null) {
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
/* On Linux check for the Lucida Oblique fonts */
if (fileName == null && FontUtilities.isLinux && !isOpenJDK()) {
if (oblmap == null) {
initObliqueLucidaFontMap();
}
@@ -233,21 +233,21 @@
registerFontDirs(fontPath);
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.warning("** Finished registering all font paths");
}
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
}
if (fileName == null && !isHeadless()) {
/* Query X11 directly to see if this font is available
* as a native font.
*/
fileName = getX11FontName(platName);
}
if (fileName == null) {
fontID = switchFontIDForName(platName);
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
}
if (fileName != null) {
fontNameMap.put(fontID, fileName);
}
}
@@ -255,12 +255,12 @@
}
@Override
protected String[] getNativeNames(String fontFileName,
String platformName) {
- Vector nativeNames;
- if ((nativeNames=(Vector)xlfdMap.get(fontFileName))==null) {
+ Vector<String> nativeNames;
+ if ((nativeNames=xlfdMap.get(fontFileName))==null) {
if (platformName == null) {
return null;
} else {
/* back-stop so that at least the name used in the
* font configuration file is known as a native name
@@ -269,11 +269,11 @@
natNames[0] = platformName;
return natNames;
}
} else {
int len = nativeNames.size();
- return (String[])nativeNames.toArray(new String[len]);
+ return nativeNames.toArray(new String[len]);
}
}
/* NOTE: this method needs to be executed in a privileged context.
* The superclass constructor which is the primary caller of
@@ -364,11 +364,11 @@
}
fileName = fileName.substring(lastColon+1);
}
String fontPart = st.sval.substring(breakPos+1);
String fontID = specificFontIDForName(fontPart);
- String sVal = (String) fontNameMap.get(fontID);
+ String sVal = fontNameMap.get(fontID);
if (FontUtilities.debugFonts()) {
PlatformLogger logger = FontUtilities.getLogger();
logger.info("file=" + fileName +
" xlfd=" + fontPart);
@@ -384,18 +384,18 @@
* found to update the X server font path
* for use by AWT heavyweights - and when 2D
* wants to use the native rasteriser.
*/
if (xFontDirsMap == null) {
- xFontDirsMap = new HashMap();
+ xFontDirsMap = new HashMap<>();
}
xFontDirsMap.put(fontID, path);
fullPath = file.getCanonicalPath();
} catch (IOException e) {
fullPath = path + File.separator + fileName;
}
- Vector xVal = (Vector) xlfdMap.get(fullPath);
+ Vector<String> xVal = xlfdMap.get(fullPath);
if (FontUtilities.debugFonts()) {
FontUtilities.getLogger()
.info("fullPath=" + fullPath +
" xVal=" + xVal);
}
@@ -406,11 +406,11 @@
.info("Map fontID:"+fontID +
"to file:" + fullPath);
}
fontNameMap.put(fontID, fullPath);
if (xVal == null) {
- xVal = new Vector();
+ xVal = new Vector<>();
xlfdMap.put (fullPath, xVal);
}
xVal.add(fontPart);
}
@@ -445,12 +445,12 @@
* simply nulling out.
* xFontDirsMap is a special case in that the implementation
* will typically not ever need to initialise it so it can be null.
*/
xFontDirsMap = null;
- xlfdMap = new HashMap(1);
- fontNameMap = new HashMap(1);
+ xlfdMap = new HashMap<>(1);
+ fontNameMap = new HashMap<>(1);
}
private String getObliqueLucidaFontID(String fontID) {
if (fontID.startsWith("-lucidasans-medium-i-normal") ||
fontID.startsWith("-lucidasans-bold-i-normal") ||
@@ -577,14 +577,14 @@
*/
public String getFileNameFromXLFD(String name) {
String fileName = null;
String fontID = specificFontIDForName(name);
if (fontID != null) {
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
if (fileName == null) {
fontID = switchFontIDForName(name);
- fileName = (String)fontNameMap.get(fontID);
+ fileName = fontNameMap.get(fontID);
}
if (fileName == null) {
fileName = getDefaultFontFile();
}
}
@@ -683,11 +683,11 @@
protected void addFontToPlatformFontPath(String platformName) {
// Lazily initialize fontConfigDirs.
getPlatformFontPathFromFontConfig();
if (xFontDirsMap != null) {
String fontID = specificFontIDForName(platformName);
- String dirName = (String)xFontDirsMap.get(fontID);
+ String dirName = xFontDirsMap.get(fontID);
if (dirName != null) {
fontConfigDirs.add(dirName);
}
}
return;