Skip to content

Commit 2e4921f

Browse files
committed
getting to work on the new gui, plus much-improved text drawing
1 parent 0ad3356 commit 2e4921f

File tree

9 files changed

+84
-92
lines changed

9 files changed

+84
-92
lines changed

app/src/processing/app/Base.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,7 @@ static public boolean isMacOS() {
15221522
}
15231523

15241524

1525+
/*
15251526
static private Boolean usableOracleJava;
15261527
15271528
// Make sure this is Oracle Java 7u40 or later. This is temporary.
@@ -1543,6 +1544,7 @@ static public boolean isUsableOracleJava() {
15431544
}
15441545
return usableOracleJava;
15451546
}
1547+
*/
15461548

15471549

15481550
/**

app/src/processing/app/EditorHeader.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -253,21 +253,17 @@ public void paintComponent(Graphics screen) {
253253
fontAscent = (int) Toolkit.getAscent(g);
254254
}
255255

256-
Graphics2D g2 = (Graphics2D) g;
257-
256+
Graphics2D g2 = Toolkit.prepareGraphics(g);
257+
/*
258258
if (Toolkit.highResDisplay()) {
259259
// scale everything 2x, will be scaled down when drawn to the screen
260260
g2.scale(2, 2);
261-
if (Base.isUsableOracleJava()) {
262-
// Oracle Java looks better with anti-aliasing turned on
263-
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
264-
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
265-
}
266-
} else {
267-
// don't anti-alias text in retina mode w/ Apple Java
268-
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
269-
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
270-
}
261+
}
262+
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
263+
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
264+
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
265+
RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
266+
*/
271267

272268
// set the background for the offscreen
273269
g.setColor(hiding ? hideColor : bgColor);

app/src/processing/app/EditorStatus.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
package processing.app;
2525

2626
import java.awt.*;
27-
//import java.awt.event.*;
2827

2928
import javax.swing.*;
3029

@@ -195,19 +194,7 @@ public void paintComponent(Graphics screen) {
195194
}
196195

197196
Graphics g = offscreen.getGraphics();
198-
199-
Graphics2D g2 = (Graphics2D) g;
200-
if (Toolkit.highResDisplay()) {
201-
g2.scale(2, 2);
202-
if (Base.isUsableOracleJava()) {
203-
// Oracle Java looks better with anti-aliasing turned on
204-
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
205-
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
206-
}
207-
} else {
208-
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
209-
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
210-
}
197+
/*Graphics2D g2 =*/ Toolkit.prepareGraphics(g);
211198

