Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions trunk/SwingSet3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
target/
dependency-reduced-pom.xml
136 changes: 136 additions & 0 deletions trunk/SwingSet3/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<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>
<groupId>com.sun</groupId>
<artifactId>swingset</artifactId>
<version>3.00.00-SNAPSHOT</version>

<name>SwingSet 3</name>

<url>https://github.com/cmarchand/swingset3</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.release>11</maven.compiler.release>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.11.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.jdesktop</groupId>
<artifactId>appframework</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>com.kenai.nbpwr</groupId>
<artifactId>org-jdesktop-animation-timing</artifactId>
<version>1.0-201002281504</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.swinglabs.swingx</groupId>
<artifactId>swingx-core</artifactId>
<version>1.6.5-1</version>
</dependency>
<dependency>
<groupId>org.swinglabs.swingx</groupId>
<artifactId>swingx-painters</artifactId>
<version>1.6.5-1</version>
</dependency>
<dependency>
<groupId>org.swinglabs.swingx</groupId>
<artifactId>swingx-graphics</artifactId>
<version>1.6.5-1</version>
</dependency>
<!--dependency>
<groupId>org.jxmapviewer</groupId>
<artifactId>jxmapviewer2</artifactId>
<version>2.8</version>
</dependency-->
<dependency>
<groupId>javax.jnlp</groupId>
<artifactId>jnlp</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.6.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<executions>
<execution>
<goals><goal>jar</goal></goals>
<configuration>
<excludeResources>true</excludeResources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals><goal>shade</goal></goals>
<configuration>
<extraArtifacts>${project.groupId}:${project.artifactId}:jar:sources:${project.version}</extraArtifacts>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.sun.swingset3.SwingSet3</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>default</id>
<name>FreeHep</name>
<releases>
<enabled>true</enabled>
</releases>
<url>https://java.freehep.org/maven2</url>
</repository>
</repositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Icon;
import javax.swing.ImageIcon;

