1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Removing Processing libraries.

This commit is contained in:
David A. Mellis 2009-06-01 20:44:24 +00:00
parent 8b6fb36ace
commit 73d7333ebd
76 changed files with 0 additions and 8391 deletions

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>dxf</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>

View File

@ -1,7 +0,0 @@
#Mon Jul 17 23:18:59 EDT 2006
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
org.eclipse.jdt.core.compiler.compliance=1.3
org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
org.eclipse.jdt.core.compiler.source=1.3

Binary file not shown.

View File

@ -1,2 +0,0 @@
dxf.jar

View File

@ -1,393 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
* RawDXF - Code to write DXF files with beginRaw/endRaw
* An extension for the Processing project - http://processing.org
* <p/>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* <p/>
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* <p/>
* You should have received a copy of the GNU Lesser General
* Public License along with the Processing project; if not,
* write to the Free Software Foundation, Inc., 59 Temple Place,
* Suite 330, Boston, MA 02111-1307 USA
*/
package processing.dxf;
import java.io.*;
import processing.core.*;
/**
* A simple library to write DXF files with Processing.
* Because this is used with beginRaw() and endRaw(), only individual
* triangles and (discontinuous) line segments will be written to the file.
* <P/>
* Use something like a keyPressed() in PApplet to trigger it,
* to avoid writing a bazillion .dxf files.
* <P/>
* Usually, the file will be saved to the sketch's folder.
* Use Sketch &rarr; Show Sketch Folder to see it from the PDE.
* <p/>
* A simple example of how to use:
* <PRE>
* import processing.dxf.*;
*
* boolean record;
*
* void setup() {
* size(500, 500, P3D);
* }
*
* void keyPressed() {
* // use a key press so that it doesn't make a million files
* if (key == 'r') record = true;
* }
*
* void draw() {
* if (record) {
* beginRaw(DXF, "output.dxf");
* }
*
* // do all your drawing here
*
* if (record) {
* endRaw();
* record = false;
* }
* }
* </PRE>
* or to use it and be able to control the current layer:
* <PRE>
* import processing.dxf.*;
*
* boolean record;
* RawDXF dxf;
*
* void setup() {
* size(500, 500, P3D);
* }
*
* void keyPressed() {
* // use a key press so that it doesn't make a million files
* if (key == 'r') record = true;
* }
*
* void draw() {
* if (record) {
* dxf = (RawDXF) createGraphics(width, height, DXF, "output.dxf");
* beginRaw(dxf);
* }
*
* // do all your drawing here, and to set the layer, call:
* // if (record) {
* // dxf.setLayer(num);
* // }
* // where 'num' is an integer.
* // the default is zero, or you can set it to whatever.
*
* if (record) {
* endRaw();
* record = false;
* dxf = null;
* }
* }
* </PRE>
* Note that even though this class is a subclass of PGraphics, it only
* implements the parts of the API that are necessary for beginRaw/endRaw.
* <P/>
* Based on the original DXF writer from Simon Greenwold, February 2004.
* Updated for Processing 0070 by Ben Fry in September 2004,
* and again for Processing beta in April 2005.
* Rewritten to support beginRaw/endRaw by Ben Fry in February 2006.
* Updated again for inclusion as a core library in March 2006.
* Constructor modifications in September 2008 as we approach 1.0.
*/
public class RawDXF extends PGraphics3D {
File file;
PrintWriter writer;
int currentLayer;
public RawDXF() { }
public void setPath(String path) {
this.path = path;
if (path != null) {
file = new File(path);
if (!file.isAbsolute()) file = null;
}
if (file == null) {
throw new RuntimeException("PGraphicsPDF requires an absolute path " +
"for the location of the output file.");
}
}
// ..............................................................
protected void allocate() {
/*
for (int i = 0; i < MAX_TRI_LAYERS; i++) {
layerList[i] = NO_LAYER;
}
*/
setLayer(0);
}
public void dispose() {
writeFooter();
writer.flush();
writer.close();
writer = null;
}
public boolean displayable() {
return false; // just in case someone wants to use this on its own
}
// ..............................................................
public void beginDraw() {
// have to create file object here, because the name isn't yet
// available in allocate()
if (writer == null) {
try {
writer = new PrintWriter(new FileWriter(file));
} catch (IOException e) {
throw new RuntimeException(e); // java 1.4+
}
writeHeader();
}
}
public void endDraw() {
// nothing done here
}
// ..............................................................
/**
* Set the current layer being used in the DXF file.
* The default is zero.
*/
public void setLayer(int layer) {
currentLayer = layer;
}
// ..............................................................
private void writeHeader() {
writer.println("0");
writer.println("SECTION");
writer.println("2");
writer.println("ENTITIES");
}
private void writeFooter() {
writer.println("0");
writer.println("ENDSEC");
writer.println("0");
writer.println("EOF");
}
/**
* Write a command on one line (as a String), then start a new line
* and write out a formatted float. Available for anyone who wants to
* insert additional commands into the DXF stream.
*/
public void write(String cmd, float val) {
writer.println(cmd);
// don't format, will cause trouble on systems that aren't en-us
// http://dev.processing.org/bugs/show_bug.cgi?id=495
writer.println(val);
}
/**
* Write a line to the dxf file. Available for anyone who wants to
* insert additional commands into the DXF stream.
*/
public void println(String what) {
writer.println(what);
}
protected void writeLine(int index1, int index2) {
writer.println("0");
writer.println("LINE");
// write out the layer
writer.println("8");
writer.println(String.valueOf(currentLayer));
write("10", vertices[index1][X]);
write("20", vertices[index1][Y]);
write("30", vertices[index1][Z]);
write("11", vertices[index2][X]);
write("21", vertices[index2][Y]);
write("31", vertices[index2][Z]);
}
/*
protected void writeLineStrip() {
writeLine();
// shift the last vertex to be the first vertex
System.arraycopy(vertices[1], 0, vertices[0], 0, vertices[1].length);
vertexCount = 1;
}
*/
protected void writeTriangle() {
writer.println("0");
writer.println("3DFACE");
// write out the layer
writer.println("8");
/*
if (i < MAX_TRI_LAYERS) {
if (layerList[i] >= 0) {
currentLayer = layerList[i];
}
}
*/
writer.println(String.valueOf(currentLayer));
write("10", vertices[0][X]);
write("20", vertices[0][Y]);
write("30", vertices[0][Z]);
write("11", vertices[1][X]);
write("21", vertices[1][Y]);
write("31", vertices[1][Z]);
write("12", vertices[2][X]);
write("22", vertices[2][Y]);
write("32", vertices[2][Z]);
// without adding EPSILON, rhino kinda freaks out
// a face is actually a quad, not a triangle,
// so instead kinda fudging the final point here.
write("13", vertices[2][X] + EPSILON);
write("23", vertices[2][Y] + EPSILON);
write("33", vertices[2][Z] + EPSILON);
vertexCount = 0;
}
// ..............................................................
public void beginShape(int kind) {
shape = kind;
if ((shape != LINES) &&
(shape != TRIANGLES) &&
(shape != POLYGON)) {
String err =
"RawDXF can only be used with beginRaw(), " +
"because it only supports lines and triangles";
throw new RuntimeException(err);
}
if ((shape == POLYGON) && fill) {
throw new RuntimeException("RawDXF only supports non-filled shapes.");
}
vertexCount = 0;
}
public void vertex(float x, float y) {
vertex(x, y, 0);
}
public void vertex(float x, float y, float z) {
float vertex[] = vertices[vertexCount];
vertex[X] = x; // note: not mx, my, mz like PGraphics3
vertex[Y] = y;
vertex[Z] = z;
if (fill) {
vertex[R] = fillR;
vertex[G] = fillG;
vertex[B] = fillB;
vertex[A] = fillA;
}
if (stroke) {
vertex[SR] = strokeR;
vertex[SG] = strokeG;
vertex[SB] = strokeB;
vertex[SA] = strokeA;
vertex[SW] = strokeWeight;
}
if (textureImage != null) { // for the future?
vertex[U] = textureU;
vertex[V] = textureV;
}
vertexCount++;
if ((shape == LINES) && (vertexCount == 2)) {
writeLine(0, 1);
vertexCount = 0;
/*
} else if ((shape == LINE_STRIP) && (vertexCount == 2)) {
writeLineStrip();
*/
} else if ((shape == TRIANGLES) && (vertexCount == 3)) {
writeTriangle();
}
}
public void endShape(int mode) {
if (shape == POLYGON) {
for (int i = 0; i < vertexCount - 1; i++) {
writeLine(i, i+1);
}
if (mode == CLOSE) {
writeLine(vertexCount - 1, 0);
}
}
/*
if ((vertexCount != 0) &&
((shape != LINE_STRIP) && (vertexCount != 1))) {
System.err.println("Extra vertex boogers found.");
}
*/
}
}

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>net</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>

View File

@ -1,263 +0,0 @@
#Mon May 05 22:36:11 EDT 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
org.eclipse.jdt.core.compiler.compliance=1.3
org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
org.eclipse.jdt.core.compiler.source=1.3
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=36
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=80
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=2
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=80
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true

View File

@ -1,4 +0,0 @@
#Tue Feb 19 14:23:49 EST 2008
eclipse.preferences.version=1
formatter_profile=_fry
formatter_settings_version=11

View File

@ -1 +0,0 @@
net.jar

View File

@ -1,493 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Client - basic network client implementation
Part of the Processing project - http://processing.org
Copyright (c) 2004-2007 Ben Fry and Casey Reas
The previous version of this code was developed by Hernando Barragan
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.net;
import processing.core.*;
import java.io.*;
import java.lang.reflect.*;
import java.net.*;
public class Client implements Runnable {
PApplet parent;
Method clientEventMethod;
Method disconnectEventMethod;
Thread thread;
Socket socket;
String ip;
int port;
String host;
public InputStream input;
public OutputStream output;
byte buffer[] = new byte[32768];
int bufferIndex;
int bufferLast;
public Client(PApplet parent, String host, int port) {
this.parent = parent;
this.host = host;
this.port = port;
try {
socket = new Socket(this.host, this.port);
input = socket.getInputStream();
output = socket.getOutputStream();
thread = new Thread(this);
thread.start();
parent.registerDispose(this);
// reflection to check whether host applet has a call for
// public void clientEvent(processing.net.Client)
// which would be called each time an event comes in
try {
clientEventMethod =
parent.getClass().getMethod("clientEvent",
new Class[] { Client.class });
} catch (Exception e) {
// no such method, or an error.. which is fine, just ignore
}
// do the same for disconnectEvent(Client c);
try {
disconnectEventMethod =
parent.getClass().getMethod("disconnectEvent",
new Class[] { Client.class });
} catch (Exception e) {
// no such method, or an error.. which is fine, just ignore
}
} catch (ConnectException ce) {
ce.printStackTrace();
dispose();
} catch (IOException e) {
e.printStackTrace();
dispose();
}
}
public Client(PApplet parent, Socket socket) throws IOException {
this.socket = socket;
input = socket.getInputStream();
output = socket.getOutputStream();
thread = new Thread(this);
thread.start();
}
/**
* Disconnect from the server and calls disconnectEvent(Client c)
* in the host PApplet.
* <P/>
* Use this to shut the connection if you're finished with it
* while your applet is still running. Otherwise, it will be
* automatically be shut down by the host PApplet
* (using dispose, which is identical)
*/
public void stop() {
dispose();
if (disconnectEventMethod != null) {
try {
disconnectEventMethod.invoke(parent, new Object[] { this });
} catch (Exception e) {
e.printStackTrace();
disconnectEventMethod = null;
}
}
}
/**
* 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.
*/
public void dispose() {
thread = null;
try {
// do io streams need to be closed first?
if (input != null) input.close();
if (output != null) output.close();
} catch (Exception e) {
e.printStackTrace();
}
input = null;
output = null;
try {
if (socket != null) socket.close();
} catch (Exception e) {
e.printStackTrace();
}
socket = null;
}
public void run() {
while (Thread.currentThread() == thread) {
try {
while ((input != null) &&
(input.available() > 0)) { // this will block
synchronized (buffer) {
if (bufferLast == buffer.length) {
byte temp[] = new byte[bufferLast << 1];
System.arraycopy(buffer, 0, temp, 0, bufferLast);
buffer = temp;
}
buffer[bufferLast++] = (byte) input.read();
}
}
// now post an event
if (clientEventMethod != null) {
try {
clientEventMethod.invoke(parent, new Object[] { this });
} catch (Exception e) {
System.err.println("error, disabling clientEvent() for " + host);
e.printStackTrace();
clientEventMethod = null;
}
}
try {
// uhh.. not sure what's best here.. since blocking,
// do we need to worry about sleeping much? or is this
// gonna try to slurp cpu away from the main applet?
Thread.sleep(10);
} catch (InterruptedException ex) { }
} catch (IOException e) {
//errorMessage("run", e);
e.printStackTrace();
}
}
}
/**
* Return true if this client is still active and hasn't run
* into any trouble.
*/
public boolean active() {
return (thread != null);
}
/**
* Returns the ip address of this feller as a String.
*/
public String ip() {
return socket.getInetAddress().getHostAddress();
}
/**
* Returns the number of bytes that have been read from serial
* and are waiting to be dealt with by the user.
*/
public int available() {
return (bufferLast - bufferIndex);
}
/**
* Ignore all the bytes read so far and empty the buffer.
*/
public void clear() {
bufferLast = 0;
bufferIndex = 0;
}
/**
* Returns a number between 0 and 255 for the next byte that's
* waiting in the buffer.
* Returns -1 if there was no byte (although the user should
* first check available() to see if things are ready to avoid this)
*/
public int read() {
if (bufferIndex == bufferLast) return -1;
synchronized (buffer) {
int outgoing = buffer[bufferIndex++] & 0xff;
if (bufferIndex == bufferLast) { // rewind
bufferIndex = 0;
bufferLast = 0;
}
return outgoing;
}
}
/**
* Returns the next byte in the buffer as a char.
* Returns -1, or 0xffff, if nothing is there.
*/
public char readChar() {
if (bufferIndex == bufferLast) return (char)(-1);
return (char) read();
}
/**
* 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).
*/
public byte[] readBytes() {
if (bufferIndex == bufferLast) return null;
synchronized (buffer) {
int length = bufferLast - bufferIndex;
byte outgoing[] = new byte[length];
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
bufferIndex = 0; // rewind
bufferLast = 0;
return outgoing;
}
}
/**
* Grab whatever is in the serial buffer, and stuff it into a
* byte buffer passed in by the user. This is more memory/time
* efficient than readBytes() returning a byte[] array.
*
* 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.
*/
public int readBytes(byte outgoing[]) {
if (bufferIndex == bufferLast) return 0;
synchronized (buffer) {
int length = bufferLast - bufferIndex;
if (length > outgoing.length) length = outgoing.length;
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
bufferIndex += length;
if (bufferIndex == bufferLast) {
bufferIndex = 0; // rewind
bufferLast = 0;
}
return length;
}
}
/**
* Reads from the serial port into a buffer of bytes up to and
* including a particular character. If the character isn't in
* the serial buffer, then 'null' is returned.
*/
public byte[] readBytesUntil(int interesting) {
if (bufferIndex == bufferLast) return null;
byte what = (byte)interesting;
synchronized (buffer) {
int found = -1;
for (int k = bufferIndex; k < bufferLast; k++) {
if (buffer[k] == what) {
found = k;
break;
}
}
if (found == -1) return null;
int length = found - bufferIndex + 1;
byte outgoing[] = new byte[length];
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
bufferIndex += length;
if (bufferIndex == bufferLast) {
bufferIndex = 0; // rewind
bufferLast = 0;
}
return outgoing;
}
}
/**
* Reads from the serial port into a buffer of bytes until a
* particular character. If the character isn't in the serial
* buffer, then 'null' is returned.
*
* If outgoing[] is not big enough, then -1 is returned,
* 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.
*/
public int readBytesUntil(int interesting, byte outgoing[]) {
if (bufferIndex == bufferLast) return 0;
byte what = (byte)interesting;
synchronized (buffer) {
int found = -1;
for (int k = bufferIndex; k < bufferLast; k++) {
if (buffer[k] == what) {
found = k;
break;
}
}
if (found == -1) return 0;
int length = found - bufferIndex + 1;
if (length > outgoing.length) {
System.err.println("readBytesUntil() byte buffer is" +
" too small for the " + length +
" bytes up to and including char " + interesting);
return -1;
}
//byte outgoing[] = new byte[length];
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
bufferIndex += length;
if (bufferIndex == bufferLast) {
bufferIndex = 0; // rewind
bufferLast = 0;
}
return length;
}
}
/**
* Return whatever has been read from the serial port so far
* as a String. It assumes that the incoming characters are ASCII.
*
* 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.
*/
public String readString() {
if (bufferIndex == bufferLast) return null;
return new String(readBytes());
}
/**
* Combination of readBytesUntil and readString. See caveats in
* each function. Returns null if it still hasn't found what
* you're looking for.
* <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.
*/
public String readStringUntil(int interesting) {
byte b[] = readBytesUntil(interesting);
if (b == null) return null;
return new String(b);
}
/**
* This will handle ints, bytes and chars transparently.
*/
public void write(int what) { // will also cover char
try {
output.write(what & 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);
e.printStackTrace();
stop();
}
}
public void write(byte bytes[]) {
try {
output.write(bytes);
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);
e.printStackTrace();
stop();
}
}
/**
* 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.
*/
public void write(String what) {
write(what.getBytes());
}
/**
* Handle disconnect due to an Exception being thrown.
*/
/*
protected void disconnect(Exception e) {
dispose();
if (e != null) {
e.printStackTrace();
}
}
*/
/**
* General error reporting, all corraled 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);
//}
}

View File

@ -1,279 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Server - basic network server implementation
Part of the Processing project - http://processing.org
Copyright (c) 2004-2007 Ben Fry and Casey Reas
The previous version of this code was developed by Hernando Barragan
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.net;
import processing.core.*;
import java.io.*;
import java.lang.reflect.*;
import java.net.*;
public class Server implements Runnable {
PApplet parent;
Method serverEventMethod;
Thread thread;
ServerSocket server;
int port;
/** Number of clients currently connected. */
public int clientCount;
/** Array of client objects, useful length is determined by clientCount. */
public Client[] clients;
public Server(PApplet parent, int port) {
this.parent = parent;
this.port = port;
try {
server = new ServerSocket(this.port);
//clients = new Vector();
clients = new Client[10];
thread = new Thread(this);
thread.start();
parent.registerDispose(this);
// reflection to check whether host applet has a call for
// public void serverEvent(Server s, Client c);
// which is called when a new guy connects
try {
serverEventMethod =
parent.getClass().getMethod("serverEvent",
new Class[] { Server.class,
Client.class });
} catch (Exception e) {
// no such method, or an error.. which is fine, just ignore
}
} catch (IOException e) {
e.printStackTrace();
thread = null;
//errorMessage("<init>", e);
}
}
/**
* Disconnect a particular client.
*/
public void disconnect(Client client) {
//client.stop();
client.dispose();
int index = clientIndex(client);
if (index != -1) {
removeIndex(index);
}
}
protected void removeIndex(int index) {
clientCount--;
// shift down the remaining clients
for (int i = index; i < clientCount; i++) {
clients[i] = clients[i+1];
}
// mark last empty var for garbage collection
clients[clientCount] = null;
}
protected void addClient(Client client) {
if (clientCount == clients.length) {
clients = (Client[]) PApplet.expand(clients);
}
clients[clientCount++] = client;
}
protected int clientIndex(Client client) {
for (int i = 0; i < clientCount; i++) {
if (clients[i] == client) {
return i;
}
}
return -1;
}
// the last index used for available. can't just cycle through
// the clients in order from 0 each time, because if client 0 won't
// shut up, then the rest of the clients will never be heard from.
int lastAvailable = -1;
/**
* Returns the next client in line that has something to say.
*/
public Client available() {
synchronized (clients) {
int index = lastAvailable + 1;
if (index >= clientCount) index = 0;
for (int i = 0; i < clientCount; i++) {
int which = (index + i) % clientCount;
Client client = clients[which];
if (client.available() > 0) {
lastAvailable = which;
return client;
}
}
}
return null;
}
/**
* Disconnect all clients and stop the server.
* <p/>
* 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.
*/
public void stop() {
dispose();
}
/**
* Disconnect all clients and stop the server: internal use only.
*/
public void dispose() {
try {
thread = null;
if (clients != null) {
for (int i = 0; i < clientCount; i++) {
disconnect(clients[i]);
}
clientCount = 0;
clients = null;
}
if (server != null) {
server.close();
server = null;
}
} catch (IOException e) {
e.printStackTrace();
//errorMessage("stop", e);
}
}
public void run() {
while (Thread.currentThread() == thread) {
try {
Socket socket = server.accept();
Client client = new Client(parent, socket);
synchronized (clients) {
addClient(client);
if (serverEventMethod != null) {
try {
serverEventMethod.invoke(parent, new Object[] { this, client });
} catch (Exception e) {
System.err.println("Disabling serverEvent() for port " + port);
e.printStackTrace();
serverEventMethod = null;
}
}
}
} catch (IOException e) {
//errorMessage("run", e);
e.printStackTrace();
thread = null;
}
try {
Thread.sleep(8);
} catch (InterruptedException ex) { }
}
}
/**
* Write a value to all the connected clients.
* See Client.write() for operational details.
*/
public void write(int what) { // will also cover char
int index = 0;
while (index < clientCount) {
clients[index].write(what);
if (clients[index].active()) {
index++;
} else {
removeIndex(index);
}
}
}
/**
* Write a byte array to all the connected clients.
* See Client.write() for operational details.
*/
public void write(byte what[]) {
int index = 0;
while (index < clientCount) {
clients[index].write(what);
if (clients[index].active()) {
index++;
} else {
removeIndex(index);
}
}
}
/**
* Write a String to all the connected clients.
* See Client.write() for operational details.
*/
public void write(String what) {
int index = 0;
while (index < clientCount) {
clients[index].write(what);
if (clients[index].active()) {
index++;
} else {
removeIndex(index);
}
}
}
/**
* General error reporting, all corraled here just in case
* I think of something slightly more intelligent to do.
*/
// public void errorMessage(String where, Exception e) {
// parent.die("Error inside Server." + where + "()", e);
// //System.err.println("Error inside Server." + where + "()");
// //e.printStackTrace(System.err);
// }
}

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry kind="lib" path="library/jogl.jar" sourcepath="jogl-src.zip">
<attributes>
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="opengl/library"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="library/gluegen-rt.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>opengl</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>

