Skip to content

Commit

Permalink
Include and display the new OSM2World logo
Browse files Browse the repository at this point in the history
  • Loading branch information
tordanik committed Feb 8, 2025
1 parent 0762c27 commit b5e0b73
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.io.InputStream;
import java.io.Serial;

import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.HyperlinkEvent;
import javax.xml.parsers.DocumentBuilderFactory;

Expand All @@ -17,6 +21,7 @@

public class AboutAction extends AbstractAction {

@Serial
private static final long serialVersionUID = -6717063896933933005L; //generated serialVersionUID

public AboutAction() {
Expand All @@ -36,15 +41,17 @@ public void actionPerformed(ActionEvent arg0) {

dialog.setLayout(new BorderLayout());
dialog.add(tabbedPane, BorderLayout.CENTER);

dialog.setSize(800, 600);
dialog.setSize(1000, 600);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);

}

private static JComponent createAboutTabContent() {

var panel = new JPanel();
panel.setLayout(new BorderLayout());

String text = "<html><body style='padding: 10px;'>"
+ "<h1>OSM2World</h1>"
+ "<p>Version " + VERSION_STRING + "</p>"
Expand All @@ -55,7 +62,22 @@ private static JComponent createAboutTabContent() {
+ "<tr><td>Issues<td><a href='https://github.com/tordanik/OSM2World/issues'>github.com/tordanik/OSM2World/issues</a><br>"
+ "</table></p></body></html>";

return createReadonlyHtmlComponent(text);
JComponent textComponent = createReadonlyHtmlComponent(text, false);
panel.add(textComponent, BorderLayout.CENTER);

try (InputStream logoStream = Thread.currentThread().getContextClassLoader().getResourceAsStream("logo.png")) {
if (logoStream == null) throw new IOException("logo is null");
var logoImage = ImageIO.read(logoStream).getScaledInstance(200, 200, Image.SCALE_DEFAULT);
var logoLabel = new JLabel(new ImageIcon(logoImage));
logoLabel.setBackground(Color.WHITE);
logoLabel.setOpaque(true);
logoLabel.setBorder(new EmptyBorder(0, 10, 0, 10));
panel.add(logoLabel, BorderLayout.WEST);
} catch (IOException e) {
System.err.println("Error loading logo image:" + e.getMessage());
}

return panel;

}

Expand Down Expand Up @@ -120,19 +142,21 @@ private static JComponent createLicenseTabContent() {
attributionText = "Could not read license information: <br/>" + e.getMessage();
}

return createReadonlyHtmlComponent(attributionText);
return createReadonlyHtmlComponent(attributionText, true);

}

/** returns a component showing scrollable, read-only HTML text with clickable links */
private static JComponent createReadonlyHtmlComponent(String text) {
/** returns a component showing read-only HTML text with clickable links */
private static JComponent createReadonlyHtmlComponent(String text, boolean scrollable) {

var tabText = new JEditorPane();
tabText.setContentType("text/html");
tabText.setText(text);
tabText.setCaretPosition(0);
tabText.setEditable(false);
tabText.setOpaque(false);
tabText.setOpaque(true);
tabText.setBackground(Color.WHITE);
tabText.setBorder(BorderFactory.createEmptyBorder());
tabText.addHyperlinkListener(e -> {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
try {
Expand All @@ -141,7 +165,11 @@ private static JComponent createReadonlyHtmlComponent(String text) {
}
});

return new JScrollPane(tabText);
if (scrollable) {
return new JScrollPane(tabText);
} else {
return tabText;
}

}

Expand Down
11 changes: 10 additions & 1 deletion desktop/src/main/java/org/osm2world/viewer/view/ViewerFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import java.awt.*;
import java.io.File;
import java.io.Serial;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -28,6 +30,7 @@

public class ViewerFrame extends JFrame {

@Serial
private static final long serialVersionUID = 5807635150399807163L;

/**
Expand All @@ -52,7 +55,13 @@ public class ViewerFrame extends JFrame {
public ViewerFrame(final O2WConfig config, @Nullable LevelOfDetail lod,
final List<File> configFiles, File inputFile) {

super("OSM2World Viewer");
super("OSM2World");

URL iconURL = Thread.currentThread().getContextClassLoader().getResource("logo.png");
if (iconURL != null) {
ImageIcon icon = new ImageIcon(iconURL);
this.setIconImage(icon.getImage());
}

data = new Data(configFiles, config);

Expand Down
Binary file added desktop/src/main/resources/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b5e0b73

Please sign in to comment.