propane 3.4.0-java → 3.4.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -2
  3. data/.travis.yml +2 -2
  4. data/CHANGELOG.md +2 -0
  5. data/README.md +12 -7
  6. data/Rakefile +2 -2
  7. data/lib/propane.rb +2 -2
  8. data/lib/propane/app.rb +18 -9
  9. data/lib/propane/helper_methods.rb +1 -1
  10. data/lib/propane/runner.rb +1 -1
  11. data/lib/propane/version.rb +1 -1
  12. data/library/color_group/color_group.rb +26 -0
  13. data/library/dxf/dxf.rb +4 -0
  14. data/library/net/net.rb +5 -0
  15. data/library/video_event/video_event.rb +2 -1
  16. data/pom.rb +3 -3
  17. data/pom.xml +3 -3
  18. data/propane.gemspec +1 -1
  19. data/src/main/java/japplemenubar/JAppleMenuBar.java +3 -3
  20. data/src/main/java/monkstone/ColorUtil.java +14 -0
  21. data/src/main/java/monkstone/MathToolModule.java +243 -194
  22. data/src/main/java/monkstone/filechooser/Chooser.java +1 -0
  23. data/src/main/java/monkstone/slider/WheelHandler.java +6 -5
  24. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +3 -2
  25. data/src/main/java/monkstone/videoevent/CaptureEvent.java +27 -0
  26. data/src/main/java/monkstone/videoevent/{VideoInterface.java → MovieEvent.java} +10 -26
  27. data/src/main/java/processing/awt/PSurfaceAWT.java +1 -1
  28. data/src/main/java/processing/core/PApplet.java +1236 -599
  29. data/src/main/java/processing/core/PGraphics.java +59 -59
  30. data/src/main/java/processing/core/PImage.java +528 -129
  31. data/src/main/java/processing/core/PShape.java +10 -10
  32. data/src/main/java/processing/core/PVector.java +2 -2
  33. data/src/main/java/processing/core/ThinkDifferent.java +5 -7
  34. data/src/main/java/processing/dxf/RawDXF.java +404 -0
  35. data/src/main/java/processing/net/Client.java +744 -0
  36. data/src/main/java/processing/net/Server.java +388 -0
  37. data/src/main/java/processing/opengl/FontTexture.java +19 -20
  38. data/src/main/java/processing/opengl/FrameBuffer.java +27 -17
  39. data/src/main/java/processing/opengl/LinePath.java +512 -508
  40. data/src/main/java/processing/opengl/PGL.java +3106 -3066
  41. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +4 -4
  42. data/src/main/java/processing/opengl/PShader.java +1442 -1341
  43. data/vendors/Rakefile +3 -27
  44. metadata +12 -25
  45. data/src/main/java/processing/core/util/image/ImageLoadFacade.java +0 -161
  46. data/src/main/java/processing/core/util/image/ImageSaveFacade.java +0 -169
  47. data/src/main/java/processing/core/util/image/constants/TifConstants.java +0 -45
  48. data/src/main/java/processing/core/util/image/load/AwtImageLoadStrategy.java +0 -80
  49. data/src/main/java/processing/core/util/image/load/Base64StringImageLoadStrategy.java +0 -73
  50. data/src/main/java/processing/core/util/image/load/FallbackImageLoadStrategy.java +0 -70
  51. data/src/main/java/processing/core/util/image/load/ImageIoImageLoadStrategy.java +0 -132
  52. data/src/main/java/processing/core/util/image/load/ImageLoadStrategy.java +0 -48
  53. data/src/main/java/processing/core/util/image/load/ImageLoadUtil.java +0 -45
  54. data/src/main/java/processing/core/util/image/load/TgaImageLoadStrategy.java +0 -255
  55. data/src/main/java/processing/core/util/image/load/TiffImageLoadStrategy.java +0 -98
  56. data/src/main/java/processing/core/util/image/save/ImageSaveStrategy.java +0 -49
  57. data/src/main/java/processing/core/util/image/save/ImageSaveUtil.java +0 -48
  58. data/src/main/java/processing/core/util/image/save/ImageWriterImageSaveStrategy.java +0 -179
  59. data/src/main/java/processing/core/util/image/save/SaveImageException.java +0 -41
  60. data/src/main/java/processing/core/util/image/save/TgaImageSaveStrategy.java +0 -198
  61. data/src/main/java/processing/core/util/image/save/TiffImageSaveStrategy.java +0 -91
  62. data/src/main/java/processing/core/util/image/save/TiffNakedFilenameImageSaveStrategy.java +0 -57
  63. data/src/main/java/processing/core/util/io/InputFactory.java +0 -285
  64. data/src/main/java/processing/core/util/io/PathUtil.java +0 -109