View File

@ -1,263 +0,0 @@
#Mon May 05 22:36:11 EDT 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
org.eclipse.jdt.core.compiler.compliance=1.4
org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
org.eclipse.jdt.core.compiler.source=1.3
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=36
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=80
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=2
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=80
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true

View File

@ -1,4 +0,0 @@
#Thu Jan 10 10:50:38 PST 2008
eclipse.preferences.version=1
formatter_profile=_fry
formatter_settings_version=11

Binary file not shown.

View File

@ -1,13 +0,0 @@
# If you want to support more platforms, see the jogl.dev.java.net to get the
# natives libraries for the platform in question (i.e. solaris). Then, add it
# them to the applet line for export. For applications, you'll have to make the
# changes by hand, i.e. use the linux version of the export, and modify its
# contents to include the necessary files for your platform.
application.macosx = opengl.jar, jogl.jar, libjogl.jnilib, libjogl_awt.jnilib, libjogl_cg.jnilib, gluegen-rt.jar, libgluegen-rt.jnilib
application.windows = opengl.jar, jogl.jar, jogl.dll, jogl_awt.dll, jogl_cg.dll, gluegen-rt.jar, gluegen-rt.dll
application.linux = opengl.jar, jogl.jar, gluegen-rt.jar, libjogl.so, libjogl_awt.so, libjogl_cg.so, libgluegen-rt.so
applet = opengl.jar, jogl.jar, jogl.jar.pack.gz, jogl-natives-linux-i586.jar, jogl-natives-linux-amd64.jar, jogl-natives-macosx-ppc.jar, jogl-natives-macosx-universal.jar, jogl-natives-windows-i586.jar, jogl-natives-windows-amd64.jar, gluegen-rt.jar, gluegen-rt.jar.pack.gz, gluegen-rt-natives-linux-amd64.jar, gluegen-rt-natives-windows-amd64.jar, gluegen-rt-natives-linux-i586.jar, gluegen-rt-natives-windows-i586.jar, gluegen-rt-natives-macosx-ppc.jar, gluegen-rt-natives-macosx-universal.jar

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,3027 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-08 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.opengl;
import processing.core.*;
import java.awt.*;
import java.awt.font.*;
import java.awt.geom.*;
import java.nio.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
import com.sun.opengl.util.*;
/**
* Implementation of the PGraphics API that employs OpenGL rendering via JOGL.
* <p/>
* JOGL requires Java 1.4 or higher, so there are no restrictions on this
* code to be compatible with Java 1.1 or Java 1.3.
* <p/>
* This code relies on PGraphics3D for all lighting and transformations.
* Meaning that translate(), rotate(), and any lighting will be done in
* PGraphics3D, and OpenGL is only used to blit lines and triangles as fast
* as it possibly can.
* <p/>
* For this reason, OpenGL may not be accelerated as far as it could be,
* but I don't have the time to maintain two separate versions of the
* renderer. My development time must always be focused on implementation
* and covering features first, and optimizing later.
* <p/>
* Further, the difference may be negligible, as the primary slowdown
* in Java is moving pixels (i.e. a large frame buffer is nearly impossible
* because Java just can't do a MemoryImageSource at screen resolution)
* and the overhead from JNI tends to be significant. In the latter case,
* we may even save time in some cases where a large number of calls to
* OpenGL would otherwise be used, but that's probably a stretch.
* <p/>
* The code is also very messy, while features are being added and
* removed rapidly as we head towards 1.0. Things got particularly ugly
* as we approached beta while both Simon and I were working on it.
* Relax, we'll get it fixed up later.
* <p/>
* When exporting applets, the JOGL Applet Launcher is used. More information
* about the launcher can be found at its <A HREF="http://download.java.net/media/jogl/builds/nightly/javadoc_public/com/sun/opengl/util/JOGLAppletLauncher.html">documentation page</A>.
*/
public class PGraphicsOpenGL extends PGraphics3D {
protected GLDrawable drawable; // the rendering 'surface'
protected GLContext context; // the rendering context (holds rendering state info)
public GL gl;
public GLU glu;
//public GLCanvas canvas;
//protected FloatBuffer projectionFloatBuffer;
protected float[] projectionFloats;
protected GLUtessellator tobj;
protected TessCallback tessCallback;
/// Buffer to hold light values before they're sent to OpenGL
//protected FloatBuffer lightBuffer;
protected float[] lightArray = new float[] { 1, 1, 1 };
static int maxTextureSize;
int[] textureDeleteQueue = new int[10];
int textureDeleteQueueCount = 0;
/// Used to hold color values to be sent to OpenGL
//protected FloatBuffer colorBuffer;
protected float[] colorBuffer;
/// Used to store empty values to be passed when a light has no ambient value
protected FloatBuffer zeroBuffer;
/// IntBuffer to go with the pixels[] array
protected IntBuffer pixelBuffer;
/**
* Set to true if the host system is big endian (PowerPC, MIPS, SPARC),
* false if little endian (x86 Intel for Mac or PC).
*/
static public boolean BIG_ENDIAN =
ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN;
public PGraphicsOpenGL() {
glu = new GLU();
tobj = glu.gluNewTess();
// unfortunately glu.gluDeleteTess(tobj); is never called
//glu.gluTessProperty(tobj, GLU.GLU_TESS_WINDING_RULE,
// GLU.GLU_TESS_WINDING_NONZERO);
//glu.gluTessProperty(tobj, GLU.GLU_TESS_WINDING_RULE,
// GLU.GLU_TESS_WINDING_POSITIVE);
//GLU.GLU_TESS_WINDING_ODD);
//glu.gluTessProperty(tobj, GLU.GLU_TESS_BOUNDARY_ONLY,
// GL.GL_TRUE);
tessCallback = new TessCallback();
glu.gluTessCallback(tobj, GLU.GLU_TESS_BEGIN, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_END, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_VERTEX, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_COMBINE, tessCallback);
glu.gluTessCallback(tobj, GLU.GLU_TESS_ERROR, tessCallback);
// lightBuffer = BufferUtil.newFloatBuffer(4);
// lightBuffer.put(3, 1.0f);
// lightBuffer.rewind();
}
//public void setParent(PApplet parent) // PGraphics
//public void setPrimary(boolean primary) // PGraphics
//public void setPath(String path) // PGraphics
//public void setSize(int iwidth, int iheight) // PGraphics3D
/**
* Called by resize(), this handles creating the actual GLCanvas the
* first time around, or simply resizing it on subsequent calls.
* There is no pixel array to allocate for an OpenGL canvas
* because OpenGL's pixel buffer is all handled internally.
*/
protected void allocate() {
if (context == null) {
// System.out.println("PGraphicsOpenGL.allocate() for " + width + " " + height);
// new Exception().printStackTrace(System.out);
// If OpenGL 2X or 4X smoothing is enabled, setup caps object for them
GLCapabilities capabilities = new GLCapabilities();
// Starting in release 0158, OpenGL smoothing is always enabled
if (!hints[DISABLE_OPENGL_2X_SMOOTH]) {
capabilities.setSampleBuffers(true);
capabilities.setNumSamples(2);
} else if (hints[ENABLE_OPENGL_4X_SMOOTH]) {
capabilities.setSampleBuffers(true);
capabilities.setNumSamples(4);
}
// get a rendering surface and a context for this canvas
GLDrawableFactory factory = GLDrawableFactory.getFactory();
/*
if (PApplet.platform == PConstants.LINUX) {
GraphicsConfiguration pconfig = parent.getGraphicsConfiguration();
System.out.println("parent config is " + pconfig);
// GraphicsDevice device = config.getDevice();
//AbstractGraphicsDevice agd = new AbstractGraphicsDevice(device);
//AbstractGraphicsConfiguration agc = factory.chooseGraphicsConfiguration(capabilities, null, null);
AWTGraphicsConfiguration agc = (AWTGraphicsConfiguration)
factory.chooseGraphicsConfiguration(capabilities, null, null);
GraphicsConfiguration config = agc.getGraphicsConfiguration();
System.out.println("agc config is " + config);
}
*/
drawable = factory.getGLDrawable(parent, capabilities, null);
context = drawable.createContext(null);
// need to get proper opengl context since will be needed below
gl = context.getGL();
// Flag defaults to be reset on the next trip into beginDraw().
settingsInited = false;
} else {
// changing for 0100, need to resize rather than re-allocate
//System.out.println("PGraphicsOpenGL.allocate() again for " + width + " " + height);
reapplySettings();
}
}
//public void dispose() // PGraphics
////////////////////////////////////////////////////////////
/**
* Get the current context, for use by libraries that need to talk to it.
*/
public GLContext getContext() {
return context;
}
/**
* Make the OpenGL rendering context current for this thread.
*/
protected void detainContext() {
try {
while (context.makeCurrent() == GLContext.CONTEXT_NOT_CURRENT) {
// System.out.println("Context not yet current...");
// new Exception().printStackTrace(System.out);
// Thread.sleep(1000);
Thread.sleep(10);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
/**
* Release the context, otherwise the AWT lock on X11 will not be released
*/
protected void releaseContext() {
context.release();
}
/**
* OpenGL cannot draw until a proper native peer is available, so this
* returns the value of PApplet.isDisplayable() (inherited from Component).
*/
public boolean canDraw() {
return parent.isDisplayable();
}
public void beginDraw() {
//if (!parent.isDisplayable()) return;
// When using an offscreen buffer, the drawable instance will be null.
// The offscreen buffer uses the drawing context of the main PApplet.
if (drawable != null) {
// Call setRealized() after addNotify() has been called
drawable.setRealized(parent.isDisplayable());
//System.out.println("OpenGL beginDraw() setting realized " + parent.isDisplayable());
if (parent.isDisplayable()) {
//System.out.println(" we'll realize it alright");
drawable.setRealized(true);
} else {
//System.out.println(" not yet ready to be realized");
return; // Should have called canDraw() anyway
}
detainContext();
}
// On the first frame that's guaranteed to be on screen,
// and the component valid and all that, ask for focus.
// if ((parent != null) && parent.frameCount == 1) {
// canvas.requestFocus();
// }
super.beginDraw();
report("top beginDraw()");
gl.glDisable(GL.GL_LIGHTING);
for (int i = 0; i < MAX_LIGHTS; i++) {
gl.glDisable(GL.GL_LIGHT0 + i);
}
gl.glMatrixMode(GL.GL_PROJECTION);
if (projectionFloats == null) {
projectionFloats = new float[] {
projection.m00, projection.m10, projection.m20, projection.m30,
projection.m01, projection.m11, projection.m21, projection.m31,
projection.m02, projection.m12, projection.m22, projection.m32,
projection.m03, projection.m13, projection.m23, projection.m33
};
} else {
projectionFloats[0] = projection.m00;
projectionFloats[1] = projection.m10;
projectionFloats[2] = projection.m20;
projectionFloats[3] = projection.m30;
projectionFloats[4] = projection.m01;
projectionFloats[5] = projection.m11;
projectionFloats[6] = projection.m21;
projectionFloats[7] = projection.m31;
projectionFloats[8] = projection.m02;
projectionFloats[9] = projection.m12;
projectionFloats[10] = projection.m22;
projectionFloats[11] = projection.m32;
projectionFloats[12] = projection.m03;
projectionFloats[13] = projection.m13;
projectionFloats[14] = projection.m23;
projectionFloats[15] = projection.m33;
}
//projection.print();
gl.glLoadMatrixf(projectionFloats, 0);
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glLoadIdentity();
// Flip Y-axis to make y count from 0 downwards
gl.glScalef(1, -1, 1);
// these are necessary for alpha (i.e. fonts) to work
gl.glEnable(GL.GL_BLEND);
gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
// this is necessary for 3D drawing
if (hints[DISABLE_DEPTH_TEST]) {
gl.glDisable(GL.GL_DEPTH_TEST);
} else {
gl.glEnable(GL.GL_DEPTH_TEST);
}
// use <= since that's what processing.core does
gl.glDepthFunc(GL.GL_LEQUAL);
// because y is flipped
gl.glFrontFace(GL.GL_CW);
// coloured stuff
gl.glEnable(GL.GL_COLOR_MATERIAL);
gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE);
gl.glColorMaterial(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR);
// these tend to make life easier
// (but sometimes at the expense of a little speed)
// Not using them right now because we're doing our own lighting.
//gl.glEnable(GL.GL_NORMALIZE);
//gl.glEnable(GL.GL_AUTO_NORMAL); // I think this is OpenGL 1.2 only
//gl.glEnable(GL.GL_RESCALE_NORMAL);
//gl.GlLightModeli(GL.GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
report("bot beginDraw()");
// are there other things to do here?
//System.out.println("beginDraw() stop error " + PApplet.hex(gl.glGetError()));
}
public void endDraw() {
//System.out.println("endDraw() error " + PApplet.hex(gl.glGetError()));
report("top endDraw()");
if (hints[ENABLE_DEPTH_SORT]) {
flush();
}
if (drawable != null) {
drawable.swapBuffers();
}
//insideDraw = false;
report("bot endDraw()");
if (drawable != null) {
releaseContext();
}
}
private float ctm[];
// this would also need to set up the lighting.. ?
public GL beginGL() {
//beginDraw(); // frame will have already started
gl.glPushMatrix();
// load p5 modelview into the opengl modelview
if (ctm == null) ctm = new float[16];
ctm[0] = modelview.m00;
ctm[1] = modelview.m10;
ctm[2] = modelview.m20;
ctm[3] = modelview.m30;
ctm[4] = modelview.m01;
ctm[5] = modelview.m11;
ctm[6] = modelview.m21;
ctm[7] = modelview.m31;
ctm[8] = modelview.m02;
ctm[9] = modelview.m12;
ctm[10] = modelview.m22;
ctm[11] = modelview.m32;
ctm[12] = modelview.m03;
ctm[13] = modelview.m13;
ctm[14] = modelview.m23;
ctm[15] = modelview.m33;
// apply this modelview and get to work
gl.glMultMatrixf(ctm, 0);
return gl;
}
public void endGL() {
// remove the p5 modelview from opengl
gl.glPopMatrix();
}
////////////////////////////////////////////////////////////
// SETTINGS
// checkSettings, defaultSettings, reapplySettings in PGraphics
////////////////////////////////////////////////////////////
// HINTS
public void hint(int which) {
// make note of whether these are set, if they are,
// then will prevent the new renderer exception from being thrown.
boolean opengl2X = !hints[DISABLE_OPENGL_2X_SMOOTH];
boolean opengl4X = hints[ENABLE_OPENGL_4X_SMOOTH];
super.hint(which);
if (which == DISABLE_DEPTH_TEST) {
gl.glDisable(GL.GL_DEPTH_TEST);
gl.glClear(GL.GL_DEPTH_BUFFER_BIT);
} else if (which == ENABLE_DEPTH_TEST) {
gl.glEnable(GL.GL_DEPTH_TEST);
} else if (which == DISABLE_OPENGL_2X_SMOOTH) {
if (opengl2X) {
releaseContext();
context.destroy();
context = null;
allocate();
throw new PApplet.RendererChangeException();
}
} else if (which == ENABLE_OPENGL_2X_SMOOTH) {
// do nothing, this is the default in release 0158 and later
} else if (which == ENABLE_OPENGL_4X_SMOOTH) {
if (!opengl4X) {
releaseContext();
context.destroy();
context = null;
allocate();
throw new PApplet.RendererChangeException();
}
}
}
//////////////////////////////////////////////////////////////
// VERTEX SHAPES
// All picked up from either PGraphics or PGraphics3D
//public void beginShape()
//public void beginShape(int kind)
//public void edge(boolean e)
//public void normal(float nx, float ny, float nz)
//public void textureMode(int mode)
//public void texture(PImage image)
//public void vertex(float x, float y)
//public void vertex(float x, float y, float z)
//public void vertex(float x, float y, float u, float v)
//public void vertex(float x, float y, float z, float u, float v)
//protected void vertexTexture(float u, float v);
//public void breakShape()
//public void endShape()
//public void endShape(int mode)
protected void endShapeLighting(boolean lights) {
super.endShapeLighting(lights);
// For now do our own lighting--sum the specular and diffuse light colors
if (lights) {
for (int i = shapeFirst; i < shapeLast; i++) {
float v[] = vertices[i];
v[R] = clamp(v[R] + v[SPR]);
v[G] = clamp(v[G] + v[SPG]);
v[B] = clamp(v[B] + v[SPB]);
}
}
}
//////////////////////////////////////////////////////////////
// BEZIER CURVE VERTICES
// All picked up from either PGraphics or PGraphics3D, however
// a faster version that made use of OpenGL's evaluator methods
// would be a nice improvement.
//protected void bezierVertexCheck();
//public void bezierVertex(float x2, float y2,
// float x3, float y3,
// float x4, float y4)
//public void bezierVertex(float x2, float y2, float z2,
// float x3, float y3, float z3,
// float x4, float y4, float z4)
//////////////////////////////////////////////////////////////
// CATMULL-ROM CURVE VERTICES
// Like bezier, these could be implemented using an OpenGL evaluator.
//protected void curveVertexCheck();
//public void curveVertex(float x, float y)
//public void curveVertex(float x, float y, float z)
//protected void curveVertexSegment(float x1, float y1,
// float x2, float y2,
// float x3, float y3,
// float x4, float y4)
//protected void curveVertexSegment(float x1, float y1, float z1,
// float x2, float y2, float z2,
// float x3, float y3, float z3,
// float x4, float y4, float z4)
//////////////////////////////////////////////////////////////
// POINTS (override from P3D)
protected void renderPoints(int start, int stop) {
float sw = vertices[lines[start][VERTEX1]][SW];
if (sw > 0) {
gl.glPointSize(sw); // can only be set outside glBegin/glEnd
gl.glBegin(GL.GL_POINTS);
for (int i = start; i < stop; i++) {
float[] a = vertices[points[i][VERTEX1]];
gl.glColor4f(a[SR], a[SG], a[SB], a[SA]);
gl.glVertex3f(a[VX], a[VY], a[VZ]);
}
gl.glEnd();
}
}
//protected void rawPoints(int start, int stop) // PGraphics3D
//////////////////////////////////////////////////////////////
// LINES (override from P3D)
//protected final void addLineBreak() // PGraphics3D
/**
* Add this line, but disable clipping because GL will handle it.
*/
protected void addLine(int a, int b) {
addLineWithoutClip(a, b);
}
//protected final void addLineWithClip(int a, int b)
//protected final void addLineWithoutClip(int a, int b)
/**
* In the current implementation, start and stop are ignored (in OpenGL).
* This will obviously have to be revisited if/when proper depth sorting
* is implemented.
*/
protected void renderLines(int start, int stop) {
report("render_lines in");
//int i = 0;
for (int j = 0; j < pathCount; j++) {
int i = pathOffset[j];
float sw = vertices[lines[i][VERTEX1]][SW];
//report("render_lines 1");
// stroke weight zero will cause a gl error
if (sw > 0) {
// glLineWidth has to occur outside glBegin/glEnd
gl.glLineWidth(sw);
gl.glBegin(GL.GL_LINE_STRIP);
// always draw a first point
float a[] = vertices[lines[i][VERTEX1]];
gl.glColor4f(a[SR], a[SG], a[SB], a[SA]);
gl.glVertex3f(a[VX], a[VY], a[VZ]);
// on this and subsequent lines, only draw the second point
//System.out.println(pathLength[j]);
for (int k = 0; k < pathLength[j]; k++) {
float b[] = vertices[lines[i][VERTEX2]];
gl.glColor4f(b[SR], b[SG], b[SB], b[SA]);
//gl.glEdgeFlag(a[EDGE] == 1);
gl.glVertex3f(b[VX], b[VY], b[VZ]);
i++;
}
gl.glEnd();
}
}
report("render_lines out");
}
//protected void rawLines(int start, int stop)
//////////////////////////////////////////////////////////////
// TRIANGLES
/**
* Add the triangle, but disable clipping because GL will handle it.
*/
protected void addTriangle(int a, int b, int c) {
addTriangleWithoutClip(a, b, c);
}
protected void renderTriangles(int start, int stop) {
report("render_triangles in");
for (int i = start; i < stop; i++) {
float a[] = vertices[triangles[i][VERTEX1]];
float b[] = vertices[triangles[i][VERTEX2]];
float c[] = vertices[triangles[i][VERTEX3]];
// This is only true when not textured.
// We really should pass specular straight through to triangle rendering.
float ar = clamp(triangleColors[i][0][TRI_DIFFUSE_R] + triangleColors[i][0][TRI_SPECULAR_R]);
float ag = clamp(triangleColors[i][0][TRI_DIFFUSE_G] + triangleColors[i][0][TRI_SPECULAR_G]);
float ab = clamp(triangleColors[i][0][TRI_DIFFUSE_B] + triangleColors[i][0][TRI_SPECULAR_B]);
float br = clamp(triangleColors[i][1][TRI_DIFFUSE_R] + triangleColors[i][1][TRI_SPECULAR_R]);
float bg = clamp(triangleColors[i][1][TRI_DIFFUSE_G] + triangleColors[i][1][TRI_SPECULAR_G]);
float bb = clamp(triangleColors[i][1][TRI_DIFFUSE_B] + triangleColors[i][1][TRI_SPECULAR_B]);
float cr = clamp(triangleColors[i][2][TRI_DIFFUSE_R] + triangleColors[i][2][TRI_SPECULAR_R]);
float cg = clamp(triangleColors[i][2][TRI_DIFFUSE_G] + triangleColors[i][2][TRI_SPECULAR_G]);
float cb = clamp(triangleColors[i][2][TRI_DIFFUSE_B] + triangleColors[i][2][TRI_SPECULAR_B]);
int textureIndex = triangles[i][TEXTURE_INDEX];
if (textureIndex != -1) {
report("before enable");
gl.glEnable(GL.GL_TEXTURE_2D);
report("after enable");
report("before bind");
PImage texture = textures[textureIndex];
bindTexture(texture);
report("after bind");
ImageCache cash = (ImageCache) texture.getCache(this);
float uscale = (float) texture.width / (float) cash.twidth;
float vscale = (float) texture.height / (float) cash.theight;
gl.glBegin(GL.GL_TRIANGLES);
//System.out.println(a[U] + " " + a[V] + " " + uscale + " " + vscale);
//System.out.println(ar + " " + ag + " " + ab + " " + a[A]);
//ar = ag = ab = 1;
gl.glColor4f(ar, ag, ab, a[A]);
gl.glTexCoord2f(a[U] * uscale, a[V] * vscale);
gl.glNormal3f(a[NX], a[NY], a[NZ]);
gl.glEdgeFlag(a[EDGE] == 1);
gl.glVertex3f(a[VX], a[VY], a[VZ]);
gl.glColor4f(br, bg, bb, b[A]);
gl.glTexCoord2f(b[U] * uscale, b[V] * vscale);
gl.glNormal3f(b[NX], b[NY], b[NZ]);
gl.glEdgeFlag(a[EDGE] == 1);
gl.glVertex3f(b[VX], b[VY], b[VZ]);
gl.glColor4f(cr, cg, cb, c[A]);
gl.glTexCoord2f(c[U] * uscale, c[V] * vscale);
gl.glNormal3f(c[NX], c[NY], c[NZ]);
gl.glEdgeFlag(a[EDGE] == 1);
gl.glVertex3f(c[VX], c[VY], c[VZ]);
gl.glEnd();
report("non-binding 6");
gl.glDisable(GL.GL_TEXTURE_2D);
} else { // no texture
gl.glBegin(GL.GL_TRIANGLES);
gl.glColor4f(ar, ag, ab, a[A]);
gl.glNormal3f(a[NX], a[NY], a[NZ]);
gl.glEdgeFlag(a[EDGE] == 1);
gl.glVertex3f(a[VX], a[VY], a[VZ]);
gl.glColor4f(br, bg, bb, b[A]);
gl.glNormal3f(b[NX], b[NY], b[NZ]);
gl.glEdgeFlag(a[EDGE] == 1);
gl.glVertex3f(b[VX], b[VY], b[VZ]);
gl.glColor4f(cr, cg, cb, c[A]);
gl.glNormal3f(c[NX], c[NY], c[NZ]);
gl.glEdgeFlag(a[EDGE] == 1);
gl.glVertex3f(c[VX], c[VY], c[VZ]);
gl.glEnd();
}
}
report("render_triangles out");
}
//protected void rawTriangles(int start, int stop) // PGraphics3D
protected void bindTexture(PImage texture) {
ImageCache cash = (ImageCache) texture.getCache(this); // as in johnny
if (cash == null) {
cash = new ImageCache();
texture.setCache(this, cash);
texture.setModified(true);
}
if (texture.isModified()) {
//System.out.println("texture modified");
// TODO make this more efficient and just update a sub-part
// based on mx1 et al, also use gl function to update
// only a sub-portion of the image.
cash.rebind(texture);
// clear the modified flag
texture.setModified(false);
} else {
gl.glBindTexture(GL.GL_TEXTURE_2D, cash.tindex);
}
}
protected class ImageCache {
int tindex = -1; // not yet ready
int tpixels[];
IntBuffer tbuffer;
public int twidth, theight;
int[] tp;
/**
* Delete any texture memory that had been allocated.
* Added for 0125 to deal with memory problems reported in Bug #150.
*/
protected void finalize() {
if (textureDeleteQueue.length == textureDeleteQueueCount) {
textureDeleteQueue = (int[]) PApplet.expand(textureDeleteQueue);
}
if (tindex != -1) {
textureDeleteQueue[textureDeleteQueueCount++] = tindex;
}
}
/**
* Generate a texture ID and do the necessary bitshifting for the image.
*/
public void rebind(PImage source) {
if (textureDeleteQueueCount != 0) {
//gl.glDeleteTextures(1, new int[] { tindex }, 0);
gl.glDeleteTextures(textureDeleteQueueCount, textureDeleteQueue, 0);
textureDeleteQueueCount = 0;
}
//System.out.println("rebinding texture for " + source);
if (tindex != -1) {
// free up the old memory
gl.glDeleteTextures(1, new int[] { tindex }, 0);
}
// generate a new texture number to bind to
int[] tmp = new int[1];
gl.glGenTextures(1, tmp, 0);
tindex = tmp[0];
//System.out.println("got index " + tindex);
// bit shifting this might be more efficient
int width2 = nextPowerOfTwo(source.width);
//(int) Math.pow(2, Math.ceil(Math.log(source.width) / Math.log(2)));
int height2 = nextPowerOfTwo(source.height);
//(int) Math.pow(2, Math.ceil(Math.log(source.height) / Math.log(2)));
// use glGetIntegerv with the argument GL_MAX_TEXTURE_SIZE
// to figure out min/max texture sizes
if (maxTextureSize == 0) {
int maxSize[] = new int[1];
gl.glGetIntegerv(GL.GL_MAX_TEXTURE_SIZE, maxSize, 0);
maxTextureSize = maxSize[0];
//System.out.println("max texture size is " + maxTextureSize);
}
if ((width2 > maxTextureSize) || (height2 > maxTextureSize)) {
throw new RuntimeException("Image width and height cannot be" +
" larger than " + maxTextureSize +
" with your graphics card.");
}
if ((width2 > twidth) || (height2 > theight)) {
// either twidth/theight are zero, or size has changed
tpixels = null;
}
if (tpixels == null) {
twidth = width2;
theight = height2;
tpixels = new int[twidth * theight];
tbuffer = BufferUtil.newIntBuffer(twidth * theight);
}
// copy image data into the texture
int p = 0;
int t = 0;
if (BIG_ENDIAN) {
switch (source.format) {
case ALPHA:
for (int y = 0; y < source.height; y++) {
for (int x = 0; x < source.width; x++) {
tpixels[t++] = 0xFFFFFF00 | source.pixels[p++];
}
t += twidth - source.width;
}
break;
case RGB:
for (int y = 0; y < source.height; y++) {
for (int x = 0; x < source.width; x++) {
int pixel = source.pixels[p++];
tpixels[t++] = (pixel << 8) | 0xff;
}
t += twidth - source.width;
}
break;
case ARGB:
for (int y = 0; y < source.height; y++) {
for (int x = 0; x < source.width; x++) {
int pixel = source.pixels[p++];
tpixels[t++] = (pixel << 8) | ((pixel >> 24) & 0xff);
}
t += twidth - source.width;
}
break;
}
} else { // LITTLE_ENDIAN
// ARGB native, and RGBA opengl means ABGR on windows
// for the most part just need to swap two components here
// the sun.cpu.endian here might be "false", oddly enough..
// (that's why just using an "else", rather than check for "little")
switch (source.format) {
case ALPHA:
for (int y = 0; y < source.height; y++) {
for (int x = 0; x < source.width; x++) {
tpixels[t++] = (source.pixels[p++] << 24) | 0x00FFFFFF;
}
t += twidth - source.width;
}
break;
case RGB:
for (int y = 0; y < source.height; y++) {
for (int x = 0; x < source.width; x++) {
int pixel = source.pixels[p++];
// needs to be ABGR, stored in memory xRGB
// so R and B must be swapped, and the x just made FF
tpixels[t++] =
0xff000000 | // force opacity for good measure
((pixel & 0xFF) << 16) |
((pixel & 0xFF0000) >> 16) |
(pixel & 0x0000FF00);
}
t += twidth - source.width;
}
break;
case ARGB:
for (int y = 0; y < source.height; y++) {
for (int x = 0; x < source.width; x++) {
int pixel = source.pixels[p++];
// needs to be ABGR stored in memory ARGB
// so R and B must be swapped, A and G just brought back in
tpixels[t++] =
((pixel & 0xFF) << 16) |
((pixel & 0xFF0000) >> 16) |
(pixel & 0xFF00FF00);
}
t += twidth - source.width;
}
break;
}
}
tbuffer.put(tpixels);
tbuffer.rewind();
//
gl.glBindTexture(GL.GL_TEXTURE_2D, tindex);
gl.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1);
//gl.glPixelStorei(GL.GL_UNPACK_SWAP_BYTES, 0);
gl.glTexImage2D(GL.GL_TEXTURE_2D, 0, 4, twidth, theight,
//0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, cash.tpixels);
0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, tbuffer);
gl.glTexParameterf(GL.GL_TEXTURE_2D,
//GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST);
GL.GL_TEXTURE_MAG_FILTER, GL.GL_LINEAR);
gl.glTexParameterf(GL.GL_TEXTURE_2D,
//GL.GL_TEXTURE_MIN_FILTER, GL.GL_NEAREST);
GL.GL_TEXTURE_MIN_FILTER, GL.GL_LINEAR);
//
/*int err =*/ glu.gluBuild2DMipmaps(GL.GL_TEXTURE_2D, 4,
twidth, theight,
GL.GL_RGBA,
GL.GL_UNSIGNED_BYTE, tbuffer);
//System.out.println("mipmap: " + err);
// The MAG_FILTER should only be GL_LINEAR or GL_NEAREST.
// Some cards are OK with LINEAR_MIPMAP_LINEAR, but not the
// Radeon 9700, which is in all the PB G4s.. Not sure if this
// is an OpenGL version thing, tho it makes sense MIN_FILTER
// is the only one that uses mipmapping.
gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER,
GL.GL_LINEAR);
gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MIN_FILTER,
GL.GL_LINEAR_MIPMAP_LINEAR);
// gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP);
// gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP);
gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_S, GL.GL_CLAMP_TO_EDGE);
gl.glTexParameterf(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_WRAP_T, GL.GL_CLAMP_TO_EDGE);
//
gl.glTexEnvf(GL.GL_TEXTURE_ENV, GL.GL_TEXTURE_ENV_MODE, GL.GL_MODULATE);
}
private int nextPowerOfTwo(int val) {
int ret = 1;
while (ret < val) {
ret <<= 1;
}
return ret;
}
}
//////////////////////////////////////////////////////////////
// RENDERING
//public void flush()
//protected void render()
//protected void sort()
//////////////////////////////////////////////////////////////
// POINT, LINE, TRIANGLE, QUAD
// Because vertex(x, y) is mapped to vertex(x, y, 0), none of these commands
// need to be overridden from their default implementation in PGraphics.
//public void point(float x, float y)
//public void point(float x, float y, float z)
//public void line(float x1, float y1, float x2, float y2)
//public void line(float x1, float y1, float z1,
// float x2, float y2, float z2)
//public void triangle(float x1, float y1, float x2, float y2,
// float x3, float y3)
//public void quad(float x1, float y1, float x2, float y2,
// float x3, float y3, float x4, float y4)
//////////////////////////////////////////////////////////////
// RECT
//public void rectMode(int mode)
//public void rect(float a, float b, float c, float d)
//protected void rectImpl(float x1, float y1, float x2, float y2)
//////////////////////////////////////////////////////////////
// ELLIPSE
//public void ellipseMode(int mode)
//public void ellipse(float a, float b, float c, float d)
/*
boolean ellipseInited;
int ellipseFillList;
int ellipseStrokeList;
protected void ellipseImpl(float x1, float y1, float w, float h) {
float hradius = w / 2f;
float vradius = h / 2f;
float centerX = x1 + hradius;
float centerY = y1 + vradius;
// adapt accuracy to radii used w/ a minimum of 4 segments [toxi]
// now uses current scale factors to determine "real" transformed radius
//int cAccuracy = (int)(4+Math.sqrt(hradius*abs(m00)+vradius*abs(m11))*2);
//int cAccuracy = (int)(4+Math.sqrt(hradius+vradius)*2);
// notched this up to *3 instead of *2 because things were
// looking a little rough, i.e. the calculate->arctangent example [fry]
// also removed the m00 and m11 because those were causing weirdness
// need an actual measure of magnitude in there [fry]
int accuracy = (int)(4+Math.sqrt(hradius+vradius)*3);
//System.out.println("accuracy is " + accuracy);
//accuracy = 5;
// [toxi031031] adapted to use new lookup tables
float inc = (float)SINCOS_LENGTH / accuracy;
float val = 0;
if (fill) {
boolean savedStroke = stroke;
stroke = false;
beginShape(TRIANGLE_FAN);
normal(0, 0, 1);
vertex(centerX, centerY);
for (int i = 0; i < accuracy; i++) {
vertex(centerX + cosLUT[(int) val] * hradius,
centerY + sinLUT[(int) val] * vradius);
val += inc;
}
// back to the beginning
vertex(centerX + cosLUT[0] * hradius,
centerY + sinLUT[0] * vradius);
endShape();
stroke = savedStroke;
}
if (stroke) {
boolean savedFill = fill;
fill = false;
val = 0;
beginShape(); //LINE_LOOP);
for (int i = 0; i < accuracy; i++) {
vertex(centerX + cosLUT[(int) val] * hradius,
centerY + sinLUT[(int) val] * vradius);
val += inc;
}
endShape(CLOSE);
fill = savedFill;
}
}
*/
/*
pgl.beginGL();
//PGraphics gr = PApplet.this.g;
//GL gl = ((PGraphicsOpenGL).gr).beginGL();
if (!ellipseInited) {
ellipseList = gl.glGenLists(1);
gl.glNewList(ellipseList, GL.GL_COMPILE);
gl.glBegin(GL.GL_LINE_LOOP);
int seg = 15;
float segf = 15;
for (int i = 0; i < seg; i++) {
float theta = TWO_PI * (float)i / segf;
gl.glVertex2f(cos(theta), sin(theta));
}
gl.glEnd();
gl.glEndList();
ellipseInited = true;
}
for (int i=1; i<numSegments-1; i++) {
gl.glPushMatrix();
gl.glTranslatef(x[i], y[i], z);
float r = w[i]/2f;
gl.glScalef(r, r, r);
gl.glColor4f(1, 1, 1, 150.0/255.0);
gl.glCallList(ellipseList);
gl.glScalef(0.5, 0.5, 0.5);
gl.glColor4f(1, 1, 1, 50.0/255.0);
gl.glCallList(ellipseList);
gl.glPopMatrix();
}
pgl.endGL();
*/
//public void arc(float a, float b, float c, float d,
// float start, float stop)
//protected void arcImpl(float x, float y, float w, float h,
// float start, float stop)
//////////////////////////////////////////////////////////////
// BOX
// TODO P3D overrides box to turn on triangle culling, but that's a waste
// for OpenGL. Also could just use the cube method from GL or GLUT.
//public void box(float size)
//public void box(float w, float h, float d) // P3D
//////////////////////////////////////////////////////////////
// SPHERE
// TODO P3D overrides sphere to turn on triangle culling, but that's a waste
// for OpenGL. Also could just use the cube method from GL or GLUT.
//public void sphereDetail(int res)
//public void sphereDetail(int ures, int vres)
//public void sphere(float r)
//////////////////////////////////////////////////////////////
// BEZIER
//public float bezierPoint(float a, float b, float c, float d, float t)
//public float bezierTangent(float a, float b, float c, float d, float t)
//public void bezierDetail(int detail)
//public void bezier(float x1, float y1,
// float x2, float y2,
// float x3, float y3,
// float x4, float y4)
//public void bezier(float x1, float y1, float z1,
// float x2, float y2, float z2,
// float x3, float y3, float z3,
// float x4, float y4, float z4)
//////////////////////////////////////////////////////////////
// CATMULL-ROM CURVES
//public float curvePoint(float a, float b, float c, float d, float t)
//public float curveTangent(float a, float b, float c, float d, float t)
//public void curveDetail(int detail)
//public void curveTightness(float tightness)
//public void curve(float x1, float y1,
// float x2, float y2,
// float x3, float y3,
// float x4, float y4)
//public void curve(float x1, float y1, float z1,
// float x2, float y2, float z2,
// float x3, float y3, float z3,
// float x4, float y4, float z4)
//////////////////////////////////////////////////////////////
// SMOOTH
public void smooth() {
smooth = true;
if (hints[DISABLE_OPENGL_2X_SMOOTH]) {
//gl.glEnable(GL.GL_MULTISAMPLE);
gl.glEnable(GL.GL_POINT_SMOOTH);
gl.glEnable(GL.GL_LINE_SMOOTH);
gl.glEnable(GL.GL_POLYGON_SMOOTH);
}
}
public void noSmooth() {
smooth = false;
if (hints[DISABLE_OPENGL_2X_SMOOTH]) {
//gl.glDisable(GL.GL_MULTISAMPLE);
gl.glDisable(GL.GL_POINT_SMOOTH);
gl.glDisable(GL.GL_LINE_SMOOTH);
gl.glDisable(GL.GL_POLYGON_SMOOTH);
}
}
//////////////////////////////////////////////////////////////
// IMAGES
//public void imageMode(int mode)
//public void image(PImage image, float x, float y)
//public void image(PImage image, float x, float y, float c, float d)
//public void image(PImage image,
// float a, float b, float c, float d,
// int u1, int v1, int u2, int v2)
//protected void imageImpl(PImage image,
// float x1, float y1, float x2, float y2,
// int u1, int v1, int u2, int v2)
//////////////////////////////////////////////////////////////
// SHAPE
//public void shapeMode(int mode)
//public void shape(PShape shape)
//public void shape(PShape shape, float x, float y)
//public void shape(PShape shape, float x, float y, float c, float d)
//////////////////////////////////////////////////////////////
// TEXT SETTINGS
//public void textAlign(int align)
//public void textAlign(int alignX, int alignY)
public float textAscent() {
Font font = textFont.getFont();
if ((textMode != SHAPE) || (font == null)) {
return super.textAscent();
}
FontMetrics metrics = parent.getFontMetrics(font);
return metrics.getAscent();
}
public float textDescent() {
Font font = textFont.getFont();
if ((textMode != SHAPE) || (font == null)) {
return super.textDescent();
}
FontMetrics metrics = parent.getFontMetrics(font);
return metrics.getDescent();
}
public void textFont(PFont which) {
super.textFont(which);
if (textMode == SHAPE) {
if (textFont.findFont() == null) {
showWarning("Cannot use " + which.name + " as with textMode(SHAPE) " +
"because its native equivalent cannot be found.");
}
}
}
//public void textFont(PFont which, float size)
//public void textLeading(float leading)
// public void textMode(int mode) {
// if (mode == SHAPE) {
// textMode = SHAPE;
//
// } else {
// // if not SHAPE mode, then pass off to the PGraphics.textMode()
// // which is built for error handling (but objects to SHAPE).
// super.textMode(mode);
// }
// }
protected boolean textModeCheck(int mode) {
return (textMode == MODEL) || (textMode == SCREEN) || (textMode == SHAPE);
}
/**
* Same as parent, but override for native version of the font.
* <p/>
* Also gets called by textFont, so the metrics
* will get recorded properly.
*/
// public void textSize(float size) {
// can't cancel on textMode(SHAPE) because textMode() must happen
// after textFont() and textFont() calls textSize()
//if ((textMode != SHAPE) || (textFontNative == null)) {
// call this anyway to set the base variables for cases
// where textMode(SHAPE) will not be used
// super.textSize(size);
/*
// derive the font just in case the user is gonna call
// textMode(SHAPE) afterwards
if (textFontNative != null) {
textFontNative = textFontNative.deriveFont(size);
Graphics2D graphics = (Graphics2D) parent.getGraphics();
graphics.setFont(textFontNative);
// get the metrics info
textFontNativeMetrics = graphics.getFontMetrics(textFontNative);
}
*/
// }
//public float textWidth(char c)
//public float textWidth(String str)
protected float textWidthImpl(char buffer[], int start, int stop) {
Font font = textFont.getFont();
if ((textMode != SHAPE) || (font == null)) {
return super.textWidthImpl(buffer, start, stop);
}
/*
// maybe should use one of the newer/fancier functions for this?
int length = stop - start;
return textFontNativeMetrics.charsWidth(buffer, start, length);
*/
Graphics2D graphics = (Graphics2D) parent.getGraphics();
// otherwise smaller sizes will be totally crapped up
// seems to need to be before the getFRC, but after the canvas.getGraphics
// (placing this inside textSize(), even though it was called, wasn't working)
graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
FontRenderContext frc = graphics.getFontRenderContext();
GlyphVector gv;
/*
if (start == 0 && stop == buffer.length) {
gv = textFontNative.createGlyphVector(frc, buffer);
} else {
char[] fellas = PApplet.subset(buffer, start, length);
gv = textFontNative.createGlyphVector(frc, fellas);
}
*/
gv = font.createGlyphVector(frc, buffer);
float sum = 0;
for (int i = start; i < stop; i++) {
GlyphMetrics gm = gv.getGlyphMetrics(i);
sum += gm.getAdvance();
}
return sum;
}
//////////////////////////////////////////////////////////////
// TEXT
// None of the variations of text() are overridden from PGraphics.
//////////////////////////////////////////////////////////////
// TEXT IMPL
//protected void textLineAlignImpl(char buffer[], int start, int stop,
// float x, float y)
//protected void textLineImpl(char buffer[], int start, int stop,
// float x, float y)
/**
* Override to handle rendering characters with textMode(SHAPE).
*/
protected void textCharImpl(char ch, float x, float y) {
if (textMode == SHAPE) {
if (textFont.getFont() == null) {
PGraphics.showWarning("textMode(SHAPE) is disabled because the font " +
"\"" + textFont.name + "\" is not available.");
} else {
textCharShapeImpl(ch, x, y);
}
} else {
super.textCharImpl(ch, x, y);
}
}
/**
* This uses the tesselation functions from GLU to handle triangulation
* to convert the character into a series of shapes.
* <p/>
* <EM>No attempt has been made to optimize this code</EM>
* <p/>
* TODO: Should instead override textPlacedImpl() because createGlyphVector
* takes a char array. Or better yet, cache the font on a per-char basis,
* so that it's not being re-tessellated each time, could make it into
* a display list which would be nice and speedy.
* <p/>
* Also a problem where some fonts seem to be a bit slight, as if the
* control points aren't being mapped quite correctly. Probably doing
* something dumb that the control points don't map to P5's control
* points. Perhaps it's returning b-spline data from the TrueType font?
* Though it seems like that would make a lot of garbage rather than
* just a little flattening.
* <p/>
* There also seems to be a bug that is causing a line (but not a filled
* triangle) back to the origin on some letters (i.e. a capital L when
* tested with Akzidenz Grotesk Light). But this won't be visible
* with the stroke shut off, so tabling that bug for now.
*/
protected void textCharShapeImpl(char ch, float x, float y) {
// save the current stroke because it needs to be disabled
// while the text is being drawn
boolean strokeSaved = stroke;
stroke = false;
// six element array received from the Java2D path iterator
float textPoints[] = new float[6];
// array passed to createGylphVector
char textArray[] = new char[] { ch };
Graphics2D graphics = (Graphics2D) parent.getGraphics();
FontRenderContext frc = graphics.getFontRenderContext();
Font font = textFont.getFont();
GlyphVector gv = font.createGlyphVector(frc, textArray);
Shape shp = gv.getOutline();
//PathIterator iter = shp.getPathIterator(null, 0.05);
PathIterator iter = shp.getPathIterator(null);
glu.gluTessBeginPolygon(tobj, null);
// second param to gluTessVertex is for a user defined object that contains
// additional info about this point, but that's not needed for anything
float lastX = 0;
float lastY = 0;
// unfortunately the tesselator won't work properly unless a
// new array of doubles is allocated for each point. that bites ass,
// but also just reaffirms that in order to make things fast,
// display lists will be the way to go.
double vertex[];
final boolean DEBUG_OPCODES = false; //true;
while (!iter.isDone()) {
int type = iter.currentSegment(textPoints);
switch (type) {
case PathIterator.SEG_MOVETO: // 1 point (2 vars) in textPoints
case PathIterator.SEG_LINETO: // 1 point
if (type == PathIterator.SEG_MOVETO) {
if (DEBUG_OPCODES) {
System.out.println("moveto\t" +
textPoints[0] + "\t" + textPoints[1]);
}
glu.gluTessBeginContour(tobj);
} else {
if (DEBUG_OPCODES) {
System.out.println("lineto\t" +
textPoints[0] + "\t" + textPoints[1]);
}
}
vertex = new double[] {
x + textPoints[0], y + textPoints[1], 0
};
glu.gluTessVertex(tobj, vertex, 0, vertex);
lastX = textPoints[0];
lastY = textPoints[1];
break;
case PathIterator.SEG_QUADTO: // 2 points
if (DEBUG_OPCODES) {
System.out.println("quadto\t" +
textPoints[0] + "\t" + textPoints[1] + "\t" +
textPoints[2] + "\t" + textPoints[3]);
}
for (int i = 1; i < bezierDetail; i++) {
float t = (float)i / (float)bezierDetail;
vertex = new double[] {
x + bezierPoint(lastX,
lastX + (float) ((textPoints[0] - lastX) * 2/3.0),
textPoints[2] + (float) ((textPoints[0] - textPoints[2]) * 2/3.0),
textPoints[2], t),
y + bezierPoint(lastY,
lastY + (float) ((textPoints[1] - lastY) * 2/3.0),
textPoints[3] + (float) ((textPoints[1] - textPoints[3]) * 2/3.0),
textPoints[3], t),
0.0f
};
glu.gluTessVertex(tobj, vertex, 0, vertex);
}
lastX = textPoints[2];
lastY = textPoints[3];
break;
case PathIterator.SEG_CUBICTO: // 3 points
if (DEBUG_OPCODES) {
System.out.println("cubicto\t" +
textPoints[0] + "\t" + textPoints[1] + "\t" +
textPoints[2] + "\t" + textPoints[3] + "\t" +
textPoints[4] + "\t" + textPoints[5]);
}
for (int i = 1; i < bezierDetail; i++) {
float t = (float)i / (float)bezierDetail;
vertex = new double[] {
x + bezierPoint(lastX, textPoints[0],
textPoints[2], textPoints[4], t),
y + bezierPoint(lastY, textPoints[1],
textPoints[3], textPoints[5], t), 0
};
glu.gluTessVertex(tobj, vertex, 0, vertex);
}
lastX = textPoints[4];
lastY = textPoints[5];
break;
case PathIterator.SEG_CLOSE:
if (DEBUG_OPCODES) {
System.out.println("close");
System.out.println();
}
glu.gluTessEndContour(tobj);
break;
}
iter.next();
}
glu.gluTessEndPolygon(tobj);
// re-enable stroke if it was in use before
stroke = strokeSaved;
}
/**
* There must be a better way to do this, but I'm having a brain fart
* with all the inner class crap. Fix it later once this stuff is debugged.
* <p/>
* The method "void vertex(float $1, float $2, float $3);" contained in
* the enclosing type "processing.core.PGraphics3" is a perfect match for
* this method call. However, it is not visible in this nested class because
* a method with the same name in an intervening class is hiding it.
*/
/*
public void vertexRedirect(float x, float y, float z) {
vertex(x, y, z);
}
*/
public class TessCallback extends GLUtessellatorCallbackAdapter {
public void begin(int type) {
switch (type) {
case GL.GL_TRIANGLE_FAN: beginShape(TRIANGLE_FAN); break;
case GL.GL_TRIANGLE_STRIP: beginShape(TRIANGLE_STRIP); break;
case GL.GL_TRIANGLES: beginShape(TRIANGLES); break;
}
}
public void end() {
//gl.glEnd();
endShape();
}
public void edge(boolean e) {
PGraphicsOpenGL.this.edge(e);
}
public void vertex(Object data) {
if (data instanceof double[]) {
double[] d = (double[]) data;
if (d.length != 3) {
throw new RuntimeException("TessCallback vertex() data " +
"isn't length 3");
}
//System.out.println("tess callback vertex " +
// d[0] + " " + d[1] + " " + d[2]);
//vertexRedirect((float) d[0], (float) d[1], (float) d[2]);
PGraphicsOpenGL.this.vertex((float) d[0], (float) d[1], (float) d[2]);
/*
if (d.length == 6) {
double[] d2 = {d[0], d[1], d[2]};
gl.glVertex3dv(d2);
d2 = new double[]{d[3], d[4], d[5]};
gl.glColor3dv(d2);
} else if (d.length == 3) {
gl.glVertex3dv(d);
}
*/
} else {
throw new RuntimeException("TessCallback vertex() data not understood");
}
}
public void error(int errnum) {
String estring = glu.gluErrorString(errnum);
PGraphics.showWarning("Tessellation Error: " + estring);
}
/**
* Implementation of the GLU_TESS_COMBINE callback.
* @param coords is the 3-vector of the new vertex
* @param data is the vertex data to be combined, up to four elements.
* This is useful when mixing colors together or any other
* user data that was passed in to gluTessVertex.
* @param weight is an array of weights, one for each element of "data"
* that should be linearly combined for new values.
* @param outData is the set of new values of "data" after being
* put back together based on the weights. it's passed back as a
* single element Object[] array because that's the closest
* that Java gets to a pointer.
*/
public void combine(double[] coords, Object[] data,
float[] weight, Object[] outData) {
//System.out.println("coords.length = " + coords.length);
//System.out.println("data.length = " + data.length);
//System.out.println("weight.length = " + weight.length);
//for (int i = 0; i < data.length; i++) {
//System.out.println(i + " " + data[i].getClass().getName() + " " + weight[i]);
//}
double[] vertex = new double[coords.length];
vertex[0] = coords[0];
vertex[1] = coords[1];
vertex[2] = coords[2];
//System.out.println("combine " +
// vertex[0] + " " + vertex[1] + " " + vertex[2]);
// this is just 3, so nothing interesting to bother combining
//System.out.println("data length " + ((double[]) data[0]).length);
// not gonna bother doing any combining,
// since no user data is being passed in.
/*
for (int i = 3; i < 6; i++) {
vertex[i] =
weight[0] * ((double[]) data[0])[i] +
weight[1] * ((double[]) data[1])[i] +
weight[2] * ((double[]) data[2])[i] +
weight[3] * ((double[]) data[3])[i];
}
*/
outData[0] = vertex;
}
}
//////////////////////////////////////////////////////////////
// MATRIX MATH
//public void pushMatrix()
//public void popMatrix()
//public void translate(float tx, float ty)
//public void translate(float tx, float ty, float tz)
//public void rotate(float angle)
//public void rotateX(float angle)
//public void rotateY(float angle)
//public void rotateZ(float angle)
//public void rotate(float angle, float vx, float vy, float vz)
//public void scale(float s)
//public void scale(float sx, float sy)
//public void scale(float x, float y, float z)
//public void resetMatrix()
//public void applyMatrix(PMatrix2D source)
//public void applyMatrix(float n00, float n01, float n02,
// float n10, float n11, float n12)
//public void applyMatrix(PMatrix3D source)
//public void applyMatrix(float n00, float n01, float n02, float n03,
// float n10, float n11, float n12, float n13,
// float n20, float n21, float n22, float n23,
// float n30, float n31, float n32, float n33)
//public getMatrix(PMatrix2D target)
//public getMatrix(PMatrix3D target)
//public void setMatrix(PMatrix2D source)
//public void setMatrix(PMatrix3D source)
//public void printMatrix()
//public void beginCamera()
//public void endCamera()
//public void camera()
//public void camera(float eyeX, float eyeY, float eyeZ,
// float centerX, float centerY, float centerZ,
// float upX, float upY, float upZ)
//public void printCamera()
//public void ortho()
//public void ortho(float left, float right,
// float bottom, float top,
// float near, float far)
//public void perspective()
//public void perspective(float fov, float aspect, float near, float far)
//public void frustum(float left, float right,
// float bottom, float top,
// float near, float far)
//public void printProjection()
//public float screenX(float x, float y)
//public float screenY(float x, float y)
//public float screenX(float x, float y, float z)
//public float screenY(float x, float y, float z)
//public float screenZ(float x, float y, float z)
//public float modelX(float x, float y, float z)
//public float modelY(float x, float y, float z)
//public float modelZ(float x, float y, float z)
//////////////////////////////////////////////////////////////
// STYLES
//public void pushStyle()
//public void popStyle()
//public void style(PStyle)
//public PStyle getStyle()
//public void getStyle(PStyle)
//////////////////////////////////////////////////////////////
// COLOR MODE
//public void colorMode(int mode)
//public void colorMode(int mode, float max)
//public void colorMode(int mode, float mx, float my, float mz);
//public void colorMode(int mode, float mx, float my, float mz, float ma);
//////////////////////////////////////////////////////////////
// COLOR CALC
//protected void colorCalc(int rgb)
//protected void colorCalc(int rgb, float alpha)
//protected void colorCalc(float gray)
//protected void colorCalc(float gray, float alpha)
//protected void colorCalc(float x, float y, float z)
//protected void colorCalc(float x, float y, float z, float a)
//protected void colorCalcARGB(int argb, float alpha)
//////////////////////////////////////////////////////////////
// STROKE CAP/JOIN/WEIGHT
public void strokeWeight(float weight) {
this.strokeWeight = weight;
}
public void strokeJoin(int join) {
if (join != DEFAULT_STROKE_JOIN) {
showMethodWarning("strokeJoin");
}
}
public void strokeCap(int cap) {
if (cap != DEFAULT_STROKE_CAP) {
showMethodWarning("strokeCap");
}
}
//////////////////////////////////////////////////////////////
// STROKE, TINT, FILL
//public void noStroke()
//public void stroke(int rgb)
//public void stroke(int rgb, float alpha)
//public void stroke(float gray)
//public void stroke(float gray, float alpha)
//public void stroke(float x, float y, float z)
//public void stroke(float x, float y, float z, float a)
//protected void strokeFromCalc()
//public void noTint()
//public void tint(int rgb)
//public void tint(int rgb, float alpha)
//public void tint(float gray)
//public void tint(float gray, float alpha)
//public void tint(float x, float y, float z)
//public void tint(float x, float y, float z, float a)
//protected void tintFromCalc()
//public void noFill()
//public void fill(int rgb)
//public void fill(int rgb, float alpha)
//public void fill(float gray)
//public void fill(float gray, float alpha)
//public void fill(float x, float y, float z)
//public void fill(float x, float y, float z, float a)
protected void fillFromCalc() {
super.fillFromCalc();
calcColorBuffer();
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT_AND_DIFFUSE,
colorBuffer, 0);
}
//////////////////////////////////////////////////////////////
// MATERIAL PROPERTIES
// public void ambient(int rgb) {
// super.ambient(rgb);
// calcColorBuffer();
// gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, colorBuffer, 0);
// }
// public void ambient(float gray) {
// super.ambient(gray);
// calcColorBuffer();
// gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, colorBuffer, 0);
// }
// public void ambient(float x, float y, float z) {
// super.ambient(x, y, z);
// calcColorBuffer();
// gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, colorBuffer, 0);
// }
protected void ambientFromCalc() {
super.ambientFromCalc();
calcColorBuffer();
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_AMBIENT, colorBuffer, 0);
}
// public void specular(int rgb) {
// super.specular(rgb);
// calcColorBuffer();
// gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, colorBuffer, 0);
// }
// public void specular(float gray) {
// super.specular(gray);
// calcColorBuffer();
// gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, colorBuffer, 0);
// }
// public void specular(float x, float y, float z) {
// super.specular(x, y, z);
// calcColorBuffer();
// gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, colorBuffer, 0);
// }
protected void specularFromCalc() {
super.specularFromCalc();
calcColorBuffer();
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_SPECULAR, colorBuffer, 0);
}
public void shininess(float shine) {
super.shininess(shine);
gl.glMaterialf(GL.GL_FRONT_AND_BACK, GL.GL_SHININESS, shine);
}
// public void emissive(int rgb) {
// super.emissive(rgb);
// calcColorBuffer();
// gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, colorBuffer, 0);
// }
// public void emissive(float gray) {
// super.emissive(gray);
// calcColorBuffer();
// gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, colorBuffer, 0);
// }
// public void emissive(float x, float y, float z) {
// super.emissive(x, y, z);
// calcColorBuffer();
// gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, colorBuffer, 0);
// }
protected void emissiveFromCalc() {
super.emissiveFromCalc();
calcColorBuffer();
gl.glMaterialfv(GL.GL_FRONT_AND_BACK, GL.GL_EMISSION, colorBuffer, 0);
}
//////////////////////////////////////////////////////////////
// LIGHTING
// We're not actually turning on GL lights right now
// because our home-grown ones work better for now.
// public void lights() {
// super.lights();
// gl.glEnable(GL.GL_LIGHTING);
// }
// public void noLights() {
// super.noLights();
// gl.glDisable(GL.GL_LIGHTING);
// }
public void ambientLight(float r, float g, float b) {
super.ambientLight(r, g, b);
glLightEnable(lightCount - 1);
glLightAmbient(lightCount - 1);
glLightPosition(lightCount - 1);
glLightFalloff(lightCount - 1);
}
public void ambientLight(float r, float g, float b,
float x, float y, float z) {
super.ambientLight(r, g, b, x, y, z);
glLightEnable(lightCount - 1);
glLightAmbient(lightCount - 1);
glLightPosition(lightCount - 1);
glLightFalloff(lightCount - 1);
}
public void directionalLight(float r, float g, float b,
float nx, float ny, float nz) {
super.directionalLight(r, g, b, nx, ny, nz);
glLightEnable(lightCount - 1);
glLightNoAmbient(lightCount - 1);
glLightDirection(lightCount - 1);
glLightDiffuse(lightCount - 1);
glLightSpecular(lightCount - 1);
glLightFalloff(lightCount - 1);
}
public void pointLight(float r, float g, float b,
float x, float y, float z) {
super.pointLight(r, g, b, x, y, z);
glLightEnable(lightCount - 1);
glLightNoAmbient(lightCount - 1);
glLightPosition(lightCount - 1);
glLightDiffuse(lightCount - 1);
glLightSpecular(lightCount - 1);
glLightFalloff(lightCount - 1);
}
public void spotLight(float r, float g, float b,
float x, float y, float z,
float nx, float ny, float nz,
float angle, float concentration) {
super.spotLight(r, g, b, x, y, z, nx, ny, nz, angle, concentration);
glLightNoAmbient(lightCount - 1);
glLightPosition(lightCount - 1);
glLightDirection(lightCount - 1);
glLightDiffuse(lightCount - 1);
glLightSpecular(lightCount - 1);
glLightFalloff(lightCount - 1);
glLightSpotAngle(lightCount - 1);
glLightSpotConcentration(lightCount - 1);
}
public void lightFalloff(float constant, float linear, float quadratic) {
super.lightFalloff(constant, linear, quadratic);
glLightFalloff(lightCount);
}
public void lightSpecular(float x, float y, float z) {
super.lightSpecular(x, y, z);
glLightSpecular(lightCount);
}
protected void lightPosition(int num, float x, float y, float z) {
super.lightPosition(num, x, y, z);
glLightPosition(num);
}
protected void lightDirection(int num, float x, float y, float z) {
super.lightDirection(num, x, y, z);
glLightDirection(num);
}
private void glLightAmbient(int num) {
// lightBuffer.put(lightDiffuse[num]);
// lightBuffer.rewind();
// gl.glLightfv(GL.GL_LIGHT0 + num,
// GL.GL_AMBIENT, lightBuffer);
gl.glLightfv(GL.GL_LIGHT0 + num,
GL.GL_AMBIENT, lightDiffuse[num], 0);
}
private void glLightNoAmbient(int num) {
if (zeroBuffer == null) {
// hopefully buffers are filled with zeroes..
zeroBuffer = BufferUtil.newFloatBuffer(3);
}
gl.glLightfv(GL.GL_LIGHT0 + num,
GL.GL_AMBIENT, zeroBuffer);
}
private void glLightDiffuse(int num) {
// lightBuffer.put(lightDiffuse[num]);
// lightBuffer.rewind();
// gl.glLightfv(GL.GL_LIGHT0 + num,
// GL.GL_DIFFUSE, lightBuffer);
gl.glLightfv(GL.GL_LIGHT0 + num,
GL.GL_DIFFUSE, lightDiffuse[num], 0);
}
private void glLightDirection(int num) {
// lightBuffer.put(lightNormal[num]);
// lightBuffer.rewind();
if (lightType[num] == DIRECTIONAL) {
// TODO this expects a fourth arg that will be set to 1
// this is why lightBuffer is length 4,
// and the [3] element set to 1 in the constructor.
// however this may be a source of problems since
// it seems a bit "hack"
gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_POSITION,
lightNormal[num].array(), 0);
} else { // spotlight
// this one only needs the 3 arg version
gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_SPOT_DIRECTION,
lightNormal[num].array(), 0);
}
}
private void glLightEnable(int num) {
gl.glEnable(GL.GL_LIGHT0 + num);
}
private void glLightFalloff(int num) {
gl.glLightf(GL.GL_LIGHT0 + num,
GL.GL_CONSTANT_ATTENUATION, lightFalloffConstant[num]);
gl.glLightf(GL.GL_LIGHT0 + num,
GL.GL_LINEAR_ATTENUATION, lightFalloffLinear[num]);
gl.glLightf(GL.GL_LIGHT0 + num,
GL.GL_QUADRATIC_ATTENUATION, lightFalloffQuadratic[num]);
}
private void glLightPosition(int num) {
gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_POSITION, lightPosition[num].array(), 0);
}
private void glLightSpecular(int num) {
gl.glLightfv(GL.GL_LIGHT0 + num, GL.GL_SPECULAR, lightSpecular[num], 0);
}
private void glLightSpotAngle(int num) {
gl.glLightf(GL.GL_LIGHT0 + num,
GL.GL_SPOT_CUTOFF, lightSpotAngle[num]);
}
private void glLightSpotConcentration(int num) {
gl.glLightf(GL.GL_LIGHT0 + num,
GL.GL_SPOT_EXPONENT, lightSpotConcentration[num]);
}
//////////////////////////////////////////////////////////////
// BACKGROUND
protected void backgroundImpl(PImage image) {
gl.glClearColor(backgroundR, backgroundG, backgroundB, 1);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
set(0, 0, image);
}
protected void backgroundImpl() {
gl.glClearColor(backgroundR, backgroundG, backgroundB, 1);
gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
}
//////////////////////////////////////////////////////////////
// COLOR MODE
// colorMode() is inherited from PGraphics.
//////////////////////////////////////////////////////////////
// COLOR CALC
// This is the OpenGL complement to the colorCalc() methods.
/**
* Load the calculated color into a pre-allocated array so that
* it can be quickly passed over to OpenGL.
*/
private final void calcColorBuffer() {
if (colorBuffer == null) {
// colorBuffer = BufferUtil.newFloatBuffer(4);
colorBuffer = new float[4];
}
colorBuffer[0] = calcR;
colorBuffer[1] = calcG;
colorBuffer[2] = calcB;
colorBuffer[3] = calcA;
// colorBuffer.put(0, calcR);
// colorBuffer.put(1, calcG);
// colorBuffer.put(2, calcB);
// colorBuffer.put(3, calcA);
// colorBuffer.rewind();
}
//////////////////////////////////////////////////////////////
// COLOR METHODS
//public final int color(int gray)
//public final int color(int gray, int alpha)
//public final int color(int rgb, float alpha)
//public final int color(int x, int y, int z)
//public final float alpha(int what)
//public final float red(int what)
//public final float green(int what)
//public final float blue(int what)
//public final float hue(int what)
//public final float saturation(int what)
//public final float brightness(int what)
//public int lerpColor(int c1, int c2, float amt)
//static public int lerpColor(int c1, int c2, float amt, int mode)
//////////////////////////////////////////////////////////////
// BEGINRAW/ENDRAW
// beginRaw, endRaw() both inherited.
//////////////////////////////////////////////////////////////
// WARNINGS and EXCEPTIONS
// showWarning() and showException() available from PGraphics.
/**
* Report on anything from glError().
* Don't use this inside glBegin/glEnd otherwise it'll
* throw an GL_INVALID_OPERATION error.
*/
public void report(String where) {
if (!hints[DISABLE_OPENGL_ERROR_REPORT]) {
int err = gl.glGetError();
if (err != 0) {
String errString = glu.gluErrorString(err);
String msg = "OpenGL error " + err + " at " + where + ": " + errString;
PGraphics.showWarning(msg);
}
}
}
//////////////////////////////////////////////////////////////
// RENDERER SUPPORT QUERIES
//public boolean displayable()
//public boolean dimensional() // from P3D
//////////////////////////////////////////////////////////////
// PIMAGE METHODS
// getImage
// setCache, getCache, removeCache
// isModified, setModified
//////////////////////////////////////////////////////////////
// LOAD/UPDATE PIXELS
public void loadPixels() {
if ((pixels == null) || (pixels.length != width*height)) {
pixels = new int[width * height];
pixelBuffer = BufferUtil.newIntBuffer(pixels.length);
}
/*
for (int y = 0; y < height; y++) {
// or SKIP_PIXELS with y*width
//gl.glPixelStorei(GL.GL_PACK_SKIP_ROWS, (height-1) - y);
gl.glReadPixels(0, y, width, y + 1,
GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixels);
}
gl.glPixelStorei(GL.GL_PACK_SKIP_ROWS, 0);
*/
gl.glReadPixels(0, 0, width, height,
GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer);
pixelBuffer.get(pixels);
pixelBuffer.rewind();
//for (int i = 0; i < 5; i++) {
//System.out.println(PApplet.hex(pixels[i]));
//}
/*
int temp[] = new int[width];
// 3 rows, skips the middle
for (int y = 0; y < height/2; y++) {
int yy = (height - 1) - y;
System.arraycopy(pixels, y*width, temp, 0, width);
System.arraycopy(pixels, yy*width, pixels, y*width, width);
System.arraycopy(temp, 0, pixels, yy*width, width);
}
*/
/*
// now need to swap the RGBA components to ARGB (big endian)
for (int i = 0; i < pixels.length; i++) {
//pixels[i] = ((pixels[i] & 0xff) << 24) |
pixels[i] = ((pixels[i] << 24) & 0xff) | // safer?
((pixels[i] >> 8) & 0xffffff);
}
*/
// flip vertically (opengl stores images upside down),
// and swap RGBA components to ARGB (big endian)
int index = 0;
int yindex = (height - 1) * width;
for (int y = 0; y < height/2; y++) {
if (BIG_ENDIAN) {
for (int x = 0; x < width; x++) {
int temp = pixels[index];
// ignores alpha component, just sets it opaque
pixels[index] = 0xff000000 | ((pixels[yindex] >> 8) & 0x00ffffff);
pixels[yindex] = 0xff000000 | ((temp >> 8) & 0x00ffffff);
index++;
yindex++;
}
} else { // LITTLE_ENDIAN, convert ABGR to ARGB
for (int x = 0; x < width; x++) {
int temp = pixels[index];
// identical to endPixels because only two
// components are being swapped
pixels[index] = 0xff000000 |
((pixels[yindex] << 16) & 0xff0000) |
(pixels[yindex] & 0xff00) |
((pixels[yindex] >> 16) & 0xff);
pixels[yindex] = 0xff000000 |
((temp << 16) & 0xff0000) |
(temp & 0xff00) |
((temp >> 16) & 0xff);
index++;
yindex++;
}
}
yindex -= width*2;
}
// When height is an odd number, the middle line needs to be
// endian swapped, but not y-swapped.
// http://dev.processing.org/bugs/show_bug.cgi?id=944
if ((height % 2) == 1) {
index = (height / 2) * width;
if (BIG_ENDIAN) {
for (int x = 0; x < width; x++) {
// ignores alpha component, just sets it opaque
pixels[index] = 0xff000000 | ((pixels[index] >> 8) & 0x00ffffff);
}
} else {
for (int x = 0; x < width; x++) {
pixels[index] = 0xff000000 |
((pixels[index] << 16) & 0xff0000) |
(pixels[index] & 0xff00) |
((pixels[index] >> 16) & 0xff);
}
}
}
}
/**
* Convert native OpenGL format into palatable ARGB format.
* This function leaves alone (ignores) the alpha component.
* Also flips the image vertically, since images are upside-down in GL.
*/
static void nativeToJavaRGB(PImage image) {
int index = 0;
int yindex = (image.height - 1) * image.width;
for (int y = 0; y < image.height/2; y++) {
if (BIG_ENDIAN) {
for (int x = 0; x < image.width; x++) {
int temp = image.pixels[index];
// ignores alpha component, just sets it opaque
image.pixels[index] =
0xff000000 | ((image.pixels[yindex] >> 8) & 0x00ffffff);
image.pixels[yindex] =
0xff000000 | ((temp >> 8) & 0x00ffffff);
index++;
yindex++;
}
} else { // LITTLE_ENDIAN, convert ABGR to ARGB
for (int x = 0; x < image.width; x++) {
int temp = image.pixels[index];
// identical to endPixels because only two
// components are being swapped
image.pixels[index] = 0xff000000 |
((image.pixels[yindex] << 16) & 0xff0000) |
(image.pixels[yindex] & 0xff00) |
((image.pixels[yindex] >> 16) & 0xff);
image.pixels[yindex] = 0xff000000 |
((temp << 16) & 0xff0000) |
(temp & 0xff00) |
((temp >> 16) & 0xff);
index++;
yindex++;
}
}
yindex -= image.width*2;
}
}
/**
* Convert native OpenGL format into palatable ARGB format.
* This function leaves alone (ignores) the alpha component.
* Also flips the image vertically, since images are upside-down in GL.
*/
static void nativeToJavaARGB(PImage image) {
int index = 0;
int yindex = (image.height - 1) * image.width;
for (int y = 0; y < image.height/2; y++) {
if (BIG_ENDIAN) {
for (int x = 0; x < image.width; x++) {
int temp = image.pixels[index];
// ignores alpha component, just sets it opaque
image.pixels[index] =
(image.pixels[yindex] & 0xff000000) |
((image.pixels[yindex] >> 8) & 0x00ffffff);
image.pixels[yindex] =
(temp & 0xff000000) |
((temp >> 8) & 0x00ffffff);
index++;
yindex++;
}
} else { // LITTLE_ENDIAN, convert ABGR to ARGB
for (int x = 0; x < image.width; x++) {
int temp = image.pixels[index];
// identical to endPixels because only two
// components are being swapped
image.pixels[index] =
(image.pixels[yindex] & 0xff000000) |
((image.pixels[yindex] << 16) & 0xff0000) |
(image.pixels[yindex] & 0xff00) |
((image.pixels[yindex] >> 16) & 0xff);
image.pixels[yindex] =
(temp & 0xff000000) |
((temp << 16) & 0xff0000) |
(temp & 0xff00) |
((temp >> 16) & 0xff);
index++;
yindex++;
}
}
yindex -= image.width*2;
}
}
/**
* Convert ARGB (Java/Processing) data to native OpenGL format.
* This function leaves alone (ignores) the alpha component.
* Also flips the image vertically, since images are upside-down in GL.
*/
static void javaToNativeRGB(PImage image) {
int width = image.width;
int height = image.height;
int pixels[] = image.pixels;
int index = 0;
int yindex = (height - 1) * width;
for (int y = 0; y < height/2; y++) {
if (BIG_ENDIAN) {
// and convert ARGB back to opengl RGBA components (big endian)
for (int x = 0; x < image.width; x++) {
int temp = pixels[index];
/*
pixels[index] =
((pixels[yindex] >> 24) & 0xff) |
((pixels[yindex] << 8) & 0xffffff00);
pixels[yindex] =
((temp >> 24) & 0xff) |
((temp << 8) & 0xffffff00);
*/
pixels[index] = ((pixels[yindex] << 8) & 0xffffff00) | 0xff;
pixels[yindex] = ((temp << 8) & 0xffffff00) | 0xff;
index++;
yindex++;
}
} else {
// convert ARGB back to native little endian ABGR
for (int x = 0; x < width; x++) {
int temp = pixels[index];
pixels[index] = 0xff000000 |
((pixels[yindex] << 16) & 0xff0000) |
(pixels[yindex] & 0xff00) |
((pixels[yindex] >> 16) & 0xff);
pixels[yindex] = 0xff000000 |
((temp << 16) & 0xff0000) |
(temp & 0xff00) |
((temp >> 16) & 0xff);
index++;
yindex++;
}
}
yindex -= width*2;
}
}
/**
* Convert Java ARGB to native OpenGL format.
* Also flips the image vertically, since images are upside-down in GL.
*/
static void javaToNativeARGB(PImage image) {
int width = image.width;
int height = image.height;
int pixels[] = image.pixels;
int index = 0;
int yindex = (height - 1) * width;
for (int y = 0; y < height/2; y++) {
if (BIG_ENDIAN) {
// and convert ARGB back to opengl RGBA components (big endian)
for (int x = 0; x < image.width; x++) {
int temp = pixels[index];
pixels[index] =
((pixels[yindex] >> 24) & 0xff) |
((pixels[yindex] << 8) & 0xffffff00);
pixels[yindex] =
((temp >> 24) & 0xff) |
((temp << 8) & 0xffffff00);
index++;
yindex++;
}
} else {
// convert ARGB back to native little endian ABGR
for (int x = 0; x < width; x++) {
int temp = pixels[index];
pixels[index] =
(pixels[yindex] & 0xff000000) |
((pixels[yindex] << 16) & 0xff0000) |
(pixels[yindex] & 0xff00) |
((pixels[yindex] >> 16) & 0xff);
pixels[yindex] =
(pixels[yindex] & 0xff000000) |
((temp << 16) & 0xff0000) |
(temp & 0xff00) |
((temp >> 16) & 0xff);
index++;
yindex++;
}
}
yindex -= width*2;
}
}
public void updatePixels() {
// flip vertically (opengl stores images upside down),
int index = 0;
int yindex = (height - 1) * width;
for (int y = 0; y < height/2; y++) {
if (BIG_ENDIAN) {
// and convert ARGB back to opengl RGBA components (big endian)
for (int x = 0; x < width; x++) {
int temp = pixels[index];
pixels[index] = ((pixels[yindex] << 8) & 0xffffff00) | 0xff;
pixels[yindex] = ((temp << 8) & 0xffffff00) | 0xff;
index++;
yindex++;
}
} else {
// convert ARGB back to native little endian ABGR
for (int x = 0; x < width; x++) {
int temp = pixels[index];
pixels[index] = 0xff000000 |
((pixels[yindex] << 16) & 0xff0000) |
(pixels[yindex] & 0xff00) |
((pixels[yindex] >> 16) & 0xff);
pixels[yindex] = 0xff000000 |
((temp << 16) & 0xff0000) |
(temp & 0xff00) |
((temp >> 16) & 0xff);
index++;
yindex++;
}
}
yindex -= width*2;
}
// re-pack ARGB data into RGBA for opengl (big endian)
//for (int i = 0; i < pixels.length; i++) {
//pixels[i] = ((pixels[i] >> 24) & 0xff) |
//((pixels[i] << 8) & 0xffffff00);
//}
setRasterPos(0, 0); // lower-left corner
pixelBuffer.put(pixels);
pixelBuffer.rewind();
gl.glDrawPixels(width, height,
GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixelBuffer);
}
//////////////////////////////////////////////////////////////
// RESIZE
public void resize(int wide, int high) {
PGraphics.showMethodWarning("resize");
}
//////////////////////////////////////////////////////////////
// GET/SET
IntBuffer getsetBuffer = BufferUtil.newIntBuffer(1);
// int getset[] = new int[1];
public int get(int x, int y) {
gl.glReadPixels(x, y, 1, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, getsetBuffer);
// gl.glReadPixels(x, y, 1, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, getset, 0);
int getset = getsetBuffer.get(0);
if (BIG_ENDIAN) {
return 0xff000000 | ((getset >> 8) & 0x00ffffff);
} else {
return 0xff000000 |
((getset << 16) & 0xff0000) |
(getset & 0xff00) |
((getset >> 16) & 0xff);
}
}
//public PImage get(int x, int y, int w, int h)
protected PImage getImpl(int x, int y, int w, int h) {
PImage newbie = new PImage(w, h); //new int[w*h], w, h, ARGB);
IntBuffer newbieBuffer = BufferUtil.newIntBuffer(w*h);
gl.glReadPixels(x, y, w, h, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, newbieBuffer);
newbieBuffer.get(newbie.pixels);
nativeToJavaARGB(newbie);
return newbie;
}
public PImage get() {
return get(0, 0, width, height);
}
public void set(int x, int y, int argb) {
int getset = 0;
if (BIG_ENDIAN) {
// convert ARGB to RGBA
getset = (argb << 8) | 0xff;
} else {
// convert ARGB to ABGR
getset =
(argb & 0xff00ff00) |
((argb << 16) & 0xff0000) |
((argb >> 16) & 0xff);
}
getsetBuffer.put(0, getset);
getsetBuffer.rewind();
//gl.glRasterPos2f(x + EPSILON, y + EPSILON);
setRasterPos(x, (height-y) - 1);
gl.glDrawPixels(1, 1, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, getsetBuffer);
}
/**
* Set an image directly to the screen.
* <P>
* TODO not optimized properly, creates multiple temporary buffers
* the size of the image. Needs to instead use image cache, but that
* requires two types of image cache. One for power of 2 textures
* and another for glReadPixels/glDrawPixels data that's flipped
* vertically. Both have their components all swapped to native.
*/
public void set(int x, int y, PImage source) {
int[] backup = new int[source.pixels.length];
System.arraycopy(source.pixels, 0, backup, 0, source.pixels.length);
javaToNativeARGB(source);
// TODO is this possible without intbuffer?
IntBuffer setBuffer = BufferUtil.newIntBuffer(source.pixels.length);
setBuffer.put(source.pixels);
setBuffer.rewind();
setRasterPos(x, (height-y) - source.height); //+source.height);
gl.glDrawPixels(source.width, source.height,
GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, setBuffer);
source.pixels = backup;
}
// TODO remove the implementation above and use setImpl instead,
// since it'll be more efficient
// http://dev.processing.org/bugs/show_bug.cgi?id=943
//protected void setImpl(int dx, int dy, int sx, int sy, int sw, int sh,
// PImage src)
/**
* Definitive method for setting raster pos, including offscreen locations.
* The raster position is tricky because it's affected by the modelview and
* projection matrices. Further, offscreen coords won't properly set the
* raster position. This code gets around both issues.
* http://www.mesa3d.org/brianp/sig97/gotchas.htm
* @param y the Y-coordinate, which is flipped upside down in OpenGL
*/
protected void setRasterPos(float x, float y) {
float z = 0;
float w = 1;
float fx, fy;
// Push current matrix mode and viewport attributes
gl.glPushAttrib(GL.GL_TRANSFORM_BIT | GL.GL_VIEWPORT_BIT);
// Setup projection parameters
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glMatrixMode(GL.GL_MODELVIEW);
gl.glPushMatrix();
gl.glLoadIdentity();
gl.glDepthRange(z, z);
gl.glViewport((int) x - 1, (int) y - 1, 2, 2);
// set the raster (window) position
fx = x - (int) x;
fy = y - (int) y;
gl.glRasterPos4f(fx, fy, 0, w);
// restore matrices, viewport and matrix mode
gl.glPopMatrix();
gl.glMatrixMode(GL.GL_PROJECTION);
gl.glPopMatrix();
gl.glPopAttrib();
}
//////////////////////////////////////////////////////////////
// MASK
public void mask(int alpha[]) {
PGraphics.showMethodWarning("mask");
}
public void mask(PImage alpha) {
PGraphics.showMethodWarning("mask");
}
//////////////////////////////////////////////////////////////
// FILTER
/**
* This is really inefficient and not a good idea in OpenGL.
* Use get() and set() with a smaller image area, or call the
* filter on an image instead, and then draw that.
*/
public void filter(int kind) {
PImage temp = get();
temp.filter(kind);
set(0, 0, temp);
}
/**
* This is really inefficient and not a good idea in OpenGL.
* Use get() and set() with a smaller image area, or call the
* filter on an image instead, and then draw that.
*/
public void filter(int kind, float param) {
PImage temp = get();
temp.filter(kind, param);
set(0, 0, temp);
}
//////////////////////////////////////////////////////////////
/**
* Extremely slow and not optimized, should use GL methods instead.
* Currently calls a beginPixels() on the whole canvas, then does the copy,
* then it calls endPixels().
*/
//public void copy(int sx1, int sy1, int sx2, int sy2,
// int dx1, int dy1, int dx2, int dy2)
/**
* TODO - extremely slow and not optimized.
* Currently calls a beginPixels() on the whole canvas,
* then does the copy, then it calls endPixels().
*/
//public void copy(PImage src,
// int sx1, int sy1, int sx2, int sy2,
// int dx1, int dy1, int dx2, int dy2)
//////////////////////////////////////////////////////////////
// BLEND
//static public int blendColor(int c1, int c2, int mode)
// this function was removed
// public void blend(PImage src,
// int sx, int sy, int dx, int dy, int mode) {
// set(dx, dy, PImage.blendColor(src.get(sx, sy), get(dx, dy), mode));
// }
// the following two were removed for 1.0.2 because loadPixels and
// updatePixels are now called in the superclass.
// http://dev.processing.org/bugs/show_bug.cgi?id=1137
/**
* Extremely slow and not optimized, should use GL methods instead.
* Currently calls a beginPixels() on the whole canvas, then does the copy,
* then it calls endPixels(). Please help fix:
* <A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=941">Bug 941</A>,
* <A HREF="http://dev.processing.org/bugs/show_bug.cgi?id=942">Bug 942</A>.
*/
// public void blend(int sx1, int sy1, int sx2, int sy2,
// int dx1, int dy1, int dx2, int dy2, int mode) {
// loadPixels();
// super.blend(sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, mode);
// updatePixels();
// }
// public void blend(PImage src,
// int sx1, int sy1, int sx2, int sy2,
// int dx1, int dy1, int dx2, int dy2, int mode) {
// loadPixels();
// super.blend(src, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2, mode);
// updatePixels();
// }
//////////////////////////////////////////////////////////////
// SAVE
//public void save(String filename) // PImage calls loadPixels()
//////////////////////////////////////////////////////////////
// INTERNAL MATH
protected final float clamp(float a) {
return (a < 1) ? a : 1;
}
}

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry kind="lib" path="library/itext.jar" sourcepath="itext-src.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>pdf</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>

