propane 3.10.0-java → 3.11.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  3. data/CHANGELOG.md +2 -0
  4. data/README.md +7 -7
  5. data/lib/propane/app.rb +2 -5
  6. data/lib/propane/helper_methods.rb +6 -6
  7. data/lib/propane/version.rb +1 -1
  8. data/lib/{propane-3.10.0.jar → propane-3.11.0.jar} +0 -0
  9. data/pom.rb +6 -6
  10. data/pom.xml +6 -6
  11. data/propane.gemspec +3 -3
  12. data/src/main/java/monkstone/noise/OpenSimplex2F.java +838 -737
  13. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +8 -13
  14. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +14 -28
  15. data/src/main/java/processing/awt/PImageAWT.java +6 -4
  16. data/src/main/java/processing/core/PApplet.java +71 -59
  17. data/src/main/java/processing/core/PImage.java +14 -14
  18. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +13 -13
  19. data/src/main/java/processing/opengl/PShader.java +1 -6
  20. data/src/main/java/processing/opengl/PSurfaceJOGL.java +6 -6
  21. data/{lib/java/processing/opengl → src/main/resources}/cursors/arrow.png +0 -0
  22. data/{lib/java/processing/opengl → src/main/resources}/cursors/cross.png +0 -0
  23. data/{lib/java/processing/opengl → src/main/resources}/cursors/hand.png +0 -0
  24. data/{lib/java/processing/opengl → src/main/resources}/cursors/license.txt +0 -0
  25. data/{lib/java/processing/opengl → src/main/resources}/cursors/move.png +0 -0
  26. data/{lib/java/processing/opengl → src/main/resources}/cursors/text.png +0 -0
  27. data/{lib/java/processing/opengl → src/main/resources}/cursors/wait.png +0 -0
  28. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorFrag.glsl +0 -0
  29. data/{lib/java/processing/opengl → src/main/resources}/shaders/ColorVert.glsl +0 -0
  30. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightFrag.glsl +0 -0
  31. data/{lib/java/processing/opengl → src/main/resources}/shaders/LightVert.glsl +0 -0
  32. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineFrag.glsl +0 -0
  33. data/{lib/java/processing/opengl → src/main/resources}/shaders/LineVert.glsl +0 -0
  34. data/{lib/java/processing/opengl → src/main/resources}/shaders/MaskFrag.glsl +0 -0
  35. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointFrag.glsl +0 -0
  36. data/{lib/java/processing/opengl → src/main/resources}/shaders/PointVert.glsl +0 -0
  37. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexFrag.glsl +0 -0
  38. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightFrag.glsl +0 -0
  39. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexLightVert.glsl +0 -0
  40. data/{lib/java/processing/opengl → src/main/resources}/shaders/TexVert.glsl +0 -0
  41. data/test/test_helper.rb +1 -0
  42. data/vendors/Rakefile +1 -1
  43. metadata +29 -155
  44. data/lib/java/japplemenubar/JAppleMenuBar.java +0 -88
  45. data/lib/java/japplemenubar/libjAppleMenuBar.jnilib +0 -0
  46. data/lib/java/monkstone/ColorUtil.java +0 -127
  47. data/lib/java/monkstone/MathToolModule.java +0 -287
  48. data/lib/java/monkstone/PropaneLibrary.java +0 -46
  49. data/lib/java/monkstone/core/LibraryProxy.java +0 -136
  50. data/lib/java/monkstone/fastmath/DegLutTables.java +0 -111
  51. data/lib/java/monkstone/fastmath/Deglut.java +0 -71
  52. data/lib/java/monkstone/fastmath/package-info.java +0 -6
  53. data/lib/java/monkstone/filechooser/Chooser.java +0 -39
  54. data/lib/java/monkstone/noise/FastTerrain.java +0 -874
  55. data/lib/java/monkstone/noise/Noise.java +0 -90
  56. data/lib/java/monkstone/noise/NoiseGenerator.java +0 -75
  57. data/lib/java/monkstone/noise/NoiseMode.java +0 -28
  58. data/lib/java/monkstone/noise/OpenSimplex2F.java +0 -881
  59. data/lib/java/monkstone/noise/OpenSimplex2S.java +0 -1106
  60. data/lib/java/monkstone/noise/SmoothTerrain.java +0 -1099
  61. data/lib/java/monkstone/slider/CustomHorizontalSlider.java +0 -164
  62. data/lib/java/monkstone/slider/CustomVerticalSlider.java +0 -178
  63. data/lib/java/monkstone/slider/SimpleHorizontalSlider.java +0 -145
  64. data/lib/java/monkstone/slider/SimpleSlider.java +0 -166
  65. data/lib/java/monkstone/slider/SimpleVerticalSlider.java +0 -157
  66. data/lib/java/monkstone/slider/Slider.java +0 -61
  67. data/lib/java/monkstone/slider/SliderBar.java +0 -245
  68. data/lib/java/monkstone/slider/SliderGroup.java +0 -56
  69. data/lib/java/monkstone/slider/WheelHandler.java +0 -35
  70. data/lib/java/monkstone/vecmath/GfxRender.java +0 -86
  71. data/lib/java/monkstone/vecmath/JRender.java +0 -56
  72. data/lib/java/monkstone/vecmath/ShapeRender.java +0 -87
  73. data/lib/java/monkstone/vecmath/package-info.java +0 -20
  74. data/lib/java/monkstone/vecmath/vec2/Vec2.java +0 -802
  75. data/lib/java/monkstone/vecmath/vec2/package-info.java +0 -6
  76. data/lib/java/monkstone/vecmath/vec3/Vec3.java +0 -727
  77. data/lib/java/monkstone/vecmath/vec3/package-info.java +0 -6
  78. data/lib/java/monkstone/videoevent/CaptureEvent.java +0 -27
  79. data/lib/java/monkstone/videoevent/MovieEvent.java +0 -32
  80. data/lib/java/monkstone/videoevent/package-info.java +0 -20
  81. data/lib/java/processing/awt/PGraphicsJava2D.java +0 -3040
  82. data/lib/java/processing/awt/PImageAWT.java +0 -377
  83. data/lib/java/processing/awt/PShapeJava2D.java +0 -387
  84. data/lib/java/processing/awt/PSurfaceAWT.java +0 -1581
  85. data/lib/java/processing/awt/ShimAWT.java +0 -581
  86. data/lib/java/processing/core/PApplet.java +0 -15156
  87. data/lib/java/processing/core/PConstants.java +0 -523
  88. data/lib/java/processing/core/PFont.java +0 -1126
  89. data/lib/java/processing/core/PGraphics.java +0 -8600
  90. data/lib/java/processing/core/PImage.java +0 -3377
  91. data/lib/java/processing/core/PMatrix.java +0 -208
  92. data/lib/java/processing/core/PMatrix2D.java +0 -562
  93. data/lib/java/processing/core/PMatrix3D.java +0 -890
  94. data/lib/java/processing/core/PShape.java +0 -3561
  95. data/lib/java/processing/core/PShapeOBJ.java +0 -483
  96. data/lib/java/processing/core/PShapeSVG.java +0 -2016
  97. data/lib/java/processing/core/PStyle.java +0 -63
  98. data/lib/java/processing/core/PSurface.java +0 -198
  99. data/lib/java/processing/core/PSurfaceNone.java +0 -431
  100. data/lib/java/processing/core/PVector.java +0 -1066
  101. data/lib/java/processing/core/ThinkDifferent.java +0 -115
  102. data/lib/java/processing/data/DoubleDict.java +0 -850
  103. data/lib/java/processing/data/DoubleList.java +0 -928
  104. data/lib/java/processing/data/FloatDict.java +0 -847
  105. data/lib/java/processing/data/FloatList.java +0 -936
  106. data/lib/java/processing/data/IntDict.java +0 -807
  107. data/lib/java/processing/data/IntList.java +0 -936
  108. data/lib/java/processing/data/JSONArray.java +0 -1260
  109. data/lib/java/processing/data/JSONObject.java +0 -2282
  110. data/lib/java/processing/data/JSONTokener.java +0 -435
  111. data/lib/java/processing/data/LongDict.java +0 -802
  112. data/lib/java/processing/data/LongList.java +0 -937
  113. data/lib/java/processing/data/Sort.java +0 -46
  114. data/lib/java/processing/data/StringDict.java +0 -613
  115. data/lib/java/processing/data/StringList.java +0 -800
  116. data/lib/java/processing/data/Table.java +0 -4936
  117. data/lib/java/processing/data/TableRow.java +0 -198
  118. data/lib/java/processing/data/XML.java +0 -1156
  119. data/lib/java/processing/dxf/RawDXF.java +0 -404
  120. data/lib/java/processing/event/Event.java +0 -125
  121. data/lib/java/processing/event/KeyEvent.java +0 -70
  122. data/lib/java/processing/event/MouseEvent.java +0 -114
  123. data/lib/java/processing/event/TouchEvent.java +0 -57
  124. data/lib/java/processing/javafx/PGraphicsFX2D.java +0 -32
  125. data/lib/java/processing/javafx/PSurfaceFX.java +0 -173
  126. data/lib/java/processing/net/Client.java +0 -744
  127. data/lib/java/processing/net/Server.java +0 -388
  128. data/lib/java/processing/opengl/FontTexture.java +0 -378
  129. data/lib/java/processing/opengl/FrameBuffer.java +0 -513
  130. data/lib/java/processing/opengl/LinePath.java +0 -627
  131. data/lib/java/processing/opengl/LineStroker.java +0 -681
  132. data/lib/java/processing/opengl/PGL.java +0 -3483
  133. data/lib/java/processing/opengl/PGraphics2D.java +0 -615
  134. data/lib/java/processing/opengl/PGraphics3D.java +0 -281
  135. data/lib/java/processing/opengl/PGraphicsOpenGL.java +0 -13753
  136. data/lib/java/processing/opengl/PJOGL.java +0 -2008
  137. data/lib/java/processing/opengl/PShader.java +0 -1484
  138. data/lib/java/processing/opengl/PShapeOpenGL.java +0 -5269
  139. data/lib/java/processing/opengl/PSurfaceJOGL.java +0 -1385
  140. data/lib/java/processing/opengl/Texture.java +0 -1696
  141. data/lib/java/processing/opengl/VertexBuffer.java +0 -88
  142. data/lib/java/processing/pdf/PGraphicsPDF.java +0 -581
  143. data/lib/java/processing/svg/PGraphicsSVG.java +0 -378
  144. data/src/main/java/processing/opengl/cursors/arrow.png +0 -0
  145. data/src/main/java/processing/opengl/cursors/cross.png +0 -0
  146. data/src/main/java/processing/opengl/cursors/hand.png +0 -0
  147. data/src/main/java/processing/opengl/cursors/license.txt +0 -27
  148. data/src/main/java/processing/opengl/cursors/move.png +0 -0
  149. data/src/main/java/processing/opengl/cursors/text.png +0 -0
  150. data/src/main/java/processing/opengl/cursors/wait.png +0 -0
  151. data/src/main/java/processing/opengl/shaders/ColorFrag.glsl +0 -32
  152. data/src/main/java/processing/opengl/shaders/ColorVert.glsl +0 -34
  153. data/src/main/java/processing/opengl/shaders/LightFrag.glsl +0 -33
  154. data/src/main/java/processing/opengl/shaders/LightVert.glsl +0 -151
  155. data/src/main/java/processing/opengl/shaders/LineFrag.glsl +0 -32
  156. data/src/main/java/processing/opengl/shaders/LineVert.glsl +0 -100
  157. data/src/main/java/processing/opengl/shaders/MaskFrag.glsl +0 -40
  158. data/src/main/java/processing/opengl/shaders/PointFrag.glsl +0 -32
  159. data/src/main/java/processing/opengl/shaders/PointVert.glsl +0 -56
  160. data/src/main/java/processing/opengl/shaders/TexFrag.glsl +0 -37
  161. data/src/main/java/processing/opengl/shaders/TexLightFrag.glsl +0 -37
  162. data/src/main/java/processing/opengl/shaders/TexLightVert.glsl +0 -157
  163. data/src/main/java/processing/opengl/shaders/TexVert.glsl +0 -38
