working on Java 7u40 build for OS X

This commit is contained in:
Ben Fry
2013-07-12 23:46:14 -04:00
parent 3542b6c79c
commit 503cebc56a
8 changed files with 1147 additions and 24 deletions
+37 -7
View File
@@ -1640,6 +1640,29 @@ public class Base {
//return PApplet.platform == PConstants.MACOSX;
return System.getProperty("os.name").indexOf("Mac") != -1; //$NON-NLS-1$ //$NON-NLS-2$
}
static private Boolean usableOracleJava;
// Make sure this is Oracle Java 7u40 or later. This is temporary.
static public boolean isUsableOracleJava() {
if (usableOracleJava == null) {
usableOracleJava = false;
if (Base.isMacOS() &&
System.getProperty("java.vendor").contains("Oracle")) {
String version = System.getProperty("java.version"); // 1.7.0_40
String[] m = PApplet.match(version, "1.(\\d).*_(\\d+)");
if (m != null &&
PApplet.parseInt(m[1]) >= 7 &&
PApplet.parseInt(m[2]) >= 40) {
usableOracleJava = true;
}
}
}
return usableOracleJava;
}
/**
@@ -2316,13 +2339,20 @@ public class Base {
// Path may have URL encoding, so remove it
String decodedPath = PApplet.urlDecode(path);
// The .jar file will be in the lib folder
File libFolder = new File(decodedPath).getParentFile();
if (libFolder.getName().equals("lib")) {
// The main Processing installation directory
processingRoot = libFolder.getParentFile();
} else {
Base.log("Could not find lib in " +
libFolder.getAbsolutePath() + ", switching to user.dir");
File jarFolder = new File(decodedPath).getParentFile();
if (jarFolder.getName().equals("lib")) {
// The main Processing installation directory.
// This works for Windows, Linux, and Apple's Java 6 on OS X.
processingRoot = jarFolder.getParentFile();
} else if (Base.isMacOS()) {
// This works for Java 7 on OS X.
processingRoot = jarFolder;
}
if (processingRoot == null || !processingRoot.exists()) {
// Try working directory instead (user.dir, different from user.home)
Base.log("Could not find lib folder via " +
jarFolder.getAbsolutePath() +
", switching to user.dir");
processingRoot = new File(System.getProperty("user.dir"));
}
}
+6 -1
View File
@@ -259,8 +259,13 @@ public class EditorHeader extends JComponent {
if (Toolkit.highResDisplay()) {
// scale everything 2x, will be scaled down when drawn to the screen
g2.scale(2, 2);
if (Base.isUsableOracleJava()) {
// Oracle Java looks better with anti-aliasing turned on
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
} else {
// don't anti-alias text in retina mode
// don't anti-alias text in retina mode w/ Apple Java
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
+6 -1
View File
@@ -211,8 +211,13 @@ public abstract class EditorToolbar extends JComponent implements MouseInputList
if (Toolkit.highResDisplay()) {
// scale everything 2x, will be scaled down when drawn to the screen
g2.scale(2, 2);
if (Base.isUsableOracleJava()) {
// Oracle Java looks better with anti-aliasing turned on
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
} else {
// don't anti-alias text in retina mode
// don't anti-alias text in retina mode w/ Apple Java
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
}
+46 -9
View File
@@ -27,6 +27,8 @@ import java.awt.FontFormatException;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.datatransfer.Clipboard;
import java.awt.event.ActionEvent;
@@ -38,6 +40,7 @@ import java.io.BufferedInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.util.ArrayList;
import javax.swing.ImageIcon;
@@ -216,24 +219,58 @@ public class Toolkit {
return awtToolkit.getSystemClipboard();
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
static Boolean highResProp;
static Boolean retinaProp;
static public boolean highResDisplay() {
if (highResProp == null) {
highResProp = checkRetina();
}
return highResProp;
}
static private boolean checkRetina() {
if (Base.isMacOS()) {
// This should probably be reset each time there's a display change.
// A 5-minute search didn't turn up any such event in the Java API.
// Also, should we use the Toolkit associated with the editor window?
if (retinaProp == null) {
// This should probably be reset each time there's a display change.
// A 5-minute search didn't turn up any such event in the Java API.
// Also, should we use the Toolkit associated with the editor window?
// String javaVendor = System.getProperty("java.vendor");
// if (javaVendor.contains("Apple")) {
if (System.getProperty("java.vendor").contains("Apple")) {
Float prop = (Float)
awtToolkit.getDesktopProperty("apple.awt.contentScaleFactor");
if (prop != null) {
retinaProp = prop == 2;
} else {
retinaProp = false;
return prop == 2;
}
// } else if (javaVendor.contains("Oracle")) {
// String version = System.getProperty("java.version"); // 1.7.0_40
// String[] m = PApplet.match(version, "1.(\\d).*_(\\d+)");
//
// // Make sure this is Oracle Java 7u40 or later
// if (m != null &&
// PApplet.parseInt(m[1]) >= 7 &&
// PApplet.parseInt(m[1]) >= 40) {
} else if (Base.isUsableOracleJava()) {
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = env.getDefaultScreenDevice();
try {
Field field = device.getClass().getDeclaredField("scale");
if (field != null) {
field.setAccessible(true);
Object scale = field.get(device);
if (scale instanceof Integer && ((Integer)scale).intValue() == 2) {
return true;
}
}
} catch (Exception ignore) { }
}
return retinaProp;
}
return false;
}
@@ -81,6 +81,8 @@ public class ThinkDifferent implements ApplicationListener {
// Only available since Java for Mac OS X 10.6 Update 1, and
// Java for Mac OS X 10.5 Update 6, so need to load this dynamically
if (PApplet.javaVersion <= 1.6f) { // doesn't work on Oracle's Java
// if (System.getProperty("java.vendor").contains("Apple") ||
// Base.isUsableOracleJava()) {
try {
// com.apple.eawt.Application.setDefaultMenuBar(JMenuBar)
Class<?> appClass = Application.class;
@@ -101,7 +103,8 @@ public class ThinkDifferent implements ApplicationListener {
}
} else {
// http://java.net/jira/browse/MACOSX_PORT-775?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel
System.out.println("Skipping default menu bar due to apparent Oracle Java bug.");
System.err.println("Skipping default menu bar due to Oracle Java 7 bug:");
System.err.println("http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8007267");
}
}
+1029
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -16,6 +16,12 @@ X https://github.com/processing/processing/issues/1852
_ implement version of Table that takes a dictionary file
_ addRow() is not efficient, probably need to do the doubling
_ or have a setIncrement() function?
_ it would default to 1 on tables loaded from a file
_ and default to doubling when created with "new Table"
_ constructing table from an iterator is missing
_ https://github.com/processing/processing/issues/1956
_ finish PFont.getShape() implementation
_ needs to have a way to set width/height properly
_ draw(s) doesn't work on the returned PShape
+13 -5
View File
@@ -7,10 +7,15 @@ X https://github.com/processing/processing/issues/1681
X Fix from Github user hamzaissa
X selectInput() in exported OS X sketch treats .app package as a folder
X https://github.com/processing/processing/issues/1959
X waiting on retina support for JDK 7
o b86 supposed to have some support (not available yet)
o http://jdk8.java.net/download.html
high
_ Present Mode trouble on Windows 7 (64-bit)?
_ libraries need to support multiple categories
_ https://github.com/processing/processing/issues/1970
_ Present Mode trouble on Windows 7 (64-bit) completely broken
_ https://github.com/processing/processing/issues/1955
_ Add "Processing Foundation" to the Help menu
_ https://github.com/processing/processing/issues/1908
@@ -791,14 +796,17 @@ DIST / Mac OS X
_ package Java 7 version of the app
_ docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html
_ http://www.intransitione.com/blog/take-java-to-app-store/
X retina support http://bugs.sun.com/view_bug.do?bug_id=8009754
_ useful retina digging/findings for Oracle Java
_ http://bulenkov.com/2013/06/23/retina-support-in-oracle-jdk-1-7/
_ 7u40 target release is "late August"
_ http://openjdk.java.net/projects/jdk7u/releases/7u40.html
_ but default menu bar is still broken
_ http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=8007267
_ blank sketch opened even if another opened by double-click
_ add a 150 ms or more lag before opening the untitled window (on os x)
_ https://github.com/processing/processing/issues/218
_ OS X not opening a sketch at all on pde double-click? (though opening the app)
_ waiting on retina support for JDK 7
_ http://bugs.sun.com/view_bug.do?bug_id=8009754
_ b86 supposed to have some support (not available yet)
_ http://jdk8.java.net/download.html
_ "Are you sure you want to quit?" when switching modes on Oracle JVM
_ because it's OS X, but menubar isn't available
_ LWJGL forum discussion