View File

@ -1,268 +0,0 @@
#Fri Feb 20 11:31:48 EST 2009
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.3
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=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
org.eclipse.jdt.core.compiler.source=1.3
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=36
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=80
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=2
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=80
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true

View File

@ -1,5 +0,0 @@
#Fri Feb 20 11:31:48 EST 2009
eclipse.preferences.version=1
formatter_profile=_fry
formatter_settings_version=11
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates/>

Binary file not shown.

View File

@ -1,2 +0,0 @@
pdf.jar

Binary file not shown.

View File

@ -1,8 +0,0 @@
The majority of the work in this library is done by iText.
http://www.lowagie.com/iText/
The version bundled in this release is 2.1.4.
The files in the library must be named itext.jar because they're specifically
included on the classpath as part of the build/platform/make.sh scripts.

View File

@ -1,619 +0,0 @@
/*
Part of the Processing project - http://processing.org
Copyright (c) 2005-06 Ben Fry and Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.pdf;
import java.io.*;
import java.util.*;
import com.lowagie.text.*;
import com.lowagie.text.pdf.*;
import processing.core.*;
public class PGraphicsPDF extends PGraphicsJava2D {
File temp;
File file;
Document document;
PdfWriter writer;
PdfContentByte content;
// PdfTemplate template;
DefaultFontMapper mapper;
// BaseFont baseFont = mapper.awtToPdf(java.awt.Font awtFont)
public PGraphicsPDF() { }
public void setPath(String path) {
this.path = path;
if (path != null) {
file = new File(path);
if (!file.isAbsolute()) file = null;
}
if (file == null) {
throw new RuntimeException("PGraphicsPDF requires an absolute path " +
"for the location of the output file.");
}
}
//if (applet != null) {
// applet.registerDispose(this);
//}
//System.out.println("making " + path);
//if (path == null) path = "output.pdf";
//this.file = new File(path);
// don't want to require PApplet as the way to do this.. but how?
//if (applet != null) {
//applet.registerDispose(this);
//}
/*
mapper = new DefaultFontMapper();
FontFactory.registerDirectories();
// ummm.. problematic?
//mapper.insertDirectory("c:\\winxp\\fonts");
mapper.insertDirectory("/System/Library/Fonts");
mapper.insertDirectory("/Library/Fonts");
mapper.insertDirectory("/Users/fry/Library/Fonts");
*/
// seems to only pick up ttf and otf fonts
//FontFactory.registerDirectory("/System/Library/Fonts");
//FontFactory.registerDirectory("/Library/Fonts");
//FontFactory.registerDirectory("/Users/fry/Library/Fonts");
/*
Set registered = FontFactory.getRegisteredFonts();
for (Iterator i = registered.iterator(); i.hasNext(); ) {
System.out.println((String) i.next());
}
*/
// public void setPrimarySurface() {
// // set as main drawing surface
// primarySurface = true;
// // this shouldn't actually affect anything
// format = RGB;
// // don't bother adding listeners for this guy
// //parent.addListeners();
// }
// create a temporary file and put the graphics crap there
// don't start a fresh page if frameCount is zero (setup isn't its own page)
/**
* all the init stuff happens in here, in case someone calls size()
* along the way and wants to hork things up.
*/
protected void allocate() {
// can't do anything here, because this will be called by the
// superclass PGraphics, and the file/path object won't be set yet
// (since super() called right at the beginning of the constructor)
}
/*
public void defaults() {
System.out.println("PGraphicsPDF.defaults()");
super.defaults();
}
*/
// if the File object changes, then need to start a new file
//
/*
public void record(int frameCount, File ifile) {
this.frameCount = frameCount;
if (ifile == file) {
// same shit, different pile
// start a new page on the file that's currently open
return;
} else {
if (!file.getName().endsWith(".pdf")) {
// yeaeaargh
}
}
*/
public void beginDraw() {
// temporary
//file = new File(filename); //"test.pdf");
//System.out.println("pdf beginDraw()");
//document = new Document();
if (document == null) {
document = new Document(new Rectangle(width, height));
try {
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos, 16384);
writer = PdfWriter.getInstance(document, bos);
document.open();
content = writer.getDirectContent();
// template = content.createTemplate(width, height);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Problem saving the PDF file.");
}
// how to call newPage() in here?
/*
System.out.println("beginDraw() " + width + ", " + height);
tp = content.createTemplate(width, height);
//g2 = tp.createGraphics(width, height, mapper);
g2 = tp.createGraphicsShapes(width, height);
//System.out.println("g2 is " + g2);
tp.setWidth(width);
tp.setHeight(height);
*/
// what's a good way to switch between these?
// the regular createGraphics doesn't seem to recognize fonts
// how should the insertDirectory stuff be used properly?
//g2 = content.createGraphics(width, height);
// g2 = content.createGraphicsShapes(width, height);
mapper = new DefaultFontMapper();
//System.out.println("registering directories");
//FontFactory.registerDirectories();
//mapper.insertDirectory("c:\\windows\\fonts");
//System.out.println("done registering directories");
if (PApplet.platform == PApplet.MACOSX) {
try {
String homeLibraryFonts =
System.getProperty("user.home") + "/Library/Fonts";
mapper.insertDirectory(homeLibraryFonts);
} catch (Exception e) {
// might be a security issue with getProperty() and user.home
// if this sketch is running from the web
}
// add the system font paths
mapper.insertDirectory("/System/Library/Fonts");
mapper.insertDirectory("/Library/Fonts");
} else if (PApplet.platform == PApplet.WINDOWS) {
// how to get the windows fonts directory?
// could be c:\winnt\fonts or c:\windows\fonts or not even c:
// maybe do a Runtime.exec() on echo %WINDIR% ?
// Runtime.exec solution might be a mess on systems where the
// the backslash/colon characters not really used (i.e. JP)
// find the windows fonts folder
File roots[] = File.listRoots();
/*
PApplet.println(roots);
roots = new File[] { new File("A:\\"),
new File("C:\\"),
new File("D:\\") };
PApplet.println(roots);
*/
for (int i = 0; i < roots.length; i++) {
if (roots[i].toString().startsWith("A:")) {
// Seems to be a problem with some machines that the A:
// drive is returned as an actual root, even if not available.
// 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
// If not, will need to use the other fileExists() code below.
continue;
}
File folder = new File(roots[i], "WINDOWS/Fonts");
if (folder.exists()) {
mapper.insertDirectory(folder.getAbsolutePath());
break;
}
folder = new File(roots[i], "WINNT/Fonts");
if (folder.exists()) {
mapper.insertDirectory(folder.getAbsolutePath());
break;
}
}
}
g2 = content.createGraphics(width, height, mapper);
// g2 = template.createGraphics(width, height, mapper);
}
super.beginDraw();
}
public void endDraw() {
// 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
}
/**
* Gives the same basic functionality of File.exists but can be
* used to look for removable media without showing a system
* dialog if the media is not present. Workaround pulled from the
* <A HREF="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4089199">
* bug report</A> on bugs.sun.com. This bug was fixed in Java 6, and we
* can remove the workaround when we start requiring Java 6.
*/
protected static boolean fileExists(File file) {
try {
Process process =
Runtime.getRuntime().exec(new String[] {
"cmd.exe", "/c", "dir", file.getAbsolutePath()
});
// We need to consume all available output or the process will block.
boolean haveExitCode = false;
int exitCode = -1;
InputStream out = process.getInputStream();
InputStream err = process.getErrorStream();
while (!haveExitCode) {
while (out.read() >= 0) {
}
while (err.read() >= 0) {
}
try {
exitCode = process.exitValue();
haveExitCode = true;
} catch ( IllegalThreadStateException e ) {
// Not yet complete.
Thread.sleep(100);
}
}
//int exitCode = process.waitFor();
return exitCode == 0;
} catch (IOException e) {
System.out.println("Unable to check for file: " + file + " : " + e);
return false;
} catch ( InterruptedException e ) {
System.out.println("Unable to check for file. Interrupted: " +
file + " : " + e);
return false;
}
}
/**
* Change the textMode() to either SHAPE or MODEL.
* <br/>
* This resets all renderer settings, and should therefore
* be called <EM>before</EM> any other commands that set the fill()
* or the textFont() or anything. Unlike other renderers,
* use textMode() directly after the size() command.
*/
public void textMode(int mode) {
if (textMode != mode) {
if (mode == SHAPE) {
g2.dispose();
g2 = content.createGraphicsShapes(width, height);
} else if (mode == MODEL) {
g2.dispose();
g2 = content.createGraphics(width, height, mapper);
// g2 = template.createGraphics(width, height, mapper);
} else if (mode == SCREEN) {
throw new RuntimeException("textMode(SCREEN) not supported with PDF");
} else {
throw new RuntimeException("That textMode() does not exist");
}
}
}
/**
* Call to explicitly go to the next page from within a single draw().
*/
public void nextPage() {
PStyle savedStyle = getStyle();
g2.dispose();
try {
// writer.setPageEmpty(false); // maybe useful later
document.newPage(); // is this bad if no addl pages are made?
} catch (Exception e) {
e.printStackTrace();
}
if (textMode == SHAPE) {
g2 = content.createGraphicsShapes(width, height);
} else if (textMode == MODEL) {
g2 = content.createGraphics(width, height, mapper);
}
style(savedStyle);
// should there be a beginDraw/endDraw in here?
}
public void dispose() {
if (document != null) {
g2.dispose();
document.close(); // can't be done in finalize, not always called
document = null;
}
//new Exception().printStackTrace(System.out);
}
/**
* Don't open a window for this renderer, it won't be used.
*/
public boolean displayable() {
return false;
}
/*
protected void finalize() throws Throwable {
System.out.println("calling finalize");
//document.close(); // do this in dispose instead?
}
*/
//////////////////////////////////////////////////////////////
/*
public void endRecord() {
super.endRecord();
dispose();
}
public void endRaw() {
System.out.println("ending raw");
super.endRaw();
System.out.println("disposing");
dispose();
System.out.println("done");
}
*/
//////////////////////////////////////////////////////////////
/*
protected void rectImpl(float x1, float y1, float x2, float y2) {
//rect.setFrame(x1, y1, x2-x1, y2-y1);
//draw_shape(rect);
System.out.println("rect implements");
g2.fillRect((int)x1, (int)y1, (int) (x2-x1), (int) (y2-y1));
}
*
/*
public void clear() {
g2.setColor(Color.red);
g2.fillRect(0, 0, width, height);
}
*/
//////////////////////////////////////////////////////////////
/*
protected void imageImplAWT(java.awt.Image awtImage,
float x1, float y1, float x2, float y2,
int u1, int v1, int u2, int v2) {
pushMatrix();
translate(x1, y1);
int awtImageWidth = awtImage.getWidth(null);
int awtImageHeight = awtImage.getHeight(null);
scale((x2 - x1) / (float)awtImageWidth,
(y2 - y1) / (float)awtImageHeight);
g2.drawImage(awtImage,
0, 0, awtImageWidth, awtImageHeight,
u1, v1, u2, v2, null);
popMatrix();
}
*/
//////////////////////////////////////////////////////////////
public void loadPixels() {
nope("loadPixels");
}
public void updatePixels() {
nope("updatePixels");
}
public void updatePixels(int x, int y, int c, int d) {
nope("updatePixels");
}
//
public int get(int x, int y) {
nope("get");
return 0; // not reached
}
public PImage get(int x, int y, int c, int d) {
nope("get");
return null; // not reached
}
public PImage get() {
nope("get");
return null; // not reached
}
public void set(int x, int y, int argb) {
nope("set");
}
public void set(int x, int y, PImage image) {
nope("set");
}
//
public void mask(int alpha[]) {
nope("mask");
}
public void mask(PImage alpha) {
nope("mask");
}
//
public void filter(int kind) {
nope("filter");
}
public void filter(int kind, float param) {
nope("filter");
}
//
public void copy(int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2) {
nope("copy");
}
public void copy(PImage src,
int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2) {
nope("copy");
}
//
public void blend(int sx, int sy, int dx, int dy, int mode) {
nope("blend");
}
public void blend(PImage src,
int sx, int sy, int dx, int dy, int mode) {
nope("blend");
}
public void blend(int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2, int mode) {
nope("blend");
}
public void blend(PImage src,
int sx1, int sy1, int sx2, int sy2,
int dx1, int dy1, int dx2, int dy2, int mode) {
nope("blend");
}
//
public void save(String filename) {
nope("save");
}
//////////////////////////////////////////////////////////////
/**
* Add a directory that should be searched for font data.
* <br/>
* On Mac OS X, the following directories are added by default:
* <UL>
* <LI>/System/Library/Fonts
* <LI>/Library/Fonts
* <LI>~/Library/Fonts
* </UL>
* On Windows, all drive letters are searched for WINDOWS\Fonts
* or WINNT\Fonts, any that exists is added.
* <br/><br/>
* On Linux or any other platform, you'll need to add the
* directories by hand. (If there are actual standards here that we
* can use as a starting point, please file a bug to make a note of it)
*/
public void addFonts(String directory) {
mapper.insertDirectory(directory);
}
/**
* List the fonts known to the PDF renderer. This is like PFont.list(),
* however not all those fonts are available by default.
*/
public String[] listFonts() {
/*
//System.out.println("list of fonts");
HashMap map = mapper.getAliases();
//KeySet keys = map.keySet();
Set entries = map.entrySet();
Iterator it = entries.iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
System.out.println(entry.getKey() + "-->" + entry.getValue());
}
*/
/*
HashMap map = mapper.getAliases();
KeySet keys = map.keySet();
Iterator it = entries.iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
System.out.println(entry.getKey() + "-->" + entry.getValue());
}
*/
HashMap map = mapper.getAliases();
Set entries = map.entrySet();
String list[] = new String[entries.size()];
Iterator it = entries.iterator();
int count = 0;
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
//System.out.println(entry.getKey() + "-->" + entry.getValue());
list[count++] = (String) entry.getKey();
}
return PApplet.sort(list);
}
//////////////////////////////////////////////////////////////
protected void nope(String function) {
throw new RuntimeException("No " + function + "() for PGraphicsPDF");
}
}

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="library/RXTXcomm.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>serial</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>

