From 6b2bf022894f67e1e72690834a08e6640854d80a Mon Sep 17 00:00:00 2001 From: Steven Yi Date: Tue, 24 Sep 2024 07:06:25 -0400 Subject: [PATCH] chore: convert to using instanceof pattern matching --- blue-core/src/main/java/blue/Arrangement.java | 16 ++--- blue-core/src/main/java/blue/CompileData.java | 3 +- .../src/main/java/blue/InstrumentLibrary.java | 11 ++- .../src/main/java/blue/mixer/Channel.java | 8 +-- .../main/java/blue/mixer/EffectsChain.java | 22 +++--- .../src/main/java/blue/mixer/MixerNode.java | 9 +-- .../blueSynthBuilder/BSBGraphicInterface.java | 5 +- .../orchestra/blueSynthBuilder/BSBGroup.java | 72 +++++++++---------- .../blueSynthBuilder/UniqueNameManager.java | 3 +- blue-core/src/main/java/blue/score/Score.java | 8 +-- .../java/blue/scripting/ScriptLibrary.java | 11 ++- .../java/blue/soundObject/PolyObject.java | 13 ++-- .../soundObject/SoundObjectUtilities.java | 3 +- .../java/blue/soundObject/jmask/Field.java | 3 +- .../java/blue/soundObject/jmask/ItemList.java | 4 +- .../src/main/java/blue/udo/UDOLibrary.java | 11 ++- .../java/blue/utility/ScoreUtilities.java | 3 +- .../main/java/blue/WindowSettingManager.java | 6 +- .../blue/automation/AutomationManager.java | 28 ++++---- .../blue/components/FindReplaceDialog.java | 8 +-- .../java/blue/components/PaletteWindow.java | 3 +- .../components/lines/LineEditorDialog.java | 8 +-- .../blue/components/lines/LineListTable.java | 4 +- .../PresetsManagerDialog.java | 30 ++++---- .../PresetsTreeDropTarget.java | 6 +- .../blueSynthBuilder/PresetsTreeModel.java | 11 ++- .../blueSynthBuilder/swing/BSBEditPanel.java | 19 ++--- .../blueSynthBuilder/swing/BSBGroupPanel.java | 8 +-- .../swing/BSBObjectEditorFactory.java | 60 ++++++++-------- .../blueSynthBuilder/swing/PresetsPanel.java | 8 +-- .../editor/jmask/GeneratorEditorFactory.java | 24 +++---- .../probability/ProbabilityEditorFactory.java | 24 +++---- .../pianoRoll/FieldDefinitionsEditor.java | 12 ++-- .../editor/pianoRoll/FieldEditor.java | 6 +- .../pianoRoll/FieldEditorMouseListener.java | 3 +- .../pianoRoll/NoteCanvasMouseListener.java | 10 ++- .../editor/pianoRoll/PianoRollCanvas.java | 6 +- .../soundObjects/SoundObjectExportPane.java | 8 +-- .../java/blue/ui/core/CompileProcessor.java | 4 +- .../ui/core/blueLive/KeyboardKeyRenderer.java | 4 +- .../ui/core/blueLive/MidiKeyRenderer.java | 4 +- .../blue/ui/core/blueLive/ScoPadReceiver.java | 3 +- .../blue/ui/core/midi/MidiInputEngine.java | 3 +- .../java/blue/ui/core/mixer/ChannelPanel.java | 38 +++++----- .../ui/core/mixer/EffectTreeDragSource.java | 17 +++-- .../ui/core/mixer/EffectTreeDropTarget.java | 3 +- .../blue/ui/core/mixer/EffectsLibrary.java | 11 ++- .../ui/core/mixer/EffectsLibraryDialog.java | 10 +-- .../java/blue/ui/core/mixer/EffectsPopup.java | 58 ++++++--------- .../ui/core/mixer/SubChannelListPanel.java | 12 ++-- .../core/orchestra/ArrangementEditPanel.java | 11 ++- .../orchestra/InstrumentTreeDragSource.java | 16 ++--- .../orchestra/InstrumentTreeDropTarget.java | 8 +-- .../core/orchestra/OrchestraTopComponent.java | 4 +- .../core/orchestra/UserInstrumentLibrary.java | 16 ++--- .../stems/RenderStemsWizardIterator.java | 4 +- .../java/blue/ui/core/render/CSDRender.java | 3 +- .../blue/ui/core/render/ParameterHelper.java | 9 +-- .../core/score/LayerHeightWheelListener.java | 3 +- .../java/blue/ui/core/score/MarkersBar.java | 6 +- .../blue/ui/core/score/ScoreController.java | 6 +- .../ScoreNavigatorContainerListener.java | 6 +- .../ui/core/score/ScoreNavigatorDialog.java | 4 +- .../blue/ui/core/score/ScoreTopComponent.java | 4 +- .../soundObject/PolyObjectUIProvider.java | 8 +-- .../ScoreObjectEditorTopComponent.java | 4 +- .../layers/soundObject/ScoreTimeCanvas.java | 11 ++- .../SoundObjectPropertiesTopComponent.java | 8 +-- .../AddSoundObjectActionsPresenter.java | 7 +- .../actions/PasteAsPolyObjectAction.java | 4 +- .../actions/PasteSoundObjectAction.java | 15 ++-- .../actions/SelectAllAfterAction.java | 5 +- .../actions/SelectAllBeforeAction.java | 5 +- .../library/SoundObjectLibraryUtils.java | 14 ++-- .../score/mouse/MarqueeSelectionListener.java | 4 +- .../mouse/MultiLineMoveMouseListener.java | 3 +- .../mouse/MultiLineScaleMouseListener.java | 3 +- .../MultiLineSelectionMouseProcessor.java | 4 +- .../mouse/ScoreObjectSelectionListener.java | 3 +- .../NoteProcessorChainTableModel.java | 4 +- .../PropertyEditProxyRenderer.java | 4 +- .../object/actions/AlignActionsPresenter.java | 4 +- .../actions/ConvertToObjectBuilderAction.java | 6 +- .../score/object/actions/ExportAction.java | 4 +- .../object/actions/FreezeUnfreezeAction.java | 14 ++-- .../ReplaceWithBufferSoundObjectAction.java | 8 +-- .../score/undo/DurationScoreObjectEdit.java | 4 +- .../score/undo/ReplaceScoreObjectEdit.java | 4 +- .../blue/ui/core/score/undo/SetColorEdit.java | 4 +- .../blue/ui/core/udo/OpcodeListEditPanel.java | 10 ++- .../blue/ui/core/udo/UDOLibraryPanel.java | 20 +++--- .../blue/ui/core/udo/UDOTreeDragSource.java | 12 ++-- .../blue/ui/core/udo/UDOTreeDropTarget.java | 3 +- .../udo/UserDefinedOpcodeTopComponent.java | 4 +- 94 files changed, 433 insertions(+), 534 deletions(-) diff --git a/blue-core/src/main/java/blue/Arrangement.java b/blue-core/src/main/java/blue/Arrangement.java index b03fc89ee..5a3ae538a 100644 --- a/blue-core/src/main/java/blue/Arrangement.java +++ b/blue-core/src/main/java/blue/Arrangement.java @@ -168,8 +168,8 @@ public int addInstrument(String instrumentId, Instrument instrument) { fireTableDataChanged(); - if (instrument instanceof Automatable) { - fireAutomatableAdded((Automatable) instrument); + if (instrument instanceof Automatable automatable) { + fireAutomatableAdded(automatable); } return retVal; @@ -190,8 +190,8 @@ public void addInstrumentWithId(Instrument instr, String instrId, boolean sort) Collections.sort(arrangement); } - if (instr instanceof Automatable) { - fireAutomatableAdded((Automatable) instr); + if (instr instanceof Automatable automatable) { + fireAutomatableAdded(automatable); } fireTableDataChanged(); @@ -229,8 +229,8 @@ public void replaceInstrument(String instrumentId, Instrument instr) { } fireTableDataChanged(); - if (instr instanceof Automatable) { - fireAutomatableAdded((Automatable) instr); + if (instr instanceof Automatable automatable) { + fireAutomatableAdded(automatable); } } @@ -804,8 +804,8 @@ public Instrument removeInstrument(int index) { fireTableDataChanged(); - if (ia.instr instanceof Automatable) { - fireAutomatableRemoved((Automatable) ia.instr); + if (ia.instr instanceof Automatable automatable) { + fireAutomatableRemoved(automatable); } return ia.instr; diff --git a/blue-core/src/main/java/blue/CompileData.java b/blue-core/src/main/java/blue/CompileData.java index 275e37d25..35ca82dea 100644 --- a/blue-core/src/main/java/blue/CompileData.java +++ b/blue-core/src/main/java/blue/CompileData.java @@ -102,8 +102,7 @@ public void setHandleParametersAndChannels(boolean handleParametersAndChannels) public int addInstrument(Instrument instrument) { if(handleParametersAndChannels && stringChannels != null && originalParameters != null) { - if(instrument instanceof Automatable) { - Automatable auto = (Automatable) instrument; + if(instrument instanceof Automatable auto) { ArrayList tempStringChannels = auto.getStringChannels(); if(tempStringChannels != null) { stringChannels.addAll(tempStringChannels); diff --git a/blue-core/src/main/java/blue/InstrumentLibrary.java b/blue-core/src/main/java/blue/InstrumentLibrary.java index 5b9fa291c..936a1182a 100644 --- a/blue-core/src/main/java/blue/InstrumentLibrary.java +++ b/blue-core/src/main/java/blue/InstrumentLibrary.java @@ -224,8 +224,7 @@ public Object getRoot() { public int getChildCount(Object parent) { if (parent instanceof Instrument) { return 0; - } else if (parent instanceof InstrumentCategory) { - InstrumentCategory cat = (InstrumentCategory) parent; + } else if (parent instanceof InstrumentCategory cat) { return cat.getSubCategories().size() + cat.getInstruments().size(); } @@ -272,10 +271,10 @@ public void removeTreeModelListener(TreeModelListener l) { public void valueForPathChanged(TreePath path, Object newValue) { Object obj = path.getLastPathComponent(); - if (obj instanceof InstrumentCategory) { - ((InstrumentCategory) obj).setCategoryName(newValue.toString()); - } else if (obj instanceof Instrument) { - ((Instrument) obj).setName(newValue.toString()); + if (obj instanceof InstrumentCategory instrumentCategory) { + instrumentCategory.setCategoryName(newValue.toString()); + } else if (obj instanceof Instrument instrument) { + instrument.setName(newValue.toString()); } TreeModelEvent e = new TreeModelEvent(this, path); diff --git a/blue-core/src/main/java/blue/mixer/Channel.java b/blue-core/src/main/java/blue/mixer/Channel.java index cb5752409..05eca8ac5 100644 --- a/blue-core/src/main/java/blue/mixer/Channel.java +++ b/blue-core/src/main/java/blue/mixer/Channel.java @@ -412,16 +412,16 @@ public Send[] getSends() { for (int i = 0; i < preEffects.size(); i++) { Object obj = preEffects.getElementAt(i); - if (obj instanceof Send) { - temp.add((Send)obj); + if (obj instanceof Send send) { + temp.add(send); } } for (int i = 0; i < postEffects.size(); i++) { Object obj = postEffects.getElementAt(i); - if (obj instanceof Send) { - temp.add((Send)obj); + if (obj instanceof Send send) { + temp.add(send); } } diff --git a/blue-core/src/main/java/blue/mixer/EffectsChain.java b/blue-core/src/main/java/blue/mixer/EffectsChain.java index 8f3406ea9..d6d98300d 100644 --- a/blue-core/src/main/java/blue/mixer/EffectsChain.java +++ b/blue-core/src/main/java/blue/mixer/EffectsChain.java @@ -48,10 +48,10 @@ public EffectsChain() { public EffectsChain(EffectsChain chain) { for(Object item : chain.effects) { - if(item instanceof Effect) { - addEffect(new Effect((Effect)item)); - } else if (item instanceof Send){ - addSend(new Send((Send)item)); + if(item instanceof Effect effect) { + addEffect(new Effect(effect)); + } else if (item instanceof Send send){ + addSend(new Send(send)); } } } @@ -62,11 +62,9 @@ public Element saveAsXML() { for (Iterator it = effects.iterator(); it.hasNext();) { Object obj = it.next(); - if (obj instanceof Effect) { - Effect elem = (Effect) obj; + if (obj instanceof Effect elem) { retVal.addElement(elem.saveAsXML()); - } else if (obj instanceof Send) { - Send send = (Send) obj; + } else if (obj instanceof Send send) { retVal.addElement(send.saveAsXML()); } } @@ -124,8 +122,8 @@ public void addSend(Send send) { public Object removeElementAt(int index) { Object obj = effects.remove(index); - if (obj instanceof Send) { - ((Send) obj).removePropertyChangeListener(this); + if (obj instanceof Send send) { + send.removePropertyChangeListener(this); } ListDataEvent lde = new ListDataEvent(this, @@ -172,8 +170,8 @@ public Send[] getSends() { for (int i = 0; i < this.size(); i++) { Object obj = this.getElementAt(i); - if (obj instanceof Send) { - temp.add((Send) obj); + if (obj instanceof Send send) { + temp.add(send); } } diff --git a/blue-core/src/main/java/blue/mixer/MixerNode.java b/blue-core/src/main/java/blue/mixer/MixerNode.java index 3ad4b7b45..04080d74d 100644 --- a/blue-core/src/main/java/blue/mixer/MixerNode.java +++ b/blue-core/src/main/java/blue/mixer/MixerNode.java @@ -291,8 +291,7 @@ protected static int indexOfLastValidSend(EffectsChain chain, for (int i = 0; i < chain.getSize(); i++) { Object obj = chain.getElementAt(i); - if (obj instanceof Send) { - Send send = (Send) obj; + if (obj instanceof Send send) { if (send.getSendChannel().equals(Channel.MASTER)) { index = i; @@ -365,8 +364,7 @@ private static void applyEffects(EffectsChain chain, OpcodeList udos, for (int i = 0; i <= lastIndex; i++) { Object obj = chain.getElementAt(i); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { if (effect.isEnabled()) { @@ -387,8 +385,7 @@ private static void applyEffects(EffectsChain chain, OpcodeList udos, buffer.append(effectName).append("\t"); buffer.append(signalChannels).append("\n"); } - } else if (obj instanceof Send) { - Send send = (Send) obj; + } else if (obj instanceof Send send) { if (send.isEnabled()) { String[] parts = signalChannels.split(","); diff --git a/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/BSBGraphicInterface.java b/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/BSBGraphicInterface.java index c02c8e671..7a4a8453d 100644 --- a/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/BSBGraphicInterface.java +++ b/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/BSBGraphicInterface.java @@ -93,13 +93,14 @@ public static BSBGraphicInterface loadFromXML(Element data) switch (name) { case "bsbObject": BSBObject obj = (BSBObject) ObjectUtilities.loadFromXML(node); - if (obj instanceof BSBGroup) { - graphicInterface.setRootGroup((BSBGroup) obj); + if (obj instanceof BSBGroup bSBGroup) { + graphicInterface.setRootGroup(bSBGroup); } else { // legacy reading of BSBObjects stored here pre-2.7.0 graphicInterface.getRootGroup().addBSBObject(obj); } break; + case "gridSettings": gridSettings = GridSettings.loadFromXML(node); break; diff --git a/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/BSBGroup.java b/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/BSBGroup.java index c859e0815..807067b32 100644 --- a/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/BSBGroup.java +++ b/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/BSBGroup.java @@ -78,7 +78,7 @@ public boolean add(BSBObject bsbObj) { } } - if (bsbObj instanceof BSBGroup) { + if (bsbObj instanceof BSBGroup bSBGroup) { if (unm != null) { UniqueNameManager tempUNM = new UniqueNameManager(); Set additionalNames = new HashSet<>(); @@ -90,9 +90,9 @@ public boolean add(BSBObject bsbObj) { } return temp; }); - ((BSBGroup) bsbObj).makeNamesUnique(tempUNM, additionalNames); + bSBGroup.makeNamesUnique(tempUNM, additionalNames); } - ((BSBGroup) bsbObj).setParameterList(parameterList); + bSBGroup.setParameterList(parameterList); } bsbObj.setUniqueNameManager(unm); @@ -111,23 +111,23 @@ public boolean add(BSBObject bsbObj) { bsbObj = change.getElementAdded(); allSet.add(bsbObj); - if (bsbObj instanceof BSBGroup) { - ((BSBGroup) bsbObj).setAllSet(allSet); - ((BSBGroup) bsbObj).setParameterList(parameterList); + if (bsbObj instanceof BSBGroup bSBGroup) { + bSBGroup.setAllSet(allSet); + bSBGroup.setParameterList(parameterList); } - if (bsbObj instanceof AutomatableBSBObject) { - ((AutomatableBSBObject) bsbObj).setParameterList( + if (bsbObj instanceof AutomatableBSBObject automatableBSBObject) { + automatableBSBObject.setParameterList( parameterList); } bsbObj.setUniqueNameManager(unm); } else if (change.wasRemoved()) { bsbObj = change.getElementRemoved(); allSet.remove(bsbObj); - if (bsbObj instanceof BSBGroup) { - ((BSBGroup) bsbObj).setAllSet(null); - ((BSBGroup) bsbObj).removeParameters(); - } else if (bsbObj instanceof AutomatableBSBObject) { - ((AutomatableBSBObject) bsbObj).setAutomationAllowed(false); + if (bsbObj instanceof BSBGroup bSBGroup) { + bSBGroup.setAllSet(null); + bSBGroup.removeParameters(); + } else if (bsbObj instanceof AutomatableBSBObject automatableBSBObject) { + automatableBSBObject.setAutomationAllowed(false); } } } @@ -252,8 +252,8 @@ public Set getNames() { Set names = new HashSet<>(); for (BSBObject bsbObj : interfaceItems) { - if (bsbObj instanceof BSBGroup) { - names.addAll(((BSBGroup) bsbObj).getNames()); + if (bsbObj instanceof BSBGroup bSBGroup) { + names.addAll(bSBGroup.getNames()); } else { String[] replacementKeys = bsbObj.getReplacementKeys(); @@ -357,8 +357,7 @@ public BSBObject deepCopy() { public void randomize() { for (BSBObject bsbObj : interfaceItems) { - if (bsbObj instanceof Randomizable) { - Randomizable randomizable = (Randomizable) bsbObj; + if (bsbObj instanceof Randomizable randomizable) { if (randomizable.isRandomizable()) { randomizable.randomize(); } @@ -389,11 +388,11 @@ public void setUniqueNameManager(UniqueNameManager unm) { public void resetSubChannels() { for (BSBObject bsbObj : interfaceItems) { - if (bsbObj instanceof BSBSubChannelDropdown) { - ((BSBSubChannelDropdown) bsbObj) + if (bsbObj instanceof BSBSubChannelDropdown bSBSubChannelDropdown) { + bSBSubChannelDropdown .setChannelOutput(Channel.MASTER); - } else if (bsbObj instanceof BSBGroup) { - ((BSBGroup) bsbObj).resetSubChannels(); + } else if (bsbObj instanceof BSBGroup bSBGroup) { + bSBGroup.resetSubChannels(); } } } @@ -401,10 +400,9 @@ public void resetSubChannels() { public void getStringChannels(ArrayList stringChannels) { for (BSBObject bsbObj : interfaceItems) { - if (bsbObj instanceof BSBGroup) { - ((BSBGroup) bsbObj).getStringChannels(stringChannels); - } else if (bsbObj instanceof StringChannelProvider) { - StringChannelProvider provider = (StringChannelProvider) bsbObj; + if (bsbObj instanceof BSBGroup bSBGroup) { + bSBGroup.getStringChannels(stringChannels); + } else if (bsbObj instanceof StringChannelProvider provider) { if (provider.isStringChannelEnabled()) { stringChannels.add(provider.getStringChannel()); } @@ -416,10 +414,10 @@ public void setParameterList(ParameterList paramList) { this.parameterList = paramList; for (BSBObject bsbObj : interfaceItems) { - if (bsbObj instanceof BSBGroup) { - ((BSBGroup) bsbObj).setParameterList(paramList); - } else if (bsbObj instanceof AutomatableBSBObject) { - ((AutomatableBSBObject) bsbObj).setParameterList(paramList); + if (bsbObj instanceof BSBGroup bSBGroup) { + bSBGroup.setParameterList(paramList); + } else if (bsbObj instanceof AutomatableBSBObject automatableBSBObject) { + automatableBSBObject.setParameterList(paramList); } } @@ -453,18 +451,18 @@ public void setAllSet(ObservableSet allSet) { } for (BSBObject bsbObj : interfaceItems) { - if (bsbObj instanceof BSBGroup) { - ((BSBGroup) bsbObj).setAllSet(allSet); + if (bsbObj instanceof BSBGroup bSBGroup) { + bSBGroup.setAllSet(allSet); } } } protected void removeParameters() { for (BSBObject bsbObj : interfaceItemsProperty()) { - if (bsbObj instanceof BSBGroup) { - ((BSBGroup) bsbObj).removeParameters(); - } else if (bsbObj instanceof AutomatableBSBObject) { - ((AutomatableBSBObject) bsbObj).setAutomationAllowed(false); + if (bsbObj instanceof BSBGroup bSBGroup) { + bSBGroup.removeParameters(); + } else if (bsbObj instanceof AutomatableBSBObject automatableBSBObject) { + automatableBSBObject.setAutomationAllowed(false); } } @@ -521,8 +519,8 @@ private void makeNamesUnique(UniqueNameManager unm, for (BSBObject bsbObj : interfaceItems) { // guarantee unique names for objects - if (bsbObj instanceof BSBGroup) { - ((BSBGroup) bsbObj).makeNamesUnique(unm, additionalNames); + if (bsbObj instanceof BSBGroup bSBGroup) { + bSBGroup.makeNamesUnique(unm, additionalNames); } else { String objName = bsbObj.getObjectName(); diff --git a/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/UniqueNameManager.java b/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/UniqueNameManager.java index d351d4221..2c8cc4096 100644 --- a/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/UniqueNameManager.java +++ b/blue-core/src/main/java/blue/orchestra/blueSynthBuilder/UniqueNameManager.java @@ -142,8 +142,7 @@ private boolean isUnique(String name, Set names) { @Override public boolean equals(Object obj) { - if (obj instanceof UniqueNameManager) { - UniqueNameManager unm = (UniqueNameManager) obj; + if (obj instanceof UniqueNameManager unm) { return defaultPrefix.equals(unm.defaultPrefix); } diff --git a/blue-core/src/main/java/blue/score/Score.java b/blue-core/src/main/java/blue/score/Score.java index d49d1fbbe..5017f6ff8 100644 --- a/blue-core/src/main/java/blue/score/Score.java +++ b/blue-core/src/main/java/blue/score/Score.java @@ -141,10 +141,11 @@ public static Score loadFromXML(Element data, Map objRefMap) thr "Unable to load Score LayerGroup of type: " + node.getName()); } score.add(layerGroup); - if(layerGroup instanceof PolyObject) { - ((PolyObject)layerGroup).setTimeBehavior(TimeBehavior.NONE); + if(layerGroup instanceof PolyObject polyObject) { + polyObject.setTimeBehavior(TimeBehavior.NONE); } break; + } } @@ -195,8 +196,7 @@ public List getLayerGroupsForScoreObjects(Collection layerGroup : this) { for (Layer layer : layerGroup) { boolean found = false; - if (layer instanceof ScoreObjectLayer) { - ScoreObjectLayer scoreLayer = (ScoreObjectLayer) layer; + if (layer instanceof ScoreObjectLayer scoreLayer) { if (!Collections.disjoint(scoreLayer, scoreObjects)) { retVal.add(layerGroup); found = true; diff --git a/blue-core/src/main/java/blue/scripting/ScriptLibrary.java b/blue-core/src/main/java/blue/scripting/ScriptLibrary.java index 0e2999109..51e072272 100644 --- a/blue-core/src/main/java/blue/scripting/ScriptLibrary.java +++ b/blue-core/src/main/java/blue/scripting/ScriptLibrary.java @@ -299,8 +299,7 @@ public Object getRoot() { public int getChildCount(Object parent) { if (parent instanceof Script) { return 0; - } else if (parent instanceof ScriptCategory) { - ScriptCategory cat = (ScriptCategory) parent; + } else if (parent instanceof ScriptCategory cat) { return cat.getSubCategories().size() + cat.getScripts().size(); } @@ -347,10 +346,10 @@ public void removeTreeModelListener(TreeModelListener l) { public void valueForPathChanged(TreePath path, Object newValue) { Object obj = path.getLastPathComponent(); - if (obj instanceof ScriptCategory) { - ((ScriptCategory) obj).setCategoryName(newValue.toString()); - } else if (obj instanceof Script) { - ((Script) obj).setName(newValue.toString()); + if (obj instanceof ScriptCategory scriptCategory) { + scriptCategory.setCategoryName(newValue.toString()); + } else if (obj instanceof Script script) { + script.setName(newValue.toString()); } TreeModelEvent e = new TreeModelEvent(this, path); diff --git a/blue-core/src/main/java/blue/soundObject/PolyObject.java b/blue-core/src/main/java/blue/soundObject/PolyObject.java index d84fbd4ec..73eb366ec 100644 --- a/blue-core/src/main/java/blue/soundObject/PolyObject.java +++ b/blue-core/src/main/java/blue/soundObject/PolyObject.java @@ -696,8 +696,7 @@ public boolean isScoreGenerationEmpty() { for (SoundObject element : sObjects) { if (element instanceof Comment) { continue; - } else if (element instanceof PolyObject) { - PolyObject pObj = (PolyObject) element; + } else if (element instanceof PolyObject pObj) { if (!pObj.isScoreGenerationEmpty()) { return false; } @@ -719,8 +718,7 @@ public boolean isAdjustedTimeCalculateable() { return false; } - if (element instanceof PolyObject) { - PolyObject pObj = (PolyObject) element; + if (element instanceof PolyObject pObj) { if (!pObj.isAdjustedTimeCalculateable()) { return false; } @@ -740,10 +738,9 @@ public void onLoadComplete() { for (int j = 0; j < sLayer.size(); j++) { sObj = sLayer.get(j); - if (sObj instanceof PolyObject) { - ((PolyObject) sObj).onLoadComplete(); - } else if (sObj instanceof OnLoadProcessable) { - OnLoadProcessable olp = (OnLoadProcessable) sObj; + if (sObj instanceof PolyObject polyObject) { + polyObject.onLoadComplete(); + } else if (sObj instanceof OnLoadProcessable olp) { if (olp.isOnLoadProcessable()) { try { olp.processOnLoad(); diff --git a/blue-core/src/main/java/blue/soundObject/SoundObjectUtilities.java b/blue-core/src/main/java/blue/soundObject/SoundObjectUtilities.java index 1f8e0d80b..38ccb3d5e 100644 --- a/blue-core/src/main/java/blue/soundObject/SoundObjectUtilities.java +++ b/blue-core/src/main/java/blue/soundObject/SoundObjectUtilities.java @@ -100,8 +100,7 @@ public static boolean isOrContainsInstance(SoundObject sObj) { return true; } - if (sObj instanceof PolyObject) { - PolyObject pObj = (PolyObject) sObj; + if (sObj instanceof PolyObject pObj) { for (SoundObject soundObject : pObj.getSoundObjects(true)) { if (isOrContainsInstance(soundObject)) { return true; diff --git a/blue-core/src/main/java/blue/soundObject/jmask/Field.java b/blue-core/src/main/java/blue/soundObject/jmask/Field.java index c51ecff75..d4401be57 100644 --- a/blue-core/src/main/java/blue/soundObject/jmask/Field.java +++ b/blue-core/src/main/java/blue/soundObject/jmask/Field.java @@ -116,8 +116,7 @@ public Element saveAsXML() { public NoteList generateNotes(final double duration, java.util.Random rnd) { Parameter param2 = getParameter(1); - if(param2.getGenerator() instanceof Constant) { - Constant c = (Constant) param2.getGenerator(); + if(param2.getGenerator() instanceof Constant c) { if(c.getValue() <= 0.0) { throw new RuntimeException("Error: JMask p2 Constant field must use " + "value > 0.0."); diff --git a/blue-core/src/main/java/blue/soundObject/jmask/ItemList.java b/blue-core/src/main/java/blue/soundObject/jmask/ItemList.java index cfbac6d6c..29a5f3f78 100644 --- a/blue-core/src/main/java/blue/soundObject/jmask/ItemList.java +++ b/blue-core/src/main/java/blue/soundObject/jmask/ItemList.java @@ -280,9 +280,9 @@ public void removeTableModelListener(TableModelListener l) { @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - if (aValue instanceof Double) { + if (aValue instanceof Double aDouble) { listItems.remove(rowIndex); - listItems.add(rowIndex, (Double) aValue); + listItems.add(rowIndex, aDouble); } TableModelEvent tme = new TableModelEvent(this, rowIndex); diff --git a/blue-core/src/main/java/blue/udo/UDOLibrary.java b/blue-core/src/main/java/blue/udo/UDOLibrary.java index 3c863910e..707ebac4b 100644 --- a/blue-core/src/main/java/blue/udo/UDOLibrary.java +++ b/blue-core/src/main/java/blue/udo/UDOLibrary.java @@ -223,8 +223,7 @@ public Object getRoot() { public int getChildCount(Object parent) { if (parent instanceof UserDefinedOpcode) { return 0; - } else if (parent instanceof UDOCategory) { - UDOCategory cat = (UDOCategory) parent; + } else if (parent instanceof UDOCategory cat) { return cat.getSubCategories().size() + cat.getUserDefinedOpcodes().size(); } @@ -272,10 +271,10 @@ public void removeTreeModelListener(TreeModelListener l) { public void valueForPathChanged(TreePath path, Object newValue) { Object obj = path.getLastPathComponent(); - if (obj instanceof UDOCategory) { - ((UDOCategory) obj).setCategoryName(newValue.toString()); - } else if (obj instanceof UserDefinedOpcode) { - ((UserDefinedOpcode) obj).setOpcodeName(newValue.toString()); + if (obj instanceof UDOCategory uDOCategory) { + uDOCategory.setCategoryName(newValue.toString()); + } else if (obj instanceof UserDefinedOpcode userDefinedOpcode) { + userDefinedOpcode.setOpcodeName(newValue.toString()); } TreeModelEvent e = new TreeModelEvent(this, path); diff --git a/blue-core/src/main/java/blue/utility/ScoreUtilities.java b/blue-core/src/main/java/blue/utility/ScoreUtilities.java index 974c93df9..a1dd65b62 100644 --- a/blue-core/src/main/java/blue/utility/ScoreUtilities.java +++ b/blue-core/src/main/java/blue/utility/ScoreUtilities.java @@ -652,8 +652,7 @@ public static double getMaxTimeWithEmptyCheck(List sObjects) { if (sObj instanceof Comment) { continue; - } else if (sObj instanceof PolyObject) { - PolyObject pObj = (PolyObject) sObj; + } else if (sObj instanceof PolyObject pObj) { if (pObj.isScoreGenerationEmpty()) { continue; } diff --git a/blue-ui-core/src/main/java/blue/WindowSettingManager.java b/blue-ui-core/src/main/java/blue/WindowSettingManager.java index f85b21ebf..dbdece08e 100644 --- a/blue-ui-core/src/main/java/blue/WindowSettingManager.java +++ b/blue-ui-core/src/main/java/blue/WindowSettingManager.java @@ -123,8 +123,7 @@ private void updateSettings() { Element node; - if (w instanceof WindowSettingsSavable) { - WindowSettingsSavable savable = (WindowSettingsSavable) w; + if (w instanceof WindowSettingsSavable savable) { node = savable.saveWindowSettings(); } else { node = getBasicSettings(w); @@ -151,8 +150,7 @@ public void registerWindow(String windowName, Window window) { windows.put(windowName, window); if (settings.containsKey(windowName)) { - if (window instanceof WindowSettingsSavable) { - WindowSettingsSavable savable = (WindowSettingsSavable) window; + if (window instanceof WindowSettingsSavable savable) { savable.loadWindowSettings(settings.get(windowName)); } } diff --git a/blue-ui-core/src/main/java/blue/automation/AutomationManager.java b/blue-ui-core/src/main/java/blue/automation/AutomationManager.java index 6870c32cd..8499aa03a 100644 --- a/blue-ui-core/src/main/java/blue/automation/AutomationManager.java +++ b/blue-ui-core/src/main/java/blue/automation/AutomationManager.java @@ -205,8 +205,7 @@ public void setData(BlueData data) { for (int i = 0; i < arrangement.size(); i++) { Instrument instr = arrangement.getInstrument(i); - if (instr instanceof Automatable) { - Automatable temp = (Automatable) instr; + if (instr instanceof Automatable temp) { ParameterList parameters = temp.getParameterList(); // parameterMap.put(temp, parameters); @@ -260,8 +259,7 @@ public void setData(BlueData data) { for (int i = 0; i < arrangement.size(); i++) { Instrument instr = arrangement.getInstrument(i); - if (instr instanceof Automatable) { - Automatable temp = (Automatable) instr; + if (instr instanceof Automatable temp) { ParameterList parameters = temp.getParameterList(); allParameters.addAll(parameters); @@ -494,11 +492,11 @@ public JMenu buildChannelMenu(Channel channel, ParameterIdList paramIdList) { JMenu effectMenu = new JMenu(); MenuScroller.setScrollerFor(effectMenu); - if (automatable instanceof Effect) { - effectMenu.setText(((Effect) automatable).getName()); - } else if (automatable instanceof Send) { + if (automatable instanceof Effect effect) { + effectMenu.setText(effect.getName()); + } else if (automatable instanceof Send send) { effectMenu.setText("Send: " - + ((Send) automatable).getSendChannel()); + + send.getSendChannel()); } else { effectMenu.setText("ERROR"); } @@ -562,11 +560,11 @@ public JMenu buildChannelMenu(Channel channel, ParameterIdList paramIdList) { JMenu effectMenu = new JMenu(); MenuScroller.setScrollerFor(effectMenu); - if (automatable instanceof Effect) { - effectMenu.setText(((Effect) automatable).getName()); - } else if (automatable instanceof Send) { + if (automatable instanceof Effect effect) { + effectMenu.setText(effect.getName()); + } else if (automatable instanceof Send send) { effectMenu.setText("Send: " - + ((Send) automatable).getSendChannel()); + + send.getSendChannel()); } else { effectMenu.setText("ERROR"); } @@ -607,8 +605,7 @@ public void parameterRemoved(Parameter param) { for (LayerGroup layerGroup : score) { - if (layerGroup instanceof PolyObject) { - PolyObject pObj = (PolyObject) layerGroup; + if (layerGroup instanceof PolyObject pObj) { for (SoundLayer layer : pObj) { ParameterIdList automationParameters = layer.getAutomationParameters(); @@ -747,8 +744,7 @@ private void removeParameters(ArrayList paramIds) { for (LayerGroup layerGroup : score) { - if (layerGroup instanceof PolyObject) { - PolyObject pObj = (PolyObject) layerGroup; + if (layerGroup instanceof PolyObject pObj) { for (SoundLayer layer : pObj) { ParameterIdList automationParameters = layer.getAutomationParameters(); diff --git a/blue-ui-core/src/main/java/blue/components/FindReplaceDialog.java b/blue-ui-core/src/main/java/blue/components/FindReplaceDialog.java index 62e928681..5f18700a3 100644 --- a/blue-ui-core/src/main/java/blue/components/FindReplaceDialog.java +++ b/blue-ui-core/src/main/java/blue/components/FindReplaceDialog.java @@ -54,10 +54,10 @@ public static void showFindReplace(JTextComponent textComponent) { if (!map.containsKey(root)) { FindReplaceDialog dialog; - if (root instanceof Frame) { - dialog = new FindReplaceDialog((Frame) root); - } else if (root instanceof Dialog) { - dialog = new FindReplaceDialog((Dialog) root); + if (root instanceof Frame frame) { + dialog = new FindReplaceDialog(frame); + } else if (root instanceof Dialog dialog1) { + dialog = new FindReplaceDialog(dialog1); } else { return; } diff --git a/blue-ui-core/src/main/java/blue/components/PaletteWindow.java b/blue-ui-core/src/main/java/blue/components/PaletteWindow.java index 7eeb354e4..bca6228b3 100644 --- a/blue-ui-core/src/main/java/blue/components/PaletteWindow.java +++ b/blue-ui-core/src/main/java/blue/components/PaletteWindow.java @@ -70,8 +70,7 @@ public static void main(String[] args) { for (int j = 0; j < subComponents.length; j++) { Component component2 = subComponents[j]; - if (component2 instanceof JButton) { - JButton b = (JButton) component2; + if (component2 instanceof JButton b) { b.setIcon(UIManager .getIcon("InternalFrame.paletteCloseIcon")); diff --git a/blue-ui-core/src/main/java/blue/components/lines/LineEditorDialog.java b/blue-ui-core/src/main/java/blue/components/lines/LineEditorDialog.java index 3d2a4b46a..21dd2a09c 100644 --- a/blue-ui-core/src/main/java/blue/components/lines/LineEditorDialog.java +++ b/blue-ui-core/src/main/java/blue/components/lines/LineEditorDialog.java @@ -72,10 +72,10 @@ public static LineEditorDialog getInstance(Component obj) { if (!map.containsKey(root)) { LineEditorDialog dialog; - if (root instanceof Frame) { - dialog = new LineEditorDialog((Frame) root); - } else if (root instanceof Dialog) { - dialog = new LineEditorDialog((Dialog) root); + if (root instanceof Frame frame) { + dialog = new LineEditorDialog(frame); + } else if (root instanceof Dialog dialog1) { + dialog = new LineEditorDialog(dialog1); } else { return null; } diff --git a/blue-ui-core/src/main/java/blue/components/lines/LineListTable.java b/blue-ui-core/src/main/java/blue/components/lines/LineListTable.java index c68751c76..76ee6f850 100644 --- a/blue-ui-core/src/main/java/blue/components/lines/LineListTable.java +++ b/blue-ui-core/src/main/java/blue/components/lines/LineListTable.java @@ -154,8 +154,8 @@ class ColorCellRenderer extends DefaultTableCellRenderer { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int col) { - if (value instanceof Color) { - this.setBackground((Color) value); + if (value instanceof Color color) { + this.setBackground(color); } else { this.setBackground(Color.BLACK); } diff --git a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsManagerDialog.java b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsManagerDialog.java index 923468ab9..e6a49ee77 100644 --- a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsManagerDialog.java +++ b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsManagerDialog.java @@ -208,10 +208,10 @@ public PresetsTreePopup() { return; } - if (userObj instanceof Preset) { - model.removePreset((Preset) userObj); - } else if (userObj instanceof PresetGroup) { - model.removePresetGroup((PresetGroup) userObj); + if (userObj instanceof Preset preset) { + model.removePreset(preset); + } else if (userObj instanceof PresetGroup presetGroup) { + model.removePresetGroup(presetGroup); } }); @@ -220,9 +220,9 @@ public PresetsTreePopup() { return; } - if (userObj instanceof Preset) { - buffer.setBufferedItem(new Preset((Preset)userObj)); - model.removePreset((Preset) userObj); + if (userObj instanceof Preset preset) { + buffer.setBufferedItem(new Preset(preset)); + model.removePreset(preset); } else { buffer.setBufferedItem(new PresetGroup((PresetGroup)userObj)); model.removePresetGroup((PresetGroup) userObj); @@ -234,8 +234,8 @@ public PresetsTreePopup() { return; } - if (userObj instanceof Preset) { - buffer.setBufferedItem(new Preset((Preset)userObj)); + if (userObj instanceof Preset preset) { + buffer.setBufferedItem(new Preset(preset)); } else { buffer.setBufferedItem(new PresetGroup((PresetGroup)userObj)); } @@ -250,8 +250,8 @@ public PresetsTreePopup() { Object item = buffer.getBufferedItem(); - if (item instanceof Preset) { - model.addPreset(group, new Preset((Preset)item)); + if (item instanceof Preset preset) { + model.addPreset(group, new Preset(preset)); } else { model.addPresetGroup(group, new PresetGroup((PresetGroup) item)); @@ -318,10 +318,10 @@ public PresetsTreePopup() { } } Element node; - if (userObj instanceof PresetGroup) { - node = ((PresetGroup) userObj).saveAsXML(); - } else if (userObj instanceof Preset) { - node = ((Preset) userObj).saveAsXML(); + if (userObj instanceof PresetGroup presetGroup) { + node = presetGroup.saveAsXML(); + } else if (userObj instanceof Preset preset) { + node = preset.saveAsXML(); } else { return; } diff --git a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsTreeDropTarget.java b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsTreeDropTarget.java index 4ee743a4e..374458025 100644 --- a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsTreeDropTarget.java +++ b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsTreeDropTarget.java @@ -97,17 +97,15 @@ public void drop(DropTargetDropEvent dtde) { PresetGroup parentNode = (PresetGroup) node; - if (transferNode instanceof Preset) { - Preset preset = (Preset) transferNode; + if (transferNode instanceof Preset preset) { presetsTreeModel.removePreset(preset); presetsTreeModel.addPreset(parentNode, new Preset(preset)); dtde.dropComplete(true); - } else if (transferNode instanceof PresetGroup) { + } else if (transferNode instanceof PresetGroup presetGroup) { - PresetGroup presetGroup = (PresetGroup) transferNode; presetsTreeModel.removePresetGroup(presetGroup); presetsTreeModel diff --git a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsTreeModel.java b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsTreeModel.java index 2678ab346..d657d1561 100644 --- a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsTreeModel.java +++ b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/PresetsTreeModel.java @@ -154,8 +154,7 @@ public Object getChild(Object parent, int index) { public int getChildCount(Object parent) { if (parent instanceof Preset) { return 0; - } else if (parent instanceof PresetGroup) { - PresetGroup presetGroup = (PresetGroup) parent; + } else if (parent instanceof PresetGroup presetGroup) { return presetGroup.getSubGroups().size() + presetGroup.getPresets().size(); } @@ -184,10 +183,10 @@ public boolean isLeaf(Object node) { public void valueForPathChanged(TreePath path, Object newValue) { Object obj = path.getLastPathComponent(); - if (obj instanceof PresetGroup) { - ((PresetGroup) obj).setPresetGroupName(newValue.toString()); - } else if (obj instanceof Preset) { - ((Preset) obj).setPresetName(newValue.toString()); + if (obj instanceof PresetGroup presetGroup) { + presetGroup.setPresetGroupName(newValue.toString()); + } else if (obj instanceof Preset preset) { + preset.setPresetName(newValue.toString()); } TreeModelEvent e = new TreeModelEvent(this, path); diff --git a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBEditPanel.java b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBEditPanel.java index f3d1fa823..9e389890b 100644 --- a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBEditPanel.java +++ b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBEditPanel.java @@ -187,8 +187,7 @@ public void mouseReleased(MouseEvent e) { if (marquee.isVisible()) { for (var c : getComponentsInLayer(DEFAULT_LAYER)) { - if (c instanceof BSBObjectViewHolder) { - var viewHolder = (BSBObjectViewHolder) c; + if (c instanceof BSBObjectViewHolder viewHolder) { if (marquee.intersects(viewHolder)) { selection.add(viewHolder.getBSBObjectView().getBSBObject()); } @@ -463,8 +462,7 @@ private void clearBSBObjects() { // this.remove(c); // } for (var c : getComponents()) { - if (c instanceof BSBObjectViewHolder) { - var viewHolder = (BSBObjectViewHolder) c; + if (c instanceof BSBObjectViewHolder viewHolder) { viewHolder.removeComponentListener(cl); } @@ -531,8 +529,8 @@ private BSBObjectViewHolder getEditorForBSBObject(BSBObject bsbObj) { BSBObjectView objectView = BSBObjectEditorFactory.getView(bsbObj); - if (objectView instanceof EditModeConditional) { - ((EditModeConditional) objectView).setEditEnabledProperty(editEnabledProperty); + if (objectView instanceof EditModeConditional editModeConditional) { + editModeConditional.setEditEnabledProperty(editEnabledProperty); } BSBObjectViewHolder viewHolder @@ -558,8 +556,7 @@ private BSBObjectViewHolder getEditorForBSBObject(BSBObject bsbObj) { protected void removeBSBObject(BSBObject bsbObj) { BSBObjectViewHolder found = null; for (var c : getComponents()) { - if (c instanceof BSBObjectViewHolder) { - var vh = (BSBObjectViewHolder) c; + if (c instanceof BSBObjectViewHolder vh) { if (vh.getBSBObjectView().getBSBObject() == bsbObj) { found = vh; break; @@ -708,8 +705,7 @@ public List getSelectedViews() { List retVal = new ArrayList<>(); for (var c : getComponents()) { - if (c instanceof BSBObjectViewHolder) { - var holder = (BSBObjectViewHolder) c; + if (c instanceof BSBObjectViewHolder holder) { var bsbObjView = holder.getBSBObjectView(); if (selection.contains(bsbObjView.getBSBObject())) { retVal.add(holder); @@ -733,8 +729,7 @@ public Dimension getPreferredSize() { int maxH = 1; for (var c : getComponents()) { - if (c instanceof BSBObjectViewHolder) { - var viewHolder = (BSBObjectViewHolder) c; + if (c instanceof BSBObjectViewHolder viewHolder) { if (!isEditing() && viewHolder.isEditModeOnly()) { continue; } diff --git a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBGroupPanel.java b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBGroupPanel.java index 5c8240bab..5c178e1f9 100644 --- a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBGroupPanel.java +++ b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBGroupPanel.java @@ -219,8 +219,8 @@ protected void addBSBObject(BSBObject bsbObj) { BSBObjectView objectView = BSBObjectEditorFactory.getView(bsbObj); - if (objectView instanceof EditModeConditional) { - ((EditModeConditional) objectView).setEditEnabledProperty(editEnabledProperty); + if (objectView instanceof EditModeConditional editModeConditional) { + editModeConditional.setEditEnabledProperty(editEnabledProperty); } objectView.setLocation(bsbObj.getX(), bsbObj.getY()); @@ -310,8 +310,8 @@ public void setEditEnabledProperty(BooleanProperty editEnabled) { this.editEnabledProperty = editEnabled; for (var c : editorPanel.getComponents()) { - if (c instanceof EditModeConditional) { - ((EditModeConditional) c).setEditEnabledProperty(editEnabled); + if (c instanceof EditModeConditional editModeConditional) { + editModeConditional.setEditEnabledProperty(editEnabled); } } } diff --git a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBObjectEditorFactory.java b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBObjectEditorFactory.java index 3c1f6a067..2fcb80cfc 100644 --- a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBObjectEditorFactory.java +++ b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/BSBObjectEditorFactory.java @@ -70,40 +70,40 @@ public class BSBObjectEditorFactory { // } public static BSBObjectView getView(BSBObject bsbObject) { - if (bsbObject instanceof BSBGroup) { - return new BSBGroupPanel((BSBGroup)bsbObject); - } else if (bsbObject instanceof BSBCheckBox) { - return new BSBCheckBoxView((BSBCheckBox) bsbObject); - } else if (bsbObject instanceof BSBDropdown) { - return new BSBDropdownView((BSBDropdown) bsbObject); + if (bsbObject instanceof BSBGroup bSBGroup) { + return new BSBGroupPanel(bSBGroup); + } else if (bsbObject instanceof BSBCheckBox bSBCheckBox) { + return new BSBCheckBoxView(bSBCheckBox); + } else if (bsbObject instanceof BSBDropdown bSBDropdown) { + return new BSBDropdownView(bSBDropdown); // } else if (bsbObject instanceof BSBEnvelopeGenerator) { // return new BSBEnvelopeGenerator((BSBEnvelopeGenerator)bsbObject); - } else if (bsbObject instanceof BSBFileSelector) { - return new BSBFileSelectorView((BSBFileSelector)bsbObject); - } else if (bsbObject instanceof BSBHSlider) { - return new BSBHSliderView((BSBHSlider)bsbObject); - } else if (bsbObject instanceof BSBHSliderBank) { - return new BSBHSliderBankView((BSBHSliderBank)bsbObject); - } else if (bsbObject instanceof BSBKnob) { - return new BSBKnobView((BSBKnob)bsbObject); - } else if (bsbObject instanceof BSBLabel) { - return new BSBLabelView((BSBLabel)bsbObject); - } else if (bsbObject instanceof BSBLineObject) { - return new BSBLineObjectView((BSBLineObject)bsbObject); - } else if (bsbObject instanceof BSBSubChannelDropdown) { - return new BSBSubChannelDropdownView((BSBSubChannelDropdown)bsbObject); + } else if (bsbObject instanceof BSBFileSelector bSBFileSelector) { + return new BSBFileSelectorView(bSBFileSelector); + } else if (bsbObject instanceof BSBHSlider bSBHSlider) { + return new BSBHSliderView(bSBHSlider); + } else if (bsbObject instanceof BSBHSliderBank bSBHSliderBank) { + return new BSBHSliderBankView(bSBHSliderBank); + } else if (bsbObject instanceof BSBKnob bSBKnob) { + return new BSBKnobView(bSBKnob); + } else if (bsbObject instanceof BSBLabel bSBLabel) { + return new BSBLabelView(bSBLabel); + } else if (bsbObject instanceof BSBLineObject bSBLineObject) { + return new BSBLineObjectView(bSBLineObject); + } else if (bsbObject instanceof BSBSubChannelDropdown bSBSubChannelDropdown) { + return new BSBSubChannelDropdownView(bSBSubChannelDropdown); // } else if (bsbObject instanceof BSBTabbedPane) { // return new BSBTabbedPaneView((BSBTabbedPane)bsbObject); - } else if (bsbObject instanceof BSBTextField) { - return new BSBTextFieldView((BSBTextField)bsbObject); - } else if (bsbObject instanceof BSBVSlider) { - return new BSBVSliderView((BSBVSlider)bsbObject); - } else if (bsbObject instanceof BSBVSliderBank) { - return new BSBVSliderBankView((BSBVSliderBank)bsbObject); - } else if (bsbObject instanceof BSBXYController) { - return new BSBXYControllerView((BSBXYController)bsbObject); - } else if (bsbObject instanceof BSBValue) { - return new BSBValueView((BSBValue)bsbObject); + } else if (bsbObject instanceof BSBTextField bSBTextField) { + return new BSBTextFieldView(bSBTextField); + } else if (bsbObject instanceof BSBVSlider bSBVSlider) { + return new BSBVSliderView(bSBVSlider); + } else if (bsbObject instanceof BSBVSliderBank bSBVSliderBank) { + return new BSBVSliderBankView(bSBVSliderBank); + } else if (bsbObject instanceof BSBXYController bSBXYController) { + return new BSBXYControllerView(bSBXYController); + } else if (bsbObject instanceof BSBValue bSBValue) { + return new BSBValueView(bSBValue); } else { Exceptions.printStackTrace(new Exception("Unknown BSBObject: " + bsbObject.getClass())); } diff --git a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/PresetsPanel.java b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/PresetsPanel.java index 7f2af6e4f..8939172c7 100644 --- a/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/PresetsPanel.java +++ b/blue-ui-core/src/main/java/blue/orchestra/editor/blueSynthBuilder/swing/PresetsPanel.java @@ -69,8 +69,8 @@ public PresetsPanel() { addPresetListener = (ActionEvent e) -> { Object obj = e.getSource(); - if (obj instanceof AddPresetMenuItem) { - PresetGroup presetGroup1 = ((AddPresetMenuItem) obj). + if (obj instanceof AddPresetMenuItem addPresetMenuItem) { + PresetGroup presetGroup1 = addPresetMenuItem. getPresetGroup(); addPreset(presetGroup1); } @@ -78,8 +78,8 @@ public PresetsPanel() { addFolderListener = (ActionEvent e) -> { Object obj = e.getSource(); - if (obj instanceof AddFolderMenuItem) { - PresetGroup presetGroup1 = ((AddFolderMenuItem) obj). + if (obj instanceof AddFolderMenuItem addFolderMenuItem) { + PresetGroup presetGroup1 = addFolderMenuItem. getPresetGroup(); addFolder(presetGroup1); } diff --git a/blue-ui-core/src/main/java/blue/soundObject/editor/jmask/GeneratorEditorFactory.java b/blue-ui-core/src/main/java/blue/soundObject/editor/jmask/GeneratorEditorFactory.java index f6647aab1..fc767d1d2 100644 --- a/blue-ui-core/src/main/java/blue/soundObject/editor/jmask/GeneratorEditorFactory.java +++ b/blue-ui-core/src/main/java/blue/soundObject/editor/jmask/GeneratorEditorFactory.java @@ -36,20 +36,20 @@ public class GeneratorEditorFactory { public static JComponent getView(Generator generator) { - if(generator instanceof Probability) { - return new ProbabilityEditor((Probability)generator); - } else if(generator instanceof Segment) { + if(generator instanceof Probability probability) { + return new ProbabilityEditor(probability); + } else if(generator instanceof Segment segment) { SegmentEditor editor = new SegmentEditor(); - editor.setSegment((Segment)generator); + editor.setSegment(segment); return editor; - } else if(generator instanceof ItemList) { - return new ItemListEditor((ItemList)generator); - } else if(generator instanceof Oscillator) { - return new OscillatorEditor((Oscillator)generator); - } else if(generator instanceof Random) { - return new RandomEditor((Random)generator); - } else if(generator instanceof Constant) { - return new ConstantEditor((Constant)generator); + } else if(generator instanceof ItemList itemList) { + return new ItemListEditor(itemList); + } else if(generator instanceof Oscillator oscillator) { + return new OscillatorEditor(oscillator); + } else if(generator instanceof Random random) { + return new RandomEditor(random); + } else if(generator instanceof Constant constant) { + return new ConstantEditor(constant); } return null; diff --git a/blue-ui-core/src/main/java/blue/soundObject/editor/jmask/probability/ProbabilityEditorFactory.java b/blue-ui-core/src/main/java/blue/soundObject/editor/jmask/probability/ProbabilityEditorFactory.java index 5e289e4fe..9318127b5 100644 --- a/blue-ui-core/src/main/java/blue/soundObject/editor/jmask/probability/ProbabilityEditorFactory.java +++ b/blue-ui-core/src/main/java/blue/soundObject/editor/jmask/probability/ProbabilityEditorFactory.java @@ -35,18 +35,18 @@ public class ProbabilityEditorFactory { public static JComponent getView(ProbabilityGenerator pGen) { - if (pGen instanceof Beta) { - return new BetaEditor((Beta)pGen); - } else if (pGen instanceof Cauchy) { - return new CauchyEditor((Cauchy)pGen); - } else if (pGen instanceof Exponential) { - return new ExponentialEditor((Exponential)pGen); - } else if (pGen instanceof Gaussian) { - return new GaussianEditor((Gaussian)pGen); - } else if (pGen instanceof Linear) { - return new LinearEditor((Linear)pGen); - } else if (pGen instanceof Weibull) { - return new WeibullEditor((Weibull)pGen); + if (pGen instanceof Beta beta) { + return new BetaEditor(beta); + } else if (pGen instanceof Cauchy cauchy) { + return new CauchyEditor(cauchy); + } else if (pGen instanceof Exponential exponential) { + return new ExponentialEditor(exponential); + } else if (pGen instanceof Gaussian gaussian) { + return new GaussianEditor(gaussian); + } else if (pGen instanceof Linear linear) { + return new LinearEditor(linear); + } else if (pGen instanceof Weibull weibull) { + return new WeibullEditor(weibull); } return null; diff --git a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldDefinitionsEditor.java b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldDefinitionsEditor.java index 351f8e8ee..7a02b5844 100644 --- a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldDefinitionsEditor.java +++ b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldDefinitionsEditor.java @@ -64,9 +64,9 @@ public TableCellEditor getDefaultEditor(Class columnClass) { return new DefaultCellEditor(new JTextField()) { @Override public boolean isCellEditable(EventObject anEvent) { - if (anEvent instanceof KeyEvent) { + if (anEvent instanceof KeyEvent keyEvent) { int shortcutKey = BlueSystem.getMenuShortcutKey(); - KeyEvent ke = (KeyEvent) anEvent; + KeyEvent ke = keyEvent; if ((ke.getKeyCode() == KeyEvent.VK_Z || ke.getKeyCode() == KeyEvent.VK_Y) && (ke.getModifiers() & shortcutKey) == shortcutKey) { return false; @@ -90,8 +90,8 @@ public void editPianoRoll(PianoRoll p) { this.fieldDefinitions = fieldDefinitions; var oldModel = fieldDefinitionTable.getModel(); - if (oldModel instanceof FieldDefinitionsTableModel) { - ((FieldDefinitionsTableModel) oldModel).clearListener(); + if (oldModel instanceof FieldDefinitionsTableModel fieldDefinitionsTableModel) { + fieldDefinitionsTableModel.clearListener(); } var model = new FieldDefinitionsTableModel(p, fieldDefinitions, undoManager); @@ -106,9 +106,9 @@ public void editPianoRoll(PianoRoll p) { fieldTypeColumn.setCellEditor(new DefaultCellEditor(comboBox) { @Override public boolean isCellEditable(EventObject anEvent) { - if (anEvent instanceof KeyEvent) { + if (anEvent instanceof KeyEvent keyEvent) { int shortcutKey = BlueSystem.getMenuShortcutKey(); - KeyEvent ke = (KeyEvent) anEvent; + KeyEvent ke = keyEvent; if ((ke.getKeyCode() == KeyEvent.VK_Z || ke.getKeyCode() == KeyEvent.VK_Y) && (ke.getModifiers() & shortcutKey) == shortcutKey) { return false; diff --git a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldEditor.java b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldEditor.java index 504d8cfa3..94a5cdd1a 100644 --- a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldEditor.java +++ b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldEditor.java @@ -111,8 +111,7 @@ public void componentResized(ComponentEvent e) { // TODO: Change this algorithm for (var note : change.getRemoved()) { for (var c : getComponents()) { - if (c instanceof Pin) { - Pin p = (Pin) c; + if (c instanceof Pin p) { if (p.note == note) { remove(p); break; @@ -172,9 +171,8 @@ public String getToolTipText(MouseEvent e) { String tip = null; Object obj = this.getComponentAt(e.getPoint()); - if (obj instanceof Pin) { + if (obj instanceof Pin pin) { - var pin = (Pin) obj; var fd = pin.field; if (fd.getFieldDef().getFieldType() == FieldType.DISCRETE) { diff --git a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldEditorMouseListener.java b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldEditorMouseListener.java index 0e1ad53e2..4b48bbb16 100644 --- a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldEditorMouseListener.java +++ b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/FieldEditorMouseListener.java @@ -78,9 +78,8 @@ public void mousePressed(MouseEvent e) { var comp = fEditor.getComponentAt(e.getPoint()); - if (comp instanceof Pin) { + if (comp instanceof Pin src) { - var src = (Pin) comp; currentPin = src; if (selectedNotes.contains(src.note)) { diff --git a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/NoteCanvasMouseListener.java b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/NoteCanvasMouseListener.java index d107d03a6..d14bb4f39 100644 --- a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/NoteCanvasMouseListener.java +++ b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/NoteCanvasMouseListener.java @@ -151,8 +151,7 @@ public void mousePressed(MouseEvent e) { var p = currentPianoRoll.get(); if (UiUtilities.isRightMouseButton(e)) { - if (comp instanceof PianoNoteView) { - var pnv = (PianoNoteView) comp; + if (comp instanceof PianoNoteView pnv) { if (ListUtil.containsByRef(selectedNotes, pnv.getPianoNote())) { canvas.showPopup(e.getX(), e.getY()); @@ -163,8 +162,7 @@ public void mousePressed(MouseEvent e) { pasteMenu.show(canvas, pastePoint.x, pastePoint.y); } } else if (SwingUtilities.isLeftMouseButton(e)) { - if (comp instanceof PianoNoteView) { - var noteView = (PianoNoteView) comp; + if (comp instanceof PianoNoteView noteView) { var note = noteView.getPianoNote(); if ((e.getModifiers() & OS_CTRL_KEY) == OS_CTRL_KEY && selectedFieldDef.getValue() != null) { @@ -614,8 +612,8 @@ private void resizeNotesRight(MouseEvent e) { @Override public void mouseMoved(MouseEvent e) { Component comp = canvas.getComponentAt(e.getPoint()); - if (comp instanceof PianoNoteView) { - mouseMoveNoteView = (PianoNoteView) comp; + if (comp instanceof PianoNoteView pianoNoteView) { + mouseMoveNoteView = pianoNoteView; var x = e.getX(); if ((e.getModifiers() & OS_CTRL_KEY) == OS_CTRL_KEY diff --git a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/PianoRollCanvas.java b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/PianoRollCanvas.java index bcf3dd495..7283a94a1 100644 --- a/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/PianoRollCanvas.java +++ b/blue-ui-core/src/main/java/blue/soundObject/editor/pianoRoll/PianoRollCanvas.java @@ -309,8 +309,7 @@ public String getToolTipText(MouseEvent e) { String tip = null; Object obj = this.getComponentAt(e.getPoint()); - if (obj instanceof PianoNoteView) { - var pnv = (PianoNoteView) obj; + if (obj instanceof PianoNoteView pnv) { var note = pnv.getPianoNote(); var p = currentPianoRoll.get(); @@ -750,8 +749,7 @@ public void onChanged(Change change) { // TODO - Improve algorithm as this performance is not good for (var note : change.getRemoved()) { for (var c : getComponents()) { - if (c instanceof PianoNoteView) { - var pnv = (PianoNoteView) c; + if (c instanceof PianoNoteView pnv) { if (pnv.getPianoNote() == note) { remove(pnv); diff --git a/blue-ui-core/src/main/java/blue/tools/blueShare/soundObjects/SoundObjectExportPane.java b/blue-ui-core/src/main/java/blue/tools/blueShare/soundObjects/SoundObjectExportPane.java index 070862a6b..e5896e423 100644 --- a/blue-ui-core/src/main/java/blue/tools/blueShare/soundObjects/SoundObjectExportPane.java +++ b/blue-ui-core/src/main/java/blue/tools/blueShare/soundObjects/SoundObjectExportPane.java @@ -174,10 +174,10 @@ public void mouseClicked(MouseEvent e) { SoundObject instr = node.getValue(); - if (instr instanceof Sound) { - descriptionText.setText(((Sound) instr).getComment()); - } else if (instr instanceof ObjectBuilder) { - descriptionText.setText(((ObjectBuilder) instr).getComment()); + if (instr instanceof Sound sound) { + descriptionText.setText(sound.getComment()); + } else if (instr instanceof ObjectBuilder objectBuilder) { + descriptionText.setText(objectBuilder.getComment()); } else { descriptionText.setText(""); } diff --git a/blue-ui-core/src/main/java/blue/ui/core/CompileProcessor.java b/blue-ui-core/src/main/java/blue/ui/core/CompileProcessor.java index 9a8a11229..5c340081d 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/CompileProcessor.java +++ b/blue-ui-core/src/main/java/blue/ui/core/CompileProcessor.java @@ -123,8 +123,8 @@ protected void process(Env env, out.close(); } - if(e instanceof CommandException) { - throw (CommandException)e; + if(e instanceof CommandException commandException) { + throw commandException; } throw new CommandException(1, BlueSystem.getString("message.errorLabel") + " " + BlueSystem.getString("blue.csdCompileError") + e.getMessage()); diff --git a/blue-ui-core/src/main/java/blue/ui/core/blueLive/KeyboardKeyRenderer.java b/blue-ui-core/src/main/java/blue/ui/core/blueLive/KeyboardKeyRenderer.java index de910d051..2c0a76bd1 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/blueLive/KeyboardKeyRenderer.java +++ b/blue-ui-core/src/main/java/blue/ui/core/blueLive/KeyboardKeyRenderer.java @@ -50,8 +50,8 @@ public Component getTableCellRendererComponent(JTable table, Object value, String label = ""; - if (value instanceof Integer) { - int val = ((Integer) value).intValue(); + if (value instanceof Integer integer) { + int val = integer.intValue(); if (val < 0) { label = ""; diff --git a/blue-ui-core/src/main/java/blue/ui/core/blueLive/MidiKeyRenderer.java b/blue-ui-core/src/main/java/blue/ui/core/blueLive/MidiKeyRenderer.java index 1edfa9e27..f9d43bc53 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/blueLive/MidiKeyRenderer.java +++ b/blue-ui-core/src/main/java/blue/ui/core/blueLive/MidiKeyRenderer.java @@ -49,8 +49,8 @@ public Component getTableCellRendererComponent(JTable table, Object value, String label = ""; - if (value instanceof Integer) { - int val = ((Integer) value).intValue(); + if (value instanceof Integer integer) { + int val = integer.intValue(); if (val < 0 || val > 127) { label = ""; diff --git a/blue-ui-core/src/main/java/blue/ui/core/blueLive/ScoPadReceiver.java b/blue-ui-core/src/main/java/blue/ui/core/blueLive/ScoPadReceiver.java index 76a5dc2da..63f60716a 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/blueLive/ScoPadReceiver.java +++ b/blue-ui-core/src/main/java/blue/ui/core/blueLive/ScoPadReceiver.java @@ -67,9 +67,8 @@ public String getNotes(String noteTemplate, String instrId, double start, @Override public void send(MidiMessage message, long timeStamp) { - if (message instanceof ShortMessage) { + if (message instanceof ShortMessage shortMsg) { - ShortMessage shortMsg = (ShortMessage) message; int noteNum, velocity; // long duration; MidiNote n; diff --git a/blue-ui-core/src/main/java/blue/ui/core/midi/MidiInputEngine.java b/blue-ui-core/src/main/java/blue/ui/core/midi/MidiInputEngine.java index 3dd387034..962868f79 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/midi/MidiInputEngine.java +++ b/blue-ui-core/src/main/java/blue/ui/core/midi/MidiInputEngine.java @@ -73,9 +73,8 @@ protected void reinitialize() { @Override public void send(MidiMessage message, long timeStamp) { - if (message instanceof ShortMessage) { + if (message instanceof ShortMessage shortMsg) { - ShortMessage shortMsg = (ShortMessage) message; int channel = shortMsg.getChannel(); int noteNum = shortMsg.getData1(); int velocity = shortMsg.getData2(); diff --git a/blue-ui-core/src/main/java/blue/ui/core/mixer/ChannelPanel.java b/blue-ui-core/src/main/java/blue/ui/core/mixer/ChannelPanel.java index df2e5b217..706cff7bb 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/mixer/ChannelPanel.java +++ b/blue-ui-core/src/main/java/blue/ui/core/mixer/ChannelPanel.java @@ -218,8 +218,8 @@ public synchronized void clear() { postList.setModel(fakeModel); ComboBoxModel model = this.outputList.getModel(); - if (model instanceof ChannelOutComboBoxModel) { - ((ChannelOutComboBoxModel) model).clearListeners(); + if (model instanceof ChannelOutComboBoxModel channelOutComboBoxModel) { + channelOutComboBoxModel.clearListeners(); } } @@ -436,21 +436,19 @@ private void postListMouseClicked(java.awt.event.MouseEvent evt) {// GEN-FIRST:e Frame root = WindowManager.getDefault().getMainWindow(); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { EffectEditorManager.getInstance() .openEffectEditor(root, effect); - } else if (obj instanceof Send) { - Send send = (Send) obj; + } else if (obj instanceof Send send) { ComboBoxModel model = outputList.getModel(); ComboBoxModel temp = null; - if (model instanceof ChannelOutComboBoxModel) { - temp = ((ChannelOutComboBoxModel) model).getCopy(); - } else if (model instanceof SubChannelOutComboBoxModel) { - temp = ((SubChannelOutComboBoxModel) model).getCopy(); + if (model instanceof ChannelOutComboBoxModel channelOutComboBoxModel) { + temp = channelOutComboBoxModel.getCopy(); + } else if (model instanceof SubChannelOutComboBoxModel subChannelOutComboBoxModel) { + temp = subChannelOutComboBoxModel.getCopy(); } SendEditorManager.getInstance() @@ -487,21 +485,19 @@ private void preListMouseClicked(java.awt.event.MouseEvent evt) {// GEN-FIRST:ev Frame root = WindowManager.getDefault().getMainWindow(); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { EffectEditorManager.getInstance() .openEffectEditor(root, effect); - } else if (obj instanceof Send) { - Send send = (Send) obj; + } else if (obj instanceof Send send) { ComboBoxModel model = outputList.getModel(); ComboBoxModel temp = null; - if (model instanceof ChannelOutComboBoxModel) { - temp = ((ChannelOutComboBoxModel) model).getCopy(); - } else if (model instanceof SubChannelOutComboBoxModel) { - temp = ((SubChannelOutComboBoxModel) model).getCopy(); + if (model instanceof ChannelOutComboBoxModel channelOutComboBoxModel) { + temp = channelOutComboBoxModel.getCopy(); + } else if (model instanceof SubChannelOutComboBoxModel subChannelOutComboBoxModel) { + temp = subChannelOutComboBoxModel.getCopy(); } SendEditorManager.getInstance() @@ -682,14 +678,12 @@ public Component getListCellRendererComponent(JList list, Object value, index, isSelected, cellHasFocus); if (list.getModel() != null && index >= 0) { - if (list.getModel() instanceof EffectsChain) { + if (list.getModel() instanceof EffectsChain chain) { - EffectsChain chain = (EffectsChain) list.getModel(); Object obj = chain.getElementAt(index); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { if (effect.isEnabled()) { c.setForeground(ENABLED_COLOR); diff --git a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectTreeDragSource.java b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectTreeDragSource.java index fb3e3dc70..ddd98cb88 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectTreeDragSource.java +++ b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectTreeDragSource.java @@ -70,10 +70,10 @@ public void dragGestureRecognized(DragGestureEvent dge) { || path.getLastPathComponent() instanceof EffectCategory) { oldNode = path.getLastPathComponent(); Object cloneNode = null; - if (oldNode instanceof Effect) { - cloneNode = new Effect((Effect)oldNode); - } else if(oldNode instanceof EffectCategory) { - cloneNode = new EffectCategory((EffectCategory)oldNode); + if (oldNode instanceof Effect effect) { + cloneNode = new Effect(effect); + } else if(oldNode instanceof EffectCategory effectCategory) { + cloneNode = new EffectCategory(effectCategory); } transferable = new TransferableEffect(cloneNode); @@ -89,11 +89,10 @@ public void dragDropEnd(DragSourceDropEvent dsde) { // System.out.println("DragSource: " + oldNode.hashCode()); if (dsde.getDropAction() == DnDConstants.ACTION_MOVE) { - if (oldNode instanceof Effect) { - EffectsLibrary.getInstance().removeEffect((Effect) oldNode); - } else if (oldNode instanceof EffectCategory) { - EffectsLibrary.getInstance().removeEffectCategory( - (EffectCategory) oldNode); + if (oldNode instanceof Effect effect) { + EffectsLibrary.getInstance().removeEffect(effect); + } else if (oldNode instanceof EffectCategory effectCategory) { + EffectsLibrary.getInstance().removeEffectCategory(effectCategory); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectTreeDropTarget.java b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectTreeDropTarget.java index d460489c6..24e757ec9 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectTreeDropTarget.java +++ b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectTreeDropTarget.java @@ -130,9 +130,8 @@ public void drop(DropTargetDropEvent dtde) { effect.clearParameters(); // iLibrary.removeInstrument(instrument); - if (node instanceof EffectCategory) { + if (node instanceof EffectCategory parentNode) { - EffectCategory parentNode = (EffectCategory) node; eLibrary.addEffect(parentNode, effect); } else if (node instanceof Effect) { diff --git a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsLibrary.java b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsLibrary.java index adbe59378..c7e3bc18c 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsLibrary.java +++ b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsLibrary.java @@ -307,8 +307,7 @@ public Object getRoot() { public int getChildCount(Object parent) { if (parent instanceof Effect) { return 0; - } else if (parent instanceof EffectCategory) { - EffectCategory cat = (EffectCategory) parent; + } else if (parent instanceof EffectCategory cat) { return cat.getSubCategories().size() + cat.getEffects().size(); } @@ -355,10 +354,10 @@ public void removeTreeModelListener(TreeModelListener l) { public void valueForPathChanged(TreePath path, Object newValue) { Object obj = path.getLastPathComponent(); - if (obj instanceof EffectCategory) { - ((EffectCategory) obj).setCategoryName(newValue.toString()); - } else if (obj instanceof Effect) { - ((Effect) obj).setName(newValue.toString()); + if (obj instanceof EffectCategory effectCategory) { + effectCategory.setCategoryName(newValue.toString()); + } else if (obj instanceof Effect effect) { + effect.setName(newValue.toString()); } TreeModelEvent e = new TreeModelEvent(this, path); diff --git a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsLibraryDialog.java b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsLibraryDialog.java index c03b66d86..df6e3627a 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsLibraryDialog.java +++ b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsLibraryDialog.java @@ -341,17 +341,17 @@ public void actionPerformed(ActionEvent ae) { if (bufferedObject != null) { - if (bufferedObject instanceof EffectCategory) { + if (bufferedObject instanceof EffectCategory effectCategory) { EffectCategory category = new EffectCategory( - (EffectCategory) bufferedObject); + effectCategory); EffectsLibrary.getInstance().addCategory(cat, category); - } else if (bufferedObject instanceof Effect) { - Effect effect = new Effect((Effect) bufferedObject); + } else if (bufferedObject instanceof Effect effect) { + Effect effectCopy = new Effect(effect); - EffectsLibrary.getInstance().addEffect(cat, effect); + EffectsLibrary.getInstance().addEffect(cat, effectCopy); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsPopup.java b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsPopup.java index c114cc9ea..599bf31da 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsPopup.java +++ b/blue-ui-core/src/main/java/blue/ui/core/mixer/EffectsPopup.java @@ -104,8 +104,7 @@ public void actionPerformed(ActionEvent ae) { if (selectedIndex >= 0 && chain != null) { Object obj = chain.removeElementAt(selectedIndex); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { EffectEditorManager.getInstance().removeEffect(effect); } @@ -120,10 +119,9 @@ public void actionPerformed(ActionEvent ae) { Object obj = chain.removeElementAt(selectedIndex); - if (obj instanceof Effect) { - bufferedEffect = new Effect((Effect) obj); - EffectEditorManager.getInstance().removeEffect( - (Effect) obj); + if (obj instanceof Effect effect) { + bufferedEffect = new Effect(effect); + EffectEditorManager.getInstance().removeEffect(effect); } } @@ -137,8 +135,8 @@ public void actionPerformed(ActionEvent ae) { Object obj = chain.getElementAt(selectedIndex); - if (obj instanceof Effect) { - bufferedEffect = new Effect((Effect) obj); + if (obj instanceof Effect effect) { + bufferedEffect = new Effect(effect); } } @@ -180,8 +178,8 @@ public void actionPerformed(ActionEvent e) { if (selectedIndex >= 0 && chain != null) { Object obj = chain.getElementAt(selectedIndex); - if (obj instanceof Effect) { - EffectsUtil.exportEffect((Effect) obj); + if (obj instanceof Effect effect) { + EffectsUtil.exportEffect(effect); } } } @@ -208,8 +206,7 @@ public void popupMenuWillBecomeVisible(PopupMenuEvent e) { if (itemSelected) { Object obj = chain.getElementAt(selectedIndex); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { if (effect.isEnabled()) { enableDisableEffect.putValue(Action.NAME, @@ -435,8 +432,7 @@ public void actionPerformed(ActionEvent e) { if (chain != null && selectedIndex >= 0) { Object obj = chain.getElementAt(selectedIndex); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { Effect copy = new Effect(effect); @@ -462,23 +458,18 @@ public void actionPerformed(ActionEvent e) { Frame root = WindowManager.getDefault().getMainWindow(); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { EffectEditorManager.getInstance().openEffectEditor(root, effect); - } else if (obj instanceof Send) { - // JOptionPane.showMessageDialog(null, "Show editor for - // Send!"); - - Send send = (Send) obj; + } else if (obj instanceof Send send) { ComboBoxModel temp = null; - if (model instanceof ChannelOutComboBoxModel) { - temp = ((ChannelOutComboBoxModel) model).getCopy(); - } else if (model instanceof SubChannelOutComboBoxModel) { - temp = ((SubChannelOutComboBoxModel) model).getCopy(); + if (model instanceof ChannelOutComboBoxModel channelOutComboBoxModel) { + temp = channelOutComboBoxModel.getCopy(); + } else if (model instanceof SubChannelOutComboBoxModel subChannelOutComboBoxModel) { + temp = subChannelOutComboBoxModel.getCopy(); } SendEditorManager.getInstance().openSendEditor(root, send, @@ -501,8 +492,7 @@ public void actionPerformed(ActionEvent e) { if (chain != null && selectedIndex >= 0) { Object obj = chain.getElementAt(selectedIndex); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { if (effectDialog == null) { // Frame root = WindowManager.getDefault().getMainWindow(); @@ -532,11 +522,9 @@ public void actionPerformed(ActionEvent e) { if (chain != null && selectedIndex >= 0) { Object obj = chain.getElementAt(selectedIndex); - if (obj instanceof Effect) { - Effect effect = (Effect) obj; + if (obj instanceof Effect effect) { effect.setEnabled(!effect.isEnabled()); - } else if (obj instanceof Send) { - Send send = (Send) obj; + } else if (obj instanceof Send send) { send.setEnabled(!send.isEnabled()); } } @@ -586,10 +574,10 @@ public void actionPerformed(ActionEvent e) { ComboBoxModel temp = null; - if (model instanceof ChannelOutComboBoxModel) { - temp = ((ChannelOutComboBoxModel) model).getCopy(); - } else if (model instanceof SubChannelOutComboBoxModel) { - temp = ((SubChannelOutComboBoxModel) model).getCopy(); + if (model instanceof ChannelOutComboBoxModel channelOutComboBoxModel) { + temp = channelOutComboBoxModel.getCopy(); + } else if (model instanceof SubChannelOutComboBoxModel subChannelOutComboBoxModel) { + temp = subChannelOutComboBoxModel.getCopy(); } Frame root = WindowManager.getDefault().getMainWindow(); diff --git a/blue-ui-core/src/main/java/blue/ui/core/mixer/SubChannelListPanel.java b/blue-ui-core/src/main/java/blue/ui/core/mixer/SubChannelListPanel.java index d887f5feb..c88e6e2b8 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/mixer/SubChannelListPanel.java +++ b/blue-ui-core/src/main/java/blue/ui/core/mixer/SubChannelListPanel.java @@ -327,14 +327,12 @@ private void reconcileNameChangeInBlueArrangement(String oldName, for (int i = 0; i < arr.size(); i++) { Instrument instr = arr.getInstrument(i); - if (instr instanceof BlueSynthBuilder) { - BlueSynthBuilder bsb = (BlueSynthBuilder) instr; + if (instr instanceof BlueSynthBuilder bsb) { BSBGraphicInterface bsbInterface = bsb.getGraphicInterface(); for (BSBObject bsbObj : bsbInterface.getAllSet()) { - if (bsbObj instanceof BSBSubChannelDropdown) { - BSBSubChannelDropdown bsbSubDrop = (BSBSubChannelDropdown) bsbObj; + if (bsbObj instanceof BSBSubChannelDropdown bsbSubDrop) { if (bsbSubDrop.getChannelOutput().equals(oldName)) { bsbSubDrop.setChannelOutput(newName); } @@ -367,14 +365,12 @@ private void reconcileSubChannelRemoveInBlueArrangement( for (int i = 0; i < arr.size(); i++) { Instrument instr = arr.getInstrument(i); - if (instr instanceof BlueSynthBuilder) { - BlueSynthBuilder bsb = (BlueSynthBuilder) instr; + if (instr instanceof BlueSynthBuilder bsb) { BSBGraphicInterface bsbInterface = bsb.getGraphicInterface(); for (BSBObject bsbObj : bsbInterface.getAllSet()) { - if (bsbObj instanceof BSBSubChannelDropdown) { - BSBSubChannelDropdown bsbSubDrop = (BSBSubChannelDropdown) bsbObj; + if (bsbObj instanceof BSBSubChannelDropdown bsbSubDrop) { if (bsbSubDrop.getChannelOutput() .equals(removedChannel)) { bsbSubDrop.setChannelOutput(Channel.MASTER); diff --git a/blue-ui-core/src/main/java/blue/ui/core/orchestra/ArrangementEditPanel.java b/blue-ui-core/src/main/java/blue/ui/core/orchestra/ArrangementEditPanel.java index 2ee499fb6..81466aab1 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/orchestra/ArrangementEditPanel.java +++ b/blue-ui-core/src/main/java/blue/ui/core/orchestra/ArrangementEditPanel.java @@ -312,8 +312,7 @@ public void convertToBSB() { Instrument instr = arrangement.getInstrument(selectedRow); - if (instr instanceof GenericInstrument) { - GenericInstrument genInstr = (GenericInstrument) instr; + if (instr instanceof GenericInstrument genInstr) { BlueSynthBuilder bsb = new BlueSynthBuilder(); @@ -376,8 +375,8 @@ public void pasteInstrument() { Instrument clone = instr.deepCopy(); - if (clone instanceof BlueSynthBuilder) { - ((BlueSynthBuilder) clone).clearParameters(); + if (clone instanceof BlueSynthBuilder blueSynthBuilder) { + blueSynthBuilder.clearParameters(); } addInstrument(clone); @@ -576,8 +575,8 @@ public void drop(DropTargetDropEvent dtde) { dtde.acceptDrop(DnDConstants.ACTION_COPY); - if (instrument instanceof BlueSynthBuilder) { - ((BlueSynthBuilder) instrument).clearParameters(); + if (instrument instanceof BlueSynthBuilder blueSynthBuilder) { + blueSynthBuilder.clearParameters(); } addInstrument(instrument, listIndex); diff --git a/blue-ui-core/src/main/java/blue/ui/core/orchestra/InstrumentTreeDragSource.java b/blue-ui-core/src/main/java/blue/ui/core/orchestra/InstrumentTreeDragSource.java index 48407403e..1a97a914a 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/orchestra/InstrumentTreeDragSource.java +++ b/blue-ui-core/src/main/java/blue/ui/core/orchestra/InstrumentTreeDragSource.java @@ -71,10 +71,10 @@ public void dragGestureRecognized(DragGestureEvent dge) { oldNode = path.getLastPathComponent(); Object cloneNode = null; - if(oldNode instanceof Instrument) { - cloneNode = ((Instrument)oldNode).deepCopy(); - } else if(oldNode instanceof InstrumentCategory){ - cloneNode = new InstrumentCategory((InstrumentCategory) oldNode); + if(oldNode instanceof Instrument instrument) { + cloneNode = instrument.deepCopy(); + } else if(oldNode instanceof InstrumentCategory instrumentCategory){ + cloneNode = new InstrumentCategory(instrumentCategory); } transferable = new TransferableInstrument(cloneNode); @@ -92,15 +92,15 @@ public void dragDropEnd(DragSourceDropEvent dsde) { if (dsde.getDropAction() == DnDConstants.ACTION_MOVE) { - if (oldNode instanceof Instrument) { + if (oldNode instanceof Instrument instrument) { ((InstrumentLibrary) sourceTree.getModel()) - .removeInstrument((Instrument) oldNode); + .removeInstrument(instrument); - } else if (oldNode instanceof InstrumentCategory) { + } else if (oldNode instanceof InstrumentCategory instrumentCategory) { ((InstrumentLibrary) sourceTree.getModel()) - .removeCategory((InstrumentCategory) oldNode); + .removeCategory(instrumentCategory); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/orchestra/InstrumentTreeDropTarget.java b/blue-ui-core/src/main/java/blue/ui/core/orchestra/InstrumentTreeDropTarget.java index 3d426a72b..8058ee3ff 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/orchestra/InstrumentTreeDropTarget.java +++ b/blue-ui-core/src/main/java/blue/ui/core/orchestra/InstrumentTreeDropTarget.java @@ -136,13 +136,11 @@ public void drop(DropTargetDropEvent dtde) { InstrumentLibrary iLibrary = (InstrumentLibrary) tree .getModel(); - if (instrument instanceof BlueSynthBuilder) { - ((BlueSynthBuilder) instrument).clearParameters(); + if (instrument instanceof BlueSynthBuilder blueSynthBuilder) { + blueSynthBuilder.clearParameters(); } - // iLibrary.removeInstrument(instrument); - if (node instanceof InstrumentCategory) { - InstrumentCategory parentNode = (InstrumentCategory) node; + if (node instanceof InstrumentCategory parentNode) { iLibrary.addInstrument(parentNode, instrument); } else if (node instanceof Instrument) { InstrumentCategory parentNode = (InstrumentCategory) parentpath diff --git a/blue-ui-core/src/main/java/blue/ui/core/orchestra/OrchestraTopComponent.java b/blue-ui-core/src/main/java/blue/ui/core/orchestra/OrchestraTopComponent.java index 9026a1bb1..a647b7e82 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/orchestra/OrchestraTopComponent.java +++ b/blue-ui-core/src/main/java/blue/ui/core/orchestra/OrchestraTopComponent.java @@ -75,11 +75,11 @@ private OrchestraTopComponent() { userInstrumentLibrary.addSelectionListener((SelectionEvent e) -> { Object obj = e.getSelectedItem(); - if (obj instanceof Instrument) { + if (obj instanceof Instrument instrument) { isChanging = true; instrumentEditPanel1.setEditingLibraryObject(true); - editInstrument((Instrument) obj); + editInstrument(instrument); arrangementPanel.deselect(); isChanging = false; diff --git a/blue-ui-core/src/main/java/blue/ui/core/orchestra/UserInstrumentLibrary.java b/blue-ui-core/src/main/java/blue/ui/core/orchestra/UserInstrumentLibrary.java index 33f6c31b5..3b4c08e2b 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/orchestra/UserInstrumentLibrary.java +++ b/blue-ui-core/src/main/java/blue/ui/core/orchestra/UserInstrumentLibrary.java @@ -317,8 +317,8 @@ public Instrument getSelectedInstrument() { } Object obj = selectionPath.getLastPathComponent(); - if (obj instanceof Instrument) { - return (Instrument) obj; + if (obj instanceof Instrument instrument) { + return instrument; } return null; } @@ -530,8 +530,8 @@ protected void copyNode() { Object bufferedObj; - if (userObj instanceof Instrument) { - bufferedObj = ((Instrument) userObj).deepCopy(); + if (userObj instanceof Instrument instrument) { + bufferedObj = instrument.deepCopy(); } else { bufferedObj = new InstrumentCategory((InstrumentCategory)userObj); } @@ -545,8 +545,8 @@ protected void pasteNode() { } Object bufferedObj = CopyBuffer.getBufferedObject(CopyBuffer.INSTRUMENT); - if (bufferedObj instanceof Instrument) { - addInstrument((Instrument) bufferedObj); + if (bufferedObj instanceof Instrument instrument) { + addInstrument(instrument); } else { addInstrumentCategory( new InstrumentCategory((InstrumentCategory)bufferedObj)); @@ -603,10 +603,10 @@ public void show(UserInstrumentLibrary instrGui, Object userObj, int x, this.instrGUI = instrGui; this.userObj = userObj; - if (userObj instanceof InstrumentCategory) { + if (userObj instanceof InstrumentCategory instrumentCategory) { addCategoryMenuItem.setVisible(true); - removeCategoryMenuItem.setVisible(!((InstrumentCategory) userObj).isRoot()); + removeCategoryMenuItem.setVisible(!instrumentCategory.isRoot()); addInstrumentMenu.setVisible(true); removeInstrumentMenuItem.setVisible(false); diff --git a/blue-ui-core/src/main/java/blue/ui/core/project/stems/RenderStemsWizardIterator.java b/blue-ui-core/src/main/java/blue/ui/core/project/stems/RenderStemsWizardIterator.java index edf8db7b7..5420183d6 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/project/stems/RenderStemsWizardIterator.java +++ b/blue-ui-core/src/main/java/blue/ui/core/project/stems/RenderStemsWizardIterator.java @@ -67,9 +67,7 @@ private WizardDescriptor.Panel[] getPanels() { Component c = panels[i].getComponent(); // Default step name to component name of panel. steps[i] = c.getName(); - if (c instanceof JComponent) { // assume Swing components - JComponent jc = (JComponent) c; - // Sets step number of a component + if (c instanceof JComponent jc) { // Sets step number of a component // TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_*: jc.putClientProperty("WizardPanel_contentSelectedIndex", new Integer(i)); // Sets steps names for a panel diff --git a/blue-ui-core/src/main/java/blue/ui/core/render/CSDRender.java b/blue-ui-core/src/main/java/blue/ui/core/render/CSDRender.java index 8158f14f8..227397357 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/render/CSDRender.java +++ b/blue-ui-core/src/main/java/blue/ui/core/render/CSDRender.java @@ -438,8 +438,7 @@ private ArrayList getStringChannels(Arrangement arrangement, if (ia.enabled) { Instrument instr = ia.instr; - if (instr instanceof Automatable) { - Automatable auto = (Automatable) instr; + if (instr instanceof Automatable auto) { ArrayList stringChannels = auto.getStringChannels(); if (stringChannels != null) { diff --git a/blue-ui-core/src/main/java/blue/ui/core/render/ParameterHelper.java b/blue-ui-core/src/main/java/blue/ui/core/render/ParameterHelper.java index 336d95307..8fb26a660 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/render/ParameterHelper.java +++ b/blue-ui-core/src/main/java/blue/ui/core/render/ParameterHelper.java @@ -42,8 +42,7 @@ public static ArrayList getAllParameters(Arrangement arr, Mixer mixer if (ia.enabled) { Instrument instr = ia.instr; - if (instr instanceof Automatable) { - Automatable auto = (Automatable) instr; + if (instr instanceof Automatable auto) { ParameterList list = auto.getParameterList(); params.addAll(list); } @@ -76,8 +75,7 @@ public static List getActiveParameters(Arrangement arr, Mixer mixer) if (ia.enabled) { Instrument instr = ia.instr; - if (instr instanceof Automatable) { - Automatable auto = (Automatable) instr; + if (instr instanceof Automatable auto) { ParameterList list = auto.getParameterList(); addActiveParametersFromList(params, list); @@ -166,8 +164,7 @@ public static void clearCompilationVarNames(BlueData data) { for (int i = 0; i < arrangement.size(); i++) { Instrument instr = arrangement.getInstrument(i); - if (instr instanceof Automatable) { - Automatable temp = (Automatable) instr; + if (instr instanceof Automatable temp) { temp.getParameterList().clearCompilationVarNames(); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/LayerHeightWheelListener.java b/blue-ui-core/src/main/java/blue/ui/core/score/LayerHeightWheelListener.java index 95199016f..82dce3ee3 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/LayerHeightWheelListener.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/LayerHeightWheelListener.java @@ -56,8 +56,7 @@ public void mouseWheelMoved(MouseWheelEvent e) { Layer layer = ScoreController.getInstance().getScorePath().getGlobalLayerForY( p.y); - if(layer instanceof ScoreObjectLayer) { - ScoreObjectLayer sLayer = (ScoreObjectLayer)layer; + if(layer instanceof ScoreObjectLayer sLayer) { int index = sLayer.getHeightIndex(); int newIndex = index + value; diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/MarkersBar.java b/blue-ui-core/src/main/java/blue/ui/core/score/MarkersBar.java index eb7467cab..0d40d3f1e 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/MarkersBar.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/MarkersBar.java @@ -243,8 +243,7 @@ public void propertyChange(PropertyChangeEvent evt) { if (rootTimeline) { for (var c : getComponents()) { - if (c instanceof PlayMarker) { - var pMarker = (PlayMarker) c; + if (c instanceof PlayMarker pMarker) { var x = pMarker.marker.getTime() * timeState.getPixelSecond(); pMarker.setLocation((int) x, 0); } @@ -267,8 +266,7 @@ public void tableChanged(TableModelEvent e) { break; case TableModelEvent.DELETE: for (var c : getComponents()) { - if (c instanceof PlayMarker) { - var pm = (PlayMarker) c; + if (c instanceof PlayMarker pm) { if (!markersList.contains(pm.marker)) { remove(pm); } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/ScoreController.java b/blue-ui-core/src/main/java/blue/ui/core/score/ScoreController.java index 8c92934ee..f5333a6bb 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/ScoreController.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/ScoreController.java @@ -385,8 +385,7 @@ public void copyMultiLine() { // COPY AUTOMATION DATA for (Layer layer : selection.getSelectedLayers()) { - if (layer instanceof AutomatableLayer) { - AutomatableLayer al = (AutomatableLayer) layer; + if (layer instanceof AutomatableLayer al) { ParameterIdList params = al.getAutomationParameters(); for (String paramId : params) { @@ -417,8 +416,7 @@ public void deleteMultiLine() { CompoundAppendable compoundEdit = new CompoundAppendable(); for (Layer layer : selection.getSelectedLayers()) { - if (layer instanceof AutomatableLayer) { - AutomatableLayer al = (AutomatableLayer) layer; + if (layer instanceof AutomatableLayer al) { ParameterIdList params = al.getAutomationParameters(); for (String paramId : params) { diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/ScoreNavigatorContainerListener.java b/blue-ui-core/src/main/java/blue/ui/core/score/ScoreNavigatorContainerListener.java index e0601080e..cc88451ff 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/ScoreNavigatorContainerListener.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/ScoreNavigatorContainerListener.java @@ -31,8 +31,7 @@ public ScoreNavigatorContainerListener(ChangeListener cl) { public void install(Component c) { c.addComponentListener(this); - if (c instanceof Container) { - Container container = (Container) c; + if (c instanceof Container container) { container.addContainerListener(this); for (var comp : container.getComponents()) { @@ -45,8 +44,7 @@ public void install(Component c) { public void uninstall(Component c) { c.removeComponentListener(this); - if (c instanceof Container) { - Container container = (Container) c; + if (c instanceof Container container) { container.removeContainerListener(this); for (var comp : container.getComponents()) { uninstall(comp); diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/ScoreNavigatorDialog.java b/blue-ui-core/src/main/java/blue/ui/core/score/ScoreNavigatorDialog.java index ed8622c26..c7665bff3 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/ScoreNavigatorDialog.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/ScoreNavigatorDialog.java @@ -396,9 +396,9 @@ public void paintComponent(Graphics g) { Component[] comps = layerPanel.getComponents(); for (Component c : comps) { - if (c instanceof LayerGroupPanel) { + if (c instanceof LayerGroupPanel layerGroupPanel) { g2d.translate(c.getX(), c.getY()); - ((LayerGroupPanel) c).paintNavigatorView(g2d); + layerGroupPanel.paintNavigatorView(g2d); g2d.translate(-c.getX(), -c.getY()); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/ScoreTopComponent.java b/blue-ui-core/src/main/java/blue/ui/core/score/ScoreTopComponent.java index 3571d3ca8..b1f0d7e5b 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/ScoreTopComponent.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/ScoreTopComponent.java @@ -1259,8 +1259,8 @@ public LayerGroupPanel getLayerGroupPanelAtPoint(MouseEvent e) { layerPanel); Component c = layerPanel.getComponentAt(p); - if (c instanceof LayerGroupPanel) { - retVal = (LayerGroupPanel) c; + if (c instanceof LayerGroupPanel layerGroupPanel) { + retVal = layerGroupPanel; } return retVal; } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/PolyObjectUIProvider.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/PolyObjectUIProvider.java index 6094866d4..177685ce6 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/PolyObjectUIProvider.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/PolyObjectUIProvider.java @@ -40,9 +40,9 @@ public class PolyObjectUIProvider implements LayerGroupUIProvider { public JComponent getLayerGroupPanel(LayerGroup layerGroup, TimeState timeState, BlueData data, InstanceContent ic) { - if (layerGroup instanceof PolyObject) { + if (layerGroup instanceof PolyObject polyObject) { ScoreTimeCanvas sTimeCanvas = new ScoreTimeCanvas(data, ic); - sTimeCanvas.setPolyObject((PolyObject) layerGroup, timeState); + sTimeCanvas.setPolyObject(polyObject, timeState); return sTimeCanvas; } return null; @@ -53,9 +53,9 @@ public JComponent getLayerGroupHeaderPanel(LayerGroup layerGroup, TimeState timeState, BlueData data, InstanceContent ic) { JComponent returnValue = null; - if(layerGroup instanceof PolyObject) { + if(layerGroup instanceof PolyObject polyObject) { SoundLayerListPanel panel = new SoundLayerListPanel(); - panel.setPolyObject((PolyObject)layerGroup); + panel.setPolyObject(polyObject); returnValue = panel; } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/ScoreObjectEditorTopComponent.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/ScoreObjectEditorTopComponent.java index a958339c0..e3981aaa8 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/ScoreObjectEditorTopComponent.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/ScoreObjectEditorTopComponent.java @@ -244,8 +244,8 @@ public void editScoreObject(ScoreObject sObj) { BlueData data = BlueProjectManager.getInstance() .getCurrentBlueData(); - if (sObj instanceof Instance) { - sObjToEdit = ((Instance) sObj).getSoundObject(); + if (sObj instanceof Instance instance1) { + sObjToEdit = instance1.getSoundObject(); this.setEditingLibraryObject(SelectionEvent.SELECTION_LIBRARY); } else if (data.getSoundObjectLibrary().contains(sObjToEdit)){ this.setEditingLibraryObject(SelectionEvent.SELECTION_LIBRARY); diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/ScoreTimeCanvas.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/ScoreTimeCanvas.java index 568a48a45..aa29f45dd 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/ScoreTimeCanvas.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/ScoreTimeCanvas.java @@ -160,8 +160,8 @@ public String getToolTipText(MouseEvent e) { String tip = null; Object obj = this.getComponentAt(e.getPoint()); - if (obj instanceof SoundObjectView) { - SoundObject sObj = ((SoundObjectView) obj).getSoundObject(); + if (obj instanceof SoundObjectView soundObjectView) { + SoundObject sObj = soundObjectView.getSoundObject(); double subjectiveDuration = sObj.getSubjectiveDuration(); double startTime = sObj.getStartTime(); @@ -197,8 +197,7 @@ public void reset() { for (int i = 0; i < components.length; i++) { Component c = components[i]; - if (c instanceof SoundObjectView) { - SoundObjectView sObjView = (SoundObjectView) c; + if (c instanceof SoundObjectView sObjView) { int index = getPolyObject().getSoundLayerIndex( sObjView.getSoundObject()); @@ -606,8 +605,8 @@ public void marqueeSelectionPerformed(SelectionMarquee marquee) { @Override public ScoreObjectView getScoreObjectViewAtPoint(Point p) { Component c = sObjPanel.getComponentAt(p); - if (c instanceof ScoreObjectView) { - return (ScoreObjectView) c; + if (c instanceof ScoreObjectView scoreObjectView) { + return scoreObjectView; } return null; } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/SoundObjectPropertiesTopComponent.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/SoundObjectPropertiesTopComponent.java index ce7e3ee62..1cddd5625 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/SoundObjectPropertiesTopComponent.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/SoundObjectPropertiesTopComponent.java @@ -128,8 +128,8 @@ public void documentChanged(DocumentEvent e) { private void setScoreObject(ScoreObject scoreObj) { SoundObject soundObj = null; - if (scoreObj instanceof SoundObject) { - soundObj = (SoundObject) scoreObj; + if (scoreObj instanceof SoundObject soundObject) { + soundObj = soundObject; } isUpdating = true; @@ -203,8 +203,8 @@ private void updateProperties() { subjectiveDurationText.setText(Double.toString(sObj .getSubjectiveDuration())); - if (sObj instanceof SoundObject) { - double repeatPoint = ((SoundObject) sObj).getRepeatPoint(); + if (sObj instanceof SoundObject soundObject) { + double repeatPoint = soundObject.getRepeatPoint(); repeatePointText.setText(Double.toString(repeatPoint)); } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/AddSoundObjectActionsPresenter.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/AddSoundObjectActionsPresenter.java index ea06f12ca..e56eef12a 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/AddSoundObjectActionsPresenter.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/AddSoundObjectActionsPresenter.java @@ -91,13 +91,12 @@ public void actionPerformed(ActionEvent e) { var l = scorePath.getGlobalLayerForY(p.y); - if (l instanceof SoundLayer) { - var sLayer = (SoundLayer) l; + if (l instanceof SoundLayer sLayer) { SoundObject sObj = plugin.getInstance(). getClass().getDeclaredConstructor().newInstance(); - if (sObj instanceof PolyObject) { - ((PolyObject) sObj).newLayerAt(0); + if (sObj instanceof PolyObject polyObject) { + polyObject.newLayerAt(0); } TimeState timeState = stc.getTimeState(); diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/PasteAsPolyObjectAction.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/PasteAsPolyObjectAction.java index 7267fb047..3b6a61dd7 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/PasteAsPolyObjectAction.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/PasteAsPolyObjectAction.java @@ -126,8 +126,8 @@ public void actionPerformed(ActionEvent e) { SoundObject clone = (SoundObject)scoreObj.deepCopy(); layer.add(clone); - if (clone instanceof Instance) { - instanceSoundObjects.add((Instance) clone); + if (clone instanceof Instance instance) { + instanceSoundObjects.add(instance); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/PasteSoundObjectAction.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/PasteSoundObjectAction.java index eea1d52b9..11bfefa11 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/PasteSoundObjectAction.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/PasteSoundObjectAction.java @@ -171,10 +171,9 @@ public void actionPerformed(ActionEvent e) { int newLayerIndex = buffer.layerIndices.get(i) + layerTranslation; - if (sObj instanceof Instance) { - instanceSoundObjects.add((Instance) sObj); - } else if (sObj instanceof PolyObject) { - PolyObject pObj = (PolyObject) sObj; + if (sObj instanceof Instance instance) { + instanceSoundObjects.add(instance); + } else if (sObj instanceof PolyObject pObj) { getInstancesFromPolyObject(instanceSoundObjects, pObj); } @@ -209,12 +208,10 @@ private void getInstancesFromPolyObject(List instanceSoundObjects, PolyObject pObj) { for (SoundLayer layer : pObj) { for (SoundObject sObj : layer) { - if (sObj instanceof Instance) { - Instance instance = (Instance) sObj; + if (sObj instanceof Instance instance) { instanceSoundObjects.add(instance); - } else if (sObj instanceof PolyObject) { - getInstancesFromPolyObject(instanceSoundObjects, - (PolyObject) sObj); + } else if (sObj instanceof PolyObject polyObject) { + getInstancesFromPolyObject(instanceSoundObjects, polyObject); } } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/SelectAllAfterAction.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/SelectAllAfterAction.java index ecb2f0ac6..bfa22a148 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/SelectAllAfterAction.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/SelectAllAfterAction.java @@ -80,10 +80,9 @@ public void actionPerformed(ActionEvent e) { List allLayers = scorePath.getAllLayers(); for (Layer layer : allLayers) { - if (layer instanceof ScoreObjectLayer) { - ScoreObjectLayer sLayer = (ScoreObjectLayer) layer; + if (layer instanceof ScoreObjectLayer sLayer) { - for (ScoreObject scoreObject : sLayer) { + for (ScoreObject scoreObject : (ScoreObjectLayer) sLayer) { if (scoreObject.getStartTime() >= pointTime) { newSelected.add(scoreObject); } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/SelectAllBeforeAction.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/SelectAllBeforeAction.java index c39446fde..3171b2d53 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/SelectAllBeforeAction.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/actions/SelectAllBeforeAction.java @@ -82,10 +82,9 @@ public void actionPerformed(ActionEvent e) { List allLayers = scorePath.getAllLayers(); for (Layer layer : allLayers) { - if (layer instanceof ScoreObjectLayer) { - ScoreObjectLayer sLayer = (ScoreObjectLayer) layer; + if (layer instanceof ScoreObjectLayer sLayer) { - for (ScoreObject scoreObject : sLayer) { + for (ScoreObject scoreObject : (ScoreObjectLayer)sLayer) { if (scoreObject.getStartTime() + scoreObject.getSubjectiveDuration() <= pointTime) { newSelected.add(scoreObject); diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/library/SoundObjectLibraryUtils.java b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/library/SoundObjectLibraryUtils.java index dbe4bfdd8..7d9aa02eb 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/library/SoundObjectLibraryUtils.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/layers/soundObject/library/SoundObjectLibraryUtils.java @@ -41,16 +41,15 @@ public static void removeLibrarySoundObject(BlueData data, SoundObject sObj) { library.removeSoundObject(sObj); for (SoundObject tempObj : library) { - if(tempObj instanceof PolyObject) { - removeSoundObjectInstances((PolyObject)tempObj, sObj); + if(tempObj instanceof PolyObject polyObject) { + removeSoundObjectInstances(polyObject, sObj); } } Score score = data.getScore(); for(LayerGroup layerGroup : score) { - if(layerGroup instanceof PolyObject) { - PolyObject pObj = (PolyObject) layerGroup; + if(layerGroup instanceof PolyObject pObj) { removeSoundObjectInstances(pObj, sObj); } } @@ -64,13 +63,12 @@ protected static void removeSoundObjectInstances(PolyObject polyObject, SoundObj ArrayList instances = new ArrayList<>(); for (SoundObject tempObject : layer) { - if(tempObject instanceof Instance) { - Instance instance = (Instance)tempObject; + if(tempObject instanceof Instance instance) { if(instance.getSoundObject() == sObj) { instances.add(instance); } - } else if (tempObject instanceof PolyObject) { - removeSoundObjectInstances((PolyObject)tempObject, sObj); + } else if (tempObject instanceof PolyObject polyObject1) { + removeSoundObjectInstances(polyObject1, sObj); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MarqueeSelectionListener.java b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MarqueeSelectionListener.java index 474d1ee90..ea6cc1aab 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MarqueeSelectionListener.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MarqueeSelectionListener.java @@ -81,8 +81,8 @@ public void mouseReleased(MouseEvent e) { Component[] comps = scoreTC.getLayerPanel().getComponents(); for (Component c : comps) { - if (c instanceof LayerGroupPanel) { - ((LayerGroupPanel) c).marqueeSelectionPerformed( + if (c instanceof LayerGroupPanel layerGroupPanel) { + layerGroupPanel.marqueeSelectionPerformed( scoreTC.getMarquee()); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineMoveMouseListener.java b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineMoveMouseListener.java index 38e3f39b0..0c81967df 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineMoveMouseListener.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineMoveMouseListener.java @@ -102,8 +102,7 @@ public void mousePressed(MouseEvent e) { lineSourceCopyMap.clear(); for (var layer : selection.getSelectedLayers()) { - if (layer instanceof AutomatableLayer) { - var autoLayer = (AutomatableLayer) layer; + if (layer instanceof AutomatableLayer autoLayer) { var paramIds = autoLayer.getAutomationParameters(); var autoManager = AutomationManager.getInstance(); for (var paramId : paramIds) { diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineScaleMouseListener.java b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineScaleMouseListener.java index 0527008ac..80f318600 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineScaleMouseListener.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineScaleMouseListener.java @@ -118,8 +118,7 @@ public void mousePressed(MouseEvent e) { lineSourceCopyMap.clear(); for (var layer : selection.getSelectedLayers()) { - if (layer instanceof AutomatableLayer) { - var autoLayer = (AutomatableLayer) layer; + if (layer instanceof AutomatableLayer autoLayer) { var paramIds = autoLayer.getAutomationParameters(); var autoManager = AutomationManager.getInstance(); for (var paramId : paramIds) { diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineSelectionMouseProcessor.java b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineSelectionMouseProcessor.java index b080cd702..e7ee8a5e8 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineSelectionMouseProcessor.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/MultiLineSelectionMouseProcessor.java @@ -214,8 +214,8 @@ public void mouseReleased(MouseEvent e) { Component[] comps = scoreTC.getLayerPanel().getComponents(); for (Component c : comps) { - if (c instanceof LayerGroupPanel) { - ((LayerGroupPanel) c).marqueeSelectionPerformed( + if (c instanceof LayerGroupPanel layerGroupPanel) { + layerGroupPanel.marqueeSelectionPerformed( scoreTC.getMarquee()); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/ScoreObjectSelectionListener.java b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/ScoreObjectSelectionListener.java index 839656a36..ee8251ab4 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/mouse/ScoreObjectSelectionListener.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/mouse/ScoreObjectSelectionListener.java @@ -79,8 +79,7 @@ public void mousePressed(MouseEvent e) { protected void editScoreObject(Collection selectedScoreObjects, ScoreObject scoreObj) { - if (scoreObj instanceof PolyObject) { - PolyObject pObj = (PolyObject) scoreObj; + if (scoreObj instanceof PolyObject pObj) { ScoreController.getInstance().editLayerGroup(pObj); } else { if (selectedScoreObjects.size() == 1) { diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/noteProcessorChain/NoteProcessorChainTableModel.java b/blue-ui-core/src/main/java/blue/ui/core/score/noteProcessorChain/NoteProcessorChainTableModel.java index 4a9228c29..4cc2ea634 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/noteProcessorChain/NoteProcessorChainTableModel.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/noteProcessorChain/NoteProcessorChainTableModel.java @@ -218,9 +218,9 @@ public int getColumnCount() { public Object getValueAt(int row, int column) { Object obj = props.get(row); - if (obj instanceof NoteProcessorEditProxy) { + if (obj instanceof NoteProcessorEditProxy noteProcessorEditProxy) { if (column == 0) { - return ((NoteProcessorEditProxy) obj).getName(); + return noteProcessorEditProxy.getName(); } return ""; diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/noteProcessorChain/PropertyEditProxyRenderer.java b/blue-ui-core/src/main/java/blue/ui/core/score/noteProcessorChain/PropertyEditProxyRenderer.java index 426a56629..ac303325d 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/noteProcessorChain/PropertyEditProxyRenderer.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/noteProcessorChain/PropertyEditProxyRenderer.java @@ -37,8 +37,8 @@ public class PropertyEditProxyRenderer implements TableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - if(value instanceof Boolean) { - checkbox.setSelected((Boolean)value); + if(value instanceof Boolean aBoolean) { + checkbox.setSelected(aBoolean); return checkbox; } return defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/AlignActionsPresenter.java b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/AlignActionsPresenter.java index 855699104..bbf9175d2 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/AlignActionsPresenter.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/AlignActionsPresenter.java @@ -59,8 +59,8 @@ public JMenuItem getPopupPresenter() { for (Action action : actions) { Action temp = action; - if (action instanceof ContextAwareAction) { - temp = ((ContextAwareAction) action).createContextAwareInstance( + if (action instanceof ContextAwareAction contextAwareAction) { + temp = contextAwareAction.createContextAwareInstance( scoreTC.getLookup()); } menu.add(new JMenuItem(temp)); diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ConvertToObjectBuilderAction.java b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ConvertToObjectBuilderAction.java index 98fdd34c4..df8d57931 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ConvertToObjectBuilderAction.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ConvertToObjectBuilderAction.java @@ -87,8 +87,7 @@ public void actionPerformed(ActionEvent e) { ObjectBuilder objBuilder = new ObjectBuilder(); - if (temp instanceof PythonObject) { - PythonObject tempPython = (PythonObject) temp; + if (temp instanceof PythonObject tempPython) { objBuilder.setName(tempPython.getName()); objBuilder.setNoteProcessorChain(tempPython.getNoteProcessorChain()); objBuilder.setTimeBehavior(tempPython.getTimeBehavior()); @@ -97,8 +96,7 @@ public void actionPerformed(ActionEvent e) { objBuilder.setCode(tempPython.getText()); objBuilder.setBackgroundColor(tempPython.getBackgroundColor()); - } else if (temp instanceof External) { - External tempExt = (External) temp; + } else if (temp instanceof External tempExt) { objBuilder.setName(tempExt.getName()); objBuilder.setNoteProcessorChain(tempExt.getNoteProcessorChain()); objBuilder.setTimeBehavior(tempExt.getTimeBehavior()); diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ExportAction.java b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ExportAction.java index 83e09178b..c7b04e692 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ExportAction.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ExportAction.java @@ -131,8 +131,8 @@ protected boolean containsInstance(PolyObject pObj) { for (Iterator iter = soundObjects.iterator(); iter.hasNext();) { SoundObject sObj = iter.next(); - if (sObj instanceof PolyObject) { - if (containsInstance((PolyObject) sObj)) { + if (sObj instanceof PolyObject polyObject) { + if (containsInstance(polyObject)) { return true; } } else if (sObj instanceof Instance) { diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/FreezeUnfreezeAction.java b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/FreezeUnfreezeAction.java index bcc7812d7..ccd49c689 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/FreezeUnfreezeAction.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/FreezeUnfreezeAction.java @@ -143,9 +143,9 @@ public Void run(ProgressHandle handle) { SoundObject sObj = soundObjects.get(i); SoundLayer layer = (SoundLayer) layers.get(i); - if (sObj instanceof FrozenSoundObject) { + if (sObj instanceof FrozenSoundObject frozenSoundObject) { handle.progress("Unfreezing SoundObject...", i); - FrozenSoundObject frozenObj = (FrozenSoundObject) sObj; + FrozenSoundObject frozenObj = frozenSoundObject; layer.remove(sObj); @@ -341,9 +341,8 @@ private int freezeReferenceCount(Score score, String waveFileName) { for (LayerGroup lGroup : score) { - if (lGroup instanceof PolyObject) { + if (lGroup instanceof PolyObject pObj) { - PolyObject pObj = (PolyObject) lGroup; retVal += freezeReferenceCount(pObj, waveFileName); } } @@ -356,11 +355,10 @@ private int freezeReferenceCount(PolyObject pObj, String waveFileName) { List sObjects = pObj.getSoundObjects(true); for (SoundObject sObj : sObjects) { - if (sObj instanceof PolyObject) { - retVal += freezeReferenceCount((PolyObject)sObj, + if (sObj instanceof PolyObject polyObject) { + retVal += freezeReferenceCount(polyObject, waveFileName); - } else if (sObj instanceof FrozenSoundObject) { - FrozenSoundObject fso = (FrozenSoundObject) sObj; + } else if (sObj instanceof FrozenSoundObject fso) { if (fso.getFrozenWaveFileName().equals(waveFileName)) { retVal += 1; } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ReplaceWithBufferSoundObjectAction.java b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ReplaceWithBufferSoundObjectAction.java index a6ce85c04..225236d8c 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ReplaceWithBufferSoundObjectAction.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/object/actions/ReplaceWithBufferSoundObjectAction.java @@ -135,8 +135,8 @@ protected SoundObject getReplacementObject(ScoreObjectCopy buffer, if (buffer.scoreObjects.size() == 1) { SoundObject sObj = (SoundObject) buffer.scoreObjects.get(0).deepCopy(); - if (sObj instanceof Instance) { - instances.add((Instance) sObj); + if (sObj instanceof Instance instance) { + instances.add(instance); } return sObj; } @@ -169,8 +169,8 @@ protected SoundObject getReplacementObject(ScoreObjectCopy buffer, SoundObject clone = (SoundObject) scoreObj.deepCopy(); layer.add(clone); - if (clone instanceof Instance) { - instances.add((Instance) clone); + if (clone instanceof Instance instance) { + instances.add(instance); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/undo/DurationScoreObjectEdit.java b/blue-ui-core/src/main/java/blue/ui/core/score/undo/DurationScoreObjectEdit.java index 82d94a376..6032587a8 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/undo/DurationScoreObjectEdit.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/undo/DurationScoreObjectEdit.java @@ -57,9 +57,9 @@ public String getPresentationName() { @Override public boolean addEdit(UndoableEdit anEdit) { - if (anEdit instanceof DurationScoreObjectEdit) { + if (anEdit instanceof DurationScoreObjectEdit durationScoreObjectEdit) { if (nextEdit == null) { - nextEdit = (DurationScoreObjectEdit) anEdit; + nextEdit = durationScoreObjectEdit; return true; } else { return nextEdit.addEdit(anEdit); diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/undo/ReplaceScoreObjectEdit.java b/blue-ui-core/src/main/java/blue/ui/core/score/undo/ReplaceScoreObjectEdit.java index 6cf323005..6068bf82d 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/undo/ReplaceScoreObjectEdit.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/undo/ReplaceScoreObjectEdit.java @@ -63,9 +63,9 @@ public String getPresentationName() { @Override public boolean addEdit(UndoableEdit anEdit) { - if (anEdit instanceof ReplaceScoreObjectEdit) { + if (anEdit instanceof ReplaceScoreObjectEdit replaceScoreObjectEdit) { if (nextEdit == null) { - nextEdit = (ReplaceScoreObjectEdit) anEdit; + nextEdit = replaceScoreObjectEdit; return true; } else { return nextEdit.addEdit(anEdit); diff --git a/blue-ui-core/src/main/java/blue/ui/core/score/undo/SetColorEdit.java b/blue-ui-core/src/main/java/blue/ui/core/score/undo/SetColorEdit.java index ef4885114..3012d1939 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/score/undo/SetColorEdit.java +++ b/blue-ui-core/src/main/java/blue/ui/core/score/undo/SetColorEdit.java @@ -71,9 +71,9 @@ public String getPresentationName() { @Override public boolean addEdit(UndoableEdit anEdit) { - if (anEdit instanceof SetColorEdit) { + if (anEdit instanceof SetColorEdit setColorEdit) { if (nextEdit == null) { - nextEdit = (SetColorEdit) anEdit; + nextEdit = setColorEdit; return true; } else { return nextEdit.addEdit(anEdit); diff --git a/blue-ui-core/src/main/java/blue/ui/core/udo/OpcodeListEditPanel.java b/blue-ui-core/src/main/java/blue/ui/core/udo/OpcodeListEditPanel.java index 07e5388a1..f0a1ada04 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/udo/OpcodeListEditPanel.java +++ b/blue-ui-core/src/main/java/blue/ui/core/udo/OpcodeListEditPanel.java @@ -370,13 +370,12 @@ protected void pasteUDO() { } private void handlePaste(Object obj) { - if (obj instanceof UserDefinedOpcode) { + if (obj instanceof UserDefinedOpcode userDefinedOpcode) { - opcodeList.addOpcode(new UserDefinedOpcode((UserDefinedOpcode) obj)); + opcodeList.addOpcode(new UserDefinedOpcode(userDefinedOpcode)); - } else if (obj instanceof UserDefinedOpcode[]) { + } else if (obj instanceof UserDefinedOpcode[] udos) { - UserDefinedOpcode[] udos = (UserDefinedOpcode[]) obj; UserDefinedOpcode[] copies = new UserDefinedOpcode[udos.length]; @@ -385,8 +384,7 @@ private void handlePaste(Object obj) { } opcodeList.addOpcodes(copies); - } else if (obj instanceof UDOCategory) { - UDOCategory cat = (UDOCategory) obj; + } else if (obj instanceof UDOCategory cat) { ArrayList udos = cat.getAllUserDefinedOpcodes(); diff --git a/blue-ui-core/src/main/java/blue/ui/core/udo/UDOLibraryPanel.java b/blue-ui-core/src/main/java/blue/ui/core/udo/UDOLibraryPanel.java index 2aa86ee36..407b7a6ad 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/udo/UDOLibraryPanel.java +++ b/blue-ui-core/src/main/java/blue/ui/core/udo/UDOLibraryPanel.java @@ -292,8 +292,8 @@ public UserDefinedOpcode getSelectedUDO() { } Object obj = selectionPath.getLastPathComponent(); - if (obj instanceof UserDefinedOpcode) { - return (UserDefinedOpcode) obj; + if (obj instanceof UserDefinedOpcode userDefinedOpcode) { + return userDefinedOpcode; } return null; } @@ -412,8 +412,8 @@ protected void copyNode() { } Object bufObj; - if (userObj instanceof UserDefinedOpcode) { - bufObj = new UserDefinedOpcode((UserDefinedOpcode) userObj); + if (userObj instanceof UserDefinedOpcode userDefinedOpcode) { + bufObj = new UserDefinedOpcode(userDefinedOpcode); } else { bufObj = new UDOCategory((UDOCategory) userObj); } @@ -428,10 +428,10 @@ protected void pasteNode() { return; } - if (bufferedObj instanceof UserDefinedOpcode) { - addUDO((UserDefinedOpcode) bufferedObj); - } else if(bufferedObj instanceof UserDefinedOpcode[]) { - for(UserDefinedOpcode udo : (UserDefinedOpcode[])bufferedObj) { + if (bufferedObj instanceof UserDefinedOpcode userDefinedOpcode) { + addUDO(userDefinedOpcode); + } else if(bufferedObj instanceof UserDefinedOpcode[] userDefinedOpcodes) { + for(UserDefinedOpcode udo : userDefinedOpcodes) { addUDO(udo); } } else { @@ -495,10 +495,10 @@ public void show(UDOLibraryPanel instrGui, Object userObj, int x, int y) { this.instrGUI = instrGui; this.userObj = userObj; - if (userObj instanceof UDOCategory) { + if (userObj instanceof UDOCategory uDOCategory) { addCategoryMenuItem.setVisible(true); - removeCategoryMenuItem.setVisible(!((UDOCategory) userObj).isRoot()); + removeCategoryMenuItem.setVisible(!uDOCategory.isRoot()); addInstrumentMenu.setVisible(true); removeInstrumentMenuItem.setVisible(false); diff --git a/blue-ui-core/src/main/java/blue/ui/core/udo/UDOTreeDragSource.java b/blue-ui-core/src/main/java/blue/ui/core/udo/UDOTreeDragSource.java index bca4763d1..b6ad9582c 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/udo/UDOTreeDragSource.java +++ b/blue-ui-core/src/main/java/blue/ui/core/udo/UDOTreeDragSource.java @@ -72,8 +72,8 @@ public void dragGestureRecognized(DragGestureEvent dge) { oldNode = path.getLastPathComponent(); Object cloneNode; - if(oldNode instanceof UserDefinedOpcode) { - cloneNode = new UserDefinedOpcode((UserDefinedOpcode) oldNode); + if(oldNode instanceof UserDefinedOpcode userDefinedOpcode) { + cloneNode = new UserDefinedOpcode(userDefinedOpcode); } else { cloneNode = new UDOCategory((UDOCategory) oldNode); } @@ -92,15 +92,15 @@ public void dragDropEnd(DragSourceDropEvent dsde) { if (dsde.getDropAction() == DnDConstants.ACTION_MOVE) { - if (oldNode instanceof UserDefinedOpcode) { + if (oldNode instanceof UserDefinedOpcode userDefinedOpcode) { ((UDOLibrary) sourceTree.getModel()) - .removeUDO((UserDefinedOpcode) oldNode); + .removeUDO(userDefinedOpcode); - } else if (oldNode instanceof UDOCategory) { + } else if (oldNode instanceof UDOCategory uDOCategory) { ((UDOLibrary) sourceTree.getModel()) - .removeCategory((UDOCategory) oldNode); + .removeCategory(uDOCategory); } } diff --git a/blue-ui-core/src/main/java/blue/ui/core/udo/UDOTreeDropTarget.java b/blue-ui-core/src/main/java/blue/ui/core/udo/UDOTreeDropTarget.java index 9c292bad3..37fa7e06c 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/udo/UDOTreeDropTarget.java +++ b/blue-ui-core/src/main/java/blue/ui/core/udo/UDOTreeDropTarget.java @@ -130,8 +130,7 @@ public void drop(DropTargetDropEvent dtde) { UDOLibrary udoLibrary = (UDOLibrary) tree.getModel(); // iLibrary.removeInstrument(instrument); - if (node instanceof UDOCategory) { - UDOCategory parentNode = (UDOCategory) node; + if (node instanceof UDOCategory parentNode) { udoLibrary.addUDO(parentNode, udo); } else if (node instanceof UserDefinedOpcode) { diff --git a/blue-ui-core/src/main/java/blue/ui/core/udo/UserDefinedOpcodeTopComponent.java b/blue-ui-core/src/main/java/blue/ui/core/udo/UserDefinedOpcodeTopComponent.java index ed609431d..bbcd00d5b 100644 --- a/blue-ui-core/src/main/java/blue/ui/core/udo/UserDefinedOpcodeTopComponent.java +++ b/blue-ui-core/src/main/java/blue/ui/core/udo/UserDefinedOpcodeTopComponent.java @@ -68,8 +68,8 @@ private UserDefinedOpcodeTopComponent() { isChanging = true; - if (obj instanceof UserDefinedOpcode) { - uDOEditor1.editUserDefinedOpcode((UserDefinedOpcode) obj); + if (obj instanceof UserDefinedOpcode userDefinedOpcode) { + uDOEditor1.editUserDefinedOpcode(userDefinedOpcode); uDOEditor1.setBorder(libraryBorder); } else { uDOEditor1.editUserDefinedOpcode(null);