Skip to content

Commit

Permalink
Fix #23894: AIOOBE in SelectLayerView.getLayerNames
Browse files Browse the repository at this point in the history
Also add a pom.xml for integration with JOSM plugins in SVN

Signed-off-by: Taylor Smock <[email protected]>
  • Loading branch information
tsmock committed Sep 4, 2024
1 parent c84d622 commit 311515d
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 9 deletions.
44 changes: 44 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.openstreetmap.josm.plugins</groupId>
<artifactId>plugin-root</artifactId>
<version>SNAPSHOT</version>
</parent>
<artifactId>PicLayer</artifactId>

<url>${plugin.link}</url>
<developers>
<developer>
<name>Tomasz Stelmach</name>
</developer>
</developers>
<properties>
<plugin.src.dir>src</plugin.src.dir>
<plugin.main.version>18494</plugin.main.version>
<plugin.author>Tomasz Stelmach</plugin.author>
<plugin.class>org.openstreetmap.josm.plugins.piclayer.PicLayerPlugin</plugin.class>
<plugin.description>This plugin allows to display any picture as a background in the editor and align it with the map.</plugin.description>
<plugin.icon>images/layericon.png</plugin.icon>
<plugin.link>https://josm.openstreetmap.de/wiki/Help/Plugin/PicLayer</plugin.link>
<plugin.canloadatruntime>true</plugin.canloadatruntime>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Plugin-Link>${plugin.link}</Plugin-Link>
<Plugin-Icon>${plugin.icon}</Plugin-Icon>
<Plugin-Canloadatruntime>${plugin.canloadatruntime}</Plugin-Canloadatruntime>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JFrame;
Expand All @@ -22,7 +23,6 @@

public class SelectLayerView {

private final String[] labels;
private final JList<Object> list;
private final JFrame frame;
private JScrollPane scrollPane;
Expand All @@ -32,9 +32,7 @@ public class SelectLayerView {


public SelectLayerView() {
labels = new String[10];
getLayerNames();
list = new JList<>(labels);
list = new JList<>(getLayerNames());

frame = new JFrame("Layer Selector");
frame.setSize(400, 200);
Expand All @@ -51,11 +49,9 @@ public SelectLayerView() {
contentPane.add(buttonBar, BorderLayout.SOUTH);
}

private void getLayerNames() {
java.util.List<Layer> layer = MainApplication.getLayerManager().getLayers();
for (int i = 0; i < layer.size(); i++) {
labels[i] = layer.get(i).getName();
}
private static String[] getLayerNames() {
return MainApplication.getLayerManager().getLayers().stream()
.map(Layer::getName).toArray(String[]::new);
}

public void setVisible(boolean value) {
Expand Down

0 comments on commit 311515d

Please sign in to comment.