View File

@ -1,12 +0,0 @@
#Sat Oct 11 19:36:05 EDT 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.5
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.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.5

View File

@ -1 +0,0 @@
serial.jar

Binary file not shown.

View File

@ -1,3 +0,0 @@
application.macosx = serial.jar, RXTXcomm.jar, librxtxSerial.jnilib
application.windows = serial.jar, RXTXcomm.jar, rxtxSerial.dll
application.linux = serial.jar, RXTXcomm.jar, librxtxSerial.so

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,673 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
PSerial - class for serial port goodness
Part of the Processing project - http://processing.org
Copyright (c) 2004-05 Ben Fry & Casey Reas
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.serial;
import processing.core.*;
import gnu.io.*;
import java.io.*;
import java.util.*;
import java.lang.reflect.*;
public class Serial implements SerialPortEventListener {
PApplet parent;
Method serialEventMethod;
// properties can be passed in for default values
// otherwise defaults to 9600 N81
// these could be made static, which might be a solution
// for the classloading problem.. because if code ran again,
// the static class would have an object that could be closed
public SerialPort port;
public int rate;
public int parity;
public int databits;
public int stopbits;
// read buffer and streams
public InputStream input;
public OutputStream output;
byte buffer[] = new byte[32768];
int bufferIndex;
int bufferLast;
//boolean bufferUntil = false;
int bufferSize = 1; // how big before reset or event firing
boolean bufferUntil;
int bufferUntilByte;
// defaults
static String dname = "COM1";
static int drate = 9600;
static char dparity = 'N';
static int ddatabits = 8;
static float dstopbits = 1;
public void setProperties(Properties props) {
dname =
props.getProperty("serial.port", dname);
drate =
Integer.parseInt(props.getProperty("serial.rate", "9600"));
dparity =
props.getProperty("serial.parity", "N").charAt(0);
ddatabits =
Integer.parseInt(props.getProperty("serial.databits", "8"));
dstopbits =
new Float(props.getProperty("serial.stopbits", "1")).floatValue();
}
public Serial(PApplet parent) {
this(parent, dname, drate, dparity, ddatabits, dstopbits);
}
public Serial(PApplet parent, int irate) {
this(parent, dname, irate, dparity, ddatabits, dstopbits);
}
public Serial(PApplet parent, String iname, int irate) {
this(parent, iname, irate, dparity, ddatabits, dstopbits);
}
public Serial(PApplet parent, String iname) {
this(parent, iname, drate, dparity, ddatabits, dstopbits);
}
public Serial(PApplet parent, String iname, int irate,
char iparity, int idatabits, float istopbits) {
//if (port != null) port.close();
this.parent = parent;
//parent.attach(this);
this.rate = irate;
parity = SerialPort.PARITY_NONE;
if (iparity == 'E') parity = SerialPort.PARITY_EVEN;
if (iparity == 'O') parity = SerialPort.PARITY_ODD;
this.databits = idatabits;
stopbits = SerialPort.STOPBITS_1;
if (istopbits == 1.5f) stopbits = SerialPort.STOPBITS_1_5;
if (istopbits == 2) stopbits = SerialPort.STOPBITS_2;
try {
Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier portId =
(CommPortIdentifier) portList.nextElement();
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
//System.out.println("found " + portId.getName());
if (portId.getName().equals(iname)) {
port = (SerialPort)portId.open("serial madness", 2000);
input = port.getInputStream();
output = port.getOutputStream();
port.setSerialPortParams(rate, databits, stopbits, parity);
port.addEventListener(this);
port.notifyOnDataAvailable(true);
//System.out.println("opening, ready to roll");
}
}
}
} catch (Exception e) {
errorMessage("<init>", e);
//exception = e;
//e.printStackTrace();
port = null;
input = null;
output = null;
}
parent.registerDispose(this);
// reflection to check whether host applet has a call for
// public void serialEvent(processing.serial.Serial)
// which would be called each time an event comes in
try {
serialEventMethod =
parent.getClass().getMethod("serialEvent",
new Class[] { Serial.class });
} catch (Exception e) {
// no such method, or an error.. which is fine, just ignore
}
}
/**
* Stop talking to serial and shut things down.
* <P>
* Basically just a user-accessible version of dispose().
* For now, it just calls dispose(), but dispose shouldn't
* be called from applets, because in some libraries,
* dispose() blows shit up if it's called by a user who
* doesn't know what they're doing.
*/
public void stop() {
dispose();
}
/**
* Used by PApplet to shut things down.
*/
public void dispose() {
try {
// do io streams need to be closed first?
if (input != null) input.close();
if (output != null) output.close();
} catch (Exception e) {
e.printStackTrace();
}
input = null;
output = null;
try {
if (port != null) port.close(); // close the port
} catch (Exception e) {
e.printStackTrace();
}
port = null;
}
/**
* Set the DTR line. Addition from Tom Hulbert.
*/
public void setDTR(boolean state) {
port.setDTR(state);
}
synchronized public void serialEvent(SerialPortEvent serialEvent) {
if (serialEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
try {
while (input.available() > 0) {
synchronized (buffer) {
if (bufferLast == buffer.length) {
byte temp[] = new byte[bufferLast << 1];
System.arraycopy(buffer, 0, temp, 0, bufferLast);
buffer = temp;
}
buffer[bufferLast++] = (byte) input.read();
if (serialEventMethod != null) {
if ((bufferUntil &&
(buffer[bufferLast-1] == bufferUntilByte)) ||
(!bufferUntil &&
((bufferLast - bufferIndex) >= bufferSize))) {
try {
serialEventMethod.invoke(parent, new Object[] { this });
} catch (Exception e) {
String msg = "error, disabling serialEvent() for " + port;
System.err.println(msg);
e.printStackTrace();
serialEventMethod = null;
}
}
}
}
}
} catch (IOException e) {
errorMessage("serialEvent", e);
}
}
}
/**
* Set number of bytes to buffer before calling serialEvent()
* in the host applet.
*/
public void buffer(int count) {
bufferUntil = false;
bufferSize = count;
}
/**
* Set a specific byte to buffer until before calling
* serialEvent() in the host applet.
*/
public void bufferUntil(int what) {
bufferUntil = true;
bufferUntilByte = what;
}
/**
* Returns the number of bytes that have been read from serial
* and are waiting to be dealt with by the user.
*/
public int available() {
return (bufferLast - bufferIndex);
}
/**
* Ignore all the bytes read so far and empty the buffer.
*/
public void clear() {
bufferLast = 0;
bufferIndex = 0;
}
/**
* Returns a number between 0 and 255 for the next byte that's
* waiting in the buffer.
* Returns -1 if there was no byte (although the user should
* first check available() to see if things are ready to avoid this)
*/
public int read() {
if (bufferIndex == bufferLast) return -1;
synchronized (buffer) {
int outgoing = buffer[bufferIndex++] & 0xff;
if (bufferIndex == bufferLast) { // rewind
bufferIndex = 0;
bufferLast = 0;
}
return outgoing;
}
}
/**
* Same as read() but returns the very last value received
* and clears the buffer. Useful when you just want the most
* recent value sent over the port.
*/
public int last() {
if (bufferIndex == bufferLast) return -1;
synchronized (buffer) {
int outgoing = buffer[bufferLast-1];
bufferIndex = 0;
bufferLast = 0;
return outgoing;
}
}
/**
* Returns the next byte in the buffer as a char.
* Returns -1, or 0xffff, if nothing is there.
*/
public char readChar() {
if (bufferIndex == bufferLast) return (char)(-1);
return (char) read();
}
/**
* Just like last() and readChar().
*/
public char lastChar() {
if (bufferIndex == bufferLast) return (char)(-1);
return (char) last();
}
/**
* 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).
*/
public byte[] readBytes() {
if (bufferIndex == bufferLast) return null;
synchronized (buffer) {
int length = bufferLast - bufferIndex;
byte outgoing[] = new byte[length];
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
bufferIndex = 0; // rewind
bufferLast = 0;
return outgoing;
}
}
/**
* Grab whatever is in the serial buffer, and stuff it into a
* byte buffer passed in by the user. This is more memory/time
* efficient than readBytes() returning a byte[] array.
*
* 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.
*/
public int readBytes(byte outgoing[]) {
if (bufferIndex == bufferLast) return 0;
synchronized (buffer) {
int length = bufferLast - bufferIndex;
if (length > outgoing.length) length = outgoing.length;
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
bufferIndex += length;
if (bufferIndex == bufferLast) {
bufferIndex = 0; // rewind
bufferLast = 0;
}
return length;
}
}
/**
* Reads from the serial port into a buffer of bytes up to and
* including a particular character. If the character isn't in
* the serial buffer, then 'null' is returned.
*/
public byte[] readBytesUntil(int interesting) {
if (bufferIndex == bufferLast) return null;
byte what = (byte)interesting;
synchronized (buffer) {
int found = -1;
for (int k = bufferIndex; k < bufferLast; k++) {
if (buffer[k] == what) {
found = k;
break;
}
}
if (found == -1) return null;
int length = found - bufferIndex + 1;
byte outgoing[] = new byte[length];
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
bufferIndex += length;
if (bufferIndex == bufferLast) {
bufferIndex = 0; // rewind
bufferLast = 0;
}
return outgoing;
}
}
/**
* Reads from the serial port into a buffer of bytes until a
* particular character. If the character isn't in the serial
* buffer, then 'null' is returned.
*
* If outgoing[] is not big enough, then -1 is returned,
* 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.
*/
public int readBytesUntil(int interesting, byte outgoing[]) {
if (bufferIndex == bufferLast) return 0;
byte what = (byte)interesting;
synchronized (buffer) {
int found = -1;
for (int k = bufferIndex; k < bufferLast; k++) {
if (buffer[k] == what) {
found = k;
break;
}
}
if (found == -1) return 0;
int length = found - bufferIndex + 1;
if (length > outgoing.length) {
System.err.println("readBytesUntil() byte buffer is" +
" too small for the " + length +
" bytes up to and including char " + interesting);
return -1;
}
//byte outgoing[] = new byte[length];
System.arraycopy(buffer, bufferIndex, outgoing, 0, length);
bufferIndex += length;
if (bufferIndex == bufferLast) {
bufferIndex = 0; // rewind
bufferLast = 0;
}
return length;
}
}
/**
* Return whatever has been read from the serial port so far
* as a String. It assumes that the incoming characters are ASCII.
*
* 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.
*/
public String readString() {
if (bufferIndex == bufferLast) return null;
return new String(readBytes());
}
/**
* Combination of readBytesUntil and readString. See caveats in
* each function. Returns null if it still hasn't found what
* you're looking for.
*
* 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.
*/
public String readStringUntil(int interesting) {
byte b[] = readBytesUntil(interesting);
if (b == null) return null;
return new String(b);
}
/**
* This will handle both ints, bytes and chars transparently.
*/
public void write(int what) { // will also cover char
try {
output.write(what & 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);
}
}
public void write(byte bytes[]) {
try {
output.write(bytes);
output.flush(); // hmm, not sure if a good idea
} catch (Exception e) { // null pointer or serial port dead
//errorMessage("write", e);
e.printStackTrace();
}
}
/**
* 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.
*/
public void write(String what) {
write(what.getBytes());
}
/**
* If this just hangs and never completes on Windows,
* it may be because the DLL doesn't have its exec bit set.
* Why the hell that'd be the case, who knows.
*/
static public String[] list() {
Vector<String> list = new Vector<String>();
try {
//System.err.println("trying");
Enumeration<?> portList = CommPortIdentifier.getPortIdentifiers();
//System.err.println("got port list");
while (portList.hasMoreElements()) {
CommPortIdentifier portId =
(CommPortIdentifier) portList.nextElement();
//System.out.println(portId);
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
String name = portId.getName();
list.addElement(name);
}
}
} catch (UnsatisfiedLinkError e) {
//System.err.println("1");
errorMessage("ports", e);
} catch (Exception e) {
//System.err.println("2");
errorMessage("ports", e);
}
//System.err.println("move out");
String outgoing[] = new String[list.size()];
list.copyInto(outgoing);
return outgoing;
}
/**
* General error reporting, all corraled here just in case
* I think of something slightly more intelligent to do.
*/
static public void errorMessage(String where, Throwable e) {
e.printStackTrace();
throw new RuntimeException("Error inside Serial." + where + "()");
}
}
/*
class SerialMenuListener implements ItemListener {
//public SerialMenuListener() { }
public void itemStateChanged(ItemEvent e) {
int count = serialMenu.getItemCount();
for (int i = 0; i < count; i++) {
((CheckboxMenuItem)serialMenu.getItem(i)).setState(false);
}
CheckboxMenuItem item = (CheckboxMenuItem)e.getSource();
item.setState(true);
String name = item.getLabel();
//System.out.println(item.getLabel());
PdeBase.properties.put("serial.port", name);
//System.out.println("set to " + get("serial.port"));
}
}
*/
/*
protected Vector buildPortList() {
// get list of names for serial ports
// have the default port checked (if present)
Vector list = new Vector();
//SerialMenuListener listener = new SerialMenuListener();
boolean problem = false;
// if this is failing, it may be because
// lib/javax.comm.properties is missing.
// java is weird about how it searches for java.comm.properties
// so it tends to be very fragile. i.e. quotes in the CLASSPATH
// environment variable will hose things.
try {
//System.out.println("building port list");
Enumeration portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
CommPortIdentifier portId =
(CommPortIdentifier) portList.nextElement();
//System.out.println(portId);
if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) {
//if (portId.getName().equals(port)) {
String name = portId.getName();
//CheckboxMenuItem mi =
//new CheckboxMenuItem(name, name.equals(defaultName));
//mi.addItemListener(listener);
//serialMenu.add(mi);
list.addElement(name);
}
}
} catch (UnsatisfiedLinkError e) {
e.printStackTrace();
problem = true;
} catch (Exception e) {
System.out.println("exception building serial menu");
e.printStackTrace();
}
//if (serialMenu.getItemCount() == 0) {
//System.out.println("dimming serial menu");
//serialMenu.setEnabled(false);
//}
// only warn them if this is the first time
if (problem && PdeBase.firstTime) {
JOptionPane.showMessageDialog(this, //frame,
"Serial port support not installed.\n" +
"Check the readme for instructions\n" +
"if you need to use the serial port. ",
"Serial Port Warning",
JOptionPane.WARNING_MESSAGE);
}
return list;
}
*/

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/core"/>
<classpathentry kind="lib" path="QTJava.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>video</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>

