Skip to content

Commit

Permalink
Backport 9ca6bf0d22ac39d4ee29c756903038f09087ca12
Browse files Browse the repository at this point in the history
  • Loading branch information
duke committed Sep 5, 2024
1 parent 58cbf5d commit c329eb6
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 78 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,11 @@ private boolean loadInstruments(List<ModelInstrument> instruments) {
c.current_instrument = null;
c.current_director = null;
}
for (Instrument instrument : instruments) {
for (ModelInstrument instrument : instruments) {
String pat = patchToString(instrument.getPatch());
SoftInstrument softins
= new SoftInstrument((ModelInstrument) instrument);
SoftInstrument softins = new SoftInstrument(instrument);
inslist.put(pat, softins);
loadedlist.put(pat, (ModelInstrument) instrument);
loadedlist.put(pat, instrument);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,11 +868,11 @@ private AbstractFormatterFactory getDefaultFormatterFactory(Object type) {
return new DefaultFormatterFactory(new DateFormatter());
}
if (type instanceof Number) {
AbstractFormatter displayFormatter = new NumberFormatter();
((NumberFormatter)displayFormatter).setValueClass(type.getClass());
AbstractFormatter editFormatter = new NumberFormatter(
NumberFormatter displayFormatter = new NumberFormatter();
displayFormatter.setValueClass(type.getClass());
NumberFormatter editFormatter = new NumberFormatter(
new DecimalFormat("#.#"));
((NumberFormatter)editFormatter).setValueClass(type.getClass());
editFormatter.setValueClass(type.getClass());

return new DefaultFormatterFactory(displayFormatter,
displayFormatter,editFormatter);
Expand Down
9 changes: 2 additions & 7 deletions src/java.desktop/share/classes/javax/swing/JRootPane.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,13 @@
*/
package javax.swing;

import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.security.AccessController;
import javax.accessibility.*;
import javax.swing.plaf.RootPaneUI;
import java.util.Vector;
import java.io.Serializable;
import javax.swing.border.*;

import sun.awt.AWTAccessor;
import sun.security.action.GetBooleanAction;


Expand Down Expand Up @@ -511,10 +506,10 @@ public void addLayoutComponent(Component comp, Object constraints) {
* @return the default <code>glassPane</code>
*/
protected Component createGlassPane() {
JComponent c = new JPanel();
JPanel c = new JPanel();
c.setName(this.getName()+".glassPane");
c.setVisible(false);
((JPanel)c).setOpaque(false);
c.setOpaque(false);
return c;
}

Expand Down
19 changes: 9 additions & 10 deletions src/java.desktop/share/classes/javax/swing/JTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -2033,7 +2033,7 @@ public Enumeration<TreePath> getExpandedDescendants(TreePath parent) {
Enumeration<TreePath> toggledPaths = expandedState.keys();
Vector<TreePath> elements = null;
TreePath path;
Object value;
Boolean value;

if(toggledPaths != null) {
while(toggledPaths.hasMoreElements()) {
Expand All @@ -2042,8 +2042,7 @@ public Enumeration<TreePath> getExpandedDescendants(TreePath parent) {
// Add the path if it is expanded, a descendant of parent,
// and it is visible (all parents expanded). This is rather
// expensive!
if(path != parent && value != null &&
((Boolean)value).booleanValue() &&
if (path != parent && value != null && value &&
parent.isDescendant(path) && isVisible(path)) {
if (elements == null) {
elements = new Vector<TreePath>();
Expand Down Expand Up @@ -2081,11 +2080,11 @@ public boolean isExpanded(TreePath path) {

if(path == null)
return false;
Object value;
Boolean value;

do{
value = expandedState.get(path);
if(value == null || !((Boolean)value).booleanValue())
if (value == null || !value)
return false;
} while( (path=path.getParentPath())!=null );

Expand All @@ -2109,7 +2108,7 @@ public boolean isExpanded(int row) {
if(path != null) {
Boolean value = expandedState.get(path);

return (value != null && value.booleanValue());
return (value != null && value);
}
}
return false;
Expand Down Expand Up @@ -3729,9 +3728,9 @@ protected void setExpandedState(TreePath path, boolean state) {
}
if(!state) {
// collapse last path.
Object cValue = expandedState.get(path);
Boolean cValue = expandedState.get(path);

if(cValue != null && ((Boolean)cValue).booleanValue()) {
if (cValue != null && cValue) {
try {
fireTreeWillCollapse(path);
}
Expand All @@ -3753,9 +3752,9 @@ protected void setExpandedState(TreePath path, boolean state) {
}
else {
// Expand last path.
Object cValue = expandedState.get(path);
Boolean cValue = expandedState.get(path);

if(cValue == null || !((Boolean)cValue).booleanValue()) {
if (cValue == null || !cValue) {
try {
fireTreeWillExpand(path);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 2021, 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
Expand Down Expand Up @@ -1024,10 +1024,7 @@ private void addPainterOrMerge(List<ParsedSynthStyle.PainterInfo> painters, Stri
painter,
direction);

for (Object infoObject: painters) {
ParsedSynthStyle.PainterInfo info;
info = (ParsedSynthStyle.PainterInfo) infoObject;

for (ParsedSynthStyle.PainterInfo info: painters) {
if (painterInfo.equalsPainter(info)) {
info.addPainter(painter);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,12 @@ public AccessibleContext getAccessibleContext() {
*/
public AccessibleStateSet getAccessibleStateSet() {
AccessibleStateSet states = new AccessibleStateSet();
Component comp = getTextComponent();
JTextComponent comp = getTextComponent();

if (comp.isEnabled()) {
states.add(AccessibleState.ENABLED);
}
if (comp instanceof JTextComponent &&
((JTextComponent)comp).isEditable()) {

if (comp.isEditable()) {
states.add(AccessibleState.EDITABLE);
states.add(AccessibleState.FOCUSABLE);
}
Expand Down Expand Up @@ -742,11 +740,9 @@ private ElementInfo getElementInfoAt(ElementInfo elementInfo, Point p) {
* @see AccessibleStateSet
*/
public boolean isFocusTraversable() {
Component comp = getTextComponent();
if (comp instanceof JTextComponent) {
if (((JTextComponent)comp).isEditable()) {
return true;
}
JTextComponent comp = getTextComponent();
if (comp != null && comp.isEditable()) {
return true;
}
return false;
}
Expand All @@ -763,16 +759,16 @@ public void requestFocus() {
return;
}

Component comp = getTextComponent();
if (comp instanceof JTextComponent) {
JTextComponent comp = getTextComponent();
if (comp != null) {

comp.requestFocusInWindow();

try {
if (elementInfo.validateIfNecessary()) {
// set the caret position to the start of this component
Element elem = elementInfo.getElement();
((JTextComponent)comp).setCaretPosition(elem.getStartOffset());
comp.setCaretPosition(elem.getStartOffset());

// fire a AccessibleState.FOCUSED property change event
AccessibleContext ac = editor.getAccessibleContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4225,7 +4225,7 @@ private void foundInsertTag(boolean isBlockTag) {
try {
if (offset == 0 || !getText(offset - 1, 1).equals("\n")) {
// Need to insert a newline.
AttributeSet newAttrs = null;
SimpleAttributeSet newAttrs = null;
boolean joinP = true;

if (offset != 0) {
Expand Down Expand Up @@ -4259,9 +4259,8 @@ private void foundInsertTag(boolean isBlockTag) {
// sure and set the name (otherwise it will be
// inherited).
newAttrs = new SimpleAttributeSet();
((SimpleAttributeSet)newAttrs).addAttribute
(StyleConstants.NameAttribute,
HTML.Tag.CONTENT);
newAttrs.addAttribute(StyleConstants.NameAttribute,
HTML.Tag.CONTENT);
}
ElementSpec es = new ElementSpec(newAttrs,
ElementSpec.ContentType, NEWLINE, 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import javax.accessibility.AccessibleAction;
import javax.accessibility.AccessibleContext;
import javax.swing.Action;
import javax.swing.JComponent;
import javax.swing.JEditorPane;
import javax.swing.JViewport;
import javax.swing.SizeRequirements;
Expand Down Expand Up @@ -849,13 +848,12 @@ private String getMapHREF(JEditorPane html, HTMLDocument hdoc,
Rectangle bounds;
TextUI ui = html.getUI();
try {
Shape lBounds = ui.modelToView(html, offset,
Rectangle lBounds = ui.modelToView(html, offset,
Position.Bias.Forward);
Shape rBounds = ui.modelToView(html, offset + 1,
Rectangle rBounds = ui.modelToView(html, offset + 1,
Position.Bias.Backward);
bounds = lBounds.getBounds();
bounds.add((rBounds instanceof Rectangle) ?
(Rectangle)rBounds : rBounds.getBounds());
bounds = lBounds;
bounds.add(rBounds);
} catch (BadLocationException ble) {
bounds = null;
}
Expand Down Expand Up @@ -886,18 +884,14 @@ private boolean doesElementContainLocation(JEditorPane editor,
if (e != null && offset > 0 && e.getStartOffset() == offset) {
try {
TextUI ui = editor.getUI();
Shape s1 = ui.modelToView(editor, offset,
Position.Bias.Forward);
if (s1 == null) {
Rectangle r1 = ui.modelToView(editor, offset,
Position.Bias.Forward);
if (r1 == null) {
return false;
}
Rectangle r1 = (s1 instanceof Rectangle) ? (Rectangle)s1 :
s1.getBounds();
Shape s2 = ui.modelToView(editor, e.getEndOffset(),
Position.Bias.Backward);
if (s2 != null) {
Rectangle r2 = (s2 instanceof Rectangle) ? (Rectangle)s2 :
s2.getBounds();
Rectangle r2 = ui.modelToView(editor, e.getEndOffset(),
Position.Bias.Backward);
if (r2 != null) {
r1.add(r2);
}
return r1.contains(x, y);
Expand Down Expand Up @@ -1522,9 +1516,9 @@ public void setParent(View parent) {
//if parent == null unregister component listener
if (parent == null) {
if (cachedViewPort != null) {
Object cachedObject;
JViewport cachedObject;
if ((cachedObject = cachedViewPort.get()) != null) {
((JComponent)cachedObject).removeComponentListener(this);
cachedObject.removeComponentListener(this);
}
cachedViewPort = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.lang.*;
import java.util.*;
import java.awt.Color;
import java.awt.Font;
import java.io.OutputStream;
import java.io.IOException;

Expand Down Expand Up @@ -516,13 +515,13 @@ void updateSectionAttributes(MutableAttributeSet current,
{
if (emitStyleChanges) {
Object oldStyle = current.getAttribute("sectionStyle");
Object newStyle = findStyleNumber(newAttributes, Constants.STSection);
Integer newStyle = findStyleNumber(newAttributes, Constants.STSection);
if (oldStyle != newStyle) {
if (oldStyle != null) {
resetSectionAttributes(current);
}
if (newStyle != null) {
writeControlWord("ds", ((Integer)newStyle).intValue());
writeControlWord("ds", newStyle);
current.addAttribute("sectionStyle", newStyle);
} else {
current.removeAttribute("sectionStyle");
Expand Down Expand Up @@ -555,8 +554,8 @@ void updateParagraphAttributes(MutableAttributeSet current,
boolean emitStyleChanges)
throws IOException
{
Object parm;
Object oldStyle, newStyle;
Object oldStyle;
Integer newStyle;

/* The only way to get rid of tabs or styles is with the \pard keyword,
emitted by resetParagraphAttributes(). Ideally we should avoid
Expand Down Expand Up @@ -588,7 +587,7 @@ emitted by resetParagraphAttributes(). Ideally we should avoid
}

if (oldStyle != newStyle && newStyle != null) {
writeControlWord("s", ((Integer)newStyle).intValue());
writeControlWord("s", newStyle);
current.addAttribute("paragraphStyle", newStyle);
}

Expand Down Expand Up @@ -707,14 +706,14 @@ void updateCharacterAttributes(MutableAttributeSet current,

if (updateStyleChanges) {
Object oldStyle = current.getAttribute("characterStyle");
Object newStyle = findStyleNumber(newAttributes,
Integer newStyle = findStyleNumber(newAttributes,
Constants.STCharacter);
if (oldStyle != newStyle) {
if (oldStyle != null) {
resetCharacterAttributes(current);
}
if (newStyle != null) {
writeControlWord("cs", ((Integer)newStyle).intValue());
writeControlWord("cs", newStyle.intValue());
current.addAttribute("characterStyle", newStyle);
} else {
current.removeAttribute("characterStyle");
Expand Down
4 changes: 2 additions & 2 deletions src/java.desktop/share/classes/sun/awt/SunToolkit.java
Original file line number Diff line number Diff line change
Expand Up @@ -1805,8 +1805,8 @@ public static RenderingHints getDesktopFontHints() {
if (useSystemAAFontSettings()) {
Toolkit tk = Toolkit.getDefaultToolkit();
if (tk instanceof SunToolkit) {
Object map = ((SunToolkit)tk).getDesktopAAHints();
return (RenderingHints)map;
RenderingHints map = ((SunToolkit)tk).getDesktopAAHints();
return map;
} else { /* Headless Toolkit */
return null;
}
Expand Down
8 changes: 4 additions & 4 deletions src/java.desktop/share/classes/sun/java2d/Disposer.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ synchronized void add(Object target, DisposerRecord rec) {
public void run() {
while (true) {
try {
Object obj = queue.remove();
((Reference)obj).clear();
Reference<?> obj = queue.remove();
obj.clear();
DisposerRecord rec = records.remove(obj);
rec.dispose();
obj = null;
Expand Down Expand Up @@ -200,15 +200,15 @@ public static void pollRemove() {
if (pollingQueue) {
return;
}
Object obj;
Reference<?> obj;
pollingQueue = true;
int freed = 0;
int deferred = 0;
try {
while ( freed < 10000 && deferred < 100 &&
(obj = queue.poll()) != null ) {
freed++;
((Reference)obj).clear();
obj.clear();
DisposerRecord rec = records.remove(obj);
if (rec instanceof PollDisposable) {
rec.dispose();
Expand Down

0 comments on commit c329eb6

Please sign in to comment.