diff --git a/core/LICENSE.TXT b/LICENSE.TXT similarity index 99% rename from core/LICENSE.TXT rename to LICENSE.TXT index a06056587..05af4172b 100644 --- a/core/LICENSE.TXT +++ b/LICENSE.TXT @@ -1,6 +1,6 @@ OpenRocket - A model rocket simulator -Copyright (C) 2007-2020 Sampo Niskanen and others +Copyright (C) 2007-2022 Sampo Niskanen and others This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/core/ReleaseNotes.md b/ReleaseNotes.md similarity index 100% rename from core/ReleaseNotes.md rename to ReleaseNotes.md diff --git a/core/build.xml b/core/build.xml index 27a1b4ecc..cab35e15b 100644 --- a/core/build.xml +++ b/core/build.xml @@ -69,7 +69,7 @@ - + diff --git a/core/resources/build.properties b/core/resources/build.properties index 98a12aa25..46fea8eae 100644 --- a/core/resources/build.properties +++ b/core/resources/build.properties @@ -4,7 +4,7 @@ build.version=20.11.alpha.16 # The copyright year for the build. Displayed in the about dialog. # Will show as Copyright 2013-${build.copyright} -build.copyright=2021 +build.copyright=2022 # The source of the package. When building a package for a specific # distribution (Debian, Fedora etc.), this should be changed appropriately! diff --git a/core/fileformat.txt b/fileformat.txt similarity index 100% rename from core/fileformat.txt rename to fileformat.txt diff --git a/swing/build.xml b/swing/build.xml index c6a0678b1..18fd76bc3 100644 --- a/swing/build.xml +++ b/swing/build.xml @@ -200,6 +200,10 @@ the .jar file + + diff --git a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java index 2c68b129c..9c373e261 100644 --- a/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java +++ b/swing/src/net/sf/openrocket/gui/components/DescriptionArea.java @@ -1,16 +1,30 @@ package net.sf.openrocket.gui.components; import java.awt.Color; +import java.awt.Desktop; import java.awt.Dimension; import java.awt.Font; import java.awt.Rectangle; +import java.net.URI; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import javax.swing.event.HyperlinkEvent; +import javax.swing.event.HyperlinkListener; import javax.swing.JEditorPane; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ScrollPaneConstants; import javax.swing.SwingUtilities; +import net.sf.openrocket.util.BugException; + @SuppressWarnings("serial") public class DescriptionArea extends JScrollPane { @@ -65,7 +79,71 @@ public class DescriptionArea extends JScrollPane { Font font = editorPane.getFont(); editorPane.setFont(font.deriveFont(font.getSize2D() + size)); editorPane.setEditable(false); - + editorPane.addHyperlinkListener(new HyperlinkListener() { + public void hyperlinkUpdate(HyperlinkEvent e) { + if(e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { + URI uri = null; + try { + uri = e.getURL().toURI(); + } + catch (Exception ex) { + throw new RuntimeException(ex); + } + + // If the uri scheme indicates this is a resource in a jar file, + // extract and write to a temporary file + if (uri.getScheme().equals("jar")) { + + // get the resource + final String uriString = uri.toString(); + final String resourceName = uriString.substring(uriString.indexOf("!") + 1); + final BufferedInputStream is = new BufferedInputStream(getClass().getResourceAsStream(resourceName)); + + // construct filename from resource name + String prefix = resourceName.substring(1); + String suffix; + final int dotIndex = prefix.lastIndexOf("."); + if (dotIndex > 0) { + prefix = resourceName.substring(0, dotIndex); + suffix = resourceName.substring(dotIndex+1); + } else { + // if there is no suffix, assume it's a raw text file. + suffix = ".txt"; + } + + + // create temporary file and copy resource to it + File of = null; + BufferedOutputStream os = null; + try { + of = File.createTempFile(prefix, suffix); + os = new BufferedOutputStream(new FileOutputStream(of)); + } + catch (Exception ex) { + throw new RuntimeException(ex); + } + of.deleteOnExit(); + uri = of.toURI(); + + try { + byte buffer[] = is.readAllBytes(); + os.write(buffer); + os.close(); + } + catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + try { + Desktop.getDesktop().browse(uri); + } + catch (Exception ex) { + throw new RuntimeException(ex); + } + } + } + }); if (!opaque) { Color bg = new JPanel().getBackground(); editorPane.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue())); @@ -84,7 +162,6 @@ public class DescriptionArea extends JScrollPane { Dimension dim = editorPane.getPreferredSize(); dim.height = lineheight * rows + extraheight + 2; - this.setPreferredSize(dim); this.setViewportView(editorPane); this.setText(text); diff --git a/swing/src/net/sf/openrocket/gui/dialogs/AboutDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/AboutDialog.java index e62419684..eec03049b 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/AboutDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/AboutDialog.java @@ -25,42 +25,58 @@ import net.sf.openrocket.gui.widgets.SelectColorButton; @SuppressWarnings("serial") public class AboutDialog extends JDialog { - public static final String OPENROCKET_URL = "http://openrocket.info/"; - private static final Translator trans = Application.getTranslator(); + public final String OPENROCKET_URL = "http://openrocket.info/"; + + private final Translator trans = Application.getTranslator(); - private static final String CREDITS = "
" + - "OpenRocket has been developed by:

" + - "Sampo Niskanen (main developer)
" + - "Doug Pedrick (RockSim file format, printing)
" + - "Kevin Ruland (Android version)
" + - "Bill Kuker (3D visualization)
" + - "Boris du Reau (internationalization, translation lead)
" + - "Richard Graham (geodetic computations)
" + - "Jason Blood (finset import)
" + - "Daniel Williams (pod support, maintainer)
" + - "Joe Pfeiffer (maintainer)
" + - "Billy Olsen (maintainer)
" + - "Neil Weinstock (tester, icons, forum support)
" + - "H. Craig Miller (tester)

" + - "Translations by:

" + - "Tripoli France (French)
" + - "Stefan Lobas / ERIG e.V. (German)
" + - "Tripoli Spain (Spanish)
" + - "Sky Dart Team (Russian)
" + - "Mauro Biasutti (Italian)
" + - "Vladimir Beran (Czech)
" + - "Polish Rocketry Society / \u0141ukasz & Alex Kazanski (Polish)
" + - "Sibo Van Gool (Dutch)

" + - "See all contributors at
https://github.com/openrocket/openrocket/graphs/contributors

" + - "OpenRocket utilizes the following libraries:

" + - "MiG Layout (http://www.miglayout.com/)
" + - "JFreeChart (http://www.jfree.org/jfreechart/)
" + - "iText (http://www.itextpdf.com/)
" + - "exp4j (http://projects.congrace.de/exp4j/index.html)
" + - "JOGL (http://jogamp.org/jogl/www/)
" + - "Guava (https://github.com/google/guava)
" + - "Opencsv (http://opencsv.sourceforge.net/)
" + - "Simple Logging Facade for Java (http://www.slf4j.org/)"; + private final String CREDITS = "
" + + "OpenRocket has been developed by:
" + + "
" + + "Sampo Niskanen (main developer)
" + + "Doug Pedrick (RockSim file format, printing)
" + + "Kevin Ruland (Android version)
" + + "Bill Kuker (3D visualization)
" + + "Boris du Reau (internationalization, translation lead)
" + + "Richard Graham (geodetic computations)
" + + "Jason Blood (finset import)
" + + "Daniel Williams (pod support, maintainer)
" + + "Joe Pfeiffer (maintainer)
" + + "Billy Olsen (maintainer)
" + + "Neil Weinstock (tester, icons, forum support)
" + + "H. Craig Miller (tester)

" + + "Translations by:

" + + "Tripoli France (French)
" + + "Stefan Lobas / ERIG e.V. (German)
" + + "Tripoli Spain (Spanish)
" + + "Sky Dart Team (Russian)
" + + "Mauro Biasutti (Italian)
" + + "Vladimir Beran (Czech)
" + + "Polish Rocketry Society / \u0141ukasz & Alex Kazanski (Polish)
" + + "Sibo Van Gool (Dutch)
" + + "
" + + "See all contributors at
" + + href("https://github.com/openrocket/openrocket/graphs/contributors") + "
" + + "
" + + "OpenRocket utilizes the following libraries:
" + + "
" + + "MiG Layout (" + href("http://www.miglayout.com/") + ")
" + + "JFreeChart (" + href("http://www.jfree.org/jfreechart/") + ")
" + + "iText (" + href("http://www.itextpdf.com/") + ")
" + + "exp4j (" + href("http://projects.congrace.de/exp4j/index.html") + ")
" + + "JOGL (" + href("http://jogamp.org/jogl/www/") + ")
" + + "Guava (" + href("https://github.com/google/guava") + ")
" + + "Opencsv (" + href("http://opencsv.sourceforge.net/") + ")
" + + "Simple Logging Facade for Java (" + href("http://www.slf4j.org/") + ")
" + + "Java library for parsing and rendering CommonMark (" + href("https://github.com/commonmark/commonmark-java") + ")
" + + "
" + + "OpenRocket gratefully acknowledges our use of the following databases:
" + + "
" + + "Rocket Motor Data (" + href("https://www.thrustcurve.org/") + ")
" + + "Enhanced components database for OpenRocket" + href("https://github.com/dbcook/openrocket-database/") + ")
"; + + private String href(String url) { + return "" + url + ""; + } public AboutDialog(JFrame parent) { super(parent, true); diff --git a/swing/src/net/sf/openrocket/gui/dialogs/LicenseDialog.java b/swing/src/net/sf/openrocket/gui/dialogs/LicenseDialog.java index 7ac41ce05..edfde1bda 100644 --- a/swing/src/net/sf/openrocket/gui/dialogs/LicenseDialog.java +++ b/swing/src/net/sf/openrocket/gui/dialogs/LicenseDialog.java @@ -3,66 +3,151 @@ package net.sf.openrocket.gui.dialogs; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.net.URL; import java.io.BufferedReader; +import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; +import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import net.miginfocom.swing.MigLayout; +import net.sf.openrocket.gui.components.DescriptionArea; import net.sf.openrocket.gui.components.StyledLabel; import net.sf.openrocket.gui.util.GUIUtil; import net.sf.openrocket.l10n.Translator; import net.sf.openrocket.startup.Application; +import net.sf.openrocket.gui.util.Icons; import net.sf.openrocket.gui.widgets.SelectColorButton; +import net.sf.openrocket.util.BuildProperties; +import net.sf.openrocket.util.Chars; public class LicenseDialog extends JDialog { - private static final String LICENSE_FILENAME = "LICENSE.TXT"; private static final Translator trans = Application.getTranslator(); - private static final String DEFAULT_LICENSE_TEXT = - "\n" + - "Error: Unable to load " + LICENSE_FILENAME + "!\n" + - "\n" + - "OpenRocket is licensed under the GNU GPL version 3, with additional permissions.\n" + - "See http://openrocket.sourceforge.net/ for details."; - public LicenseDialog(JFrame parent) { super(parent, true); JPanel panel = new JPanel(new MigLayout("fill")); - panel.add(new StyledLabel("OpenRocket license", 10), "ax 50%, wrap para"); - - String licenseText; - try { - - BufferedReader reader = new BufferedReader( - new InputStreamReader(ClassLoader.getSystemResourceAsStream(LICENSE_FILENAME))); - StringBuffer sb = new StringBuffer(); - for (String s = reader.readLine(); s != null; s = reader.readLine()) { - sb.append(s); - sb.append('\n'); - } - licenseText = sb.toString(); - - } catch (IOException e) { - - licenseText = DEFAULT_LICENSE_TEXT; - - } + // OpenRocket logo + panel.add(new JLabel(Icons.loadImageIcon("pix/icon/icon-about.png", "OpenRocket")), "top"); - JTextArea text = new JTextArea(licenseText); - text.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); - text.setRows(20); - text.setColumns(80); - text.setEditable(false); - panel.add(new JScrollPane(text),"grow, wrap para"); + panel.add(new StyledLabel("Software Licenses", 10), "ax 50%, wrap para"); + + final String jarUrl = "jar:" + getClass().getProtectionDomain().getCodeSource().getLocation().toString(); + final String copyrightYear = BuildProperties.getCopyrightYear(); + + /*****************************************************************************************************************************/ + /* */ + /* LICENSE TEXT: each of the licenses we're using is described here. At the end, they are all concatenated for insertion */ + /* in the description window */ + /* */ + /*****************************************************************************************************************************/ + + /*****************************************************************************************************************************/ + /* GPL: overall project */ + /*****************************************************************************************************************************/ + final String orLicense = "GNU GENERAL PUBLIC LICENSE" + "
" + + "
" + + "OpenRocket - A model rocket simulator
" + + "Copyright " + Chars.COPY + " 2007-" + copyrightYear + " Sampo Niskanen and others
" + + "Project page: https://openrocket.info/
" + + "
" + + "This program is free software: you can redistribute it and/or modify it under the terms of the " + + "GNU General Public License as published by the Free Software Foundation, either version 3 " + + "of the License, or any later version. " + + "The license may be viewed " + + "here.
" + + "
" + + "This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; " + + "without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. " + + "See the GNU General Public License for more details.
" + + "
" + + "You should have received a copy of the GNU Public License along with this program. If not, you may obtain a copy at " + + "https://www.gnu.org/licenses/gpl-3.0.html
" + + "
" + + "OpenRocket developers may be contacted electronically at:
" + + "mailto:openrocket-devel@lists.sourceforge.net
" + + "https://openrocket.slack.com
" + + "https://github.com/openrocket
" + + "
"; + + /*****************************************************************************************************************************/ + /* APACHE: components library */ + /*****************************************************************************************************************************/ + final String componentsLicense = + "APACHE LICENSE
" + + "
" + + "OpenRocket features the enhanced components database created by David B. Cook
" + + "Copyright " + Chars.COPY + " 2015-" + copyrightYear + " David B. Cook
" + + "Project page: https://github.com/dbcook/openrocket-database
" + + "
" + + "Licensed under the Apache License, Version 2.0 (the \"License\"); you may not use this work except in compliance with the License. " + + "You may view the License " + + "here.
" + + "You may also obtain a copy of the License at " + + "http://www.apache.org/licenses/LICENSE-2.0
" + + "
" + + "OpenRocket uses the Work or Derivative Works of Ant, a product which includes software developed by the Apache " + + "Software Foundation
" + + "
" + + "Ant also includes software developed by:" + + "" + + "The names \"Ant\" and \"Apache Software Foundation\" must not be used to endorse or " + + "promote products derived from this software without prior written permission. For written permission, "+ + "please contact apache@apache.org.
" + + "
"; + + /*****************************************************************************************************************************/ + /* BITSTREAM VERA: Deja Vu font */ + /*****************************************************************************************************************************/ + final String fontLicense = + "BITSTREAM VERA FONT LICENSE
" + + "
" + + "OpenRocket makes use of the DejaVu Serif Font
" + + "Fonts are Copyright " + Chars.COPY + " 2003 by Bitstream, Inc. All Rights Reserved. " + + "Bitstream Vera is a trademark of Bitstream, Inc.
" + + "DejaVu changes are in the public domain
" + + "Glyphs imported from Arev Fonts Copyright " + Chars.COPY + " 2006 by Tavmjong Bah. All Rights Reserved.
" + + "Project page: https://github.com/dejavu-fonts/dejavu-fonts/
" + + "
" + + "Licensed according to the Bitstream Vera Font License which may be found " + + "
here." + + "
" + + "You may also obtain a copy of the License at " + + "https://github.com/dejavu-fonts/dejavu-fonts/blob/master/LICENSE
" + + "
"; + + /*****************************************************************************************************************************/ + /* BSD 2-Clause: commonmark-java library */ + /*****************************************************************************************************************************/ + final String commonmarkLicense = + "BSD 2-Clause License
" + + "
" + + "OpenRocket makes use of the Commonmark-Java Library
" + + "Copyright " + Chars.COPY + " 2015-2016 Atlassian Pty Ltd. All rights reserved.
" + + "Project page: https://github.com/commonmark/commonmark-java/
" + + "
" + + "You may obtain a copy of the License at
https://github.com/commonmark/commonmark-java/blob/main/LICENSE.txt." + + "
"; + + /*****************************************************************************************************************************/ + /* End of license text */ + /*****************************************************************************************************************************/ + + DescriptionArea info = new DescriptionArea(20); + info.setText(orLicense + componentsLicense + fontLicense + commonmarkLicense); + panel.add(info, "newline, width 600lp, height 150lp, grow, spanx, wrap para"); //Close button JButton close = new SelectColorButton(trans.get("dlg.but.close"));