@@ -1,88 +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-15 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.opengl;
26
-
27
- import processing.opengl.PGraphicsOpenGL.GLResourceVertexBuffer;
28
-
29
- // TODO: need to combine with PGraphicsOpenGL.VertexAttribute
30
- public class VertexBuffer {
31
- static protected final int INIT_VERTEX_BUFFER_SIZE = 256;
32
- static protected final int INIT_INDEX_BUFFER_SIZE = 512;
33
-
34
- public int glId;
35
- int target;
36
- int elementSize;
37
- int ncoords;
38
- boolean index;
39
-
40
- protected PGL pgl; // The interface between Processing and OpenGL.
41
- protected int context; // The context that created this texture.
42
- private GLResourceVertexBuffer glres;
43
-
44
- VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize) {
45
- this(pg, target, ncoords, esize, false);
46
- }
47
-
48
- VertexBuffer(PGraphicsOpenGL pg, int target, int ncoords, int esize, boolean index) {
49
- pgl = pg.pgl;
50
- context = pgl.createEmptyContext();
51
-
52
- this.target = target;
53
- this.ncoords = ncoords;
54
- this.elementSize = esize;
55
- this.index = index;
56
- create();
57
- init();
58
- }
59
-
60
- protected final void create() {
61
- context = pgl.getCurrentContext();
62
- glres = new GLResourceVertexBuffer(this);
63
- }
64
-
65
- protected final void init() {
66
- int size = index ? ncoords * INIT_INDEX_BUFFER_SIZE * elementSize :
67
- ncoords * INIT_VERTEX_BUFFER_SIZE * elementSize;
68
- pgl.bindBuffer(target, glId);
69
- pgl.bufferData(target, size, null, PGL.STATIC_DRAW);
70
- }
71
-
72
- protected void dispose() {
73
- if (glres != null) {
74
- glres.dispose();
75
- glId = 0;
76
- glres = null;
77
- }
78
- }
79
-
80
- protected boolean contextIsOutdated() {
81
- boolean outdated = !pgl.contextIsCurrent(context);
82
- if (outdated) {
83
- dispose();
84
- }
85
- return outdated;
86
- }
87
-
88
- }
@@ -1,581 +0,0 @@
1
- /*
2
- Part of the Processing project - http://processing.org
3
-
4
- Copyright (c) 2005-12 Ben Fry and Casey Reas
5
- Copyright (c) 2012-18 The Processing Foundation
6
-
7
- This library is free software; you can redistribute it and/or
8
- modify it under the terms of the GNU Lesser General Public
9
- License version 2.1 as published by the Free Software Foundation.
10
-
11
- This library is distributed in the hope that it will be useful,
12
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
- Lesser General Public License for more details.
15
-
16
- You should have received a copy of the GNU Lesser General
17
- Public License along with this library; if not, write to the
18
- Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19
- Boston, MA 02111-1307 USA
20
- */
21
- package processing.pdf;
22
-
23
- import com.itextpdf.awt.DefaultFontMapper;
24
- import com.itextpdf.awt.PdfGraphics2D;
25
- import com.itextpdf.text.Document;
26
- import com.itextpdf.text.DocumentException;
27
- import com.itextpdf.text.Rectangle;
28
- import com.itextpdf.text.pdf.ByteBuffer;
29
- import com.itextpdf.text.pdf.PdfContentByte;
30
- import com.itextpdf.text.pdf.PdfWriter;
31
- import java.awt.Font;
32
- import java.awt.Graphics2D;
33
- import java.awt.Image;
34
- import java.io.BufferedOutputStream;
35
- import java.io.File;
36
- import java.io.FileNotFoundException;
37
- import java.io.FileOutputStream;
38
- import java.io.OutputStream;
39
- import java.util.Arrays;
40
- import java.util.HashMap;
41
- import java.util.logging.Level;
42
- import java.util.logging.Logger;
43
- import processing.awt.PGraphicsJava2D;
44
- import processing.core.PApplet;
45
- import processing.core.PConstants;
46
- import processing.core.PFont;
47
- import processing.core.PImage;
48
- import processing.core.PStyle;
49
- import processing.core.PSurface;
50
- import processing.core.PSurfaceNone;
51
-
52
- /**
53
- * Thin wrapper for the iText PDF library that handles writing PDF files. The
54
- * majority of the work in this library is done by
55
- * <a href="https://github.com/itext/itextpdf">itextpdf</a>. This is currently using
56
- * itextpdf-5.5.13.2.
57
- */
58
- public class PGraphicsPDF extends PGraphicsJava2D {
59
-
60
- /**
61
- * File being written, if it's a file.
62
- */
63
- protected File file;
64
- /**
65
- * OutputStream being written to, if using an OutputStream.
66
- */
67
- protected OutputStream output;
68
-
69
- protected Document document;
70
- protected PdfWriter writer;
71
- protected PdfContentByte content;
72
- protected PdfGraphics2D graphicContent;
73
- /**
74
- * Shared across instances because it's incredibly time-consuming to create.
75
- */
76
- static protected DefaultFontMapper mapper;
77
- static protected String[] fontList;
78
-
79
- @Override
80
- public void setPath(String path) {
81
- this.path = path;
82
- if (path != null) {
83
- file = new File(path);
84
- if (!file.isAbsolute()) {
85
- file = null;
86
- }
87
- }
88
- if (file == null) {
89
- throw new RuntimeException("PGraphicsPDF requires an absolute path "
90
- + "for the location of the output file.");
91
- }
92
- }
93
-
94
- /**
95
- * Set the library to write to an output stream instead of a file.
96
- * @param output
97
- */
98
- public void setOutput(OutputStream output) {
99
- this.output = output;
100
- }
101
-
102
- @Override
103
- public PSurface createSurface() {
104
- return surface = new PSurfaceNone(this);
105
- }
106
-
107
- @Override
108
- protected void defaultSettings() { // ignore
109
- super.defaultSettings();
110
- textMode = SHAPE;
111
- }
112
-
113
- @Override
114
- public void beginDraw() {
115
- if (document == null) {
116
- ByteBuffer.HIGH_PRECISION = true;
117
- document = new Document(new Rectangle(width, height));
118
- boolean missingPath = false;
119
- try {
120
- if (file != null) {
121
- try {
122
- output = new BufferedOutputStream(new FileOutputStream(file), 16384);
123
- } catch (FileNotFoundException ex) {
124
- Logger.getLogger(PGraphicsPDF.class.getName()).log(Level.SEVERE, null, ex);
125
- }
126
- } else if (output == null) {
127
- missingPath = true;
128
- throw new RuntimeException("PGraphicsPDF requires a path "
129
- + "for the location of the output file.");
130
- }
131
- try {
132
- writer = PdfWriter.getInstance(document, output);
133
- } catch (DocumentException ex) {
134
- Logger.getLogger(PGraphicsPDF.class.getName()).log(Level.SEVERE, null, ex);
135
- }
136
- document.open();
137
- content = writer.getDirectContent();
138
- // template = content.createTemplate(width, height);
139
-
140
- } catch (RuntimeException re) {
141
- if (missingPath) {
142
- throw re; // don't re-package our own error
143
- } else {
144
- throw new RuntimeException("Problem saving the PDF file.", re);
145
- }
146
- }
147
- g2 = new PdfGraphics2D(content, width, height);
148
- }
149
-
150
- // super in Java2D now creates an image buffer, don't do that
151
- //super.beginDraw();
152
- checkSettings();
153
- resetMatrix(); // reset model matrix
154
- vertexCount = 0;
155
- pushMatrix();
156
- }
157
-
158
- static protected DefaultFontMapper getMapper() {
159
- if (mapper == null) {
160
- mapper = new DefaultFontMapper();
161
- switch (PApplet.platform) {
162
- case PConstants.MACOS:
163
- try {
164
- String homeLibraryFonts
165
- = System.getProperty("user.home") + "/Library/Fonts";
166
- mapper.insertDirectory(homeLibraryFonts);
167
- } catch (Exception e) {
168
- // might be a security issue with getProperty() and user.home
169
- // if this sketch is running from the web
170
- } // add the system font paths
171
- mapper.insertDirectory("/System/Library/Fonts");
172
- mapper.insertDirectory("/Library/Fonts");
173
- break;
174
-
175
- case PConstants.WINDOWS:
176
- // how to get the windows fonts directory?
177
- // could be c:\winnt\fonts or c:\windows\fonts or not even c:
178
- // maybe do a Runtime.exec() on echo %WINDIR% ?
179
- // Runtime.exec solution might be a mess on systems where the
180
- // the backslash/colon characters not really used (i.e. JP)
181
-
182
- // find the windows fonts folder
183
- File roots[] = File.listRoots();
184
- for (File root : roots) {
185
- if (root.toString().startsWith("A:")) {
186
- // Seems to be a problem with some machines that the A:
187
- // drive is returned as an actual root, even if not available.
188
- // This won't fix the issue if the same thing happens with
189
- // other removable drive devices, but should fix the
190
- // initial/problem as cited by the bug report:
191
- // http://dev.processing.org/bugs/show_bug.cgi?id=478
192
- // If not, will need to use the other fileExists() code below.
193
- continue;
194
- }
195
- File folder = new File(root, "WINDOWS/Fonts");
196
- if (folder.exists()) {
197
- mapper.insertDirectory(folder.getAbsolutePath());
198
- break;
199
- }
200
- folder = new File(root, "WINNT/Fonts");
201
- if (folder.exists()) {
202
- mapper.insertDirectory(folder.getAbsolutePath());
203
- break;
204
- }
205
- }
206
- break;
207
-
208
- case PConstants.LINUX:
209
- checkDir("/usr/share/fonts/", mapper);
210
- checkDir("/usr/local/share/fonts/", mapper);
211
- checkDir(System.getProperty("user.home") + "/.fonts", mapper);
212
- break;
213
- default:
214
- break;
215
- }
216
- }
217
- return mapper;
218
- }
219
-
220
- static protected void checkDir(String path, DefaultFontMapper mapper) {
221
- File folder = new File(path);
222
- if (folder.exists()) {
223
- mapper.insertDirectory(path);
224
- traverseDir(folder, mapper);
225
- }
226
- }
227
-
228
- /**
229
- * Recursive walk to get all subdirectories for font fun.Patch submitted by
230
- * Matthias
231
- * Breuer.(<a href="http://dev.processing.org/bugs/show_bug.cgi?id=1566">Bug
232
- * 1566</a>)
233
- *
234
- * @param folder
235
- * @param mapper
236
- */
237
- static protected void traverseDir(File folder, DefaultFontMapper mapper) {
238
- File[] files = folder.listFiles();
239
- for (File file1 : files) {
240
- if (file1.isDirectory()) {
241
- mapper.insertDirectory(file1.getPath());
242
- traverseDir(new File(file1.getPath()), mapper);
243
- }
244
- }
245
- }
246
-
247
- // endDraw() needs to be overridden so that the endDraw() from
248
- // PGraphicsJava2D is not inherited (it calls loadPixels).
249
- // http://dev.processing.org/bugs/show_bug.cgi?id=1169
250
- @Override
251
- public void endDraw() {
252
- // Also need to pop the matrix since the matrix doesn't reset on each run
253
- // http://dev.processing.org/bugs/show_bug.cgi?id=1227
254
- popMatrix();
255
- }
256
-
257
- /**
258
- * Call to explicitly go to the next page from within a single draw().
259
- */
260
- public void nextPage() {
261
- PStyle savedStyle = getStyle();
262
- endDraw();
263
- g2.dispose();
264
-
265
- try {
266
- // writer.setPageEmpty(false); // maybe useful later
267
- document.newPage(); // is this bad if no addl pages are made?
268
- } catch (Exception e) {
269
- }
270
- g2 = createGraphics();
271
- beginDraw();
272
- style(savedStyle);
273
- }
274
-
275
- protected Graphics2D createGraphics() {
276
- if (textMode == SHAPE) {
277
- return new PdfGraphics2D(content, width, height);
278
- } else if (textMode == MODEL) {
279
- return new PdfGraphics2D(content, width, height, getMapper());
280
- }
281
- // Should not be reachable...
282
- throw new RuntimeException("Invalid textMode() selected for PDF.");
283
- }
284
-
285
- @Override
286
- public void dispose() {
287
- if (document != null) {
288
- g2.dispose();
289
- document.close(); // can't be done in finalize, not always called
290
- document = null;
291
- }
292
- //new Exception().printStackTrace(System.out);
293
- }
294
-
295
- /**
296
- * Don't open a window for this renderer, it won't be used.
297
- * @return
298
- */
299
- @Override
300
- public boolean displayable() {
301
- return false;
302
- }
303
-
304
- @Override
305
- protected void imageImpl(PImage image,
306
- float x1, float y1, float x2, float y2,
307
- int u1, int v1, int u2, int v2) {
308
- pushMatrix();
309
- translate(x1, y1);
310
- int imageWidth = image.width;
311
- int imageHeight = image.height;
312
- scale((x2 - x1) / imageWidth,
313
- (y2 - y1) / imageHeight);
314
- if (u2 - u1 == imageWidth && v2 - v1 == imageHeight) {
315
- g2.drawImage((Image) image.getNative(), 0, 0, null);
316
- } else {
317
- PImage tmp = image.get(u1, v1, u2 - u1, v2 - v1);
318
- g2.drawImage((Image) tmp.getNative(), 0, 0, null);
319
- }
320
- popMatrix();
321
- }
322
-
323
- //////////////////////////////////////////////////////////////
324
- @Override
325
- public void textFont(PFont which) {
326
- super.textFont(which);
327
- checkFont();
328
- }
329
-
330
- /**
331
- * Change the textMode() to either SHAPE or MODEL. This resets all renderer
332
- * settings, and therefore must be called
333
- * <EM>before</EM> any other commands that set the fill() or the textFont()
334
- * or anything. Unlike other renderers, use textMode() directly after the
335
- * size() command.
336
- */
337
- @Override
338
- public void textMode(int mode) {
339
- if (textMode != mode) {
340
- switch (mode) {
341
- case SHAPE:
342
- textMode = SHAPE;
343
- g2.dispose();
344
- g2 = createGraphics();
345
- break;
346
- case MODEL:
347
- textMode = MODEL;
348
- g2.dispose();
349
- g2 = createGraphics();
350
- break;
351
- case SCREEN:
352
- throw new RuntimeException("textMode(SCREEN) not supported with PDF");
353
- default:
354
- throw new RuntimeException("That textMode() does not exist");
355
- }
356
- }
357
- }
358
-
359
- @Override
360
- protected void textLineImpl(char buffer[], int start, int stop,
361
- float x, float y) {
362
- checkFont();
363
- super.textLineImpl(buffer, start, stop, x, y);
364
- }
365
-
366
- //////////////////////////////////////////////////////////////
367
- @Override
368
- public void loadPixels() {
369
- nope("loadPixels");
370
- }
371
-
372
- @Override
373
- public void updatePixels() {
374
- nope("updatePixels");
375
- }
376
-
377
- @Override
378
- public void updatePixels(int x, int y, int c, int d) {
379
- nope("updatePixels");
380
- }
381
-
382
- //
383
- @Override
384
- public int get(int x, int y) {
385
- nope("get");
386
- return 0; // not reached
387
- }
388
-
389
- @Override
390
- public PImage get(int x, int y, int c, int d) {
391
- nope("get");
392
- return null; // not reached
393
- }
394
-
395
- @Override
396
- public PImage get() {
397
- nope("get");
398
- return null; // not reached
399
- }
400
-
401
- @Override
402
- public void set(int x, int y, int argb) {
403
- nope("set");
404
- }
405
-
406
- @Override
407
- public void set(int x, int y, PImage image) {
408
- nope("set");
409
- }
410
-
411
- //
412
- /**
413
- *
414
- * @param alpha
415
- */
416
- @Override
417
- public void mask(int alpha[]) {
418
- nope("mask");
419
- }
420
-
421
- @Override
422
- public void mask(PImage alpha) {
423
- nope("mask");
424
- }
425
-
426
- /**
427
- *
428
- * @param kind
429
- */
430
- @Override
431
- public void filter(int kind) {
432
- nope("filter");
433
- }
434
-
435
- @Override
436
- public void filter(int kind, float param) {
437
- nope("filter");
438
- }
439
-
440
- //
441
- @Override
442
- protected void blendModeImpl() {
443
- if (blendMode != REPLACE && blendMode != BLEND) {
444
- showMissingWarning("blendMode");
445
- }
446
- }
447
-
448
- //
449
- @Override
450
- public void copy(int sx1, int sy1, int sx2, int sy2,
451
- int dx1, int dy1, int dx2, int dy2) {
452
- nope("copy");
453
- }
454
-
455
- /**
456
- *
457
- * @param src
458
- * @param sx1
459
- * @param sy1
460
- * @param sx2
461
- * @param sy2
462
- * @param dx1
463
- * @param dy1
464
- * @param dx2
465
- * @param dy2
466
- */
467
- @Override
468
- public void copy(PImage src,
469
- int sx1, int sy1, int sx2, int sy2,
470
- int dx1, int dy1, int dx2, int dy2) {
471
- nope("copy");
472
- }
473
-
474
- //
475
- public void blend(int sx, int sy, int dx, int dy, int mode) {
476
- nope("blend");
477
- }
478
-
479
- public void blend(PImage src,
480
- int sx, int sy, int dx, int dy, int mode) {
481
- nope("blend");
482
- }
483
-
484
- @Override
485
- public void blend(int sx1, int sy1, int sx2, int sy2,
486
- int dx1, int dy1, int dx2, int dy2, int mode) {
487
- nope("blend");
488
- }
489
-
490
- @Override
491
- public void blend(PImage src,
492
- int sx1, int sy1, int sx2, int sy2,
493
- int dx1, int dy1, int dx2, int dy2, int mode) {
494
- nope("blend");
495
- }
496
-
497
- //
498
- @Override
499
- public boolean save(String filename) {
500
- nope("save");
501
- return false;
502
- }
503
-
504
- //////////////////////////////////////////////////////////////
505
- /**
506
- * On Linux or any other platform, you'll need to add the directories by
507
- * hand. (If there are actual standards here that we can use as a starting
508
- * point, please file a bug to make a note of it)
509
- *
510
- * @param directory
511
- */
512
- public void addFonts(String directory) {
513
- mapper.insertDirectory(directory);
514
- }
515
-
516
- /**
517
- * Check whether the specified font can be used with the PDF library.
518
- *
519
- */
520
- protected void checkFont() {
521
- Font awtFont = (Font) textFont.getNative();
522
- if (awtFont == null) { // always need a native font or reference to it
523
- throw new RuntimeException("Use createFont() instead of loadFont() "
524
- + "when drawing text using the PDF library.");
525
- } else if (textMode != SHAPE) {
526
- if (textFont.isStream()) {
527
- throw new RuntimeException("Use textMode(SHAPE) with PDF when loading "
528
- + ".ttf and .otf files with createFont().");
529
- } else if (mapper.getAliases().get(textFont.getName()) == null) {
530
- //System.out.println("alias for " + name + " = " + mapper.getAliases().get(name));
531
- // System.err.println("Use PGraphicsPDF.listFonts() to get a list of " +
532
- // "fonts that can be used with PDF.");
533
- // throw new RuntimeException("The font “" + textFont.getName() + "” " +
534
- // "cannot be used with PDF Export.");
535
- if (textFont.getName().equals("Lucida Sans")) {
536
- throw new RuntimeException("Use textMode(SHAPE) with the default "
537
- + "font when exporting to PDF.");
538
- } else {
539
- throw new RuntimeException("Use textMode(SHAPE) with "
540
- + "“" + textFont.getName() + "” "
541
- + "when exporting to PDF.");
542
- }
543
- }
544
- }
545
- }
546
-
547
- /**
548
- * List the fonts known to the PDF renderer.This is like PFont.list(),
549
- * however not all those fonts are available by default.
550
- *
551
- * @return
552
- */
553
- static public String[] listFonts() {
554
- if (fontList == null) {
555
- HashMap<?, ?> map = getMapper().getAliases();
556
- // Set entries = map.entrySet();
557
- // fontList = new String[entries.size()];
558
- fontList = new String[map.size()];
559
- int count = 0;
560
- for (Object key : map.keySet()) {
561
- // for (Object entry : map.entrySet()) {
562
- // fontList[count++] = (String) ((Map.Entry) entry).getKey();
563
- fontList[count++] = (String) key;
564
- }
565
- // Iterator it = entries.iterator();
566
- // int count = 0;
567
- // while (it.hasNext()) {
568
- // Map.Entry entry = (Map.Entry) it.next();
569
- // //System.out.println(entry.getKey() + "-->" + entry.getValue());
570
- // fontList[count++] = (String) entry.getKey();
571
- // }
572
- Arrays.sort(fontList);
573
- }
574
- return fontList;
575
- }
576
-
577
- //////////////////////////////////////////////////////////////
578
- protected void nope(String function) {
579
- throw new RuntimeException("No " + function + "() for " + getClass().getSimpleName());
580
- }
581
- }