mirror of
https://github.com/processing/processing4.git
synced 2026-01-26 01:41:06 +01:00
Merge branch 'main' into jssc_fast_forward
This commit is contained in:
13
java/libraries/dxf/processing4-dxf.iml
Normal file
13
java/libraries/dxf/processing4-dxf.iml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<output url="file://$MODULE_DIR$/bin" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="processing4-core" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -233,7 +233,7 @@ public class RawDXF extends PGraphics {
|
||||
public void write(String cmd, float val) {
|
||||
writer.println(cmd);
|
||||
// Don't number format, will cause trouble on systems that aren't en-US
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=495
|
||||
// https://download.processing.org/bugzilla/495.html
|
||||
writer.println(val);
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ public class PWM {
|
||||
}
|
||||
|
||||
// set period
|
||||
String fn = fn = String.format("/sys/class/pwm/%s/pwm%d/period", chip, channel);
|
||||
String fn = String.format("/sys/class/pwm/%s/pwm%d/period", chip, channel);
|
||||
// convert to nanoseconds
|
||||
int ret = NativeInterface.writeFile(fn, String.format("%d", (int)(1000000000 / period)));
|
||||
if (ret < 0) {
|
||||
@@ -200,7 +200,7 @@ public class PWM {
|
||||
}
|
||||
|
||||
// set duty cycle
|
||||
fn = fn = String.format("/sys/class/pwm/%s/pwm%d/duty_cycle", chip, channel);
|
||||
fn = String.format("/sys/class/pwm/%s/pwm%d/duty_cycle", chip, channel);
|
||||
if (duty < 0.0 || 1.0 < duty) {
|
||||
System.err.println("Duty cycle must be between 0.0 and 1.0.");
|
||||
throw new IllegalArgumentException("Illegal argument");
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/adoptopenjdk-11">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="library/macosx/modules/javafx.base.jar"/>
|
||||
<classpathentry kind="lib" path="library/macosx/modules/javafx.controls.jar"/>
|
||||
<classpathentry kind="lib" path="library/macosx/modules/javafx.fxml.jar"/>
|
||||
<classpathentry kind="lib" path="library/macosx/modules/javafx.graphics.jar"/>
|
||||
<classpathentry kind="lib" path="library/macosx/modules/javafx.media.jar"/>
|
||||
<classpathentry kind="lib" path="library/macosx/modules/javafx.swing.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/processing4-core"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
5
java/libraries/javafx/.gitignore
vendored
5
java/libraries/javafx/.gitignore
vendored
@@ -1,5 +0,0 @@
|
||||
# ignore the sdk download files
|
||||
javafx-*-sdk-*.zip
|
||||
|
||||
# everything is downloaded from online
|
||||
/library
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>processing4-javafx</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
@@ -1,15 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
@@ -1,166 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="Processing JavaFX renderer" default="build">
|
||||
|
||||
<!-- Using 'location' here to resolve to an absolute path -->
|
||||
<property name="core.path" location="../../../core/library/core.jar" />
|
||||
<property name="library.path" location="./library" />
|
||||
|
||||
<target name="clean" description="Clean the build directories">
|
||||
<delete dir="bin" />
|
||||
<!-- Remove everything, which includes javafx.jar and files extracted from
|
||||
GluonHQ downloads, but those can be reproduced from the downloaded zips. -->
|
||||
<delete dir="${library.path}" />
|
||||
</target>
|
||||
|
||||
<condition property="fx.unavailable" value="true">
|
||||
<or>
|
||||
<equals arg1="${os.arch}" arg2="arm" />
|
||||
<equals arg1="${os.arch}" arg2="aarch64" />
|
||||
</or>
|
||||
</condition>
|
||||
|
||||
<condition property="jfx.available" value="true">
|
||||
<and>
|
||||
<not><equals arg1="${os.arch}" arg2="arm" /></not>
|
||||
</and>
|
||||
</condition>
|
||||
|
||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||
|
||||
<!--
|
||||
https://gluonhq.com/products/javafx/
|
||||
# use the download file specified by the server
|
||||
wget -\-content-disposition 'https://gluonhq.com/download/javafx-16-sdk-mac'
|
||||
wget -\-content-disposition 'https://gluonhq.com/download/javafx-16-sdk-windows'
|
||||
wget -\-content-disposition 'https://gluonhq.com/download/javafx-16-sdk-linux'
|
||||
|
||||
src (and therefore .jar files?) appear to be identical except for com.sun.javafx.runtime.VersionInfo which has a BUILD_TIMESTAMP variable
|
||||
|
||||
https://gluonhq.com/download/javafx-16-sdk-mac
|
||||
https://gluonhq.com/download/javafx-16-sdk-windows
|
||||
https://gluonhq.com/download/javafx-16-sdk-linux
|
||||
-->
|
||||
|
||||
<!-- JavaFX was removed from the Oracle's JDK for ARM and Java 11.
|
||||
There are arm32 and aarch64 builds for Linux (compatible with the Pi?)
|
||||
but they're Early Access releases of JavaFX 17.
|
||||
Downloads page is at https://gluonhq.com/products/javafx/
|
||||
|
||||
The links for the Apple Silicon and ARM Linux versions:
|
||||
https://gluonhq.com/download/javafx-17-ea-sdk-mac-aarch64
|
||||
https://gluonhq.com/download/javafx-17-ea-sdk-linux-aarch64
|
||||
https://gluonhq.com/download/javafx-17-ea-sdk-linux-arm32
|
||||
|
||||
These could be better than nothing, but it's a different set of .jar files
|
||||
(that would be identical across these three), but different from the main
|
||||
versions. Not a good way to mix, unless have unique JARs for each platform,
|
||||
which would be ~60 MB extra (for platforms that are < 2% usage). -->
|
||||
|
||||
<target name="retrieve-gluon">
|
||||
<get src="https://gluonhq.com/download/${gluon.base}"
|
||||
dest="${gluon.base}.zip"
|
||||
usetimestamp="true" />
|
||||
|
||||
<antcall target="unzip-gluon-jars" />
|
||||
<antcall target="unzip-gluon-natives" />
|
||||
</target>
|
||||
|
||||
<target name="unzip-gluon-jars">
|
||||
<property name="modules.path" value="${platform.path}/modules" />
|
||||
<echo message="Extracting jars from ${gluon.base}.zip to ${modules.path}" />
|
||||
<!-- should javafx.properties be copied? is it used for anything? [fry 210620] -->
|
||||
|
||||
<!-- https://ant.apache.org/manual/Tasks/unzip.html -->
|
||||
<!-- <unzip dest="${library.path}" src="${gluon.base}.zip" overwrite="true"> -->
|
||||
<!-- !#($*#! the builds have *slightly* different classes in each release
|
||||
(WinPlatformFactory not in macOS .jar... FFS it's 1100 bytes of glue code)
|
||||
So the .jar files go into the native subdirectories as well. -->
|
||||
<unzip dest="${modules.path}" src="${gluon.base}.zip" overwrite="true">
|
||||
<patternset>
|
||||
<include name="**/*.jar" />
|
||||
<!-- These two aren't supported/used -->
|
||||
<!-- <exclude name="**/javafx.web.jar" /> -->
|
||||
<exclude name="**/javafx-swt.jar" />
|
||||
</patternset>
|
||||
|
||||
<!-- remove prefixes from folder paths when extracting -->
|
||||
<mapper type="flatten" />
|
||||
</unzip>
|
||||
</target>
|
||||
|
||||
<target name="unzip-gluon-natives">
|
||||
<echo message="Extracting native libs from ${gluon.base}.zip to ${platform.path}" />
|
||||
|
||||
<unzip dest="${platform.path}" src="${gluon.base}.zip" overwrite="true">
|
||||
<patternset>
|
||||
<include name="**/*.dll" />
|
||||
<include name="**/*.dylib" />
|
||||
<include name="**/*.so" />
|
||||
<!-- The webkit library isn't included because this library is massive.
|
||||
Remove libjfxwebkit.dylib, libjfxwebkit.so, jfxwebkit.dll -->
|
||||
<!-- <exclude name="**/*jfxwebkit.*" /> -->
|
||||
|
||||
<!-- Not using this either, but since we're using 'include', no need for it -->
|
||||
<!-- <exclude name="**/src.zip" /> -->
|
||||
</patternset>
|
||||
|
||||
<!-- Ignore folder structure, which also helps because as of 210620,
|
||||
the Windows build has a different folder for the binaries. -->
|
||||
<mapper type="flatten" />
|
||||
</unzip>
|
||||
</target>
|
||||
|
||||
<target name="download-javafx">
|
||||
<property name="gluon.version" value="16" />
|
||||
<!-- current Early Access version, includes support for other architectures -->
|
||||
<!-- <property name="gluon.version" value="17-ea" /> -->
|
||||
|
||||
<!-- http://ant.apache.org/manual/Tasks/tempfile.html -->
|
||||
<!-- <tempfile property="temp.zip" destDir="${java.io.tmpdir}" suffix=".zip" /> -->
|
||||
|
||||
<!-- javafx-${gluon.version}-sdk-${gluon.platform} -->
|
||||
<antcall target="retrieve-gluon">
|
||||
<param name="gluon.base" value="javafx-${gluon.version}-sdk-mac" />
|
||||
<param name="platform.path" value="${library.path}/macosx" />
|
||||
</antcall>
|
||||
|
||||
<antcall target="retrieve-gluon">
|
||||
<param name="gluon.base" value="javafx-${gluon.version}-sdk-windows" />
|
||||
<param name="platform.path" value="${library.path}/windows64" />
|
||||
</antcall>
|
||||
|
||||
<antcall target="retrieve-gluon">
|
||||
<param name="gluon.base" value="javafx-${gluon.version}-sdk-linux" />
|
||||
<param name="platform.path" value="${library.path}/linux64" />
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="download-javafx" description="Compile sources">
|
||||
<condition property="core-built">
|
||||
<available file="${core.path}" />
|
||||
</condition>
|
||||
<fail unless="core-built"
|
||||
message="Please build the core library first: expecting core.jar at ${core.path}" />
|
||||
|
||||
<!-- just pick a platform; any should be sufficient for building -->
|
||||
<property name="javafx.jar.path" value="library/macosx/modules" />
|
||||
|
||||
<mkdir dir="bin" />
|
||||
<javac source="11" target="11"
|
||||
srcdir="src" destdir="bin"
|
||||
encoding="UTF-8"
|
||||
includeAntRuntime="false"
|
||||
classpath="${core.path};
|
||||
${javafx.jar.path}/javafx.base.jar;
|
||||
${javafx.jar.path}/javafx.controls.jar;
|
||||
${javafx.jar.path}/javafx.fxml.jar;
|
||||
${javafx.jar.path}/javafx.graphics.jar;
|
||||
${javafx.jar.path}/javafx.media.jar;
|
||||
${javafx.jar.path}/javafx.swing.jar"
|
||||
nowarn="true" />
|
||||
</target>
|
||||
|
||||
<target name="build" depends="compile" description="Build JavaFX renderer">
|
||||
<jar basedir="bin" destfile="library/javafx.jar" />
|
||||
</target>
|
||||
</project>
|
||||
@@ -1,2 +0,0 @@
|
||||
name = JavaFX
|
||||
version = 1
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
13
java/libraries/net/processing4-net.iml
Normal file
13
java/libraries/net/processing4-net.iml
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<output url="file://$MODULE_DIR$/bin" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="processing4-core" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -29,19 +29,21 @@ import processing.core.*;
|
||||
import java.io.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.net.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
*
|
||||
* A client connects to a server and sends data back and forth. If anything
|
||||
* goes wrong with the connection, for example the host is not there or is
|
||||
*
|
||||
* A client connects to a server and sends data back and forth. If anything
|
||||
* goes wrong with the connection, for example the host is not there or is
|
||||
* listening on a different port, an exception is thrown.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @webBrief The client class is used to create client Objects which connect to a server to exchange data
|
||||
* @instanceName client any variable of type Client
|
||||
* @usage Application
|
||||
* @see_external LIB_net/clientEvent
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public class Client implements Runnable {
|
||||
|
||||
protected static final int MAX_BUFFER_SIZE = 1 << 27; // 128 MB
|
||||
@@ -60,13 +62,13 @@ public class Client implements Runnable {
|
||||
|
||||
final Object bufferLock = new Object[0];
|
||||
|
||||
byte buffer[] = new byte[32768];
|
||||
byte[] buffer = new byte[32768];
|
||||
int bufferIndex;
|
||||
int bufferLast;
|
||||
|
||||
boolean disposeRegistered = false;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
* @param host address of the server
|
||||
@@ -95,14 +97,14 @@ public class Client implements Runnable {
|
||||
clientEventMethod =
|
||||
parent.getClass().getMethod("clientEvent", Client.class);
|
||||
} catch (Exception e) {
|
||||
// no such method, or an error.. which is fine, just ignore
|
||||
// no such method, or an error... which is fine, just ignore
|
||||
}
|
||||
// do the same for disconnectEvent(Client c);
|
||||
try {
|
||||
disconnectEventMethod =
|
||||
parent.getClass().getMethod("disconnectEvent", Client.class);
|
||||
} catch (Exception e) {
|
||||
// no such method, or an error.. which is fine, just ignore
|
||||
// no such method, or an error... which is fine, just ignore
|
||||
}
|
||||
|
||||
} catch (IOException e) {
|
||||
@@ -111,10 +113,9 @@ public class Client implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param socket any object of type Socket
|
||||
* @throws IOException
|
||||
*/
|
||||
public Client(PApplet parent, Socket socket) throws IOException {
|
||||
this.parent = parent;
|
||||
@@ -133,28 +134,28 @@ public class Client implements Runnable {
|
||||
clientEventMethod =
|
||||
parent.getClass().getMethod("clientEvent", Client.class);
|
||||
} catch (Exception e) {
|
||||
// no such method, or an error.. which is fine, just ignore
|
||||
// no such method, or an error... which is fine, just ignore
|
||||
}
|
||||
// do the same for disconnectEvent(Client c);
|
||||
try {
|
||||
disconnectEventMethod =
|
||||
parent.getClass().getMethod("disconnectEvent", Client.class);
|
||||
} catch (Exception e) {
|
||||
// no such method, or an error.. which is fine, just ignore
|
||||
// no such method, or an error... which is fine, just ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Disconnects from the server. Use to shut the connection when you're
|
||||
*
|
||||
* Disconnects from the server. Use to shut the connection when you're
|
||||
* finished with the Client.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @webBrief Disconnects from the server
|
||||
* @usage application
|
||||
*/
|
||||
public void stop() {
|
||||
public void stop() {
|
||||
if (disconnectEventMethod != null && thread != null){
|
||||
try {
|
||||
disconnectEventMethod.invoke(parent, this);
|
||||
@@ -180,7 +181,7 @@ public class Client implements Runnable {
|
||||
* Disconnect from the server: internal use only.
|
||||
* <P>
|
||||
* This should only be called by the internal functions in PApplet,
|
||||
* use stop() instead from within your own applets.
|
||||
* use stop() instead from within your own sketches.
|
||||
*/
|
||||
public void dispose() {
|
||||
thread = null;
|
||||
@@ -201,7 +202,7 @@ public class Client implements Runnable {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if (socket != null) {
|
||||
socket.close();
|
||||
@@ -229,7 +230,7 @@ public class Client implements Runnable {
|
||||
while (input != null) {
|
||||
int readCount;
|
||||
|
||||
// try to read a byte using a blocking read.
|
||||
// try to read a byte using a blocking read.
|
||||
// An exception will occur when the sketch is exits.
|
||||
try {
|
||||
readCount = input.read(readBuffer, 0, readBuffer.length);
|
||||
@@ -239,7 +240,7 @@ public class Client implements Runnable {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// read returns -1 if end-of-stream occurs (for example if the host disappears)
|
||||
if (readCount == -1) {
|
||||
System.err.println("Client got end-of-stream.");
|
||||
@@ -302,10 +303,10 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns <b>true</b> if this client is still active and hasn't run
|
||||
* into any trouble.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @webBrief Returns <b>true</b> if this client is still active
|
||||
* @usage application
|
||||
@@ -316,9 +317,9 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns the IP address of the computer to which the Client is attached.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the IP address of the machine as a <b>String</b>
|
||||
@@ -332,10 +333,10 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the number of bytes available. When any client has bytes
|
||||
*
|
||||
* Returns the number of bytes available. When any client has bytes
|
||||
* available from the server, it returns the number of bytes.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the number of bytes in the buffer waiting to be read
|
||||
@@ -348,9 +349,9 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Empty the buffer, removes all the data stored there.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Clears the buffer
|
||||
@@ -364,11 +365,11 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns a number between 0 and 255 for the next byte that's waiting in
|
||||
* the buffer. Returns -1 if there is no byte, although this should be
|
||||
* avoided by first cheacking <b>available()</b> to see if any data is available.
|
||||
*
|
||||
*
|
||||
* Returns a number between 0 and 255 for the next byte that's waiting in
|
||||
* the buffer. Returns -1 if there is no byte, although this should be
|
||||
* avoided by first checking <b>available()</b> to see if any data is available.
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns a value from the buffer
|
||||
@@ -388,10 +389,10 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the next byte in the buffer as a char. Returns <b>-1</b> or
|
||||
*
|
||||
* Returns the next byte in the buffer as a char. Returns <b>-1</b> or
|
||||
* <b>0xffff</b> if nothing is there.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the next byte in the buffer as a char
|
||||
@@ -405,21 +406,21 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Reads a group of bytes from the buffer. The version with no parameters
|
||||
* returns a byte array of all data in the buffer. This is not efficient,
|
||||
* but is easy to use. The version with the <b>byteBuffer</b> parameter is
|
||||
* more memory and time efficient. It grabs the data in the buffer and puts
|
||||
* it into the byte array passed in and returns an int value for the number
|
||||
* of bytes read. If more bytes are available than can fit into the
|
||||
*
|
||||
* Reads a group of bytes from the buffer. The version with no parameters
|
||||
* returns a byte array of all data in the buffer. This is not efficient,
|
||||
* but is easy to use. The version with the <b>byteBuffer</b> parameter is
|
||||
* more memory and time efficient. It grabs the data in the buffer and puts
|
||||
* it into the byte array passed in and returns an int value for the number
|
||||
* of bytes read. If more bytes are available than can fit into the
|
||||
* <b>byteBuffer</b>, only those that fit are read.
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* Return a byte array of anything that's in the serial buffer.
|
||||
* Not particularly memory/speed efficient, because it creates
|
||||
* a byte array on each read, but it's easier to use than
|
||||
* readBytes(byte b[]) (see below).
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Reads a group of bytes from the buffer
|
||||
@@ -429,7 +430,7 @@ public class Client implements Runnable {
|
||||
if (bufferIndex == bufferLast) return null;
|
||||
|
||||
int length = bufferLast - bufferIndex;
|
||||
byte outgoing[] = new byte[length];
|
||||
byte[] outgoing = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex = 0; // rewind
|
||||
@@ -455,7 +456,7 @@ public class Client implements Runnable {
|
||||
|
||||
int length = bufferLast - bufferIndex;
|
||||
if (length > max) length = max;
|
||||
byte outgoing[] = new byte[length];
|
||||
byte[] outgoing = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex += length;
|
||||
@@ -478,10 +479,10 @@ public class Client implements Runnable {
|
||||
* Returns an int for how many bytes were read. If more bytes
|
||||
* are available than can fit into the byte array, only those
|
||||
* that will fit are read.
|
||||
*
|
||||
*
|
||||
* @param bytebuffer passed in byte array to be altered
|
||||
*/
|
||||
public int readBytes(byte bytebuffer[]) {
|
||||
public int readBytes(byte[] bytebuffer) {
|
||||
synchronized (bufferLock) {
|
||||
if (bufferIndex == bufferLast) return 0;
|
||||
|
||||
@@ -500,18 +501,18 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Reads from the port into a buffer of bytes up to and including a
|
||||
* particular character. If the character isn't in the buffer, 'null' is
|
||||
* returned. The version with no <b>byteBuffer</b> parameter returns a byte
|
||||
* array of all data up to and including the <b>interesting</b> byte. This
|
||||
* is not efficient, but is easy to use. The version with the
|
||||
* <b>byteBuffer</b> parameter is more memory and time efficient. It grabs
|
||||
* the data in the buffer and puts it into the byte array passed in and
|
||||
* returns an int value for the number of bytes read. If the byte buffer is
|
||||
* not large enough, -1 is returned and an error is printed to the message
|
||||
*
|
||||
* Reads from the port into a buffer of bytes up to and including a
|
||||
* particular character. If the character isn't in the buffer, 'null' is
|
||||
* returned. The version with no <b>byteBuffer</b> parameter returns a byte
|
||||
* array of all data up to and including the <b>interesting</b> byte. This
|
||||
* is not efficient, but is easy to use. The version with the
|
||||
* <b>byteBuffer</b> parameter is more memory and time efficient. It grabs
|
||||
* the data in the buffer and puts it into the byte array passed in and
|
||||
* returns an int value for the number of bytes read. If the byte buffer is
|
||||
* not large enough, -1 is returned and an error is printed to the message
|
||||
* area. If nothing is in the buffer, 0 is returned.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Reads from the buffer of bytes up to and including a particular character
|
||||
@@ -533,7 +534,7 @@ public class Client implements Runnable {
|
||||
if (found == -1) return null;
|
||||
|
||||
int length = found - bufferIndex + 1;
|
||||
byte outgoing[] = new byte[length];
|
||||
byte[] outgoing = new byte[length];
|
||||
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
|
||||
|
||||
bufferIndex += length;
|
||||
@@ -556,10 +557,10 @@ public class Client implements Runnable {
|
||||
* and an error message is printed on the console.
|
||||
* If nothing is in the buffer, zero is returned.
|
||||
* If 'interesting' byte is not in the buffer, then 0 is returned.
|
||||
*
|
||||
*
|
||||
* @param byteBuffer passed in byte array to be altered
|
||||
*/
|
||||
public int readBytesUntil(int interesting, byte byteBuffer[]) {
|
||||
public int readBytesUntil(int interesting, byte[] byteBuffer) {
|
||||
byte what = (byte)interesting;
|
||||
|
||||
synchronized (bufferLock) {
|
||||
@@ -595,53 +596,54 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Returns the all the data from the buffer as a <b>String</b>. This method
|
||||
* assumes the incoming characters are ASCII. If you want to transfer
|
||||
* Unicode data, first convert the String to a byte stream in the
|
||||
* representation of your choice (i.e. UTF8 or two-byte Unicode data), and
|
||||
* send it as a byte array.
|
||||
*
|
||||
*
|
||||
* Returns the all the data from the buffer as a <b>String</b>.
|
||||
*
|
||||
* In 4.0 beta 3, changed to using UTF-8 as the encoding,
|
||||
* otherwise the behavior is platform-dependent.
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the buffer as a <b>String</b>
|
||||
*/
|
||||
public String readString() {
|
||||
byte b[] = readBytes();
|
||||
if (b == null) return null;
|
||||
return new String(b);
|
||||
byte[] b = readBytes();
|
||||
if (b == null) {
|
||||
return null;
|
||||
}
|
||||
return new String(b, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns
|
||||
*
|
||||
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns
|
||||
* <b>null</b> if it doesn't find what you're looking for.
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* <p/>
|
||||
* If you want to move Unicode data, you can first convert the
|
||||
* String to a byte stream in the representation of your choice
|
||||
* (i.e. UTF8 or two-byte Unicode data), and send it as a byte array.
|
||||
*
|
||||
* In 4.0 beta 3, changed to using UTF-8 as the encoding,
|
||||
* otherwise the behavior is platform-dependent.
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Returns the buffer as a <b>String</b> up to and including a particular character
|
||||
* @param interesting character designated to mark the end of the data
|
||||
*/
|
||||
public String readStringUntil(int interesting) {
|
||||
byte b[] = readBytesUntil(interesting);
|
||||
if (b == null) return null;
|
||||
return new String(b);
|
||||
byte[] b = readBytesUntil(interesting);
|
||||
if (b == null) {
|
||||
return null;
|
||||
}
|
||||
return new String(b, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Writes data to a server specified when constructing the client, or writes
|
||||
* data to the specific client obtained from the Server <b>available()</b>
|
||||
*
|
||||
* Writes data to a server specified when constructing the client, or writes
|
||||
* data to the specific client obtained from the Server <b>available()</b>
|
||||
* method.
|
||||
*
|
||||
*
|
||||
* @webref client
|
||||
* @usage application
|
||||
* @webBrief Writes <b>bytes</b>, <b>chars</b>, <b>ints</b>, <b>bytes[]</b>, <b>Strings</b>
|
||||
@@ -652,26 +654,19 @@ public class Client implements Runnable {
|
||||
output.write(data & 0xff); // for good measure do the &
|
||||
output.flush(); // hmm, not sure if a good idea
|
||||
|
||||
} catch (Exception e) { // null pointer or serial port dead
|
||||
//errorMessage("write", e);
|
||||
//e.printStackTrace();
|
||||
//dispose();
|
||||
//disconnect(e);
|
||||
} catch (Exception e) { // null pointer or serial port dead
|
||||
e.printStackTrace();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void write(byte data[]) {
|
||||
public void write(byte[] data) {
|
||||
try {
|
||||
output.write(data);
|
||||
output.flush(); // hmm, not sure if a good idea
|
||||
|
||||
} catch (Exception e) { // null pointer or serial port dead
|
||||
//errorMessage("write", e);
|
||||
//e.printStackTrace();
|
||||
//disconnect(e);
|
||||
} catch (Exception e) { // null pointer or serial port dead
|
||||
e.printStackTrace();
|
||||
stop();
|
||||
}
|
||||
@@ -679,42 +674,10 @@ public class Client implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
* <h3>Advanced</h3>
|
||||
* Write a String to the output. Note that this doesn't account
|
||||
* for Unicode (two bytes per char), nor will it send UTF8
|
||||
* characters.. It assumes that you mean to send a byte buffer
|
||||
* (most often the case for networking and serial i/o) and
|
||||
* will only use the bottom 8 bits of each char in the string.
|
||||
* (Meaning that internally it uses String.getBytes)
|
||||
*
|
||||
* If you want to move Unicode data, you can first convert the
|
||||
* String to a byte stream in the representation of your choice
|
||||
* (i.e. UTF8 or two-byte Unicode data), and send it as a byte array.
|
||||
* In 4.0 beta 3, changed to using UTF-8 as the encoding,
|
||||
* otherwise the behavior is platform-dependent.
|
||||
*/
|
||||
public void write(String data) {
|
||||
write(data.getBytes());
|
||||
write(data.getBytes(StandardCharsets.UTF_8));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle disconnect due to an Exception being thrown.
|
||||
*/
|
||||
/*
|
||||
protected void disconnect(Exception e) {
|
||||
dispose();
|
||||
if (e != null) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* General error reporting, all corralled here just in case
|
||||
* I think of something slightly more intelligent to do.
|
||||
*/
|
||||
//public void errorMessage(String where, Exception e) {
|
||||
//parent.die("Error inside Client." + where + "()", e);
|
||||
//e.printStackTrace(System.err);
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -33,17 +33,17 @@ import java.net.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* A server sends and receives data to and from its associated clients
|
||||
* (other programs connected to it). When a server is started, it begins
|
||||
* listening for connections on the port specified by the <b>port</b>
|
||||
* parameter. Computers have many ports for transferring data and some are
|
||||
* commonly used so be sure to not select one of these. For example, web
|
||||
*
|
||||
* A server sends and receives data to and from its associated clients
|
||||
* (other programs connected to it). When a server is started, it begins
|
||||
* listening for connections on the port specified by the <b>port</b>
|
||||
* parameter. Computers have many ports for transferring data and some are
|
||||
* commonly used so be sure to not select one of these. For example, web
|
||||
* servers usually use port 80 and POP mail uses port 110.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @usage application
|
||||
* @webBrief The server class is used to create server objects which send
|
||||
* @webBrief The server class is used to create server objects which send
|
||||
* and receives data to and from its associated clients (other programs connected to it)
|
||||
* @instanceName server any variable of type Server
|
||||
*/
|
||||
@@ -61,7 +61,7 @@ public class Server implements Runnable {
|
||||
/** Array of client objects, useful length is determined by clientCount. */
|
||||
public Client[] clients;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
* @param port port used to transfer data
|
||||
@@ -69,12 +69,12 @@ public class Server implements Runnable {
|
||||
public Server(PApplet parent, int port) {
|
||||
this(parent, port, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param parent typically use "this"
|
||||
* @param port port used to transfer data
|
||||
* @param host when multiple NICs are in use, the ip (or name) to bind from
|
||||
* @param host when multiple NICs are in use, the ip (or name) to bind from
|
||||
*/
|
||||
public Server(PApplet parent, int port, String host) {
|
||||
this.parent = parent;
|
||||
@@ -94,7 +94,7 @@ public class Server implements Runnable {
|
||||
|
||||
parent.registerMethod("dispose", this);
|
||||
|
||||
// reflection to check whether host applet has a call for
|
||||
// reflection to check whether host sketch has a call for
|
||||
// public void serverEvent(Server s, Client c);
|
||||
// which is called when a new guy connects
|
||||
try {
|
||||
@@ -114,9 +114,9 @@ public class Server implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Disconnect a particular client.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @webBrief Disconnect a particular client
|
||||
* @param client the client to disconnect
|
||||
@@ -130,8 +130,8 @@ public class Server implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void removeIndex(int index) {
|
||||
synchronized (clientsLock) {
|
||||
clientCount--;
|
||||
@@ -143,8 +143,8 @@ public class Server implements Runnable {
|
||||
clients[clientCount] = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void disconnectAll() {
|
||||
synchronized (clientsLock) {
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
@@ -158,8 +158,8 @@ public class Server implements Runnable {
|
||||
clientCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected void addClient(Client client) {
|
||||
synchronized (clientsLock) {
|
||||
if (clientCount == clients.length) {
|
||||
@@ -168,8 +168,8 @@ public class Server implements Runnable {
|
||||
clients[clientCount++] = client;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected int clientIndex(Client client) {
|
||||
synchronized (clientsLock) {
|
||||
for (int i = 0; i < clientCount; i++) {
|
||||
@@ -181,20 +181,20 @@ public class Server implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns <b>true</b> if this server is still active and hasn't run
|
||||
* into any trouble.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @webBrief Return <b>true</b> if this server is still active
|
||||
*/
|
||||
public boolean active() {
|
||||
return thread != null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static public String ip() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostAddress();
|
||||
@@ -211,9 +211,9 @@ public class Server implements Runnable {
|
||||
int lastAvailable = -1;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Returns the next client in line with a new message.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @webBrief Returns the next client in line with a new message
|
||||
* @usage application
|
||||
@@ -247,13 +247,13 @@ public class Server implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Disconnects all clients and stops the server.
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* Use this to shut down the server if you finish using it while your applet
|
||||
* is still running. Otherwise, it will be automatically be shut down by the
|
||||
* host PApplet using dispose(), which is identical.
|
||||
* Use this to shut down the server if you finish using it while your sketch
|
||||
* is still running. Otherwise, it will be automatically be shut down by the
|
||||
* host PApplet using dispose(), which is identical.
|
||||
* @webref server
|
||||
* @webBrief Disconnects all clients and stops the server
|
||||
* @usage application
|
||||
@@ -323,10 +323,10 @@ public class Server implements Runnable {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Writes a value to all the connected clients. It sends bytes out from the
|
||||
*
|
||||
* Writes a value to all the connected clients. It sends bytes out from the
|
||||
* Server object.
|
||||
*
|
||||
*
|
||||
* @webref server
|
||||
* @webBrief Writes data to all connected clients
|
||||
* @param data data to write
|
||||
@@ -344,7 +344,7 @@ public class Server implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void write(byte data[]) {
|
||||
synchronized (clientsLock) {
|
||||
@@ -359,7 +359,7 @@ public class Server implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void write(String data) {
|
||||
synchronized (clientsLock) {
|
||||
|
||||
21
java/libraries/pdf/processing4-pdf.iml
Normal file
21
java/libraries/pdf/processing4-pdf.iml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="processing4-core" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/library/itext.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
@@ -167,7 +167,7 @@ public class PGraphicsPDF extends PGraphicsJava2D {
|
||||
vertexCount = 0;
|
||||
|
||||
// Also need to push the matrix since the matrix doesn't reset on each run
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1227
|
||||
// https://download.processing.org/bugzilla/1227.html
|
||||
pushMatrix();
|
||||
}
|
||||
|
||||
@@ -206,7 +206,7 @@ public class PGraphicsPDF extends PGraphicsJava2D {
|
||||
// This won't fix the issue if the same thing happens with
|
||||
// other removable drive devices, but should fix the
|
||||
// initial/problem as cited by the bug report:
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=478
|
||||
// https://download.processing.org/bugzilla/478.html
|
||||
// If not, will need to use the other fileExists() code below.
|
||||
continue;
|
||||
}
|
||||
@@ -246,7 +246,7 @@ public class PGraphicsPDF extends PGraphicsJava2D {
|
||||
/**
|
||||
* Recursive walk to get all subdirectories for font fun.
|
||||
* Patch submitted by Matthias Breuer.
|
||||
* (<a href="http://dev.processing.org/bugs/show_bug.cgi?id=1566">Bug 1566</a>)
|
||||
* (<a href="https://download.processing.org/bugzilla/1566.html">Bug 1566</a>)
|
||||
*/
|
||||
static protected void traverseDir(File folder, DefaultFontMapper mapper) {
|
||||
File[] files = folder.listFiles();
|
||||
@@ -261,10 +261,10 @@ public class PGraphicsPDF extends PGraphicsJava2D {
|
||||
|
||||
// endDraw() needs to be overridden so that the endDraw() from
|
||||
// PGraphicsJava2D is not inherited (it calls loadPixels).
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1169
|
||||
// https://download.processing.org/bugzilla/1169.html
|
||||
public void endDraw() {
|
||||
// Also need to pop the matrix since the matrix doesn't reset on each run
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1227
|
||||
// https://download.processing.org/bugzilla/1227.html
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
This is using a modified version of Java Simple Serial Connector by Alexey Sokolov. See https://github.com/gohai/java-simple-serial-connector for details on the modifications.
|
||||
This is using a modified version of Java Simple Serial Connector by Alexey Sokolov. See https://github.com/gohai/java-simple-serial-connector and https://github.com/sampottinger/jssc for details on the modifications to support Processing.
|
||||
|
||||
To compile the C++ portion of the library on OS X:
|
||||
g++ -shared [or: -dynamiclib?] -arch i386 -arch x86_64 -I/System/Library/Frameworks/IOKit.framework/Versions/A/Headers -I$JAVA_HOME/include -I$JAVA_HOME/include/darwin -framework IOKit -framework CoreFoundation -o libjSSC-2.6.jnilib jssc.cpp
|
||||
|
||||
28
java/libraries/serial/processing4-serial.iml
Normal file
28
java/libraries/serial/processing4-serial.iml
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="EclipseModuleManager">
|
||||
<libelement value="jar://$MODULE_DIR$/library/jssc.jar!/" />
|
||||
<src_description expected_position="0">
|
||||
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
|
||||
</src_description>
|
||||
</component>
|
||||
<component name="NewModuleRootManager">
|
||||
<output url="file://$MODULE_DIR$/bin" />
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library">
|
||||
<library name="jssc.jar">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/library/jssc.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module" module-name="processing4-core" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -34,9 +34,9 @@ import jssc.*;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* Class for sending and receiving data using the serial communication protocol.
|
||||
*
|
||||
*
|
||||
* @webref serial
|
||||
* @webBrief Class for sending and receiving data using the serial communication protocol
|
||||
* @instanceName serial any variable of type Serial
|
||||
@@ -186,7 +186,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Returns the number of bytes available.
|
||||
*
|
||||
*
|
||||
* @generate Serial_available.xml
|
||||
* @webref serial
|
||||
* @webBrief Returns the number of bytes available
|
||||
@@ -212,7 +212,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Sets a specific byte to buffer until before calling <b>serialEvent()</b>.
|
||||
*
|
||||
*
|
||||
* @generate Serial_bufferUntil.xml
|
||||
* @webref serial
|
||||
* @webBrief Sets a specific byte to buffer until before calling <b>serialEvent()</b>
|
||||
@@ -266,7 +266,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Returns last byte received or -1 if there is none available.
|
||||
*
|
||||
*
|
||||
* @generate Serial_last.xml
|
||||
* <h3>Advanced</h3>
|
||||
* Same as read() but returns the very last value received
|
||||
@@ -292,7 +292,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Returns the last byte received as a char or -1 if there is none available.
|
||||
*
|
||||
*
|
||||
* @generate Serial_lastChar.xml
|
||||
* @webref serial
|
||||
* @webBrief Returns the last byte received as a char or -1 if there is none available
|
||||
@@ -304,9 +304,9 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Gets a list of all available serial ports. Use <b>println()</b> to write the
|
||||
* Gets a list of all available serial ports. Use <b>println()</b> to write the
|
||||
* information to the text window.
|
||||
*
|
||||
*
|
||||
* @generate Serial_list.xml
|
||||
* @webref serial
|
||||
* @webBrief Gets a list of all available serial ports
|
||||
@@ -320,10 +320,10 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Returns a number between 0 and 255 for the next byte that's waiting in the buffer.
|
||||
* Returns -1 if there is no byte, although this should be avoided by first cheacking
|
||||
* Returns a number between 0 and 255 for the next byte that's waiting in the buffer.
|
||||
* Returns -1 if there is no byte, although this should be avoided by first cheacking
|
||||
* <b>available()</b> to see if data is available.
|
||||
*
|
||||
*
|
||||
* @generate Serial_read.xml
|
||||
* @webref serial
|
||||
* @webBrief Returns a number between 0 and 255 for the next byte that's waiting in the buffer
|
||||
@@ -346,11 +346,11 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Reads a group of bytes from the buffer or <b>null</b> if there are none available. The version
|
||||
* with no parameters returns a byte array of all data in the buffer. This is not efficient, but
|
||||
* is easy to use. The version with the <b>byteBuffer</b> parameter is more memory and time
|
||||
* efficient. It grabs the data in the buffer and puts it into the byte array passed in and returns
|
||||
* an int value for the number of bytes read. If more bytes are available than can fit into the
|
||||
* Reads a group of bytes from the buffer or <b>null</b> if there are none available. The version
|
||||
* with no parameters returns a byte array of all data in the buffer. This is not efficient, but
|
||||
* is easy to use. The version with the <b>byteBuffer</b> parameter is more memory and time
|
||||
* efficient. It grabs the data in the buffer and puts it into the byte array passed in and returns
|
||||
* an int value for the number of bytes read. If more bytes are available than can fit into the
|
||||
* <b>byteBuffer</b>, only those that fit are read.
|
||||
* @generate Serial_readBytes.xml
|
||||
* @webref serial
|
||||
@@ -370,7 +370,7 @@ public class Serial implements SerialPortEventListener {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* <h3>Advanced</h3>
|
||||
@@ -432,18 +432,18 @@ public class Serial implements SerialPortEventListener {
|
||||
return toCopy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reads from the port into a buffer of bytes up to and including a particular character. If the
|
||||
* character isn't in the buffer, <b>null</b> is returned. The version with without the
|
||||
* <b>byteBuffer</b> parameter returns a byte array of all data up to and including the
|
||||
* <b>interesting</b> byte. This is not efficient, but is easy to use. The version with the
|
||||
* <b>byteBuffer</b> parameter is more memory and time efficient. It grabs the data in the buffer
|
||||
* and puts it into the byte array passed in and returns an int value for the number of bytes read.
|
||||
* If the byte buffer is not large enough, -1 is returned and an error is printed to the message
|
||||
* Reads from the port into a buffer of bytes up to and including a particular character. If the
|
||||
* character isn't in the buffer, <b>null</b> is returned. The version with without the
|
||||
* <b>byteBuffer</b> parameter returns a byte array of all data up to and including the
|
||||
* <b>interesting</b> byte. This is not efficient, but is easy to use. The version with the
|
||||
* <b>byteBuffer</b> parameter is more memory and time efficient. It grabs the data in the buffer
|
||||
* and puts it into the byte array passed in and returns an int value for the number of bytes read.
|
||||
* If the byte buffer is not large enough, -1 is returned and an error is printed to the message
|
||||
* area. If nothing is in the buffer, 0 is returned.
|
||||
*
|
||||
*
|
||||
* @generate Serial_readBytesUntil.xml
|
||||
* @webref serial
|
||||
* @webBrief Reads from the port into a buffer of bytes up to and including a particular character
|
||||
@@ -527,7 +527,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Returns the next byte in the buffer as a char. Returns <b>-1</b> or <b>0xffff</b>
|
||||
* Returns the next byte in the buffer as a char. Returns <b>-1</b> or <b>0xffff</b>
|
||||
* if nothing is there.
|
||||
*
|
||||
* @generate Serial_readChar.xml
|
||||
@@ -541,9 +541,9 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Returns all the data from the buffer as a <b>String</b> or <b>null</b> if there is nothing available.
|
||||
* This method assumes the incoming characters are ASCII. If you want to transfer Unicode data,
|
||||
* first convert the String to a byte stream in the representation of your choice (i.e. UTF8 or
|
||||
* Returns all the data from the buffer as a <b>String</b> or <b>null</b> if there is nothing available.
|
||||
* This method assumes the incoming characters are ASCII. If you want to transfer Unicode data,
|
||||
* first convert the String to a byte stream in the representation of your choice (i.e. UTF8 or
|
||||
* two-byte Unicode data), and send it as a byte array.
|
||||
*
|
||||
* @generate Serial_readString.xml
|
||||
@@ -560,7 +560,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns <b>null</b>
|
||||
* Combination of <b>readBytesUntil()</b> and <b>readString()</b>. Returns <b>null</b>
|
||||
* if it doesn't find what you're looking for.
|
||||
*
|
||||
* @generate Serial_readStringUntil.xml
|
||||
@@ -585,11 +585,11 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
|
||||
/**
|
||||
* Called when data is available. Use one of the <b>read()</b> methods to capture this data.
|
||||
* The <b>serialEvent()</b> can be set with <b>buffer()</b> to only trigger after a certain
|
||||
* number of data elements are read and can be set with <b>bufferUntil()</b> to only trigger
|
||||
* after a specific character is read. The <b>which</b> parameter contains the name of the
|
||||
* port where new data is available, but is only useful when there is more than one serial
|
||||
* Called when data is available. Use one of the <b>read()</b> methods to capture this data.
|
||||
* The <b>serialEvent()</b> can be set with <b>buffer()</b> to only trigger after a certain
|
||||
* number of data elements are read and can be set with <b>bufferUntil()</b> to only trigger
|
||||
* after a specific character is read. The <b>which</b> parameter contains the name of the
|
||||
* port where new data is available, but is only useful when there is more than one serial
|
||||
* connection open and it's necessary to distinguish between the two.
|
||||
*
|
||||
* @generate serialEvent.xml
|
||||
@@ -630,7 +630,7 @@ public class Serial implements SerialPortEventListener {
|
||||
// serialAvailable() does not provide any real benefits over using
|
||||
// available() and read() inside draw - but this function has no
|
||||
// thread-safety issues since it's being invoked during pre in the context
|
||||
// of the Processing applet
|
||||
// of the Processing sketch
|
||||
serialEventMethod.invoke(parent, this);
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error, disabling serialEvent() for "+port.getPortName());
|
||||
@@ -676,7 +676,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Stops data communication on this port. Use to shut the connection when you're finished with the Serial.
|
||||
*
|
||||
*
|
||||
* @generate Serial_stop.xml
|
||||
* @webref serial
|
||||
* @webBrief Stops data communication on this port
|
||||
@@ -723,7 +723,7 @@ public class Serial implements SerialPortEventListener {
|
||||
|
||||
/**
|
||||
* Writes <b>bytes</b>, <b>chars</b>, <b>ints</b>, <b>bytes[]</b>, <b>Strings</b> to the serial port
|
||||
*
|
||||
*
|
||||
* <h3>Advanced</h3>
|
||||
* Write a String to the output. Note that this doesn't account
|
||||
* for Unicode (two bytes per char), nor will it send UTF8
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="lib" path="/Users/fry/coconut/processing4/java/libraries/svg/library/batik-all-1.14.jar"/>
|
||||
<classpathentry kind="lib" path="library/batik.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.launching.macosx.MacOSXType/adoptopenjdk-11">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
|
||||
2
java/libraries/svg/.gitignore
vendored
2
java/libraries/svg/.gitignore
vendored
@@ -1 +1 @@
|
||||
library/batik-all-*.jar
|
||||
library/batik.jar
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<project name="Processing SVG Library" default="build">
|
||||
|
||||
<target name="clean" description="Clean the build directories">
|
||||
<delete dir="bin" />
|
||||
<delete file="library/svg.jar" />
|
||||
</target>
|
||||
<property name="core.library.jar" location="../../../core/library/core.jar" />
|
||||
|
||||
<property name="batik.version" value="1.14" />
|
||||
<!-- the .zip file to be downloaded -->
|
||||
<property name="batik.zip" value="batik-bin-${batik.version}.zip" />
|
||||
<!-- the .jar file that's the actual dependency -->
|
||||
<property name="batik.jar" value="batik-all-${batik.version}.jar" />
|
||||
<!-- the .jar file that we need from the download -->
|
||||
<property name="batik.extract.jar" value="batik-all-${batik.version}.jar" />
|
||||
<!-- the local name of the file that will be used -->
|
||||
<property name="batik.library.jar" location="library/batik.jar" />
|
||||
|
||||
<!-- URL for the version of Batik currently supported by this library. -->
|
||||
<property name="batik.url"
|
||||
@@ -21,8 +20,7 @@
|
||||
<property name="batik.url.backup"
|
||||
value="https://download.processing.org/batik/${batik.zip}" />
|
||||
|
||||
|
||||
<available file="library/${batik.jar}" property="batik.present" />
|
||||
<available file="${batik.library.jar}" property="batik.present" />
|
||||
|
||||
<!-- ok to ignore failed downloads if we at least have a version that's local -->
|
||||
<condition property="batik.ignorable" value="false" else="true">
|
||||
@@ -34,42 +32,52 @@
|
||||
ignoreerrors="${batik.ignorable}"
|
||||
usetimestamp="true" />
|
||||
|
||||
<!-- <property name="zip.prefix" value="batik-${batik.version}/lib/${batik.jar}" /> -->
|
||||
<property name="zip.prefix" value="batik-${batik.version}/lib" />
|
||||
|
||||
<!-- Formerly used batik-awt-util-1.8.jar, batik-dom-1.8.jar, batik-ext-1.8.jar,
|
||||
batik-svggen-1.8.jar, batik-util-1.8.jar, batik-xml-1.8.jar but using
|
||||
the big feller from now on since file size is less important, and there
|
||||
were complaints about some .jar files not being available. -->
|
||||
<unzip src="${batik.zip}" dest="library">
|
||||
<unzip src="${batik.zip}" dest=".">
|
||||
<patternset>
|
||||
<!-- unzip a single jar from the zip.prefix subdirectory in the .zip -->
|
||||
<include name="${zip.prefix}/${batik.jar}"/>
|
||||
<include name="${zip.prefix}/${batik.extract.jar}"/>
|
||||
</patternset>
|
||||
<mapper>
|
||||
<!-- remove the zip.prefix from the path when saving the .jar -->
|
||||
<globmapper from="${zip.prefix}/*" to="*"/>
|
||||
</mapper>
|
||||
</unzip>
|
||||
|
||||
<rename src="${batik.extract.jar}" dest="${batik.library.jar}" />
|
||||
<delete file="${batik.zip}" />
|
||||
</target>
|
||||
|
||||
<target name="compile" depends="download-batik" description="Compile sources">
|
||||
<condition property="core-built">
|
||||
<available file="../../../core/library/core.jar" />
|
||||
<available file="${core.library.jar}" />
|
||||
</condition>
|
||||
<fail unless="core-built" message="Please build the core library first and make sure it sits in ../../../core/library/core.jar" />
|
||||
<fail unless="core-built" message="Please build the core library first and make sure it is located at ${core.library.jar}" />
|
||||
|
||||
<mkdir dir="bin" />
|
||||
<javac source="11" target="11"
|
||||
srcdir="src" destdir="bin"
|
||||
encoding="UTF-8"
|
||||
includeAntRuntime="false"
|
||||
classpath="../../../core/library/core.jar; library/${batik.jar};"
|
||||
classpath="${core.library.jar}; ${batik.library.jar}"
|
||||
nowarn="true" />
|
||||
</target>
|
||||
|
||||
<target name="build" depends="compile" description="Build SVG library">
|
||||
<jar basedir="bin" destfile="library/svg.jar" />
|
||||
</target>
|
||||
|
||||
<target name="clean" description="Clean the build directories">
|
||||
<delete dir="bin" />
|
||||
<delete file="library/svg.jar" />
|
||||
</target>
|
||||
|
||||
<target name="clean-libs" description="Clean the build directories">
|
||||
<delete file="${batik.library.jar}" />
|
||||
</target>
|
||||
</project>
|
||||
|
||||
21
java/libraries/svg/processing4-svg.iml
Normal file
21
java/libraries/svg/processing4-svg.iml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="processing4-core" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/library/batik.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
Part of the Processing project - http://processing.org
|
||||
|
||||
Copyright (c) 2013-2015 The Processing Foundation
|
||||
Copyright (c) 2013-2022 The Processing Foundation
|
||||
Copyright (c) 2012 Ben Fry and Casey Reas
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
@@ -95,14 +95,14 @@ public class PGraphicsSVG extends PGraphicsJava2D {
|
||||
vertexCount = 0;
|
||||
|
||||
// Also need to push the matrix since the matrix doesn't reset on each run
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1227
|
||||
// https://download.processing.org/bugzilla/1227.html
|
||||
pushMatrix();
|
||||
}
|
||||
|
||||
|
||||
public void endDraw() {
|
||||
// Also need to pop the matrix since the matrix doesn't reset on each run
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1227
|
||||
// https://download.processing.org/bugzilla/1227.html
|
||||
popMatrix();
|
||||
|
||||
// Figure out where the output goes. If the sketch is calling setOutput()
|
||||
@@ -126,7 +126,7 @@ public class PGraphicsSVG extends PGraphicsJava2D {
|
||||
|
||||
// This needs to be overridden so that the endDraw() from PGraphicsJava2D
|
||||
// is not inherited (it calls loadPixels).
|
||||
// http://dev.processing.org/bugs/show_bug.cgi?id=1169
|
||||
// https://download.processing.org/bugzilla/1169.html
|
||||
|
||||
// Finally, stream out SVG to the standard output using UTF-8 encoding.
|
||||
boolean useCSS = true; // we want to use CSS style attributes
|
||||
|
||||
Reference in New Issue
Block a user