Skip to content

Commit fb8dfbf

Browse files
committed
purge several "applet" references from the code
1 parent 2d907da commit fb8dfbf

File tree

10 files changed

+190
-248
lines changed

10 files changed

+190
-248
lines changed

app/src/processing/app/Mode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,7 +810,7 @@ public Library findLibraryByName(String libName) {
810810

811811

812812
/**
813-
* Create a fresh applet/application folder if the 'delete target folder'
813+
* Create a fresh application folder if the 'delete target folder'
814814
* pref has been set in the preferences.
815815
*/
816816
public void prepareExportFolder(File targetFolder) {

core/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ We've removed `Applet` as the base class for `PApplet` and have redone the entir
66

77

88
#### Why?
9-
1. The changes improve performance--greatly, in some cases--and reduce flicker and quirkiness in others. Using AWT objects like `Applet` (which subclasses `Component`) cause (sometimes major) performance restrictions or other visual glitches like flicker.
9+
1. The changes improve performance--greatly, in some cases--and reduce flicker and quirkiness in others. Using AWT objects like `Applet` (which subclasses `Component`) cause (sometimes major) performance restrictions or other visual glitches like flicker.
1010
2. Without making these changes, the code to mitigate the issues from #1 is very difficult to debug and make work properly across the many platforms we support: Macs, Macs with retina displays, Windows 7, Windows 8, 32- and 64-bit machines, Linux who-knows-what, and so on.
1111
3. The design of `core` is 13 years old, and the graphics features available (OpenGL, `VolatileImage`, `BufferStrategy`, etc) have changed drastically since then. I've papered over these changes and done my best to keep performance on-pace so that we don't break a lot of old code (or libraries), but now is the time for a clean break.
12-
4. With the death of applets, keeping the `Applet` base class is anachronistic (in addition to hindering performance). However, we're keeping the name `PApplet` because with any luck, these changes will only require a recompile of any sketch (or library) code.
12+
4. With the death of applets, keeping the `Applet` base class is anachronistic (in addition to hindering performance). However, we're keeping the name `PApplet` because with any luck, these changes will only require a recompile of any sketch (or library) code.
1313

1414

1515
#### What else?
@@ -20,17 +20,17 @@ We've removed `Applet` as the base class for `PApplet` and have redone the entir
2020
5. In 3.0a2 we changed the OS X version to use Apple's "official" full screen mode. With this came a dorky animation and the inability to span multiple screens. We've rolled that back because of the latter, though the former was also a consideration.
2121

2222

23-
#### But what about...?
23+
#### But what about...?
2424

2525
We're still determining how much code we're willing to break due to API changes. Stay tuned.
2626

2727

2828
#### Integration with Java applications
29-
One downside of these changes is that you'll no longer be able to just drop a Processing sketch into other Java code, because `PApplet` will no longer subclass `Applet` (and therefore, `Component`). This is a huge downside for a tiny number of users.
29+
One downside of these changes is that you'll no longer be able to just drop a Processing sketch into other Java code, because `PApplet` will no longer subclass `Applet` (and therefore, `Component`). This is a huge downside for a tiny number of users.
3030

31-
Making it a generic `Component`, however, means that we cannot improve performance, due to the cross-platform mess of Java's outdated (and somewhat unsuspported) AWT.
31+
Making it a generic `Component`, however, means that we cannot improve performance, due to the cross-platform mess of Java's outdated (and somewhat unsuspported) AWT.
3232

33-
In 3.0 alpha 6, the `getCanvas()` method (called`getComponent()` in alpha 7) provided a way to get an object to be embedded, but it looks like we'll have to move in another direction. At the present time, it looks like it'll be necessary to create a separate `PComponent` or `PCanvas` class that can be used, but it's not clear how that will work. We'll have this sorted out by the final release of 3.0.
33+
In 3.0 alpha 6, the `getCanvas()` method (called`getComponent()` in alpha 7) provided a way to get an object to be embedded, but it looks like we'll have to move in another direction. At the present time, it looks like it'll be necessary to create a separate `PComponent` or `PCanvas` class that can be used, but it's not clear how that will work. We'll have this sorted out by the final release of 3.0.
3434

3535
This is one of many unfortunate tradeoffs I'm trying to sort through as we try to remove significant barriers to performance caused by the design of Java's AWT, while also supporting features (like embedding) that we've spent so much time supporting in the past.
3636

@@ -41,10 +41,10 @@ Prior to Processing 3, dark magic was used to make the `size()` command work. Th
4141
* `setup()` would run, and if the renderer changed, the sketch would throw an exception causing things to restart (re-calling the `setup()` method)
4242
* The previous step gave fits to any other variants of Processing (like Python or Ruby or Scala)
4343

44-
We had a tricky, stuttery situation where some things would happen automatically, other things would be delayed slightly.
45-
In the Android version of Processing, these methods weren't possible, so we enhanced the preprocessor to parse the `size()` command used in the sketch and create methods called `sketchWidth()` and `sketchHeight()` and so on, that returned the values found in `setup()`.
44+
We had a tricky, stuttery situation where some things would happen automatically, other things would be delayed slightly.
45+
In the Android version of Processing, these methods weren't possible, so we enhanced the preprocessor to parse the `size()` command used in the sketch and create methods called `sketchWidth()` and `sketchHeight()` and so on, that returned the values found in `setup()`.
4646

47-
In Processing 3, we've moved in a different direction. A new method called `settings()` has been introduced. When running inside the PDE, commands like `size()`, `fullScreen()`, `pixelDensity()`, and `smooth()` are all moved to the `settings()` method, which is called once, before `setup()`. Those are the only methods that can be called inside `settings()`. When outside the PDE (i.e. using Eclipse), you'll need to move those methods to `settings()` yourself.
47+
In Processing 3, we've moved in a different direction. A new method called `settings()` has been introduced. When running inside the PDE, commands like `size()`, `fullScreen()`, `pixelDensity()`, and `smooth()` are all moved to the `settings()` method, which is called once, before `setup()`. Those are the only methods that can be called inside `settings()`. When outside the PDE (i.e. using Eclipse), you'll need to move those methods to `settings()` yourself.
4848

4949

5050
#### Offscreen rendering
@@ -56,42 +56,42 @@ Documentation is on its way, see [here](https://github.com/processing/processing
5656

5757

5858
#### The Event Dispatch Thread
59-
The source has gone back and forth between putting all AWT (and Swing, if any) calls on the [EDT](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html). Per Oracle's statements in Java's documentation, this is best practice (at least for Swing; for AWT it's not clear). However, we've gone back and forth several times as to whether it's necessary or worthwhile.
59+
The source has gone back and forth between putting all AWT (and Swing, if any) calls on the [EDT](https://docs.oracle.com/javase/tutorial/uiswing/concurrency/dispatch.html). Per Oracle's statements in Java's documentation, this is best practice (at least for Swing; for AWT it's not clear). However, we've gone back and forth several times as to whether it's necessary or worthwhile.
6060
Actual rendering in the default renderer happens off the EDT, but the EDT is used to blit the image to the screen (or resize windows, etc). By moving to the EDT, we're looking for more consistent cross-platform results. In practice, results are either mixed or not there.
6161

6262

63-
## OpenGL
63+
## OpenGL
6464

6565
And now, for something completely different.
6666

6767
### Changes from 2.x
6868

69-
Any code that uses `javax.media.opengl` in imports should replace that `com.jogamp.opengl`. I guess the JOGL folks are fully on their own w/o Oracle/Sun support.
69+
Any code that uses `javax.media.opengl` in imports should replace that `com.jogamp.opengl`. I guess the JOGL folks are fully on their own w/o Oracle/Sun support.
7070

71-
### NEWT
71+
### NEWT
7272

7373
NEWT was written by the JOGL guys so that they could avoid AWT altogether. The outdated/outmoded AWT makes a lot of assumptions that make implementation of GL a mess and causes performance trouble. This is a big part of the rendering changes that I’ve been making in 3—that we’re moving away from AWT as much as possible so that we don’t have performance problems. In the GL case, AWT causes some stuttering and lowered frame rates. We can get rid of those by dropping Applet, Component, and Canvas, and switching to NEWT’s windowing mechanism.
7474

7575

7676
### JOGL vs LWJGL
7777

78-
During the alpha 6, 7, and 8 release process we did some juggling with what OpenGL library we should use.
78+
During the alpha 6, 7, and 8 release process we did some juggling with what OpenGL library we should use.
7979

8080
The short version of how it played out (written 15 May 2015)
8181
* JOGL had some major bugs and development seemed to have stopped (summer/fall 2014)
8282
* @codeanticode had been trying out LWJGL2 to see how it fared (last fall 2014)
8383
* The LWJGL project has moved all their development effort to LWJGL3 (since then)
8484
* Andrés spent the week rewriting OpenGL to use LWJGL3
85-
* LWJGL3 is simply too unstable for us to use, would require major reworking of PApplet to remove *all* uses of AWT, and they seem to be still struggling with many fundamental issues (this week)
86-
* Andrés went back to JOGL (last 48 hours) to find that many bugs had been fixed and development was continuing.
85+
* LWJGL3 is simply too unstable for us to use, would require major reworking of PApplet to remove *all* uses of AWT, and they seem to be still struggling with many fundamental issues (this week)
86+
* Andrés went back to JOGL (last 48 hours) to find that many bugs had been fixed and development was continuing.
8787
* For 3.0a8, we dropped LWJGL since JOGL is performing much better, and we're 99% sure that's the final decision for 3.0 (yesterday).
8888

8989
It looks like LWJGL3 will be a nice game-centric platform (full screen, affordances for game input/behavior) in the coming months, but the direction they're having to go with 3 means they're moving further away from what we need in Processing with something *slightly* more general.
9090

9191
LWJGL and JOGL are both great projects and we're thankful for all the work that they put in, and our own experience with Processing means that we couldn't be more sympathetic to the difficulty they face in maintaining their cross-platform, cross-chipset, cross-everything code. Like Processing, both projects are open source and created by volunteers who give their work away for free. We're enormously appreciative of their efforts.
9292

9393

94-
## JavaFX
94+
## JavaFX
9595

9696
Similarly to the NEWT situation in JOGL described above, we’ve hit the upper bound of what we can do on performance in Java2D as well. The graphics engineers from the Java team seem to have all moved to JavaFX for the last few years, perhaps because AWT is a dead end. So… I’ve started doing the JavaFX port so that we can drop even more of the AWT code.
9797

@@ -102,9 +102,9 @@ We hope to make JavaFX the default renderer instead of Java2D. With any luck, we
102102

103103
## Whither AWT
104104

105-
Run away from the AWT. All of our focus is on the OpenGL and JavaFX rendering engines, neither of which use AWT. Even the (currently) default `PGraphicsJava2D` renderer will be de-emphasized (though not removed) in the final 3.0.
105+
Run away from the AWT. All of our focus is on the OpenGL and JavaFX rendering engines, neither of which use AWT. Even the (currently) default `PGraphicsJava2D` renderer will be de-emphasized (though not removed) in the final 3.0.
106106

107-
* * *
107+
* * *
108108

109109
# The Mess
110110

@@ -126,11 +126,11 @@ The rest of this document are my notes while I'm making changes.
126126
6. renderer that draws to screen (Java2D) or not (PDF)
127127
7. OpenGL or not
128128

129-
resize events:
129+
resize events:
130130
Frame > Canvas > PGraphics > PApplet
131131
user-driven Frame resize events follow that order
132132
all resize events happen on the surface
133-
applet sends message to the surface, which notifies the renderer itself
133+
sketch sends message to the surface, which notifies the renderer itself
134134
resize of component is handled in thread-safe way from PSurface
135135

136136
PApplet.size() calls setSize() in PSurface, and in surface:
@@ -152,7 +152,7 @@ inside main, will know the screen that's being used for the app
152152
#### Questions/To Do
153153
- change size() command to check through renderer constants and give better error message when using one of the built-in renderers
154154
- bad idea, or worst idea, to have 'surface' var in PGraphics?
155-
- move getFontRenderContext(font) to PApplet? surface? elsewhere?
155+
- move getFontRenderContext(font) to PApplet? surface? elsewhere?
156156
_ do we need canDraw() anymore?
157157
- Can we remove while() loop that waits until defaultSize is set false?
158158
- Does init() need to go away, because it's not going to work in any other setting? Because a surface must first be created, the init() method on its own will be a mess.
@@ -165,10 +165,10 @@ _ do we need canDraw() anymore?
165165
- do we need sketchOutputPath() and sketchOutputStream()?
166166

167167
#### Removed functions (not final, just notes)
168-
param()
168+
param()
169169
the old awt event handlers (they were a warning in 2.x)
170170
PGraphics.requestDraw(), because renderers now have their own threads
171171
PGraphics.setFrameRate removed, added to PSurface
172172
requires 1.7.. uses revalidate() method
173-
destroy() (only called by applet? calls dispose())
173+
destroy() (only called by Applet? calls dispose())
174174

core/src/processing/awt/PSurfaceAWT.java

Lines changed: 3 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
Part of the Processing project - http://processing.org
55
6-
Copyright (c) 2014-15 The Processing Foundation
6+
Copyright (c) 2014-22 The Processing Foundation
77
88
This library is free software; you can redistribute it and/or
99
modify it under the terms of the GNU Lesser General Public
@@ -388,7 +388,7 @@ public void initFrame(final PApplet sketch) {/*, int backgroundColor,
388388
// For 0149, moving this code (up to the pack() method) before init().
389389
// For OpenGL (and perhaps other renderers in the future), a peer is
390390
// needed before a GLDrawable can be created. So pack() needs to be
391-
// called on the Frame before applet.init(), which itself calls size(),
391+
// called on the Frame before init(), which itself calls size(),
392392
// and launches the Thread that will kick off setup().
393393
// https://download.processing.org/bugzilla/891.html
394394
// https://download.processing.org/bugzilla/908.html
@@ -421,7 +421,6 @@ public void initFrame(final PApplet sketch) {/*, int backgroundColor,
421421
}
422422
*/
423423
frame.setLayout(null);
424-
//frame.add(applet);
425424

426425
// Need to pass back our new sketchWidth/Height here, because it may have
427426
// been overridden by numbers we calculated above if fullScreen and/or
@@ -653,63 +652,10 @@ public void mousePressed(java.awt.event.MouseEvent e) {
653652
label.setSize(labelSize);
654653
label.setLocation(20, screenRect.height - labelSize.height - 20);
655654
}
656-
657-
// if (sketch.getGraphics().displayable()) {
658-
// setVisible(true);
659-
// }
660655
}
661656

662657

663-
/*
664-
@Override
665-
public void placeWindow(int[] location) {
666-
setFrameSize(); //sketchWidth, sketchHeight);
667-
668-
if (location != null) {
669-
// a specific location was received from the Runner
670-
// (applet has been run more than once, user placed window)
671-
frame.setLocation(location[0], location[1]);
672-
673-
} else { // just center on screen
674-
// Can't use frame.setLocationRelativeTo(null) because it sends the
675-
// frame to the main display, which undermines the --display setting.
676-
frame.setLocation(screenRect.x + (screenRect.width - sketchWidth) / 2,
677-
screenRect.y + (screenRect.height - sketchHeight) / 2);
678-
}
679-
Point frameLoc = frame.getLocation();
680-
if (frameLoc.y < 0) {
681-
// Windows actually allows you to place frames where they can't be
682-
// closed. Awesome. https://download.processing.org/bugzilla/1508.html
683-
frame.setLocation(frameLoc.x, 30);
684-
}
685-
686-
// if (backgroundColor != null) {
687-
// ((JFrame) frame).getContentPane().setBackground(backgroundColor);
688-
// }
689-
690-
setCanvasSize(); //sketchWidth, sketchHeight);
691-
692-
frame.addWindowListener(new WindowAdapter() {
693-
@Override
694-
public void windowClosing(WindowEvent e) {
695-
System.exit(0);
696-
}
697-
});
698-
699-
// handle frame resizing events
700-
setupFrameResizeListener();
701-
702-
// all set for rockin
703-
if (sketch.getGraphics().displayable()) {
704-
frame.setVisible(true);
705-
}
706-
}
707-
*/
708-
709-
710658
private void setCanvasSize() {
711-
// System.out.format("setting canvas size %d %d%n", sketchWidth, sketchHeight);
712-
// new Exception().printStackTrace(System.out);
713659
int contentW = Math.max(sketchWidth, MIN_WINDOW_WIDTH);
714660
int contentH = Math.max(sketchHeight, MIN_WINDOW_HEIGHT);
715661

@@ -784,7 +730,7 @@ public void placeWindow(int[] location, int[] editorLocation) {
784730
if (!sketch.sketchFullScreen()) {
785731
if (location != null) {
786732
// a specific location was received from the Runner
787-
// (applet has been run more than once, user placed window)
733+
// (sketch has been run more than once, user placed window)
788734
frame.setLocation(location[0], location[1]);
789735

790736
} else if (editorLocation != null) {

core/src/processing/core/PGraphics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ protected void defaultSettings() { // ignore
971971
textAlign = LEFT;
972972
textMode = MODEL;
973973

974-
// if this fella is associated with an applet, then clear its background.
974+
// if this fella is associated with a component, then clear its background.
975975
// if it's been created by someone else through createGraphics,
976976
// they have to call background() themselves, otherwise everything gets
977977
// a gray background (when just a transparent surface or an empty pdf

core/src/processing/core/PShapeSVG.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
Part of the Processing project - http://processing.org
55
6-
Copyright (c) 2012-15 The Processing Foundation
6+
Copyright (c) 2012-22 The Processing Foundation
77
Copyright (c) 2006-12 Ben Fry and Casey Reas
88
Copyright (c) 2004-06 Michael Chang
99

core/src/processing/opengl/PSurfaceJOGL.java

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -549,30 +549,26 @@ private String resourceFilename(String filename) {
549549
} catch (IOException ignored) { }
550550

551551
try {
552-
// attempt to load from a local file, used when running as
553-
// an application, or as a signed applet
554-
try { // first try to catch any security exceptions
555-
try {
556-
String path = sketch.dataPath(filename);
557-
stream = new FileInputStream(path);
558-
stream.close();
559-
return path;
560-
} catch (IOException ignored) { }
561-
562-
try {
563-
String path = sketch.sketchPath(filename);
564-
stream = new FileInputStream(path);
565-
stream.close();
566-
return path;
567-
} catch (Exception ignored) { }
568-
569-
try {
570-
stream = new FileInputStream(filename);
571-
stream.close();
572-
return filename;
573-
} catch (IOException ignored) { }
574-
575-
} catch (SecurityException ignored) { } // online, whups
552+
// attempt to load from a local file
553+
try {
554+
String path = sketch.dataPath(filename);
555+
stream = new FileInputStream(path);
556+
stream.close();
557+
return path;
558+
} catch (IOException ignored) { }
559+
560+
try {
561+
String path = sketch.sketchPath(filename);
562+
stream = new FileInputStream(path);
563+
stream.close();
564+
return path;
565+
} catch (Exception ignored) { }
566+
567+
try {
568+
stream = new FileInputStream(filename);
569+
stream.close();
570+
return filename;
571+
} catch (IOException ignored) { }
576572

577573
} catch (Exception e) {
578574
//die(e.getMessage(), e);

0 commit comments

Comments
 (0)