@@ -1,48 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- Part of the Processing project - http://processing.org
5
-
6
- Copyright (c) 2012-18 The Processing Foundation
7
- Copyright (c) 2004-12 Ben Fry and Casey Reas
8
- Copyright (c) 2001-04 Massachusetts Institute of Technology
9
-
10
- This library is free software; you can redistribute it and/or
11
- modify it under the terms of the GNU Lesser General Public
12
- License as published by the Free Software Foundation, version 2.1.
13
-
14
- This library is distributed in the hope that it will be useful,
15
- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- Lesser General Public License for more details.
18
-
19
- You should have received a copy of the GNU Lesser General
20
- Public License along with this library; if not, write to the
21
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
- Boston, MA 02111-1307 USA
23
- */
24
-
25
- package processing.core.util.image.save;
26
-
27
- import java.io.BufferedOutputStream;
28
- import java.io.FileNotFoundException;
29
- import java.io.FileOutputStream;
30
- import java.io.OutputStream;
31
-
32
-
33
- /**
34
- * Common convenience functions for file saving.
35
- */
36
- public class ImageSaveUtil {
37
-
38
- /**
39
- * Create an output stream for a file.
40
- *
41
- * @param filename The filename at which the output stream should be created.
42
- * @return The newly created output stream.
43
- */
44
- public static OutputStream createForFile(String filename) throws FileNotFoundException {
45
- return new BufferedOutputStream(new FileOutputStream(filename), 32768);
46
- }
47
-
48
- }
@@ -1,179 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- Part of the Processing project - http://processing.org
5
-
6
- Copyright (c) 2012-18 The Processing Foundation
7
- Copyright (c) 2004-12 Ben Fry and Casey Reas
8
- Copyright (c) 2001-04 Massachusetts Institute of Technology
9
-
10
- This library is free software; you can redistribute it and/or
11
- modify it under the terms of the GNU Lesser General Public
12
- License as published by the Free Software Foundation, version 2.1.
13
-
14
- This library is distributed in the hope that it will be useful,
15
- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- Lesser General Public License for more details.
18
-
19
- You should have received a copy of the GNU Lesser General
20
- Public License along with this library; if not, write to the
21
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
- Boston, MA 02111-1307 USA
23
- */
24
-
25
- package processing.core.util.image.save;
26
-
27
- import processing.core.PApplet;
28
- import processing.core.PConstants;
29
- import processing.core.util.io.PathUtil;
30
-
31
- import javax.imageio.*;
32
- import javax.imageio.metadata.IIOInvalidTreeException;
33
- import javax.imageio.metadata.IIOMetadata;
34
- import javax.imageio.metadata.IIOMetadataNode;
35
- import java.awt.image.BufferedImage;
36
- import java.io.BufferedOutputStream;
37
- import java.io.File;
38
- import java.io.IOException;
39
- import java.util.Iterator;
40
-
41
-
42
- /**
43
- * Strategy to use ImageIO functions to save an image.
44
- */
45
- public class ImageWriterImageSaveStrategy implements ImageSaveStrategy {
46
-
47
- /**
48
- * Use ImageIO functions from Java 1.4 and later to handle image save.
49
- * Various formats are supported, typically jpeg, png, bmp, and wbmp.
50
- * To get a list of the supported formats for writing, use: <BR>
51
- * <TT>println(javax.imageio.ImageIO.getReaderFormatNames())</TT>
52
- */
53
- @Override
54
- public boolean save(int[] pixels, int pixelWidth, int pixelHeight, int format,
55
- String path) throws IOException {
56
-
57
- try {
58
- int outputFormat = (format == PConstants.ARGB) ?
59
- BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB;
60
-
61
- String extension = PathUtil.cleanExtension(
62
- PathUtil.parseExtension(path)
63
- );
64
-
65
- // JPEG and BMP images that have an alpha channel set get pretty unhappy.
66
- // BMP just doesn't write, and JPEG writes it as a CMYK image.
67
- // http://code.google.com/p/processing/issues/detail?id=415
68
- if (isRgbImage(extension)) {
69
- outputFormat = BufferedImage.TYPE_INT_RGB;
70
- }
71
-
72
- BufferedImage bimage = new BufferedImage(pixelWidth, pixelHeight, outputFormat);
73
- bimage.setRGB(0, 0, pixelWidth, pixelHeight, pixels, 0, pixelWidth);
74
-
75
- File file = new File(path);
76
-
77
- ImageWriter writer = null;
78
- ImageWriteParam param = null;
79
- IIOMetadata metadata = null;
80
-
81
- if (isJpeg(extension)) {
82
- if ((writer = getImageIoWriter("jpeg")) != null) {
83
- // Set JPEG quality to 90% with baseline optimization. Setting this
84
- // to 1 was a huge jump (about triple the size), so this seems good.
85
- // Oddly, a smaller file size than Photoshop at 90%, but I suppose
86
- // it's a completely different algorithm.
87
- param = writer.getDefaultWriteParam();
88
- param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
89
- param.setCompressionQuality(0.9f);
90
- }
91
- }
92
-
93
- if (isPng(extension)) {
94
- if ((writer = getImageIoWriter("png")) != null) {
95
- param = writer.getDefaultWriteParam();
96
- if (false) {
97
- metadata = getImageIoDpi(writer, param, 100);
98
- }
99
- }
100
- }
101
-
102
- if (writer != null) {
103
- BufferedOutputStream output =
104
- new BufferedOutputStream(PApplet.createOutput(file));
105
- writer.setOutput(ImageIO.createImageOutputStream(output));
106
- // writer.write(null, new IIOImage(bimage, null, null), param);
107
- writer.write(metadata, new IIOImage(bimage, null, metadata), param);
108
- writer.dispose();
109
-
110
- output.flush();
111
- output.close();
112
- return true;
113
- }
114
- // If iter.hasNext() somehow fails up top, it falls through to here
115
- return javax.imageio.ImageIO.write(bimage, extension, file);
116
-
117
- } catch (Exception e) {
118
- e.printStackTrace();
119
- throw new IOException("image save failed.");
120
- }
121
- }
122
-
123
- private ImageWriter getImageIoWriter(String extension) {
124
- Iterator<ImageWriter> iter = ImageIO.getImageWritersByFormatName(extension);
125
- if (iter.hasNext()) {
126
- return iter.next();
127
- }
128
- return null;
129
- }
130
-
131
- private IIOMetadata getImageIoDpi(ImageWriter writer, ImageWriteParam param, double dpi) {
132
- // http://stackoverflow.com/questions/321736/how-to-set-dpi-information-in-an-image
133
- ImageTypeSpecifier typeSpecifier =
134
- ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB);
135
- IIOMetadata metadata =
136
- writer.getDefaultImageMetadata(typeSpecifier, param);
137
-
138
- if (!metadata.isReadOnly() && metadata.isStandardMetadataFormatSupported()) {
139
- // for PNG, it's dots per millimeter
140
- double dotsPerMilli = dpi / 25.4;
141
-
142
- IIOMetadataNode horiz = new IIOMetadataNode("HorizontalPixelSize");
143
- horiz.setAttribute("value", Double.toString(dotsPerMilli));
144
-
145
- IIOMetadataNode vert = new IIOMetadataNode("VerticalPixelSize");
146
- vert.setAttribute("value", Double.toString(dotsPerMilli));
147
-
148
- IIOMetadataNode dim = new IIOMetadataNode("Dimension");
149
- dim.appendChild(horiz);
150
- dim.appendChild(vert);
151
-
152
- IIOMetadataNode root = new IIOMetadataNode("javax_imageio_1.0");
153
- root.appendChild(dim);
154
-
155
- try {
156
- metadata.mergeTree("javax_imageio_1.0", root);
157
- return metadata;
158
-
159
- } catch (IIOInvalidTreeException e) {
160
- System.err.println("Could not set the DPI of the output image");
161
- e.printStackTrace();
162
- }
163
- }
164
- return null;
165
- }
166
-
167
- private boolean isRgbImage(String extension) {
168
- return extension.equals("bmp") || isJpeg(extension);
169
- }
170
-
171
- private boolean isJpeg(String extension) {
172
- return extension.equals("jpg") || extension.equals("jpeg");
173
- }
174
-
175
- private boolean isPng(String extension) {
176
- return extension.equals("png");
177
- }
178
-
179
- }
@@ -1,41 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- Part of the Processing project - http://processing.org
5
-
6
- Copyright (c) 2012-18 The Processing Foundation
7
- Copyright (c) 2004-12 Ben Fry and Casey Reas
8
- Copyright (c) 2001-04 Massachusetts Institute of Technology
9
-
10
- This library is free software; you can redistribute it and/or
11
- modify it under the terms of the GNU Lesser General Public
12
- License as published by the Free Software Foundation, version 2.1.
13
-
14
- This library is distributed in the hope that it will be useful,
15
- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- Lesser General Public License for more details.
18
-
19
- You should have received a copy of the GNU Lesser General
20
- Public License along with this library; if not, write to the
21
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
- Boston, MA 02111-1307 USA
23
- */
24
-
25
- package processing.core.util.image.save;
26
-
27
-
28
- /**
29
- * Exception describing an issue encountered while saving an image.
30
- */
31
- public class SaveImageException extends RuntimeException {
32
-
33
- /**
34
- * Create a new exception with a description of why image saving failed.
35
- * @param msg The message describing failure cause.
36
- */
37
- public SaveImageException(String msg) {
38
- super(msg);
39
- }
40
-
41
- }
@@ -1,198 +0,0 @@
1
- /* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2
-
3
- /*
4
- Part of the Processing project - http://processing.org
5
-
6
- Copyright (c) 2012-18 The Processing Foundation
7
- Copyright (c) 2004-12 Ben Fry and Casey Reas
8
- Copyright (c) 2001-04 Massachusetts Institute of Technology
9
-
10
- This library is free software; you can redistribute it and/or
11
- modify it under the terms of the GNU Lesser General Public
12
- License as published by the Free Software Foundation, version 2.1.
13
-
14
- This library is distributed in the hope that it will be useful,
15
- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
- Lesser General Public License for more details.
18
-
19
- You should have received a copy of the GNU Lesser General
20
- Public License along with this library; if not, write to the
21
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22
- Boston, MA 02111-1307 USA
23
- */
24
-
25
- package processing.core.util.image.save;
26
-
27
- import processing.core.PConstants;
28
-
29
- import java.io.FileNotFoundException;
30
- import java.io.IOException;
31
- import java.io.OutputStream;
32
-
33
-
34
- /**
35
- * Strategy for creating tga (targa32) images.
36
- */
37
- public class TgaImageSaveStrategy implements ImageSaveStrategy {
38
-
39
- /**
40
- * Creates a Targa32 formatted byte sequence of specified
41
- * pixel buffer using RLE compression.
42
- * </p>
43
- * Also figured out how to avoid parsing the image upside-down
44
- * (there's a header flag to set the image origin to top-left)
45
- * </p>
46
- * Starting with revision 0092, the format setting is taken into account:
47
- * <UL>
48
- * <LI><TT>ALPHA</TT> images written as 8bit grayscale (uses lowest byte)
49
- * <LI><TT>RGB</TT> &rarr; 24 bits
50
- * <LI><TT>ARGB</TT> &rarr; 32 bits
51
- * </UL>
52
- * All versions are RLE compressed.
53
- * </p>
54
- * Contributed by toxi 8-10 May 2005, based on this RLE
55
- * <A HREF="http://www.wotsit.org/download.asp?f=tga">specification</A>
56
- */
57
- @Override
58
- public boolean save(int[] pixels, int pixelWidth, int pixelHeight, int format,
59
- String filename) throws FileNotFoundException {
60
-
61
- OutputStream output = ImageSaveUtil.createForFile(filename);
62
-
63
- byte header[] = new byte[18];
64
-
65
- if (format == PConstants.ALPHA) { // save ALPHA images as 8bit grayscale
66
- header[2] = 0x0B;
67
- header[16] = 0x08;
68
- header[17] = 0x28;
69
-
70
- } else if (format == PConstants.RGB) {
71
- header[2] = 0x0A;
72
- header[16] = 24;
73
- header[17] = 0x20;
74
-
75
- } else if (format == PConstants.ARGB) {
76
- header[2] = 0x0A;
77
- header[16] = 32;
78
- header[17] = 0x28;
79
-
80
- } else {
81
- throw new RuntimeException("Image format not recognized inside save()");
82
- }
83
- // set image dimensions lo-hi byte order
84
- header[12] = (byte) (pixelWidth & 0xff);
85
- header[13] = (byte) (pixelWidth >> 8);
86
- header[14] = (byte) (pixelHeight & 0xff);
87
- header[15] = (byte) (pixelHeight >> 8);
88
-
89
- try {
90
- output.write(header);
91
-
92
- int maxLen = pixelHeight * pixelWidth;
93
- int index = 0;
94
- int col; //, prevCol;
95
- int[] currChunk = new int[128];
96
-
97
- // 8bit image exporter is in separate loop
98
- // to avoid excessive conditionals...
99
- if (format == PConstants.ALPHA) {
100
- while (index < maxLen) {
101
- boolean isRLE = false;
102
- int rle = 1;
103
- currChunk[0] = col = pixels[index] & 0xff;
104
- while (index + rle < maxLen) {
105
- if (col != (pixels[index + rle]&0xff) || rle == 128) {
106
- isRLE = (rle > 1);
107
- break;
108
- }
109
- rle++;
110
- }
111
- if (isRLE) {
112
- output.write(0x80 | (rle - 1));
113
- output.write(col);
114
-
115
- } else {
116
- rle = 1;
117
- while (index + rle < maxLen) {
118
- int cscan = pixels[index + rle] & 0xff;
119
- if ((col != cscan && rle < 128) || rle < 3) {
120
- currChunk[rle] = col = cscan;
121
- } else {
122
- if (col == cscan) rle -= 2;
123
- break;
124
- }
125
- rle++;
126
- }
127
- output.write(rle - 1);
128
- for (int i = 0; i < rle; i++) output.write(currChunk[i]);
129
- }
130
- index += rle;
131
- }
132
- } else { // export 24/32 bit TARGA
133
- while (index < maxLen) {
134
- boolean isRLE = false;
135
- currChunk[0] = col = pixels[index];
136
- int rle = 1;
137
- // try to find repeating bytes (min. len = 2 pixels)
138
- // maximum chunk size is 128 pixels
139
- while (index + rle < maxLen) {
140
- if (col != pixels[index + rle] || rle == 128) {
141
- isRLE = (rle > 1); // set flag for RLE chunk
142
- break;
143
- }
144
- rle++;
145
- }
146
- if (isRLE) {
147
- output.write(128 | (rle - 1));
148
- output.write(col & 0xff);
149
- output.write(col >> 8 & 0xff);
150
- output.write(col >> 16 & 0xff);
151
- if (format == PConstants.ARGB) output.write(col >>> 24 & 0xff);
152
-
153
- } else { // not RLE
154
- rle = 1;
155
- while (index + rle < maxLen) {
156
- if ((col != pixels[index + rle] && rle < 128) || rle < 3) {
157
- currChunk[rle] = col = pixels[index + rle];
158
- } else {
159
- // check if the exit condition was the start of
160
- // a repeating colour
161
- if (col == pixels[index + rle]) rle -= 2;
162
- break;
163
- }
164
- rle++;
165
- }
166
- // write uncompressed chunk
167
- output.write(rle - 1);
168
- if (format == PConstants.ARGB) {
169
- for (int i = 0; i < rle; i++) {
170
- col = currChunk[i];
171
- output.write(col & 0xff);
172
- output.write(col >> 8 & 0xff);
173
- output.write(col >> 16 & 0xff);
174
- output.write(col >>> 24 & 0xff);
175
- }
176
- } else {
177
- for (int i = 0; i < rle; i++) {
178
- col = currChunk[i];
179
- output.write(col & 0xff);
180
- output.write(col >> 8 & 0xff);
181
- output.write(col >> 16 & 0xff);
182
- }
183
- }
184
- }
185
- index += rle;
186
- }
187
- }
188
- output.flush();
189
- output.close();
190
- return true;
191
-
192
- } catch (IOException e) {
193
- e.printStackTrace();
194
- return false;
195
- }
196
- }
197
-
198
- }