Expand All @@ -50,8 +53,10 @@
* @author Amy Fowler
*/
public class Demo {

public enum State { UNINITIALIZED, INITIALIZING, INITIALIZED, RUNNING, STOPPED, FAILED }

private String USER_DIR = System.getProperty("user.dir");

public enum State { UNINITIALIZED, INITIALIZING, INITIALIZED, RUNNING, STOPPED, FAILED }

private static final String IMAGE_EXTENSIONS[] = {".gif", ".png", ".jpg"};

Expand Down Expand Up @@ -203,9 +208,18 @@ public URL[] getSourceFiles() {
if (!(sourceFilePaths.length == 1 && sourceFilePaths[0].length() == 0)) {
for (String path : sourceFilePaths) {
try {
URL url = new URL("file://" + System.getProperty("user.dir") + "/src/" + path);
// sources are in jar
URL url = getClass().getClassLoader().getResource(path);
if(url==null) {
// but if ran from IDE, go to sources to load them
url = new URI("file://" + USER_DIR + "/src/main/java/" + path).toURL();
if(url==null) {
// try from resources
url = new URI("file://" + USER_DIR + "/src/main/resources/" + path).toURL();
}
}
pathURLs.add(url);
} catch (MalformedURLException e) {
} catch (Exception e) {
SwingSet3.logger.log(Level.WARNING,
"unable to load source file '" + path + "'");
}
Expand Down Expand Up @@ -246,7 +260,7 @@ void setDemoComponent(Component component) {
public Component createDemoComponent() {
Component component = null;
try {
component = (Component)demoClass.newInstance();
component = (Component)demoClass.getConstructor().newInstance();
setDemoComponent(component);
} catch (Exception e) {
System.err.println(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
import java.net.URL;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand Down Expand Up @@ -89,6 +86,8 @@
import com.sun.swingset3.utilities.RoundedPanel;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

/**
*
Expand Down Expand Up @@ -122,7 +121,7 @@ public class SwingSet3 extends SingleFrameApplication {
private static final Border EMPTY_BORDER = new EmptyBorder(0, 0, 0, 0);
private static final Border PANEL_BORDER = new EmptyBorder(10, 10, 10, 10);

private static final String DEMO_LIST_FILE = "/META-INF/demolist";
private static final String DEMO_LIST_FILE = "META-INF/demolist";

static {
// Property must be set *early* due to Apple Bug#3909714
Expand Down Expand Up @@ -236,7 +235,7 @@ protected void initialize(String args[]) {
if (demoList.isEmpty() || augment) {
// Load default Demos
try {
demoList.addAll(readDemoClassNames(new InputStreamReader(getClass().getResourceAsStream(DEMO_LIST_FILE))));
demoList.addAll(readDemoClassNames(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(DEMO_LIST_FILE))));
} catch (IOException ex) {
exception = ex;
logger.log(Level.WARNING, "unable to read resource: " + DEMO_LIST_FILE, ex);
Expand Down Expand Up @@ -272,17 +271,17 @@ protected Demo createDemo(String demoClassName) {
try {
demoClass = Class.forName(demoClassName);
} catch (ClassNotFoundException cnfe) {
logger.log(Level.WARNING, "demo class not found:"+ demoClassName);
}
logger.log(Level.WARNING, "demo class not found: "+ demoClassName);
}
if (demoClass != null) {
// Wrap Demo
demo = new Demo(demoClass);
demo.addPropertyChangeListener(getDemoPropertyChangeListener());
}
return demo;
}
protected PropertyChangeListener getDemoPropertyChangeListener() {

protected PropertyChangeListener getDemoPropertyChangeListener() {
if (demoPropertyChangeListener == null) {
demoPropertyChangeListener = new DemoPropertyChangeListener();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
package com.sun.swingset3.codeview;

import com.sun.swingset3.utilities.ArrowIcon;
import org.jdesktop.swingx.util.GraphicsUtilities;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
Expand All @@ -51,7 +53,6 @@
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.Border;
import org.jdesktop.swingx.graphics.GraphicsUtilities;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,15 @@ private void doProcessOperator(Operator operator) {

private static Double stringToValue(String value) {
try {
return new Double(value.replace(DECIMAL_SEPARATOR, '.'));
return Double.parseDouble(value.replace(DECIMAL_SEPARATOR, '.'));
} catch (NumberFormatException e) {
// Continue convertion
}

if (value.endsWith(String.valueOf(DECIMAL_SEPARATOR))) {
try {
// Try convert uncompleted value
return new Double(value.substring(0, value.length() - 1));
return Double.parseDouble(value.substring(0, value.length() - 1));
} catch (NumberFormatException e) {
// Continue convertion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public class InternalFrameDemo extends JPanel {
private final ImageIcon smIcon3;
private final ImageIcon smIcon4;

private final Integer DEMO_FRAME_LAYER = new Integer(2);
private final Integer PALETTE_LAYER = new Integer(3);
private final Integer DEMO_FRAME_LAYER = 2;
private final Integer PALETTE_LAYER = 3;

private JCheckBox windowResizable = null;
private JCheckBox windowClosable = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ private void createSliderDemo() {
s.setPaintLabels(true);
s.setSnapToTicks(true);

s.getLabelTable().put(new Integer(11), new JLabel(Integer.toString(11), JLabel.CENTER));
s.getLabelTable().put(11, new JLabel("11", JLabel.CENTER));
s.setLabelTable(s.getLabelTable());

s.getAccessibleContext().setAccessibleName(resourceManager.getString("SliderDemo.minorticks"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ public void mouseMoved(MouseEvent event) {
public void mouseClicked(MouseEvent event) {
if (checkIfPointInsideHyperlink(event.getPoint())) {

ActionEvent actionEvent = new ActionEvent(new Integer(hitRowIndex),
ActionEvent actionEvent = new ActionEvent(hitRowIndex,
ActionEvent.ACTION_PERFORMED,
"hyperlink");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.net.*;
import java.util.ArrayList;

/**
Expand All @@ -57,7 +55,7 @@ private IMDBLink() {
* @param year the year the movie was nominated for the oscar
* @return String containing URI for movie's IMDB entry or null if URI could not be found
*/
public static String getMovieURIString(String movieTitle, int year) throws IOException {
public static String getMovieURIString(String movieTitle, int year) throws IOException, URISyntaxException {
ArrayList<String> matches = new ArrayList<String>();
URL url;
BufferedReader reader;
Expand All @@ -67,8 +65,8 @@ public static String getMovieURIString(String movieTitle, int year) throws IOExc
// Thank you, yahoo, for granting our search request :-)
try {
String urlKey = URLEncoder.encode(movieTitle, "UTF-8");
url = new URL("http://search.yahoo.com/search?ei=utf-8&fr=sfp&p=imdb+" +
urlKey + "&iscqry=");
url = new URI("http://search.yahoo.com/search?ei=utf-8&fr=sfp&p=imdb+" +
urlKey + "&iscqry=").toURL();
} catch (Exception ex) {
System.err.println(ex);

Expand All @@ -84,7 +82,7 @@ public static String getMovieURIString(String movieTitle, int year) throws IOExc
// Parse response a find each imdb/titleString result
String line;
String imdbString = ".imdb.com";
String titleStrings[] = {"/title", "/Title"};
String[] titleStrings = {"/title", "/Title"};

while ((line = reader.readLine()) != null) {
for (String titleString : titleStrings) {
Expand Down Expand Up @@ -121,10 +119,10 @@ public static String getMovieURIString(String movieTitle, int year) throws IOExc
}


private static boolean verifyYear(String imdbURL, int movieYear) throws IOException {
private static boolean verifyYear(String imdbURL, int movieYear) throws IOException, URISyntaxException {
boolean yearMatches = false;

URLConnection conn = new URL(imdbURL).openConnection();
URLConnection conn = new URI(imdbURL).toURL().openConnection();
conn.connect();

// Get the response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import javax.swing.Scrollable;
import org.jdesktop.swingx.RepaintManagerX;
import org.jdesktop.swingx.TranslucentRepaintManager;
import org.jdesktop.swingx.graphics.GraphicsUtilities;
import org.jdesktop.swingx.util.GraphicsUtilities;

/**
* A simple JPanel extension that adds translucency support.
Expand Down Expand Up @@ -124,7 +124,7 @@ public void setAlpha(float alpha) {
//win, no matter the approach.
RepaintManager manager = RepaintManager.currentManager(this);
if (!manager.getClass().isAnnotationPresent(TranslucentRepaintManager.class)) {
RepaintManager.setCurrentManager(new RepaintManagerX());
RepaintManager.setCurrentManager(new RepaintManagerX(manager));
}
} else if (alpha == 1) {
//restore the oldOpaque if it was true (since opaque is false now)
Expand Down