View File

@ -1,263 +0,0 @@
#Tue Sep 30 10:42:04 EDT 2008
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.1
org.eclipse.jdt.core.compiler.compliance=1.3
org.eclipse.jdt.core.compiler.problem.assertIdentifier=ignore
org.eclipse.jdt.core.compiler.problem.enumIdentifier=ignore
org.eclipse.jdt.core.compiler.source=1.3
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=18
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=18
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=82
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=18
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
org.eclipse.jdt.core.formatter.blank_lines_before_field=1
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
org.eclipse.jdt.core.formatter.comment.format_header=false
org.eclipse.jdt.core.formatter.comment.format_html=true
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
org.eclipse.jdt.core.formatter.comment.format_source_code=true
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=80
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_empty_lines=false
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false
org.eclipse.jdt.core.formatter.indentation.size=2
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
org.eclipse.jdt.core.formatter.lineSplit=80
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true

View File

@ -1,4 +0,0 @@
#Tue Sep 30 10:42:04 EDT 2008
eclipse.preferences.version=1
formatter_profile=_two spaces no tabs
formatter_settings_version=11

Binary file not shown.

View File

@ -1 +0,0 @@
video.jar

View File

@ -1,547 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-08 Ben Fry and Casey Reas
The previous version of this code was developed by Hernando Barragan
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.video;
import processing.core.*;
import java.lang.reflect.*;
import quicktime.*;
import quicktime.qd.*;
import quicktime.std.*;
import quicktime.std.sg.*;
import quicktime.util.RawEncodedImage;
/**
* Watchin' shit on the telly.
*/
public class Capture extends PImage implements Runnable {
// there are more, but these are all we'll provide for now
// The useful ref page for <a href="http://developer.apple.com/documentation/Java/Reference/1.4.1/Java141API_QTJ/constant-values.html">quicktime constants</a>
static public final int COMPOSITE = StdQTConstants.compositeIn; // 0
static public final int SVIDEO = StdQTConstants.sVideoIn; // 1
static public final int COMPONENT = StdQTConstants.rgbComponentIn; // 2
static public final int TUNER = StdQTConstants.tvTunerIn; // 6
static public final int NTSC = StdQTConstants.ntscIn;
static public final int PAL = StdQTConstants.palIn;
static public final int SECAM = StdQTConstants.secamIn;
// no longer needed because parent field added to PImage
//PApplet parent;
Method captureEventMethod;
String name; // keep track for error messages (unused)
Thread runner;
boolean available = false;
/** Temporary storage for the raw image
data read directly from the capture device */
public int data[];
public int dataWidth;
public int dataHeight;
public int dataRowBytes;
/** True if this image is currently being cropped */
public boolean crop;
public int cropX;
public int cropY;
public int cropW;
public int cropH;
public int frameRate;
public RawEncodedImage raw;
public SequenceGrabber capture;
/** the guy who's doing all the work */
public SGVideoChannel channel;
/** boundary of image at the requested size */
protected QDRect qdrect;
/*
static {
try {
QTSession.open();
} catch (QTException e) {
e.printStackTrace();
}
// this doesn't appear to do jack
QTRuntimeException.registerHandler(new QTRuntimeHandler() {
public void exceptionOccurred(QTRuntimeException e,
Object obj, String s, boolean flag) {
System.err.println("Problem inside Capture");
e.printStackTrace();
}
});
}
*/
public Capture(PApplet parent, int requestWidth, int requestHeight) {
this(parent, requestWidth, requestHeight, null, 30);
}
public Capture(PApplet parent, int reqWidth, int reqHeight, int frameRate) {
this(parent, reqWidth, reqHeight, null, frameRate);
}
public Capture(PApplet parent, int reqWidth, int reqHeight, String name) {
this(parent, reqWidth, reqHeight, name, 30);
}
/**
* If 'name' is null or the empty string, it won't set a specific
* device, which means that QuickTime will use that last device
* used by a QuickTime application.
* <P/>
* Unfortunately, Apple's QuickTime API uses the name to select devices,
* and in some cases there might be cameras with the same name on a machine.
* If you ask for a camera of the same name in sequence, you might see if it
* just does the right thing and grabs each separate camera in succession.
* If that doesn't work, you might try calling settings() which will
* bring up the prompt where you can select a capture device.
* <P/>
* If the following function:
* <PRE>public void captureEvent(Capture c)</PRE>
* is defined in the host PApplet, then it will be called every
* time a new frame is available from the capture device.
*/
public Capture(final PApplet parent,
final int requestWidth, final int requestHeight,
final String name, final int frameRate) {
// Running on EDT because of weird hang on OS X
// http://dev.processing.org/bugs/show_bug.cgi?id=882
// QTSession.open() is hanging, not sure why, but it seems to prefer
// being run from the EDT. Not sure if that's a mistaken expectation in
// QTJava (we hadn't had trouble in the past because we did everything
// on the EDT) or if something broken in more recent QTJ. Or (maybe most
// likely) we're simply hitting some other threading strangeness, and
// using invokeLater() isolates us from that. Which is a nice way of
// saying that it's a hack.
//SwingUtilities.invokeLater(new Runnable() {
// public void run() {
init(parent, requestWidth, requestHeight, name, frameRate);
//}
//});
}
public void init(PApplet parent, int requestWidth, int requestHeight,
String name, int frameRate) {
this.parent = parent;
this.name = name;
this.frameRate = frameRate;
try {
QTSession.open();
} catch (QTException e) {
e.printStackTrace(System.out);
return;
}
try {
qdrect = new QDRect(requestWidth, requestHeight);
// workaround for bug with the intel macs
QDGraphics qdgraphics = null; //new QDGraphics(qdrect);
if (quicktime.util.EndianOrder.isNativeLittleEndian()) {
qdgraphics = new QDGraphics(QDConstants.k32BGRAPixelFormat, qdrect);
} else {
qdgraphics = new QDGraphics(QDGraphics.kDefaultPixelFormat, qdrect);
}
capture = new SequenceGrabber();
capture.setGWorld(qdgraphics, null);
channel = new SGVideoChannel(capture);
channel.setBounds(qdrect);
channel.setUsage(2); // what is this usage number?
capture.startPreview(); // maybe this comes later?
PixMap pixmap = qdgraphics.getPixMap();
raw = pixmap.getPixelData();
/*
if (name == null) {
channel.settingsDialog();
} else if (name.length() > 0) {
channel.setDevice(name);
}
*/
if ((name != null) && (name.length() > 0)) {
channel.setDevice(name);
}
dataRowBytes = raw.getRowBytes();
dataWidth = dataRowBytes / 4;
dataHeight = raw.getSize() / dataRowBytes;
if (dataWidth != requestWidth) {
crop = true;
cropX = 0;
cropY = 0;
cropW = requestWidth;
cropH = requestHeight;
}
// initialize my PImage self
super.init(requestWidth, requestHeight, RGB);
parent.registerDispose(this);
try {
captureEventMethod =
parent.getClass().getMethod("captureEvent",
new Class[] { Capture.class });
} catch (Exception e) {
// no such method, or an error.. which is fine, just ignore
}
runner = new Thread(this);
runner.start();
} catch (QTException qte) {
//} catch (StdQTException qte) {
//qte.printStackTrace();
int errorCode = qte.errorCode();
if (errorCode == Errors.couldntGetRequiredComponent) {
// this can happen when the capture device isn't available
// or wasn't shut down properly
parent.die("No capture could be found, " +
"or the VDIG is not installed correctly.", qte);
} else {
parent.die("Error while setting up Capture", qte);
}
} catch (Exception e) {
parent.die("Error while setting up Capture", e);
}
}
/**
* True if a frame is ready to be read.
* <PRE>
* // put this somewhere inside draw
* if (capture.available()) capture.read();
* </PRE>
* Alternatively, you can use captureEvent(Capture c) to notify you
* whenever available() is set to true. In which case, things might
* look like this:
* <PRE>
* public void captureEvent(Capture c) {
* c.read();
* // do something exciting now that c has been updated
* }
* </PRE>
*/
public boolean available() {
return available;
}
/**
* Set the video to crop from its original.
* <P>
* It seems common that captures add lines to the top or bottom
* of an image, so this can be useful for removing them.
* Internally, the pixel buffer size returned from QuickTime is
* often a different size than requested, so crop will be set
* more often than not.
*/
public void crop(int x, int y, int w, int h) {
/*
if (imageMode == CORNERS) {
w -= x; // w was actually x2
h -= y; // h was actually y2
}
*/
crop = true;
cropX = Math.max(0, x);
cropY = Math.max(0, y);
cropW = Math.min(w, dataWidth);
cropH = Math.min(dataHeight, y + h) - cropY;
// if size has changed, re-init this image
if ((cropW != width) || (cropH != height)) {
init(w, h, RGB);
}
}
/**
* Remove the cropping (if any) of the image.
* <P>
* By default, cropping is often enabled to trim out black pixels.
* But if you'd rather deal with them yourself (so as to avoid
* an extra lag while the data is moved around) you can shut it off.
*/
public void noCrop() {
crop = false;
}
public void read() {
//try {
//synchronized (capture) {
loadPixels();
synchronized (pixels) {
//System.out.println("read1");
if (crop) {
//System.out.println("read2a");
// f#$)(#$ing quicktime / jni is so g-d slow, calling copyToArray
// for the invidual rows is literally 100x slower. instead, first
// copy the entire buffer to a separate array (i didn't need that
// memory anyway), and do an arraycopy for each row.
if (data == null) {
data = new int[dataWidth * dataHeight];
}
raw.copyToArray(0, data, 0, dataWidth * dataHeight);
int sourceOffset = cropX + cropY*dataWidth;
int destOffset = 0;
for (int y = 0; y < cropH; y++) {
System.arraycopy(data, sourceOffset, pixels, destOffset, cropW);
sourceOffset += dataWidth;
destOffset += width;
}
} else { // no crop, just copy directly
//System.out.println("read2b");
raw.copyToArray(0, pixels, 0, width * height);
}
//System.out.println("read3");
available = false;
// mark this image as modified so that PGraphicsJava2D and
// PGraphicsOpenGL will properly re-blit and draw this guy
updatePixels();
//System.out.println("read4");
}
}
public void run() {
while ((Thread.currentThread() == runner) && (capture != null)) {
try {
synchronized (capture) {
capture.idle();
//read();
available = true;
if (captureEventMethod != null) {
try {
captureEventMethod.invoke(parent, new Object[] { this });
} catch (Exception e) {
System.err.println("Disabling captureEvent() for " + name +
" because of an error.");
e.printStackTrace();
captureEventMethod = null;
}
}
}
} catch (QTException e) {
errorMessage("run", e);
}
try {
Thread.sleep(1000 / frameRate);
} catch (InterruptedException e) { }
}
}
/**
* Set the frameRate for how quickly new frames are read
* from the capture device.
*/
public void frameRate(int iframeRate) {
if (iframeRate <= 0) {
System.err.println("Capture: ignoring bad frameRate of " +
iframeRate + " fps.");
return;
}
frameRate = iframeRate;
}
/**
* Called by applets to stop capturing video.
*/
public void stop() {
if (capture != null) {
try {
capture.stop(); // stop the "preview"
} catch (StdQTException e) {
e.printStackTrace();
}
capture = null;
}
runner = null; // unwind the thread
}
/**
* Called by PApplet to shut down video so that QuickTime
* can be used later by another applet.
*/
public void dispose() {
stop();
//System.out.println("calling dispose");
// this is important so that the next app can do video
QTSession.close();
}
/**
* General error reporting, all corraled here just in case
* I think of something slightly more intelligent to do.
*/
protected void errorMessage(String where, Exception e) {
parent.die("Error inside Capture." + where + "()", e);
}
/**
* Set the format to ask for from the video digitizer:
* TUNER, COMPOSITE, SVIDEO, or COMPONENT.
* <P>
* The constants are just aliases to the constants returned from
* QuickTime's getInputFormat() function, so any valid constant from
* that will work just fine.
*/
public void source(int which) {
try {
VideoDigitizer digitizer = channel.getDigitizerComponent();
int count = digitizer.getNumberOfInputs();
for (int i = 0; i < count; i++) {
//System.out.println("format " + digitizer.getInputFormat(i));
if (digitizer.getInputFormat(i) == which) {
digitizer.setInput(i);
return;
}
}
throw new RuntimeException("The specified source() is not available.");
} catch (StdQTException e) {
e.printStackTrace();
throw new RuntimeException("Could not set the video input source.");
}
}
/**
* Set the video format standard to use on the
* video digitizer: NTSC, PAL, or SECAM.
* <P>
* The constants are just aliases to the constants used for
* QuickTime's setInputStandard() function, so any valid
* constant from that will work just fine.
*/
public void format(int which) {
try {
VideoDigitizer digitizer = channel.getDigitizerComponent();
digitizer.setInputStandard(which);
} catch (StdQTException e) {
e.printStackTrace();
//throw new RuntimeException("Could not set the video input format");
}
}
/**
* Show the settings dialog for this input device.
*/
public void settings() {
try {
// fix for crash here submitted by hansi (stop/startPreview lines)
capture.stop();
// Whenever settingsDialog() is called, the boundries change,
// causing the image to be cropped. Fix for Bug #366
// http://dev.processing.org/bugs/show_bug.cgi?id=366
channel.setBounds(qdrect);
// Open the settings dialog (throws an Exception if canceled)
channel.settingsDialog();
} catch (StdQTException qte) {
int errorCode = qte.errorCode();
if (errorCode == Errors.userCanceledErr) {
// User only canceled the settings dialog, continue as we were
} else {
qte.printStackTrace();
throw new RuntimeException("Error inside Capture.settings()");
}
}
try {
// Start the preview again (unreachable if newly thrown exception)
capture.startPreview();
} catch (StdQTException qte) {
qte.printStackTrace();
}
}
/**
* Get a list of all available captures as a String array.
* i.e. println(Capture.list()) will show you the goodies.
*/
static public String[] list() {
try {
QTSession.open();
SequenceGrabber grabber = new SequenceGrabber();
SGVideoChannel channel = new SGVideoChannel(grabber);
SGDeviceList deviceList = channel.getDeviceList(0); // flags is 0
String listing[] = new String[deviceList.getCount()];
for (int i = 0; i < deviceList.getCount(); i++) {
listing[i] = deviceList.getDeviceName(i).getName();
}
// properly shut down the channel so the app can use it again
grabber.disposeChannel(channel);
QTSession.close();
return listing;
} catch (QTException qte) {
int errorCode = qte.errorCode();
if (errorCode == Errors.couldntGetRequiredComponent) {
throw new RuntimeException("Couldn't find any capture devices, " +
"read the video reference for more info.");
} else {
qte.printStackTrace();
throw new RuntimeException("Problem listing capture devices, " +
"read the video reference for more info.");
}
}
//return null;
}
}

