mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
removing pre-1.4 support, reflection mess from processing.core.*
This commit is contained in:
@@ -265,8 +265,8 @@ preproc.substitute_unicode = true
|
||||
# viewed in (at least) Mozilla or IE. useful when debugging the preprocessor.
|
||||
preproc.output_parse_tree = false
|
||||
|
||||
# jdk version to use..
|
||||
preproc.jdk_version = 1.1
|
||||
# jdk version to use.. (changed to 1.4 for release 0128 and later)
|
||||
preproc.jdk_version = 1.4
|
||||
|
||||
# base imports to include for java 1.1 (or higher)
|
||||
preproc.imports.jdk11 = java.applet,java.awt,java.awt.image,java.awt.event,java.io,java.net,java.text,java.util,java.util.zip
|
||||
|
||||
@@ -45,8 +45,13 @@ import java.util.zip.*;
|
||||
* problems with redraw of components drawn above it. If you'd like to
|
||||
* integrate other Java components, see below.
|
||||
* <p/>
|
||||
* This class extends Applet instead of JApplet because 1) we will eventually
|
||||
* be returning Java 1.1 support, which does not include Swing (without an
|
||||
* As of release 0126 of Processing, we have discontinued support for versions
|
||||
* of Java prior to 1.4. We don't have enough people to support it, and for a
|
||||
* project of our size, we should be focusing on the future, rather than
|
||||
* working around legacy Java code.
|
||||
* <p/>
|
||||
* This class extends Applet instead of JApplet because 1) historically,
|
||||
* we supported Java 1.1, which does not include Swing (without an
|
||||
* additional, sizable, download), and 2) Swing is a bloated piece of crap.
|
||||
* A Processing applet is a heavyweight AWT component, and can be used the
|
||||
* same as any other AWT component, with or without Swing.
|
||||
@@ -158,12 +163,6 @@ public class PApplet extends Applet
|
||||
public static final float javaVersion =
|
||||
new Float(javaVersionName.substring(0, 3)).floatValue();
|
||||
|
||||
/**
|
||||
* Current platform in use, one of the
|
||||
* PConstants WINDOWS, MACOSX, MACOS9, LINUX or OTHER.
|
||||
*/
|
||||
static public int platform;
|
||||
|
||||
/**
|
||||
* Current platform in use.
|
||||
* <P>
|
||||
@@ -172,31 +171,24 @@ public class PApplet extends Applet
|
||||
static public String platformName =
|
||||
System.getProperty("os.name");
|
||||
|
||||
static {
|
||||
// figure out which operating system
|
||||
// this has to be first, since editor needs to know
|
||||
/**
|
||||
* Current platform in use, one of the
|
||||
* PConstants WINDOWS, MACOSX, MACOS9, LINUX or OTHER.
|
||||
*/
|
||||
static public int platform;
|
||||
|
||||
if (platformName.toLowerCase().indexOf("mac") != -1) {
|
||||
// can only check this property if running on a mac
|
||||
// on a pc it throws a security exception and kills the applet
|
||||
// (but on the mac it does just fine)
|
||||
if (System.getProperty("mrj.version") != null) { // running on a mac
|
||||
platform = (platformName.equals("Mac OS X")) ?
|
||||
MACOSX : MACOS9;
|
||||
}
|
||||
static {
|
||||
if (platformName.indexOf("Mac") != -1) {
|
||||
platform = MACOSX;
|
||||
|
||||
} else if (platformName.indexOf("Windows") != -1) {
|
||||
platform = WINDOWS;
|
||||
|
||||
} else if (platformName.equals("Linux")) { // true for the ibm vm
|
||||
platform = LINUX;
|
||||
|
||||
} else {
|
||||
String osname = System.getProperty("os.name");
|
||||
|
||||
if (osname.indexOf("Windows") != -1) {
|
||||
platform = WINDOWS;
|
||||
|
||||
} else if (osname.equals("Linux")) { // true for the ibm vm
|
||||
platform = LINUX;
|
||||
|
||||
} else {
|
||||
platform = OTHER;
|
||||
}
|
||||
platform = OTHER;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,15 +520,16 @@ public class PApplet extends Applet
|
||||
Dimension initialSize = getSize();
|
||||
|
||||
// send tab keys through to the PApplet
|
||||
try {
|
||||
if (javaVersion >= 1.4f) {
|
||||
//setFocusTraversalKeysEnabled(false); // 1.4-only function
|
||||
Method defocus =
|
||||
Component.class.getMethod("setFocusTraversalKeysEnabled",
|
||||
new Class[] { Boolean.TYPE });
|
||||
defocus.invoke(this, new Object[] { Boolean.FALSE });
|
||||
}
|
||||
} catch (Exception e) { } // oh well
|
||||
setFocusTraversalKeysEnabled(false);
|
||||
// try {
|
||||
// if (javaVersion >= 1.4f) {
|
||||
// //setFocusTraversalKeysEnabled(false); // 1.4-only function
|
||||
// Method defocus =
|
||||
// Component.class.getMethod("setFocusTraversalKeysEnabled",
|
||||
// new Class[] { Boolean.TYPE });
|
||||
// defocus.invoke(this, new Object[] { Boolean.FALSE });
|
||||
// }
|
||||
// } catch (Exception e) { } // oh well
|
||||
|
||||
millisOffset = System.currentTimeMillis();
|
||||
|
||||
@@ -563,19 +556,19 @@ public class PApplet extends Applet
|
||||
online = false;
|
||||
}
|
||||
|
||||
if (javaVersion < 1.3f) {
|
||||
addMouseListener(new MouseAdapter() {
|
||||
public void mousePressed(MouseEvent e) {
|
||||
link("http://java.com/");
|
||||
}
|
||||
});
|
||||
// no init to do, so don't cause no trouble, boy
|
||||
return;
|
||||
// call this after making the methods to minimize the
|
||||
// number of places needing the javaVersion crap
|
||||
// (also needs to check online first and create empty
|
||||
// stop method register list)
|
||||
}
|
||||
// if (javaVersion < 1.3f) {
|
||||
// addMouseListener(new MouseAdapter() {
|
||||
// public void mousePressed(MouseEvent e) {
|
||||
// link("http://java.com/");
|
||||
// }
|
||||
// });
|
||||
// // no init to do, so don't cause no trouble, boy
|
||||
// return;
|
||||
// // call this after making the methods to minimize the
|
||||
// // number of places needing the javaVersion crap
|
||||
// // (also needs to check online first and create empty
|
||||
// // stop method register list)
|
||||
// }
|
||||
|
||||
try {
|
||||
if (sketchPath == null) {
|
||||
@@ -613,7 +606,7 @@ public class PApplet extends Applet
|
||||
* PAppletGL needs to have a usable screen before getting things rolling.
|
||||
*/
|
||||
public void start() {
|
||||
if (javaVersion < 1.3f) return;
|
||||
//if (javaVersion < 1.3f) return;
|
||||
|
||||
if (thread != null) return;
|
||||
thread = new Thread(this);
|
||||
@@ -1264,19 +1257,19 @@ public class PApplet extends Applet
|
||||
|
||||
|
||||
synchronized public void paint(Graphics screen) {
|
||||
if (javaVersion < 1.3f) {
|
||||
screen.setColor(new Color(64, 64, 64));
|
||||
Dimension size = getSize();
|
||||
screen.fillRect(0, 0, size.width, size.height);
|
||||
screen.setColor(Color.white);
|
||||
screen.setFont(new Font("Dialog", Font.PLAIN, 9));
|
||||
screen.drawString("You need to install", 3, 15);
|
||||
screen.drawString("Java 1.3 or later", 3, 28);
|
||||
screen.drawString("to view this content.", 3, 41);
|
||||
screen.drawString("Click here to visit", 3, 59);
|
||||
screen.drawString("java.com and install.", 3, 72);
|
||||
return;
|
||||
}
|
||||
// if (javaVersion < 1.3f) {
|
||||
// screen.setColor(new Color(64, 64, 64));
|
||||
// Dimension size = getSize();
|
||||
// screen.fillRect(0, 0, size.width, size.height);
|
||||
// screen.setColor(Color.white);
|
||||
// screen.setFont(new Font("Dialog", Font.PLAIN, 9));
|
||||
// screen.drawString("You need to install", 3, 15);
|
||||
// screen.drawString("Java 1.3 or later", 3, 28);
|
||||
// screen.drawString("to view this content.", 3, 41);
|
||||
// screen.drawString("Click here to visit", 3, 59);
|
||||
// screen.drawString("java.com and install.", 3, 72);
|
||||
// return;
|
||||
// }
|
||||
|
||||
//System.out.println("PApplet.paint()");
|
||||
if (THREAD_DEBUG) println(Thread.currentThread().getName() +
|
||||
@@ -2595,10 +2588,10 @@ public class PApplet extends Applet
|
||||
/**
|
||||
* Set the cursor type
|
||||
*/
|
||||
public void cursor(int _cursor_type) {
|
||||
setCursor(Cursor.getPredefinedCursor(_cursor_type));
|
||||
public void cursor(int cursorType) {
|
||||
setCursor(Cursor.getPredefinedCursor(cursorType));
|
||||
cursorVisible = true;
|
||||
cursorType = _cursor_type;
|
||||
this.cursorType = cursorType;
|
||||
}
|
||||
|
||||
|
||||
@@ -2618,45 +2611,20 @@ public class PApplet extends Applet
|
||||
* <P>
|
||||
* Based on code contributed by Amit Pitaru, plus additional
|
||||
* code to handle Java versions via reflection by Jonathan Feinberg.
|
||||
* Reflection removed for release 0128 and later.
|
||||
*/
|
||||
public void cursor(PImage image, int hotspotX, int hotspotY) {
|
||||
if (javaVersion < 1.2f) {
|
||||
System.err.println("Java 1.2 or higher is required to use cursor()");
|
||||
System.err.println("(You're using version " + javaVersionName + ")");
|
||||
return;
|
||||
}
|
||||
|
||||
// don't set this as cursor type, instead use cursor_type
|
||||
// to save the last cursor used in case cursor() is called
|
||||
//cursor_type = Cursor.CUSTOM_CURSOR;
|
||||
Image jimage =
|
||||
createImage(new MemoryImageSource(image.width, image.height,
|
||||
image.pixels, 0, image.width));
|
||||
|
||||
Point hotspot = new Point(hotspotX, hotspotY);
|
||||
try {
|
||||
Method mCustomCursor =
|
||||
Toolkit.class.getMethod("createCustomCursor",
|
||||
new Class[] { Image.class,
|
||||
Point.class,
|
||||
String.class, });
|
||||
Cursor cursor =
|
||||
(Cursor)mCustomCursor.invoke(Toolkit.getDefaultToolkit(),
|
||||
new Object[] { jimage,
|
||||
hotspot,
|
||||
"no cursor" });
|
||||
setCursor(cursor);
|
||||
cursorVisible = true;
|
||||
|
||||
} catch (NoSuchMethodError e) {
|
||||
System.err.println("cursor() is not available " +
|
||||
"when using Java " + javaVersionName);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
System.err.println("cursor() error: the hotspot " + hotspot +
|
||||
" is out of bounds for the given image.");
|
||||
} catch (Exception e) {
|
||||
System.err.println(e);
|
||||
}
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
Cursor cursor = tk.createCustomCursor(jimage, hotspot, "Custom Cursor");
|
||||
setCursor(cursor);
|
||||
cursorVisible = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -2687,8 +2655,8 @@ public class PApplet extends Applet
|
||||
invisibleCursor = new PImage(16, 16, ARGB);
|
||||
}
|
||||
// was formerly 16x16, but the 0x0 was added by jdf as a fix
|
||||
// for macosx, which didn't wasn't honoring the invisible cursor
|
||||
cursor(invisibleCursor, 0, 0);
|
||||
// for macosx, which wasn't honoring the invisible cursor
|
||||
cursor(invisibleCursor, 8, 8);
|
||||
cursorVisible = false;
|
||||
}
|
||||
|
||||
@@ -3601,11 +3569,11 @@ public class PApplet extends Applet
|
||||
|
||||
// Make sure that PNG images aren't being loaded by Java 1.1
|
||||
//if (lower.endsWith(".png") && PApplet.javaVersion < 1.3f) {
|
||||
if (extension.equals("png") && PApplet.javaVersion < 1.3f) {
|
||||
System.err.println("PNG images can only be loaded when " +
|
||||
"using Java 1.3 and later.");
|
||||
return null;
|
||||
}
|
||||
// if (extension.equals("png") && PApplet.javaVersion < 1.3f) {
|
||||
// System.err.println("PNG images can only be loaded when " +
|
||||
// "using Java 1.3 and later.");
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// For jpeg, gif, and png, load them using createImage(),
|
||||
// because the javax.imageio code was found to be much slower, see
|
||||
@@ -3635,28 +3603,28 @@ public class PApplet extends Applet
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (PApplet.javaVersion >= 1.4f) {
|
||||
if (loadImageFormats == null) {
|
||||
//loadImageFormats = javax.imageio.ImageIO.getReaderFormatNames();
|
||||
try {
|
||||
Class ioClass = Class.forName("javax.imageio.ImageIO");
|
||||
Method getFormatNamesMethod =
|
||||
ioClass.getMethod("getReaderFormatNames", (Class[]) null);
|
||||
loadImageFormats = (String[])
|
||||
getFormatNamesMethod.invoke((Class[]) null, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//if (PApplet.javaVersion >= 1.4f) {
|
||||
if (loadImageFormats == null) {
|
||||
//loadImageFormats = javax.imageio.ImageIO.getReaderFormatNames();
|
||||
try {
|
||||
Class ioClass = Class.forName("javax.imageio.ImageIO");
|
||||
Method getFormatNamesMethod =
|
||||
ioClass.getMethod("getReaderFormatNames", (Class[]) null);
|
||||
loadImageFormats = (String[])
|
||||
getFormatNamesMethod.invoke((Class[]) null, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (loadImageFormats != null) {
|
||||
for (int i = 0; i < loadImageFormats.length; i++) {
|
||||
//if (filename.endsWith("." + loadImageFormats[i])) {
|
||||
if (extension.equals(loadImageFormats[i])) {
|
||||
return loadImageIO(filename);
|
||||
}
|
||||
}
|
||||
if (loadImageFormats != null) {
|
||||
for (int i = 0; i < loadImageFormats.length; i++) {
|
||||
//if (filename.endsWith("." + loadImageFormats[i])) {
|
||||
if (extension.equals(loadImageFormats[i])) {
|
||||
return loadImageIO(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
|
||||
// failed, could not load image after all those attempts
|
||||
System.err.println("Could not find a method to load " + filename);
|
||||
@@ -4061,10 +4029,10 @@ public class PApplet extends Applet
|
||||
*/
|
||||
public PFont createFont(String name, float size,
|
||||
boolean smooth, char charset[]) {
|
||||
if (PApplet.javaVersion < 1.3f) {
|
||||
throw new RuntimeException("Can only create fonts with " +
|
||||
"Java 1.3 or higher");
|
||||
}
|
||||
// if (PApplet.javaVersion < 1.3f) {
|
||||
// throw new RuntimeException("Can only create fonts with " +
|
||||
// "Java 1.3 or higher");
|
||||
// }
|
||||
|
||||
String lowerName = name.toLowerCase();
|
||||
Font font = null;
|
||||
|
||||
+101
-111
@@ -25,8 +25,11 @@
|
||||
package processing.core;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.Raster;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
//import java.lang.reflect.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
@@ -655,18 +658,17 @@ public class PFont implements PConstants {
|
||||
|
||||
|
||||
/**
|
||||
* Use reflection to create a new .vlw font on the fly.
|
||||
* This only works with Java 1.3 and higher.
|
||||
* Create a new image-based font on the fly.
|
||||
*
|
||||
* @param font the font object to create from
|
||||
* @param charset array of all unicode chars that should be included
|
||||
* @param smooth true to enable smoothing/anti-aliasing
|
||||
*/
|
||||
public PFont(Font font, boolean smooth, char charset[]) {
|
||||
if (PApplet.javaVersion < 1.3f) {
|
||||
throw new RuntimeException("Can only create fonts with " +
|
||||
"Java 1.3 or higher");
|
||||
}
|
||||
// if (PApplet.javaVersion < 1.3f) {
|
||||
// throw new RuntimeException("Can only create fonts with " +
|
||||
// "Java 1.3 or higher");
|
||||
// }
|
||||
|
||||
// save this so that we can use the native version
|
||||
this.font = font;
|
||||
@@ -675,51 +677,49 @@ public class PFont implements PConstants {
|
||||
name = font.getName();
|
||||
psname = font.getPSName();
|
||||
|
||||
try {
|
||||
// fix regression from sorting (bug #564)
|
||||
if (charset != null) {
|
||||
// charset needs to be sorted to make index lookup run more quickly
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=494
|
||||
//Arrays.sort(charset);
|
||||
Class arraysClass = Class.forName("java.util.Arrays");
|
||||
Method sortMethod =
|
||||
arraysClass.getMethod("sort", new Class[] { charset.getClass() });
|
||||
sortMethod.invoke(null, new Object[] { charset });
|
||||
}
|
||||
//try {
|
||||
// fix regression from sorting (bug #564)
|
||||
if (charset != null) {
|
||||
// charset needs to be sorted to make index lookup run more quickly
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=494
|
||||
Arrays.sort(charset);
|
||||
// Class arraysClass = Class.forName("java.util.Arrays");
|
||||
// Method sortMethod =
|
||||
// arraysClass.getMethod("sort", new Class[] { charset.getClass() });
|
||||
// sortMethod.invoke(null, new Object[] { charset });
|
||||
}
|
||||
|
||||
// the count gets reset later based on how many of
|
||||
// the chars are actually found inside the font.
|
||||
this.charCount = (charset == null) ? 65536 : charset.length;
|
||||
this.size = font.getSize();
|
||||
// the count gets reset later based on how many of
|
||||
// the chars are actually found inside the font.
|
||||
this.charCount = (charset == null) ? 65536 : charset.length;
|
||||
this.size = font.getSize();
|
||||
|
||||
fwidth = fheight = size;
|
||||
fwidth = fheight = size;
|
||||
|
||||
PImage bitmaps[] = new PImage[charCount];
|
||||
PImage bitmaps[] = new PImage[charCount];
|
||||
|
||||
// allocate enough space for the character info
|
||||
value = new int[charCount];
|
||||
height = new int[charCount];
|
||||
width = new int[charCount];
|
||||
setWidth = new int[charCount];
|
||||
topExtent = new int[charCount];
|
||||
leftExtent = new int[charCount];
|
||||
// allocate enough space for the character info
|
||||
value = new int[charCount];
|
||||
height = new int[charCount];
|
||||
width = new int[charCount];
|
||||
setWidth = new int[charCount];
|
||||
topExtent = new int[charCount];
|
||||
leftExtent = new int[charCount];
|
||||
|
||||
ascii = new int[128];
|
||||
for (int i = 0; i < 128; i++) ascii[i] = -1;
|
||||
ascii = new int[128];
|
||||
for (int i = 0; i < 128; i++) ascii[i] = -1;
|
||||
|
||||
int mbox3 = size * 3;
|
||||
int mbox3 = size * 3;
|
||||
|
||||
BufferedImage playground =
|
||||
new BufferedImage(mbox3, mbox3, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
Graphics2D g = (Graphics2D) playground.getGraphics();
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
smooth ?
|
||||
RenderingHints.VALUE_ANTIALIAS_ON :
|
||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
/*
|
||||
BufferedImage playground =
|
||||
new BufferedImage(mbox3, mbox3, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
Graphics2D g = (Graphics2D) playground.getGraphics();
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
smooth ?
|
||||
RenderingHints.VALUE_ANTIALIAS_ON :
|
||||
RenderingHints.VALUE_ANTIALIAS_OFF);
|
||||
*/
|
||||
|
||||
Class bufferedImageClass =
|
||||
Class.forName("java.awt.image.BufferedImage");
|
||||
Constructor bufferedImageConstructor =
|
||||
@@ -768,16 +768,18 @@ public class PFont implements PConstants {
|
||||
antialiasingKey,
|
||||
antialiasState
|
||||
});
|
||||
*/
|
||||
|
||||
g.setFont(font);
|
||||
FontMetrics metrics = g.getFontMetrics();
|
||||
g.setFont(font);
|
||||
FontMetrics metrics = g.getFontMetrics();
|
||||
|
||||
int samples[] = new int[mbox3 * mbox3];
|
||||
|
||||
/*
|
||||
Method canDisplayMethod = null;
|
||||
Method getDataMethod = null;
|
||||
Method getSamplesMethod = null;
|
||||
|
||||
int samples[] = new int[mbox3 * mbox3];
|
||||
|
||||
canDisplayMethod =
|
||||
Font.class.getMethod("canDisplay", new Class[] { Character.TYPE });
|
||||
getDataMethod =
|
||||
@@ -798,26 +800,27 @@ public class PFont implements PConstants {
|
||||
//e.printStackTrace();
|
||||
//return;
|
||||
//}
|
||||
|
||||
//Array samples = Array.newInstance(Integer.TYPE, mbox3*mbox3);
|
||||
*/
|
||||
|
||||
int maxWidthHeight = 0;
|
||||
int index = 0;
|
||||
for (int i = 0; i < charCount; i++) {
|
||||
char c = (charset == null) ? (char)i : charset[i];
|
||||
|
||||
//if (!font.canDisplay(c)) { // skip chars not in the font
|
||||
try {
|
||||
Character ch = new Character(c);
|
||||
Boolean canDisplay = (Boolean)
|
||||
canDisplayMethod.invoke(font, new Object[] { ch });
|
||||
if (canDisplay.booleanValue() == false) {
|
||||
continue;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
if (!font.canDisplay(c)) { // skip chars not in the font
|
||||
continue;
|
||||
}
|
||||
// try {
|
||||
// Character ch = new Character(c);
|
||||
// Boolean canDisplay = (Boolean)
|
||||
// canDisplayMethod.invoke(font, new Object[] { ch });
|
||||
// if (canDisplay.booleanValue() == false) {
|
||||
// continue;
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return;
|
||||
// }
|
||||
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(0, 0, mbox3, mbox3);
|
||||
@@ -825,11 +828,10 @@ public class PFont implements PConstants {
|
||||
g.drawString(String.valueOf(c), size, size * 2);
|
||||
|
||||
// grabs copy of the current data.. so no updates (do each time)
|
||||
/*
|
||||
Raster raster = playground.getData();
|
||||
raster.getSamples(0, 0, mbox3, mbox3, 0, samples);
|
||||
*/
|
||||
|
||||
/*
|
||||
Object raster = getDataMethod.invoke(playground, new Object[] {});
|
||||
getSamplesMethod.invoke(raster, new Object[] {
|
||||
new Integer(0),
|
||||
@@ -839,8 +841,8 @@ public class PFont implements PConstants {
|
||||
new Integer(0),
|
||||
samples
|
||||
});
|
||||
*/
|
||||
|
||||
//int w = metrics.charWidth(c);
|
||||
int minX = 1000, maxX = 0;
|
||||
int minY = 1000, maxY = 0;
|
||||
boolean pixelFound = false;
|
||||
@@ -858,27 +860,15 @@ public class PFont implements PConstants {
|
||||
if (x > maxX) maxX = x;
|
||||
if (y > maxY) maxY = y;
|
||||
pixelFound = true;
|
||||
//System.out.println(x + " " + y + " = " + sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!pixelFound) {
|
||||
//System.out.println("no pixels found in unicode char " + c +
|
||||
// "(" + PApplet.hex(c) + ")");
|
||||
// this was dumb that it was set to 20 & 30, because for small
|
||||
// fonts, those guys don't exist
|
||||
minX = minY = 0; //20;
|
||||
maxX = maxY = 0; //30;
|
||||
|
||||
minX = minY = 0;
|
||||
maxX = maxY = 0;
|
||||
// this will create a 1 pixel white (clear) character..
|
||||
// maybe better to set one to -1 so nothing is added?
|
||||
/*
|
||||
} else {
|
||||
System.out.println(PApplet.hex(c) + " has bounds " +
|
||||
minX + ", " + minY + " to " +
|
||||
maxX + ", " + maxY);
|
||||
*/
|
||||
}
|
||||
|
||||
value[index] = c;
|
||||
@@ -956,10 +946,10 @@ public class PFont implements PConstants {
|
||||
bitmaps[i] = null;
|
||||
}
|
||||
|
||||
} catch (Exception e) { // catch-all for reflection stuff
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e.getMessage());
|
||||
}
|
||||
// } catch (Exception e) { // catch-all for reflection stuff
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException(e.getMessage());
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -969,7 +959,7 @@ public class PFont implements PConstants {
|
||||
* only TrueType fonts. OpenType fonts with CFF data such as Adobe's
|
||||
* OpenType fonts seem to have trouble (even though they're sort of
|
||||
* TrueType fonts as well, or may have a .ttf extension). Regular
|
||||
* PostScript fonts seem to work O.K. though.
|
||||
* PostScript fonts seem to work OK, however.
|
||||
* <P>
|
||||
* Not recommended for use in applets, but this is implemented
|
||||
* in PFont because the Java methods to access this information
|
||||
@@ -978,42 +968,42 @@ public class PFont implements PConstants {
|
||||
* that the seems to have made its way into the Java API after 1.1.
|
||||
*/
|
||||
static public String[] list() {
|
||||
if (PApplet.javaVersion < 1.3f) {
|
||||
// make this reflection too, since compilers complain about the
|
||||
// deprecation, and it's bound to stop working in 1.6 or something
|
||||
//return Toolkit.getDefaultToolkit().getFontList();
|
||||
try {
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
Method getFontListMethod =
|
||||
tk.getClass().getMethod("getFontList", (Class[]) null);
|
||||
return (String[]) getFontListMethod.invoke(tk, (Object[]) null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new String[] { };
|
||||
}
|
||||
}
|
||||
// if (PApplet.javaVersion < 1.3f) {
|
||||
// // make this reflection too, since compilers complain about the
|
||||
// // deprecation, and it's bound to stop working in 1.6 or something
|
||||
// //return Toolkit.getDefaultToolkit().getFontList();
|
||||
// try {
|
||||
// Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
// Method getFontListMethod =
|
||||
// tk.getClass().getMethod("getFontList", (Class[]) null);
|
||||
// return (String[]) getFontListMethod.invoke(tk, (Object[]) null);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// return new String[] { };
|
||||
// }
|
||||
// }
|
||||
|
||||
// getFontList is deprecated in 1.4, so this has to be used
|
||||
try {
|
||||
//GraphicsEnvironment ge =
|
||||
// GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
Class geClass = Class.forName("java.awt.GraphicsEnvironment");
|
||||
Method glgeMethod =
|
||||
geClass.getMethod("getLocalGraphicsEnvironment", (Class[]) null);
|
||||
Object ge = glgeMethod.invoke((Class[]) null, (Object[]) null);
|
||||
//try {
|
||||
GraphicsEnvironment ge =
|
||||
GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||
// Class geClass = Class.forName("java.awt.GraphicsEnvironment");
|
||||
// Method glgeMethod =
|
||||
// geClass.getMethod("getLocalGraphicsEnvironment", (Class[]) null);
|
||||
// Object ge = glgeMethod.invoke((Class[]) null, (Object[]) null);
|
||||
|
||||
//Font fonts[] = ge.getAllFonts();
|
||||
Method gafMethod = geClass.getMethod("getAllFonts", (Class[]) null);
|
||||
Font fonts[] = (Font[]) gafMethod.invoke(ge, (Object[]) null);
|
||||
Font fonts[] = ge.getAllFonts();
|
||||
// Method gafMethod = geClass.getMethod("getAllFonts", (Class[]) null);
|
||||
// Font fonts[] = (Font[]) gafMethod.invoke(ge, (Object[]) null);
|
||||
String list[] = new String[fonts.length];
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
list[i] = fonts[i].getName();
|
||||
}
|
||||
return list;
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Error inside PFont.list()");
|
||||
}
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// throw new RuntimeException("Error inside PFont.list()");
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2294,6 +2294,8 @@ public abstract class PGraphics extends PImage implements PConstants {
|
||||
// as recommended by the @deprecated flag.
|
||||
textFontNativeMetrics =
|
||||
Toolkit.getDefaultToolkit().getFontMetrics(textFontNative);
|
||||
|
||||
// float w = font.getStringBounds(text, g2.getFontRenderContext()).getWidth();
|
||||
}
|
||||
textSize(which.size);
|
||||
|
||||
@@ -2365,8 +2367,6 @@ public abstract class PGraphics extends PImage implements PConstants {
|
||||
"textMode(SCREEN)");
|
||||
}
|
||||
textSize = size;
|
||||
//textLeading = textSize *
|
||||
// ((textFont.ascent() + textFont.descent()) * 1.275f);
|
||||
textLeading = (textAscent() + textDescent()) * 1.275f;
|
||||
|
||||
} else {
|
||||
|
||||
@@ -814,7 +814,7 @@ public class PGraphicsJava2D extends PGraphics {
|
||||
* will get recorded properly.
|
||||
*/
|
||||
public void textSize(float size) {
|
||||
// if a native version available, subset this font
|
||||
// if a native version available, derive this font
|
||||
if (textFontNative != null) {
|
||||
textFontNative = textFontNative.deriveFont(size);
|
||||
g2.setFont(textFontNative);
|
||||
|
||||
+7
-2
@@ -1,8 +1,13 @@
|
||||
0128 core
|
||||
X remove PFont reflection stuff
|
||||
X remove cursor reflection stuff
|
||||
|
||||
X implement sortCompare() and sortSwap()
|
||||
X discuss this with casey
|
||||
_ also could be using Arrays.sort(blah) with Comparable (1.2+)
|
||||
_ make sorting functions static?
|
||||
|
||||
_ fix getFontMetrics() warning
|
||||
_ remove PFont reflection stuff
|
||||
_ remove cursor reflection stuff
|
||||
_ key and mouse events delivered out of order
|
||||
_ http://dev.processing.org/bugs/show_bug.cgi?id=638
|
||||
_ Java2D textLinePlacedImpl should check for ENABLE_NATIVE_FONTS hint
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
0128 pde
|
||||
|
||||
X fix macosx dist script to not require root password
|
||||
X was just a matter of not using sudo to write the image
|
||||
o hdiutil create -size 5m -fs HFS+ -volname Fooble foo
|
||||
o To mount the disk-image, without having it appear in the Finder:
|
||||
o hdiutil attach -nobrowse foo.dmg
|
||||
o The main advantage is that these don't require root privileges
|
||||
X change to jdk14 imports rather than 11 and 12 for preproc
|
||||
X though this will only happen when the prefs file is deleted
|
||||
|
||||
_ change to jdk14 imports rather than 11 and 12 for preproc
|
||||
X implement sortCompare() and sortSwap()
|
||||
X discuss this with casey
|
||||
_ also could be using Arrays.sort(blah) with Comparable (1.2+)
|
||||
_ make sorting functions static?
|
||||
|
||||
_ auto-delete of sketches might be dangerous
|
||||
_ and probably no longer necessary
|
||||
@@ -76,10 +80,7 @@ grant {
|
||||
|
||||
_ remove 'patch' designation from bugzilla
|
||||
_ ocd is broken in 0125 - do a better error message for this
|
||||
X implement sortCompare() and sortSwap()
|
||||
_ discuss this with casey
|
||||
_ also could be using Arrays.sort(blah) with Comparable (1.2+)
|
||||
_ make sorting functions static?
|
||||
|
||||
_ disallow .java tabs with same name as the sketch
|
||||
_ a .java tab with same name as the sketch is allowed (oog!)
|
||||
_ particularly look at "save as" scenario
|
||||
|
||||
Reference in New Issue
Block a user