diff --git a/.travis.yml b/.travis.yml index 0eadda7688..909b77aa12 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,7 @@ language: java # Configure the build to use Oracle JDK 9 jdk: - - openjdk11 + - openjdk21 # Install the Ant JUnit package, which is missing from the Travis CI environment. See the Travis documentation: https://docs.travis-ci.com/user/installing-dependencies/#Adding-APT-Packages addons: diff --git a/nbproject/project.properties b/nbproject/project.properties index fab181db51..de8a7bdfc9 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -56,8 +56,8 @@ javac.modulepath= javac.processormodulepath= javac.processorpath=\ ${javac.classpath} -javac.source=11 -javac.target=11 +javac.source=21 +javac.target=21 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} diff --git a/release-build.properties b/release-build.properties index cde1c0e4de..689b787445 100644 --- a/release-build.properties +++ b/release-build.properties @@ -38,7 +38,7 @@ worldwind.classes.dir=${worldwind.build.dir}/classes worldwind.doc.dir=${worldwind.build.dir}/doc worldwind.jar.dir=${worldwind.build.dir}/jar worldwind.test.results.dir=${worldwind.build.dir}/test-results -worldwind.jdk=11 +worldwind.jdk=21 #worldwind.exclude.jackson=true # MIL-STD-2525 package build properties diff --git a/release-build.xml b/release-build.xml index 9810ad732d..7948d88789 100644 --- a/release-build.xml +++ b/release-build.xml @@ -126,7 +126,7 @@ - + diff --git a/src/gov/nasa/worldwind/layers/mercator/BasicMercatorTiledImageLayer.java b/src/gov/nasa/worldwind/layers/mercator/BasicMercatorTiledImageLayer.java index 9778b9cef4..51fb26113d 100644 --- a/src/gov/nasa/worldwind/layers/mercator/BasicMercatorTiledImageLayer.java +++ b/src/gov/nasa/worldwind/layers/mercator/BasicMercatorTiledImageLayer.java @@ -332,9 +332,8 @@ public ByteBuffer run(Retriever retriever) URLRetriever r = (URLRetriever) retriever; ByteBuffer buffer = r.getBuffer(); - if (retriever instanceof HTTPRetriever) + if (retriever instanceof HTTPRetriever htr) { - HTTPRetriever htr = (HTTPRetriever) retriever; if (htr.getResponseCode() == HttpURLConnection.HTTP_NO_CONTENT) { // Mark tile as missing to avoid excessive attempts diff --git a/src/gov/nasa/worldwind/layers/rpf/RPFTiledImageLayer.java b/src/gov/nasa/worldwind/layers/rpf/RPFTiledImageLayer.java index 9d391b408f..b7255d77e5 100644 --- a/src/gov/nasa/worldwind/layers/rpf/RPFTiledImageLayer.java +++ b/src/gov/nasa/worldwind/layers/rpf/RPFTiledImageLayer.java @@ -362,9 +362,8 @@ private static String makeTitle(AVList params) StringBuilder sb = new StringBuilder(); Object o = params.getValue(RPFGenerator.RPF_FILE_INDEX); - if (o != null && o instanceof RPFFileIndex) + if (o instanceof RPFFileIndex fileIndex) { - RPFFileIndex fileIndex = (RPFFileIndex) o; if (fileIndex.getIndexProperties() != null) { if (fileIndex.getIndexProperties().getDescription() != null) @@ -401,19 +400,19 @@ private RestorableSupport makeRestorableState(AVList params) for (Map.Entry p : params.getEntries()) { - if (p.getValue() instanceof LatLon) + if (p.getValue() instanceof LatLon latLon) { - rs.addStateValueAsDouble(p.getKey() + ".Latitude", ((LatLon) p.getValue()).getLatitude().degrees); - rs.addStateValueAsDouble(p.getKey() + ".Longitude", ((LatLon) p.getValue()).getLongitude().degrees); + rs.addStateValueAsDouble(p.getKey() + ".Latitude", latLon.getLatitude().degrees); + rs.addStateValueAsDouble(p.getKey() + ".Longitude", latLon.getLongitude().degrees); } - else if (p.getValue() instanceof Sector) + else if (p.getValue() instanceof Sector sector) { - rs.addStateValueAsDouble(p.getKey() + ".MinLatitude", ((Sector) p.getValue()).getMinLatitude().degrees); - rs.addStateValueAsDouble(p.getKey() + ".MaxLatitude", ((Sector) p.getValue()).getMaxLatitude().degrees); + rs.addStateValueAsDouble(p.getKey() + ".MinLatitude", sector.getMinLatitude().degrees); + rs.addStateValueAsDouble(p.getKey() + ".MaxLatitude", sector.getMaxLatitude().degrees); rs.addStateValueAsDouble(p.getKey() + ".MinLongitude", - ((Sector) p.getValue()).getMinLongitude().degrees); + sector.getMinLongitude().degrees); rs.addStateValueAsDouble(p.getKey() + ".MaxLongitude", - ((Sector) p.getValue()).getMaxLongitude().degrees); + sector.getMaxLongitude().degrees); } else if (p.getValue() instanceof URLBuilder) { @@ -793,8 +792,8 @@ protected ByteBuffer handleSuccessfulRetrieval() @Override protected boolean validateResponseCode() { - if (this.getRetriever() instanceof RPFRetriever) - return ((RPFRetriever) this.getRetriever()).getResponseCode() == RPFRetriever.RESPONSE_CODE_OK; + if (this.getRetriever() instanceof RPFRetriever rpfRetriever) + return rpfRetriever.getResponseCode() == RPFRetriever.RESPONSE_CODE_OK; else return super.validateResponseCode(); } diff --git a/src/gov/nasa/worldwind/layers/rpf/wizard/DataChooserPanel.java b/src/gov/nasa/worldwind/layers/rpf/wizard/DataChooserPanel.java index d9f2dc461e..bc180207b2 100644 --- a/src/gov/nasa/worldwind/layers/rpf/wizard/DataChooserPanel.java +++ b/src/gov/nasa/worldwind/layers/rpf/wizard/DataChooserPanel.java @@ -166,11 +166,11 @@ private void fileSetClicked(ItemEvent e) if (e != null) { FileSet set = null; - if (e.getItem() != null && e.getItem() instanceof JComponent) + if (e.getItem() instanceof JComponent component) { - Object property = ((JComponent) e.getItem()).getClientProperty("fileSet"); - if (property != null && property instanceof FileSet) - set = (FileSet) property; + Object property = component.getClientProperty("fileSet"); + if (property instanceof FileSet fileSet) + set = fileSet; } if (set != null) @@ -207,9 +207,8 @@ private void deselectAllPressed() private void fileSetSelectionChanged(Object source) { // Make sure the CheckBox selection reflects the FileSet selection state. - if (source != null && source instanceof FileSet) + if (source instanceof FileSet set) { - FileSet set = (FileSet) source; JToggleButton button = this.selectButtons.get(set); if (button != null) button.setSelected(set.isSelected()); @@ -279,18 +278,10 @@ private void makeComponents() Dimension size = new Dimension(35, 20); this.selectAllButton.setFont(font); this.selectAllButton.setPreferredSize(size); - this.selectAllButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - selectAllPressed(); - } - }); + this.selectAllButton.addActionListener(e -> selectAllPressed()); this.deselectAllButton.setFont(font); this.deselectAllButton.setPreferredSize(size); - this.deselectAllButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - deselectAllPressed(); - } - }); + this.deselectAllButton.addActionListener(e -> deselectAllPressed()); this.dataScrollPane = new JScrollPane(); this.dataScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); size = this.dataScrollPane.getPreferredSize(); diff --git a/src/gov/nasa/worldwind/layers/rpf/wizard/FileChooserPanel.java b/src/gov/nasa/worldwind/layers/rpf/wizard/FileChooserPanel.java index 9c4d0dc619..6a588697a4 100644 --- a/src/gov/nasa/worldwind/layers/rpf/wizard/FileChooserPanel.java +++ b/src/gov/nasa/worldwind/layers/rpf/wizard/FileChooserPanel.java @@ -102,8 +102,8 @@ private File getValueAsFile(Object value) { if (value != null) { - if (value instanceof File) - return (File) value; + if (value instanceof File file) + return file; else return new File(value.toString()); } @@ -145,19 +145,15 @@ private void makeComponents() Dimension preferred = this.fileField.getPreferredSize(); Dimension max = this.fileField.getMaximumSize(); this.fileField.setMaximumSize(new Dimension(max.width, preferred.height)); - this.fileField.addPropertyChangeListener("value", new PropertyChangeListener() { - public void propertyChange(PropertyChangeEvent event) { - if (event != null) { - onFileFieldChanged(event.getNewValue()); - } + this.fileField.addPropertyChangeListener("value", event -> + { + if (event != null) + { + onFileFieldChanged(event.getNewValue()); } }); this.chooseButton = new JButton("Choose..."); - this.chooseButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - onChooseClicked(); - } - }); + this.chooseButton.addActionListener(e -> onChooseClicked()); this.fileChooser = new JFileChooser(); this.fileChooser.setDialogTitle("Choose Folder to Search"); this.fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); diff --git a/src/gov/nasa/worldwind/layers/rpf/wizard/FileChooserPanelDescriptor.java b/src/gov/nasa/worldwind/layers/rpf/wizard/FileChooserPanelDescriptor.java index cceadabb8e..7be7d1fcc3 100644 --- a/src/gov/nasa/worldwind/layers/rpf/wizard/FileChooserPanelDescriptor.java +++ b/src/gov/nasa/worldwind/layers/rpf/wizard/FileChooserPanelDescriptor.java @@ -88,7 +88,7 @@ private void setNextButtonAccordingToSelectedFile() private void selectedFileChanged(Object newValue) { WizardModel model = getWizardModel(); - if (model != null && newValue != null && newValue instanceof File) + if (model != null && newValue instanceof File) { RPFWizardUtil.setSelectedFile(model, (File) newValue); } diff --git a/src/gov/nasa/worldwind/layers/rpf/wizard/FileSearchPanelDescriptor.java b/src/gov/nasa/worldwind/layers/rpf/wizard/FileSearchPanelDescriptor.java index 831bba5a55..a7f04b0898 100644 --- a/src/gov/nasa/worldwind/layers/rpf/wizard/FileSearchPanelDescriptor.java +++ b/src/gov/nasa/worldwind/layers/rpf/wizard/FileSearchPanelDescriptor.java @@ -112,16 +112,15 @@ public void displayingPanel() if (model != null && !RPFWizardUtil.isFileListCurrent(model)) { this.panelComponent.getProgressBar().setIndeterminate(true); - startWorkerThread(new Runnable() { - public void run() { - refreshFileList(); + startWorkerThread(() -> + { + refreshFileList(); - WizardModel model = getWizardModel(); - if (model != null) - RPFWizardUtil.setFileListCurrent(model, true); + WizardModel currentModel = getWizardModel(); + if (currentModel != null) + RPFWizardUtil.setFileListCurrent(currentModel, true); - moveToNextPanel(); - } + moveToNextPanel(); }); } } diff --git a/src/gov/nasa/worldwind/layers/rpf/wizard/FileSet.java b/src/gov/nasa/worldwind/layers/rpf/wizard/FileSet.java index a87b80da35..427464601b 100644 --- a/src/gov/nasa/worldwind/layers/rpf/wizard/FileSet.java +++ b/src/gov/nasa/worldwind/layers/rpf/wizard/FileSet.java @@ -61,7 +61,7 @@ public void setIdentifier(String identifier) public Collection getFiles() { Object value = getProperty(FILES); - return (value != null && value instanceof Collection) ? (Collection) value : null; + return value instanceof Collection ? (Collection) value : null; } public void setFiles(Collection files) diff --git a/src/gov/nasa/worldwind/layers/rpf/wizard/RPFWizardUtil.java b/src/gov/nasa/worldwind/layers/rpf/wizard/RPFWizardUtil.java index ad973859e6..3b5eed6d35 100644 --- a/src/gov/nasa/worldwind/layers/rpf/wizard/RPFWizardUtil.java +++ b/src/gov/nasa/worldwind/layers/rpf/wizard/RPFWizardUtil.java @@ -57,8 +57,8 @@ public static File getSelectedFile(WizardProperties properties) File file = null; Object value = properties.getProperty(SELECTED_FILE); - if (value != null && value instanceof File) - file = (File) value; + if (value instanceof File selectedFile) + file = selectedFile; return file; } @@ -86,7 +86,7 @@ public static List getFileList(WizardProperties properties) List fileList = null; Object value = properties.getProperty(FILE_LIST); - if (value != null && value instanceof List) + if (value instanceof List) fileList = (List) value; return fileList; } @@ -143,7 +143,7 @@ public static List getFileSetList(WizardProperties properties) List fileSets = null; Object value = properties.getProperty(FILE_SET_LIST); - if (value != null && value instanceof List) + if (value instanceof List) fileSets = (List) value; return fileSets; } @@ -172,7 +172,7 @@ public static List getLayerList(WizardProperties properties) List fileSets = null; Object value = properties.getProperty(LAYER_LIST); - if (value != null && value instanceof List) + if (value instanceof List) fileSets = (List) value; return fileSets; }