6771030: Code improvement and warnings removing from the com.sun.java.swing.plaf.gtk package
Removed unnecessary castings and other warnings Reviewed-by: malenkov
This commit is contained in:
parent
1bff9286d7
commit
9487cedae1
@ -799,9 +799,9 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements
|
|||||||
Graphics g = triangleImage.getGraphics();
|
Graphics g = triangleImage.getGraphics();
|
||||||
g.setColor(new Color(0, 0, 0, 0));
|
g.setColor(new Color(0, 0, 0, 0));
|
||||||
g.fillRect(0, 0, a, a);
|
g.fillRect(0, 0, a, a);
|
||||||
g.translate((int)(a / 2), 0);
|
g.translate(a / 2, 0);
|
||||||
paintTriangle(g, triangleSize, getColor());
|
paintTriangle(g, triangleSize, getColor());
|
||||||
g.translate((int)(-a / 2), 0);
|
g.translate(-a / 2, 0);
|
||||||
g.dispose();
|
g.dispose();
|
||||||
|
|
||||||
g = wheelImage.getGraphics();
|
g = wheelImage.getGraphics();
|
||||||
@ -897,7 +897,7 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Rotate to origin and and verify x is valid.
|
// Rotate to origin and and verify x is valid.
|
||||||
int triangleSize = (int)innerR * 3 / 2;
|
int triangleSize = innerR * 3 / 2;
|
||||||
double x1 = Math.cos(angle) * x - Math.sin(angle) * y;
|
double x1 = Math.cos(angle) * x - Math.sin(angle) * y;
|
||||||
double y1 = Math.sin(angle) * x + Math.cos(angle) * y;
|
double y1 = Math.sin(angle) * x + Math.cos(angle) * y;
|
||||||
if (x1 < -(innerR / 2)) {
|
if (x1 < -(innerR / 2)) {
|
||||||
@ -960,7 +960,7 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements
|
|||||||
*/
|
*/
|
||||||
private void setSaturationAndBrightness(float s, float b) {
|
private void setSaturationAndBrightness(float s, float b) {
|
||||||
int innerR = getTriangleCircumscribedRadius();
|
int innerR = getTriangleCircumscribedRadius();
|
||||||
int triangleSize = (int)innerR * 3 / 2;
|
int triangleSize = innerR * 3 / 2;
|
||||||
double x = b * triangleSize;
|
double x = b * triangleSize;
|
||||||
double maxY = x * Math.tan(Math.toRadians(30.0));
|
double maxY = x * Math.tan(Math.toRadians(30.0));
|
||||||
double y = 2 * maxY * s - maxY;
|
double y = 2 * maxY * s - maxY;
|
||||||
@ -1156,7 +1156,7 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements
|
|||||||
* @param x X location to get color for
|
* @param x X location to get color for
|
||||||
* @param y Y location to get color for
|
* @param y Y location to get color for
|
||||||
* @param rad Radius from center of color wheel
|
* @param rad Radius from center of color wheel
|
||||||
* @param integer with red, green and blue components
|
* @return integer with red, green and blue components
|
||||||
*/
|
*/
|
||||||
private int colorWheelLocationToRGB(int x, int y, double rad) {
|
private int colorWheelLocationToRGB(int x, int y, double rad) {
|
||||||
double angle = Math.acos((double)x / rad);
|
double angle = Math.acos((double)x / rad);
|
||||||
@ -1165,12 +1165,12 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements
|
|||||||
if (angle < PI_3) {
|
if (angle < PI_3) {
|
||||||
if (y < 0) {
|
if (y < 0) {
|
||||||
// FFFF00 - FF0000
|
// FFFF00 - FF0000
|
||||||
rgb = 0xFF0000 | (int)Math.min(255,
|
rgb = 0xFF0000 | Math.min(255,
|
||||||
(int)(255 * angle / PI_3)) << 8;
|
(int)(255 * angle / PI_3)) << 8;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// FF0000 - FF00FF
|
// FF0000 - FF00FF
|
||||||
rgb = 0xFF0000 | (int)Math.min(255,
|
rgb = 0xFF0000 | Math.min(255,
|
||||||
(int)(255 * angle / PI_3));
|
(int)(255 * angle / PI_3));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1178,12 +1178,12 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements
|
|||||||
angle -= PI_3;
|
angle -= PI_3;
|
||||||
if (y < 0) {
|
if (y < 0) {
|
||||||
// 00FF00 - FFFF00
|
// 00FF00 - FFFF00
|
||||||
rgb = 0x00FF00 | (int)Math.max(0, 255 -
|
rgb = 0x00FF00 | Math.max(0, 255 -
|
||||||
(int)(255 * angle / PI_3)) << 16;
|
(int)(255 * angle / PI_3)) << 16;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// FF00FF - 0000FF
|
// FF00FF - 0000FF
|
||||||
rgb = 0x0000FF | (int)Math.max(0, 255 -
|
rgb = 0x0000FF | Math.max(0, 255 -
|
||||||
(int)(255 * angle / PI_3)) << 16;
|
(int)(255 * angle / PI_3)) << 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1191,12 +1191,12 @@ class GTKColorChooserPanel extends AbstractColorChooserPanel implements
|
|||||||
angle -= 2 * PI_3;
|
angle -= 2 * PI_3;
|
||||||
if (y < 0) {
|
if (y < 0) {
|
||||||
// 00FFFF - 00FF00
|
// 00FFFF - 00FF00
|
||||||
rgb = 0x00FF00 | (int)Math.min(255,
|
rgb = 0x00FF00 | Math.min(255,
|
||||||
(int)(255 * angle / PI_3));
|
(int)(255 * angle / PI_3));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// 0000FF - 00FFFF
|
// 0000FF - 00FFFF
|
||||||
rgb = 0x0000FF | (int)Math.min(255,
|
rgb = 0x0000FF | Math.min(255,
|
||||||
(int)(255 * angle / PI_3)) << 8;
|
(int)(255 * angle / PI_3)) << 8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ class GTKEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static HashMap regionToWidgetTypeMap;
|
private static HashMap<Region, Object> regionToWidgetTypeMap;
|
||||||
private ImageCache cache = new ImageCache(CACHE_SIZE);
|
private ImageCache cache = new ImageCache(CACHE_SIZE);
|
||||||
private int x0, y0, w0, h0;
|
private int x0, y0, w0, h0;
|
||||||
private Graphics graphics;
|
private Graphics graphics;
|
||||||
@ -178,7 +178,7 @@ class GTKEngine {
|
|||||||
Toolkit.getDefaultToolkit();
|
Toolkit.getDefaultToolkit();
|
||||||
|
|
||||||
// Initialize regionToWidgetTypeMap
|
// Initialize regionToWidgetTypeMap
|
||||||
regionToWidgetTypeMap = new HashMap(50);
|
regionToWidgetTypeMap = new HashMap<Region, Object>(50);
|
||||||
regionToWidgetTypeMap.put(Region.ARROW_BUTTON, new WidgetType[] {
|
regionToWidgetTypeMap.put(Region.ARROW_BUTTON, new WidgetType[] {
|
||||||
WidgetType.SPINNER_ARROW_BUTTON,
|
WidgetType.SPINNER_ARROW_BUTTON,
|
||||||
WidgetType.COMBO_BOX_ARROW_BUTTON,
|
WidgetType.COMBO_BOX_ARROW_BUTTON,
|
||||||
|
@ -148,7 +148,7 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
|||||||
directoryList : fileList;
|
directoryList : fileList;
|
||||||
Object[] files = list.getSelectedValues();
|
Object[] files = list.getSelectedValues();
|
||||||
int len = files.length;
|
int len = files.length;
|
||||||
Vector result = new Vector(len + 1);
|
Vector<String> result = new Vector<String>(len + 1);
|
||||||
|
|
||||||
// we return all selected file names
|
// we return all selected file names
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
@ -425,16 +425,16 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
|||||||
setDirectorySelected(true);
|
setDirectorySelected(true);
|
||||||
setDirectory(((File)objects[0]));
|
setDirectory(((File)objects[0]));
|
||||||
} else {
|
} else {
|
||||||
ArrayList fList = new ArrayList(objects.length);
|
ArrayList<File> fList = new ArrayList<File>(objects.length);
|
||||||
for (int i = 0; i < objects.length; i++) {
|
for (Object object : objects) {
|
||||||
File f = (File)objects[i];
|
File f = (File) object;
|
||||||
if ((chooser.isFileSelectionEnabled() && f.isFile())
|
if ((chooser.isFileSelectionEnabled() && f.isFile())
|
||||||
|| (chooser.isDirectorySelectionEnabled() && f.isDirectory())) {
|
|| (chooser.isDirectorySelectionEnabled() && f.isDirectory())) {
|
||||||
fList.add(f);
|
fList.add(f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fList.size() > 0) {
|
if (fList.size() > 0) {
|
||||||
files = (File[])fList.toArray(new File[fList.size()]);
|
files = fList.toArray(new File[fList.size()]);
|
||||||
}
|
}
|
||||||
setDirectorySelected(false);
|
setDirectorySelected(false);
|
||||||
}
|
}
|
||||||
@ -671,9 +671,9 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
|||||||
|
|
||||||
pathFieldLabel.setLabelFor(fileNameTextField);
|
pathFieldLabel.setLabelFor(fileNameTextField);
|
||||||
|
|
||||||
Set forwardTraversalKeys = fileNameTextField.getFocusTraversalKeys(
|
Set<AWTKeyStroke> forwardTraversalKeys = fileNameTextField.getFocusTraversalKeys(
|
||||||
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
|
KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
|
||||||
forwardTraversalKeys = new HashSet(forwardTraversalKeys);
|
forwardTraversalKeys = new HashSet<AWTKeyStroke>(forwardTraversalKeys);
|
||||||
forwardTraversalKeys.remove(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
|
forwardTraversalKeys.remove(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
|
||||||
fileNameTextField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardTraversalKeys);
|
fileNameTextField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardTraversalKeys);
|
||||||
|
|
||||||
@ -895,10 +895,9 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
|||||||
|
|
||||||
private class GTKDirectoryModel extends BasicDirectoryModel {
|
private class GTKDirectoryModel extends BasicDirectoryModel {
|
||||||
FileSystemView fsv;
|
FileSystemView fsv;
|
||||||
private Comparator fileComparator = new Comparator() {
|
private Comparator<File> fileComparator = new Comparator<File>() {
|
||||||
public int compare(Object o, Object o1) {
|
public int compare(File o, File o1) {
|
||||||
return fsv.getSystemDisplayName((File) o).compareTo
|
return fsv.getSystemDisplayName(o).compareTo(fsv.getSystemDisplayName(o1));
|
||||||
(fsv.getSystemDisplayName((File) o1));
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1352,8 +1351,8 @@ class GTKFileChooserUI extends SynthFileChooserUI {
|
|||||||
FileFilter currentFilter = getFileChooser().getFileFilter();
|
FileFilter currentFilter = getFileChooser().getFileFilter();
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
if (currentFilter != null) {
|
if (currentFilter != null) {
|
||||||
for (int i = 0; i < filters.length; i++) {
|
for (FileFilter filter : filters) {
|
||||||
if (filters[i] == currentFilter) {
|
if (filter == currentFilter) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -299,7 +299,7 @@ class GTKPainter extends SynthPainter {
|
|||||||
// Paint the default indicator
|
// Paint the default indicator
|
||||||
GTKStyle style = (GTKStyle)context.getStyle();
|
GTKStyle style = (GTKStyle)context.getStyle();
|
||||||
if (defaultCapable && !toolButton) {
|
if (defaultCapable && !toolButton) {
|
||||||
Insets defaultInsets = (Insets)style.getClassSpecificInsetsValue(
|
Insets defaultInsets = style.getClassSpecificInsetsValue(
|
||||||
context, "default-border",
|
context, "default-border",
|
||||||
GTKStyle.BUTTON_DEFAULT_BORDER_INSETS);
|
GTKStyle.BUTTON_DEFAULT_BORDER_INSETS);
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ class Metacity implements SynthConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize constants
|
// Initialize constants
|
||||||
variables = new HashMap();
|
variables = new HashMap<String, Integer>();
|
||||||
NodeList nodes = xmlDoc.getElementsByTagName("constant");
|
NodeList nodes = xmlDoc.getElementsByTagName("constant");
|
||||||
int n = nodes.getLength();
|
int n = nodes.getLength();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
@ -144,14 +144,14 @@ class Metacity implements SynthConstants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Cache frame geometries
|
// Cache frame geometries
|
||||||
frameGeometries = new HashMap();
|
frameGeometries = new HashMap<String, Map<String, Object>>();
|
||||||
nodes = xmlDoc.getElementsByTagName("frame_geometry");
|
nodes = xmlDoc.getElementsByTagName("frame_geometry");
|
||||||
n = nodes.getLength();
|
n = nodes.getLength();
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
Node node = nodes.item(i);
|
Node node = nodes.item(i);
|
||||||
String name = getStringAttr(node, "name");
|
String name = getStringAttr(node, "name");
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
HashMap<String, Object> gm = new HashMap();
|
HashMap<String, Object> gm = new HashMap<String, Object>();
|
||||||
frameGeometries.put(name, gm);
|
frameGeometries.put(name, gm);
|
||||||
|
|
||||||
String parentGM = getStringAttr(node, "parent");
|
String parentGM = getStringAttr(node, "parent");
|
||||||
@ -458,7 +458,7 @@ class Metacity implements SynthConstants {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static class Privileged implements PrivilegedAction {
|
private static class Privileged implements PrivilegedAction<Object> {
|
||||||
private static int GET_THEME_DIR = 0;
|
private static int GET_THEME_DIR = 0;
|
||||||
private static int GET_USER_THEME = 1;
|
private static int GET_USER_THEME = 1;
|
||||||
private static int GET_IMAGE = 2;
|
private static int GET_IMAGE = 2;
|
||||||
@ -598,7 +598,7 @@ class Metacity implements SynthConstants {
|
|||||||
g2.setComposite(oldComp);
|
g2.setComposite(oldComp);
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashMap<String, Image> images = new HashMap();
|
private HashMap<String, Image> images = new HashMap<String, Image>();
|
||||||
|
|
||||||
protected Image getImage(String key, Color c) {
|
protected Image getImage(String key, Color c) {
|
||||||
Image image = images.get(key+"-"+c.getRGB());
|
Image image = images.get(key+"-"+c.getRGB());
|
||||||
@ -1530,8 +1530,8 @@ class Metacity implements SynthConstants {
|
|||||||
DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
}
|
}
|
||||||
InputStream inputStream =
|
InputStream inputStream =
|
||||||
(InputStream)AccessController.doPrivileged(new PrivilegedAction() {
|
AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
|
||||||
public Object run() {
|
public InputStream run() {
|
||||||
try {
|
try {
|
||||||
return new BufferedInputStream(xmlFile.openStream());
|
return new BufferedInputStream(xmlFile.openStream());
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@ -1551,7 +1551,7 @@ class Metacity implements SynthConstants {
|
|||||||
protected Node[] getNodesByName(Node parent, String name) {
|
protected Node[] getNodesByName(Node parent, String name) {
|
||||||
NodeList nodes = parent.getChildNodes(); // ElementNode
|
NodeList nodes = parent.getChildNodes(); // ElementNode
|
||||||
int n = nodes.getLength();
|
int n = nodes.getLength();
|
||||||
ArrayList<Node> list = new ArrayList();
|
ArrayList<Node> list = new ArrayList<Node>();
|
||||||
for (int i=0; i < n; i++) {
|
for (int i=0; i < n; i++) {
|
||||||
Node node = nodes.item(i);
|
Node node = nodes.item(i);
|
||||||
if (name.equals(node.getNodeName())) {
|
if (name.equals(node.getNodeName())) {
|
||||||
@ -1603,7 +1603,7 @@ class Metacity implements SynthConstants {
|
|||||||
String aValue = attrs[a * 2 + 1];
|
String aValue = attrs[a * 2 + 1];
|
||||||
Node attr = nodeAttrs.getNamedItem(aName);
|
Node attr = nodeAttrs.getNamedItem(aName);
|
||||||
if (attr == null ||
|
if (attr == null ||
|
||||||
aValue != null && !aValue.equals((String)attr.getNodeValue())) {
|
aValue != null && !aValue.equals(attr.getNodeValue())) {
|
||||||
matches = false;
|
matches = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1642,7 +1642,7 @@ class Metacity implements SynthConstants {
|
|||||||
|
|
||||||
protected String getStringAttr(NamedNodeMap attrs, String name) {
|
protected String getStringAttr(NamedNodeMap attrs, String name) {
|
||||||
Node item = attrs.getNamedItem(name);
|
Node item = attrs.getNamedItem(name);
|
||||||
return (item != null) ? (String)item.getNodeValue() : null;
|
return (item != null) ? item.getNodeValue() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean getBooleanAttr(Node node, String name, boolean fallback) {
|
protected boolean getBooleanAttr(Node node, String name, boolean fallback) {
|
||||||
|
Loading…
Reference in New Issue
Block a user