View File

@ -1,736 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2004-07 Ben Fry and Casey Reas
The previous version of this code was developed by Hernando Barragan
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.video;
import processing.core.*;
import java.io.*;
import java.lang.reflect.*;
import quicktime.*;
import quicktime.io.QTFile;
import quicktime.qd.*;
import quicktime.std.*;
import quicktime.std.movies.media.DataRef;
import quicktime.util.QTHandle;
import quicktime.util.RawEncodedImage;
public class Movie extends PImage implements PConstants, Runnable {
// no longer needing a reference to the parent because PImage has one
//PApplet parent;
Method movieEventMethod;
String filename;
Thread runner;
PImage borderImage;
boolean removeBorders = true;
boolean play;
boolean repeat;
boolean available;
int fps;
/**
* The QuickTime for Java "Movie" object, made public
* in case anyone wants to play with it.
*/
public quicktime.std.movies.Movie movie;
QDRect movieRect;
QDGraphics movieGraphics;
boolean firstFrame = true;
RawEncodedImage raw;
/*
static {
try {
//System.out.println("jlp = " + System.getProperty("java.library.path"));
QTSession.open();
} catch (QTException e) {
e.printStackTrace();
}
// shutting off for 0116, hoping for better exception handling
QTRuntimeException.registerHandler(new QTRuntimeHandler() {
public void exceptionOccurred(QTRuntimeException e,
Object obj, String s, boolean flag) {
System.err.println("Problem inside Movie");
e.printStackTrace();
}
});
}
*/
public Movie(PApplet parent, String filename) {
this(parent, filename, 30);
}
public Movie(final PApplet parent, final String filename, final int ifps) {
// this creates a fake image so that the first time this
// attempts to draw, something happens that's not an exception
super(1, 1, RGB);
// http://dev.processing.org/bugs/show_bug.cgi?id=882
//SwingUtilities.invokeLater(new Runnable() {
//public void run() {
init(parent, filename, ifps);
//}
//});
}
public void init(PApplet parent, String filename, int fps) {
this.parent = parent;
this.fps = fps;
try {
QTSession.open();
} catch (QTException e) {
e.printStackTrace();
return;
}
// first check to see if this can be read locally from a file.
// otherwise, will have to load the file into memory, which is
// gonna make people unhappy who are trying to play back 50 MB
// quicktime movies with a locally installed piece exported
// as an application.
try {
try {
// first try a local file using the dataPath. usually this will
// work ok, but sometimes the dataPath is inside a jar file,
// which is less fun, so this will crap out.
File file = new File(parent.dataPath(filename));
if (file.exists()) {
movie = fromDataRef(new DataRef(new QTFile(file)));
//init(parent, movie, ifps);
//return;
}
} catch (Exception e) { } // ignored
// read from a folder local to the current working dir
// called "data". presumably this might be the data folder,
// though that should be caught above, if such a folder exists.
/*
if (movie == null) {
try {
File file = new File("data", filename);
if (file.exists()) {
movie = fromDataRef(new DataRef(new QTFile(file)));
init(parent, movie, ifps);
return;
}
} catch (QTException e2) { }
}
*/
// read from a file just hanging out in the local folder.
// this might happen when the video library is used with some
// other application, or the person enters a full path name
if (movie == null) {
try {
File file = new File(filename);
if (file.exists()) {
movie = fromDataRef(new DataRef(new QTFile(file)));
//init(parent, movie, ifps);
//return;
}
} catch (QTException e1) { }
}
} catch (SecurityException se) {
// online, whups. catch the security exception out here rather than
// doing it three times (or whatever) for each of the cases above.
}
// if the movie can't be read from a local file, it has to be read
// into a byte array and passed to qtjava. it's annoying that apple
// doesn't have something in the api to read a movie from a friggin
// InputStream, but oh well. it's their api.
if (movie == null) {
byte data[] = parent.loadBytes(filename);
//int dot = filename.lastIndexOf(".");
// grab the extension from the file, use mov if there is none
//String extension = (dot == -1) ? "mov" :
// filename.substring(dot + 1).toLowerCase();
try {
movie = fromDataRef(new DataRef(new QTHandle(data)));
} catch (QTException e) {
e.printStackTrace();
}
}
/*
URL url = null;
this.filename = filename; // for error messages
if (filename.startsWith("http://")) {
try {
url = new URL(filename);
DataRef urlRef = new DataRef(url.toExternalForm());
movie = fromDataRef(urlRef);
init(parent, movie, ifps);
return;
} catch (QTException qte) {
qte.printStackTrace();
return;
} catch (MalformedURLException e) {
e.printStackTrace();
return;
}
}
// updated for new loading style of 0096
ClassLoader cl = parent.getClass().getClassLoader();
url = cl.getResource("data/" + filename);
if (url != null) {
init(parent, url, ifps);
return;
}
try {
try {
File file = new File(parent.dataPath(filename));
if (file.exists()) {
movie = fromDataRef(new DataRef(new QTFile(file)));
init(parent, movie, ifps);
return;
}
} catch (Exception e) { } // ignored
try {
File file = new File("data", filename);
if (file.exists()) {
movie = fromDataRef(new DataRef(new QTFile(file)));
init(parent, movie, ifps);
return;
}
} catch (QTException e2) { }
try {
File file = new File(filename);
if (file.exists()) {
movie = fromDataRef(new DataRef(new QTFile(file)));
init(parent, movie, ifps);
return;
}
} catch (QTException e1) { }
} catch (SecurityException se) { } // online, whups
*/
if (movie == null) {
parent.die("Could not find movie file " + filename, null);
}
// we've got a valid movie! let's rock.
try {
// this is probably causing the 2 seconds of audio
// disabled pre-preroll on 0126 because of security problems
//movie.prePreroll(0, 1.0f);
movie.preroll(0, 1.0f);
// this has a possibility of running forever..
// should probably happen on the thread as well.
while (movie.maxLoadedTimeInMovie() == 0) {
movie.task(100);
// 0106: tried adding sleep time so this doesn't spin out of control
// works fine but doesn't really help anything
//try {
//Thread.sleep(5);
//} catch (InterruptedException e) { }
}
movie.setRate(1);
//fps = ifps;
// register methods
parent.registerDispose(this);
try {
movieEventMethod =
parent.getClass().getMethod("movieEvent",
new Class[] { Movie.class });
} catch (Exception e) {
// no such method, or an error.. which is fine, just ignore
}
// and now, make the magic happen
runner = new Thread(this);
runner.start();
} catch (QTException qte) {
qte.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
/*
public Movie(PApplet parent, URL url) {
init(parent, url, 30);
}
public Movie(PApplet parent, URL url, int ifps) {
init(parent, url, ifps);
}
public void init(PApplet parent, URL url, int ifps) {
String externalized = url.toExternalForm();
System.out.println("externalized is " + externalized);
// qtjava likes file: urls to read file:/// not file:/
// so this changes them when appropriate
if (externalized.startsWith("file:/") &&
!externalized.startsWith("file:///")) {
externalized = "file:///" + url.getPath();
}
// the url version is the only available that can take
// an InputStream (indirectly) since it uses url syntax
//DataRef urlRef = new DataRef(requestFile);
try {
System.out.println(url);
System.out.println(externalized);
DataRef urlRef = new DataRef(externalized);
System.out.println(urlRef);
movie = fromDataRef(urlRef);
init(parent, movie, ifps);
} catch (QTException e) {
e.printStackTrace();
}
}
*/
/**
* Why does this function have to be so bizarre? i love the huge
* constants! i think they're neato. i feel like i'm coding for
* think pascal on my mac plus! those were happier times.
*/
private quicktime.std.movies.Movie fromDataRef(DataRef ref)
throws QTException {
return
quicktime.std.movies.Movie.fromDataRef(ref,
StdQTConstants4.newMovieAsyncOK |
StdQTConstants.newMovieActive);
}
/*
public void init(PApplet parent,
quicktime.std.movies.Movie movie, int ifps) {
this.parent = parent;
try {
// this is probably causing the 2 seconds of audio
movie.prePreroll(0, 1.0f);
movie.preroll(0, 1.0f);
// this has a possibility of running forever..
// should probably happen on the thread as well.
while (movie.maxLoadedTimeInMovie() == 0) {
movie.task(100);
// 0106: tried adding sleep time so this doesn't spin out of control
// works fine but doesn't really help anything
//try {
//Thread.sleep(5);
//} catch (InterruptedException e) { }
}
movie.setRate(1);
fps = ifps;
runner = new Thread(this);
runner.start();
// register methods
parent.registerDispose(this);
try {
movieEventMethod =
parent.getClass().getMethod("movieEvent",
new Class[] { Movie.class });
} catch (Exception e) {
// no such method, or an error.. which is fine, just ignore
}
} catch (QTException qte) {
qte.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
*/
public boolean available() {
return available;
}
public void read() {
try {
if (firstFrame) {
movieRect = movie.getBox();
//movieGraphics = new QDGraphics(movieRect);
if (quicktime.util.EndianOrder.isNativeLittleEndian()) {
movieGraphics =
new QDGraphics(QDConstants.k32BGRAPixelFormat, movieRect);
} else {
movieGraphics =
new QDGraphics(QDGraphics.kDefaultPixelFormat, movieRect);
}
}
Pict pict = movie.getPict(movie.getTime()); // returns an int
pict.draw(movieGraphics, movieRect);
PixMap pixmap = movieGraphics.getPixMap();
raw = pixmap.getPixelData();
// It needs to get at least a small part
// of the video to get the parameters
if (firstFrame) {
//int intsPerRow = pixmap.getRowBytes() / 4;
int movieWidth = movieRect.getWidth();
int movieHeight = movieRect.getHeight();
int j = raw.getRowBytes() - movieWidth*4;
// this doesn't round up.. does it need to?
int k = j / 4;
int dataWidth = movieWidth + k;
if (dataWidth != movieWidth) {
if (removeBorders) {
borderImage = new PImage(dataWidth, movieHeight, RGB);
} else {
movieWidth = dataWidth;
}
}
//int vpixels[] = new int[movieWidth * movieHeight];
//image = new PImage(vpixels, movieWidth, movieHeight, RGB);
super.init(movieWidth, movieHeight, RGB);
//parent.video = image;
firstFrame = false;
}
// this happens later (found by hernando)
//raw.copyToArray(0, image.pixels, 0, image.width * image.height);
loadPixels();
// this is identical to a chunk of code inside PCamera
// this might be a candidate to move up to PVideo or something
if (borderImage != null) { // need to remove borders
raw.copyToArray(0, borderImage.pixels,
0, borderImage.width * borderImage.height);
int borderIndex = 0;
int targetIndex = 0;
for (int i = 0; i < height; i++) {
System.arraycopy(borderImage.pixels, borderIndex,
pixels, targetIndex, width);
borderIndex += borderImage.width;
targetIndex += width;
}
} else { // just copy directly
raw.copyToArray(0, pixels, 0, width * height);
}
// ready to rock
//System.out.println("updating pixels");
//updatePixels(); // mark as modified
updatePixels();
} catch (QTException qte) {
qte.printStackTrace();
//QTSession.close(); // let dispose() handle it
}
}
/**
* Begin playing the movie, with no repeat.
*/
public void play() {
// if (runner != null) {
// stop();
// }
play = true;
// runner = new Thread(this);
// runner.start();
}
/**
* Begin playing the movie, with repeat.
*/
public void loop() {
play();
repeat = true;
}
/**
* Shut off the repeating loop.
*/
public void noLoop() {
repeat = false;
}
/**
* Pause the movie at its current time.
*/
public void pause() {
play = false;
//System.out.println("pause");
}
/**
* Stop the movie, and rewind.
*/
public void stop() {
play = false;
// runner = null;
try {
movie.setTimeValue(0);
} catch (StdQTException e) {
errorMessage("stop", e);
}
}
/**
* Set how often new frames are to be read from the movie.
* Does not actually set the speed of the movie playback,
* that's handled by the speed() method.
*/
public void frameRate(int ifps) {
if (ifps <= 0) {
System.err.println("Movie: ignoring bad frame rate of " +
ifps + " fps.");
} else {
fps = ifps;
}
}
/**
* Set a multiplier for how fast/slow the movie should be run.
* The default is 1.0.
* <UL>
* <LI>speed(2) will play the movie at double speed (2x).
* <LI>speed(0.5) will play at half speed.
* <LI>speed(-1) will play backwards at regular speed.
* </UL>
*/
public void speed(float rate) {
//rate = irate;
try {
movie.setRate(rate);
} catch (StdQTException e) {
errorMessage("speed", e);
}
}
/**
* Return the current time in seconds.
* The number is a float so fractions of seconds can be used.
*/
public float time() {
try {
return (float)movie.getTime() / (float)movie.getTimeScale();
} catch (StdQTException e) {
errorMessage("time", e);
}
return -1;
}
/**
* Jump to a specific location (in seconds).
* The number is a float so fractions of seconds can be used.
*/
public void jump(float where) {
try {
//movie.setTime(new TimeRecord(rate, where)); // scale, value
//movie.setTime(new TimeRecord(1, where)); // scale, value
int scaledTime = (int) (where * movie.getTimeScale());
movie.setTimeValue(scaledTime);
} catch (StdQTException e) {
errorMessage("jump", e);
}
}
/**
* Get the full length of this movie (in seconds).
*/
public float duration() {
try {
return (float)movie.getDuration() / (float)movie.getTimeScale();
} catch (StdQTException e) {
errorMessage("length", e);
}
return -1;
}
/*
public void play() {
if(!play) {
play = true;
}
start();
while( image == null) {
try {
Thread.sleep(5);
} catch (InterruptedException e) { }
}
pixels = image.pixels;
width = image.width;
height = image.height;
}
public void repeat() {
loop = true;
if(!play) {
play = true;
}
start();
while( image == null) {
try {
Thread.sleep(5);
} catch (InterruptedException e) { }
}
pixels = image.pixels;
width = image.width;
height = image.height;
}
public void pause() {
play = false;
}
*/
public void run() {
//System.out.println("entering thread");
while (Thread.currentThread() == runner) {
//System.out.print("<");
try {
//Thread.sleep(5);
Thread.sleep(1000 / fps);
} catch (InterruptedException e) { }
//System.out.print(">");
// this could be a lie, but..
if (play) {
//read();
//System.out.println("play");
available = true;
if (movieEventMethod == null) {
// If no special handling, then automatically read from the movie.
read();
} else {
try {
movieEventMethod.invoke(parent, new Object[] { this });
} catch (Exception e) {
System.err.println("error, disabling movieEvent() for " +
filename);
e.printStackTrace();
movieEventMethod = null;
}
}
try {
if (movie.isDone() && repeat) {
movie.goToBeginning();
}
} catch (StdQTException e) {
play = false;
errorMessage("rewinding", e);
}
//} else {
//System.out.println("no play");
}
//try {
//read();
//if (movie.isDone() && loop) movie.goToBeginning();
//} catch (QTException e) {
//System.err.println("Movie exception");
//e.printStackTrace();
//QTSession.close(); ??
//}
}
}
/**
* Call this to halt the movie from running, and stop its thread.
*/
public void dispose() {
stop();
runner = null;
QTSession.close();
}
/**
* General error reporting, all corraled here just in case
* I think of something slightly more intelligent to do.
*/
protected void errorMessage(String where, Exception e) {
parent.die("Error inside Movie." + where + "()", e);
}
}

View File

@ -1,347 +0,0 @@
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
/*
Part of the Processing project - http://processing.org
Copyright (c) 2006 Daniel Shiffman
With minor modifications by Ben Fry for Processing 0125+
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General
Public License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
Boston, MA 02111-1307 USA
*/
package processing.video;
import java.io.File;
import quicktime.Errors;
import quicktime.QTException;
import quicktime.QTSession;
import quicktime.io.OpenMovieFile;
import quicktime.io.QTFile;
import quicktime.qd.QDConstants;
import quicktime.qd.QDGraphics;
import quicktime.qd.QDRect;
import quicktime.std.StdQTConstants;
import quicktime.std.StdQTException;
import quicktime.std.image.CSequence;
import quicktime.std.image.CodecComponent;
import quicktime.std.image.CompressedFrameInfo;
import quicktime.std.image.ImageDescription;
import quicktime.std.image.QTImage;
import quicktime.std.movies.Movie;
import quicktime.std.movies.Track;
import quicktime.std.movies.media.VideoMedia;
import quicktime.util.QTHandle;
import quicktime.util.QTUtils;
import quicktime.util.RawEncodedImage;
import processing.core.*;
/**
* Library to create a QuickTime movie from a Processing pixel array.
* Written by <A HREF="http://www.shiffman.net">Daniel Shiffman</A>.
* Thanks to Dan O'Sullivan and Shawn Van Every.
* <BR> <BR>
* Please note that some constructors and variable names were altered
* slightly when the library was added to the Processing distribution.
* <PRE>
* // Declare MovieMaker object
* MovieMaker mm;
*
* void setup() {
* size(320, 240);
*
* // Create MovieMaker object with size, filename,
* // compression codec and quality, framerate
* mm = new MovieMaker(this, width, height, "drawing.mov", 30,
* MovieMaker.H263, MovieMaker.HIGH);
* background(160, 32, 32);
* }
*
* void draw() {
* stroke(7, 146, 168);
* strokeWeight(4);
*
* // Draw if mouse is pressed
* if (mousePressed) {
* line(pmouseX, pmouseY, mouseX, mouseY);
* }
*
* // Add window's pixels to movie
* mm.addFrame();
* }
*
* void keyPressed() {
* // Finish the movie if space bar is pressed!
* if (key == ' ') {
* mm.finish();
* }
* }
* </PRE>
*/
public class MovieMaker {
public static final int RAW = StdQTConstants.kRawCodecType;
public static final int ANIMATION = StdQTConstants.kAnimationCodecType;
public static final int BASE = StdQTConstants.kBaseCodecType;
public static final int BMP = StdQTConstants.kBMPCodecType;
public static final int CINEPAK = StdQTConstants.kCinepakCodecType;
public static final int COMPONENT = StdQTConstants.kComponentVideoCodecType;
public static final int CMYK = StdQTConstants.kCMYKCodecType;
public static final int GIF = StdQTConstants.kGIFCodecType;
public static final int GRAPHICS = StdQTConstants.kGraphicsCodecType;
public static final int H261 = StdQTConstants.kH261CodecType;
public static final int H263 = StdQTConstants.kH263CodecType;
// H.264 encoding, added because no constant is available in QTJava
public static final int H264 = QTUtils.toOSType("avc1");
public static final int JPEG = StdQTConstants.kJPEGCodecType;
public static final int MS_VIDEO = StdQTConstants.kMicrosoftVideo1CodecType;
public static final int MOTION_JPEG_A = StdQTConstants.kMotionJPEGACodecType;
public static final int MOTION_JPEG_B = StdQTConstants.kMotionJPEGBCodecType;
public static final int SORENSON = StdQTConstants.kSorensonCodecType;
public static final int VIDEO = StdQTConstants.kVideoCodecType;
public static final int WORST = StdQTConstants.codecMinQuality;
public static final int LOW = StdQTConstants.codecLowQuality;
public static final int MEDIUM = StdQTConstants.codecNormalQuality;
public static final int HIGH = StdQTConstants.codecHighQuality;
public static final int BEST = StdQTConstants.codecMaxQuality;
public static final int LOSSLESS = StdQTConstants.codecLosslessQuality;
private int width;
private int height;
private boolean readyForFrames;
// Changed from 1000 to 600 in release 0154 to enable exact 30 fps output.
// http://dev.processing.org/bugs/show_bug.cgi?id=988
private int TIME_SCALE = 600;
// QT Stuff
private VideoMedia videoMedia;
private Track videoTrack;
private Movie movie;
private QTFile movFile;
private CSequence seq;
private QTHandle imageHandle;
private QDGraphics gw;
private QDRect bounds;
private ImageDescription imgDesc;
private RawEncodedImage compressedImage;
private int rate;
private int keyFrameRate = 15;
private int codecType, codecQuality;
// my hack to make sure we don't get error -8691
private boolean temporalSupported = true;
private PApplet parent;
/**
* Create a movie with the specified width, height, and filename.
* The movie will be created at 15 frames per second.
* The codec will be set to RAW and quality set to HIGH.
*/
public MovieMaker(PApplet p, int _w, int _h, String _filename) {
this(p, _w, _h, _filename, 30, RAW, HIGH, 15);
}
/**
* Create a movie with the specified width, height, filename, and frame rate.
* The codec will be set to RAW and quality set to HIGH.
*/
public MovieMaker(PApplet p, int _w, int _h, String _filename, int _rate) {
this(p, _w, _h, _filename, _rate, RAW, HIGH, 15);
}
/**
* Create a movie with the specified width, height, filename, frame rate,
* and codec type and quality. Key frames will be set at 15 frames.
*/
public MovieMaker(PApplet p, int _w, int _h, String _filename, int _rate,
int _codecType, int _codecQuality) {
this(p, _w, _h, _filename, _rate, _codecType, _codecQuality, 15);
}
/**
* Create a movie with the specified width, height, filename, frame rate,
* codec type and quality, and key frame rate.
*/
public MovieMaker(PApplet p, int _w, int _h, String _filename, int _rate,
int _codecType, int _codecQuality,
int _keyFrameRate) {
parent = p;
width = _w;
height = _h;
rate = _rate;
try {
QTSession.open();
} catch (QTException e1) {
e1.printStackTrace();
}
try {
ImageDescription imgD = null;
if (quicktime.util.EndianOrder.isNativeLittleEndian()) {
imgD = new ImageDescription(QDConstants.k32BGRAPixelFormat);
} else {
imgD = new ImageDescription(QDGraphics.kDefaultPixelFormat);
}
imgD.setWidth(width);
imgD.setHeight(height);
gw = new QDGraphics(imgD, 0);
} catch (QTException e) {
e.printStackTrace();
}
codecType = _codecType;
codecQuality = _codecQuality;
keyFrameRate = _keyFrameRate;
initMovie(_filename);
parent.registerDispose(this);
}
private void initMovie(String filename) {
try {
String path = parent.savePath(filename);
movFile = new QTFile(new File(path));
movie = Movie.createMovieFile(movFile, StdQTConstants.kMoviePlayer, StdQTConstants.createMovieFileDeleteCurFile);
int timeScale = TIME_SCALE; // 100 units per second
videoTrack = movie.addTrack(width, height, 0);
videoMedia = new VideoMedia(videoTrack, timeScale);
videoMedia.beginEdits();
bounds = new QDRect(0, 0, width, height);
int rawImageSize = QTImage.getMaxCompressionSize(gw, bounds, gw.getPixMap().getPixelSize(), codecQuality, codecType, CodecComponent.anyCodec);
imageHandle = new QTHandle(rawImageSize, true);
imageHandle.lock();
compressedImage = RawEncodedImage.fromQTHandle(imageHandle);
seq = new CSequence(gw, bounds, gw.getPixMap().getPixelSize(), codecType, CodecComponent.bestFidelityCodec, codecQuality, codecQuality, keyFrameRate, null, 0);
imgDesc = seq.getDescription();
readyForFrames = true;
} catch (QTException e) {
if (e.errorCode() == Errors.noCodecErr) {
if (imageHandle == null) {
// This means QTImage.getMaxCompressionSize() failed
System.err.println("The specified codec is not supported, " +
"please ensure that the parameters are valid, " +
"and in the correct order.");
} else {
// If it's a -8961 error, quietly do it the other way
// (this happens when RAW is specified)
temporalSupported = false;
readyForFrames = true;
}
} else if (e.errorCode() == Errors.fBsyErr) {
System.err.println("The movie file already exists. " +
"Please delete it first.");
} else {
e.printStackTrace();
}
}
}
// A simple add function to just add whatever is in the parent window
public void addFrame() {
// http://dev.processing.org/bugs/show_bug.cgi?id=692
parent.flush();
parent.loadPixels();
addFrame(parent.pixels, parent.width, parent.height);
}
public void addFrame(int[] _pixels, int w, int h) {
if (readyForFrames){
RawEncodedImage pixelData = gw.getPixMap().getPixelData();
int rowBytes = pixelData.getRowBytes() / 4;
int[] newpixels = new int[rowBytes*h];
for (int i = 0; i < rowBytes; i++) {
for (int j = 0; j < h; j++) {
if (i < w) {
newpixels[i+j*rowBytes] = _pixels[i+j*w];
} else {
newpixels[i+j*rowBytes] = 0;
}
}
}
pixelData.setInts(0,newpixels);
compressAndAdd();
}
}
private void compressAndAdd() {
try {
if (temporalSupported) {
CompressedFrameInfo cfInfo = seq.compressFrame(gw, bounds, StdQTConstants.codecFlagUpdatePrevious, compressedImage);
boolean syncSample = cfInfo.getSimilarity() == 0; // see developer.apple.com/qa/qtmcc/qtmcc20.html
videoMedia.addSample(imageHandle, 0, cfInfo.getDataSize(), TIME_SCALE/rate, imgDesc, 1, syncSample ? 0 : StdQTConstants.mediaSampleNotSync);
} else {
imgDesc = QTImage.fCompress(gw,gw.getBounds(),32,codecQuality,codecType, CodecComponent.anyCodec, null, 0, RawEncodedImage.fromQTHandle(imageHandle));
boolean syncSample = true; // UM, what the hell should this be???
videoMedia.addSample(imageHandle, 0, imgDesc.getDataSize(), TIME_SCALE/rate, imgDesc, 1, syncSample ? 0 : StdQTConstants.mediaSampleNotSync);
}
} catch (QTException e) {
e.printStackTrace();
}
}
/**
* Close out and finish the movie file.
*/
public void finish() {
try {
if (readyForFrames) {
//System.out.println("Finishing movie file.");
readyForFrames = false;
videoMedia.endEdits();
videoTrack.insertMedia(0, 0, videoMedia.getDuration(), 1);
OpenMovieFile omf = OpenMovieFile.asWrite(movFile);
movie.addResource(omf, StdQTConstants.movieInDataForkResID,
movFile.getName());
}
} catch (StdQTException se) {
se.printStackTrace();
} catch (QTException qe) {
qe.printStackTrace();
}
}
public void dispose() {
if (readyForFrames) finish();
try {
QTSession.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}