212199
g.setFont(font);
213200
if (metrics == null) {

app/src/processing/app/EditorToolbar.java

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -205,22 +205,8 @@ public void paintComponent(Graphics screen) {
205205
// offsetX = x2[i];
206206
// }
207207
}
208-
Graphics g = offscreen.getGraphics();
209-
Graphics2D g2 = (Graphics2D) g;
210-
211-
if (Toolkit.highResDisplay()) {
212-
// scale everything 2x, will be scaled down when drawn to the screen
213-
g2.scale(2, 2);
214-
if (Base.isUsableOracleJava()) {
215-
// Oracle Java looks better with anti-aliasing turned on
216-
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
217-
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
218-
}
219-
} else {
220-
// don't anti-alias text in retina mode w/ Apple Java
221-
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
222-
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
223-
}
208+
Graphics g = offscreen.getGraphics();
209+
/*Graphics2D g2 =*/ Toolkit.prepareGraphics(g);
224210

225211
g.setColor(hiding ? hideColor : bgColor);
226212
g.fillRect(0, 0, width, height);

app/src/processing/app/Toolkit.java

Lines changed: 41 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.awt.GraphicsDevice;
3333
import java.awt.GraphicsEnvironment;
3434
import java.awt.Image;
35+
import java.awt.RenderingHints;
3536
import java.awt.Window;
3637
import java.awt.datatransfer.Clipboard;
3738
import java.awt.event.ActionEvent;
@@ -488,8 +489,32 @@ static public Clipboard getSystemClipboard() {
488489

489490

490491
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
492+
493+
494+
/**
495+
* Handles scaling for high-res displays, also sets text anti-aliasing
496+
* options. Moved to a utility function because it's used in several classes.
497+
* @param g
498+
* @return a Graphics2D object, as a bit o sugar
499+
*/
500+
static public Graphics2D prepareGraphics(Graphics g) {
501+
Graphics2D g2 = (Graphics2D) g;
502+
503+
if (Toolkit.highResDisplay()) {
504+
// scale everything 2x, will be scaled down when drawn to the screen
505+
g2.scale(2, 2);
506+
}
507+
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
508+
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
509+
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
510+
RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
511+
return g2;
512+
}
513+
491514

515+
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
492516

517+
493518
static Boolean highResProp;
494519

495520

@@ -501,43 +526,25 @@ static public boolean highResDisplay() {
501526
}
502527

503528

529+
// This should probably be reset each time there's a display change.
530+
// A 5-minute search didn't turn up any such event in the Java API.
531+
// Also, should we use the Toolkit associated with the editor window?
504532
static private boolean checkRetina() {
505533
if (Base.isMacOS()) {
506-
// This should probably be reset each time there's a display change.
507-
// A 5-minute search didn't turn up any such event in the Java API.
508-
// Also, should we use the Toolkit associated with the editor window?
509-
// String javaVendor = System.getProperty("java.vendor");
510-
// if (javaVendor.contains("Apple")) {
511-
if (System.getProperty("java.vendor").contains("Apple")) {
512-
Float prop = (Float)
513-
awtToolkit.getDesktopProperty("apple.awt.contentScaleFactor");
514-
if (prop != null) {
515-
return prop == 2;
516-
}
517-
// } else if (javaVendor.contains("Oracle")) {
518-
// String version = System.getProperty("java.version"); // 1.7.0_40
519-
// String[] m = PApplet.match(version, "1.(\\d).*_(\\d+)");
520-
//
521-
// // Make sure this is Oracle Java 7u40 or later
522-
// if (m != null &&
523-
// PApplet.parseInt(m[1]) >= 7 &&
524-
// PApplet.parseInt(m[1]) >= 40) {
525-
} else if (Base.isUsableOracleJava()) {
526-
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
527-
GraphicsDevice device = env.getDefaultScreenDevice();
528-
529-
try {
530-
Field field = device.getClass().getDeclaredField("scale");
531-
if (field != null) {
532-
field.setAccessible(true);
533-
Object scale = field.get(device);
534-
535-
if (scale instanceof Integer && ((Integer)scale).intValue() == 2) {
536-
return true;
537-
}
534+
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
535+
GraphicsDevice device = env.getDefaultScreenDevice();
536+
537+
try {
538+
Field field = device.getClass().getDeclaredField("scale");
539+
if (field != null) {
540+
field.setAccessible(true);
541+
Object scale = field.get(device);
542+
543+
if (scale instanceof Integer && ((Integer)scale).intValue() == 2) {
544+
return true;
538545
}
539-
} catch (Exception ignore) { }
540-
}
546+
}
547+
} catch (Exception ignore) { }
541548
}
542549
return false;
543550
}

core/todo.txt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ X hint(ENABLE_RETINA_PIXELS) or hint(ENABLE_HIDPI_PIXELS)
55
X hint(ENABLE_2X_PIXELS)?
66
X hidpi is Apple's name as well
77
X mostly getting away from this
8+
X bezierSegment() function to do equal-length segments
9+
X https://github.com/processing/processing/issues/2919
10+
X handled instead as an example
811

912
_ textAlign(RIGHT) including spaces at the end of each line
1013
_ https://github.com/processing/processing/issues/3028
@@ -134,10 +137,6 @@ _ save the constructor for the version that actually copies data
134137
_ the table pointer version will be speedy and allow chaining
135138

136139

137-
_ bezierSegment() function to do equal-length segments
138-
_ https://github.com/processing/processing/issues/2919
139-
140-
141140
high
142141
_ Closing opengl sketch from the PDE doesn't stop java process on windows
143142
_ https://github.com/processing/processing/issues/2335

java/src/processing/mode/java/DebugTray.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,23 @@ public DebugTray(JavaEditor editor) {
9191

9292
scrollPane = new JScrollPane();
9393
tree = new Outline();
94-
9594
scrollPane.setViewportView(tree);
9695

9796
GroupLayout layout = new GroupLayout(getContentPane());
9897
getContentPane().setLayout(layout);
9998
layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
10099
.addGap(0, 400, Short.MAX_VALUE)
101100
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
102-
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)));
101+
.addComponent(scrollPane,
102+
GroupLayout.DEFAULT_SIZE,
103+
400, Short.MAX_VALUE)));
103104
layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
104105
.addGap(0, 300, Short.MAX_VALUE)
105106
.addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
106-
.addComponent(scrollPane, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)));
107+
.addComponent(scrollPane,
108+
GroupLayout.Alignment.TRAILING,
109+
GroupLayout.DEFAULT_SIZE,
110+
300, Short.MAX_VALUE)));
107111
pack();
108112

109113
// setup Outline
@@ -138,6 +142,11 @@ public DebugTray(JavaEditor editor) {
138142
}
139143

140144

145+
class TrayToolbar extends JComponent {
146+
147+
}
148+
149+
141150
/** Keeps the debug window adjacent the editor at all times. */
142151
class EditorFollower implements ComponentListener {
143152

java/src/processing/mode/java/Debugger.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ protected String thisName(ThreadReference t) {
922922
return "";
923923
}
924924
return t.frame(0).thisObject().referenceType().name();
925+
925926
} catch (IncompatibleThreadStateException ex) {
926927
log(Level.SEVERE, null, ex);
927928
return "";

todo.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ X don't add a ^M to files when writing
99
X https://github.com/processing/processing/issues/3014
1010
X add more bulletproofing to the save process
1111
X https://github.com/processing/processing/issues/2923
12+
X serious text improvements (at least on retina)
1213

1314
update components
1415
X moving to Java 8 because Java 7 will be discontinued
@@ -84,14 +85,22 @@ X https://github.com/processing/processing/pull/3048
8485
integration of pdex
8586
X changed JLS4 to JLS8 (but make sure it doesn't introduce anything too weird)
8687
X change build scripts, get things running
88+
X rename TextArea and TextAreaPainter to JavaTextArea
89+
X DebugEditor.createTextArea() is copy & pasted from JavaEditor
90+
X this whole setup is really gross at the moment
91+
X finish Ant task to download JRE and JDK from Oracle
92+
8793
_ remove public 'ta' object in DebugEditor, also dmode
88-
_ rename TextArea and TextAreaPainter to JavaTextArea
89-
_ DebugEditor.createTextArea() is copy & pasted from JavaEditor
90-
_ this whole setup is really gross at the moment
91-
_ auto-insert after antlr @SuppressWarnings({ "unused", "unchecked", "cast" })
9294
_ crashed on startup w/ JavaScript mode as default b/c PdeKeyListener not found
9395
_ because it's in the other ClassLoader, can no longer rely on it
9496

97+
jre download/install
98+
_ update build scripts for Windows and Linux to use JRE downloader Ant Task
99+
_ https://github.com/processing/processing/issues/3059
100+
_ add method to prompt OS X developers to download the JDK update
101+
_ make sure the file downloads correctly before renaming
102+
_ https://github.com/processing/processing/issues/2960
103+
95104
_ fix file change detection on OS X
96105
_ https://github.com/processing/processing/issues/2852
97106

@@ -102,11 +111,7 @@ _ otherwise redoing the design for 2 modes
102111
_ add span screens pref (near the display pref)
103112
_ add checkbox for spans to export dialog
104113
_ remove "save before running" message
105-
106-
X finish Ant task to download JRE and JDK from Oracle
107-
_ add method to prompt OS X developers to download the JDK update
108-
_ make sure the file downloads correctly before renaming
109-
_ https://github.com/processing/processing/issues/2960
114+
_ auto-insert after antlr @SuppressWarnings({ "unused", "unchecked", "cast" })
110115

111116

112117
from the todo list

0 commit comments

Comments
 (0)