propane 3.8.0-java → 4.0.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.mvn/extensions.xml +1 -1
  3. data/.mvn/wrapper/maven-wrapper.properties +1 -1
  4. data/.travis.yml +1 -1
  5. data/CHANGELOG.md +7 -1
  6. data/README.md +7 -7
  7. data/Rakefile +6 -5
  8. data/lib/propane/app.rb +10 -17
  9. data/lib/propane/helper_methods.rb +6 -6
  10. data/lib/propane/version.rb +1 -1
  11. data/lib/propane-4.0.0.jar +0 -0
  12. data/library/pdf/itextpdf-5.5.13.2.jar +0 -0
  13. data/library/pdf/pdf.rb +7 -0
  14. data/library/slider/slider.rb +1 -1
  15. data/library/svg/batik-all-1.14.jar +0 -0
  16. data/library/svg/svg.rb +7 -0
  17. data/mvnw +3 -3
  18. data/mvnw.cmd +2 -2
  19. data/pom.rb +35 -8
  20. data/pom.xml +60 -9
  21. data/propane.gemspec +9 -7
  22. data/src/main/java/monkstone/ColorUtil.java +1 -1
  23. data/src/main/java/monkstone/FastNoiseModuleJava.java +127 -0
  24. data/src/main/java/monkstone/MathToolModule.java +31 -31
  25. data/src/main/java/monkstone/PropaneLibrary.java +3 -1
  26. data/src/main/java/monkstone/SmoothNoiseModuleJava.java +127 -0
  27. data/src/main/java/monkstone/fastmath/DegLutTables.java +25 -26
  28. data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
  29. data/src/main/java/monkstone/filechooser/Chooser.java +2 -2
  30. data/src/main/java/monkstone/noise/LICENSE +121 -0
  31. data/src/main/java/monkstone/noise/OpenSimplex2F.java +914 -0
  32. data/src/main/java/monkstone/noise/OpenSimplex2S.java +1138 -0
  33. data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
  34. data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
  35. data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
  36. data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
  37. data/src/main/java/monkstone/slider/SliderBar.java +1 -1
  38. data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
  39. data/src/main/java/monkstone/slider/WheelHandler.java +2 -2
  40. data/src/main/java/monkstone/vecmath/JRender.java +6 -6
  41. data/src/main/java/monkstone/vecmath/package-info.java +1 -1
  42. data/src/main/java/monkstone/vecmath/vec2/Vec2.java +103 -83
  43. data/src/main/java/monkstone/vecmath/vec3/Vec3.java +27 -41
  44. data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
  45. data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
  46. data/src/main/java/monkstone/videoevent/package-info.java +1 -1
  47. data/src/main/java/processing/awt/PGraphicsJava2D.java +11 -4
  48. data/src/main/java/processing/awt/PImageAWT.java +8 -8
  49. data/src/main/java/processing/core/PApplet.java +245 -254
  50. data/src/main/java/processing/core/PConstants.java +155 -163
  51. data/src/main/java/processing/core/PGraphics.java +116 -109
  52. data/src/main/java/processing/core/PImage.java +3025 -3047
  53. data/src/main/java/processing/core/PMatrix.java +5 -2
  54. data/src/main/java/processing/data/DoubleDict.java +72 -43
  55. data/src/main/java/processing/data/DoubleList.java +6 -2
  56. data/src/main/java/processing/data/FloatDict.java +744 -756
  57. data/src/main/java/processing/data/FloatList.java +68 -26
  58. data/src/main/java/processing/data/IntDict.java +72 -45
  59. data/src/main/java/processing/data/IntList.java +63 -26
  60. data/src/main/java/processing/data/JSONArray.java +892 -931
  61. data/src/main/java/processing/data/JSONObject.java +1169 -1262
  62. data/src/main/java/processing/data/JSONTokener.java +30 -49
  63. data/src/main/java/processing/data/LongDict.java +699 -712
  64. data/src/main/java/processing/data/LongList.java +676 -700
  65. data/src/main/java/processing/data/Sort.java +1 -0
  66. data/src/main/java/processing/data/Table.java +4040 -3661
  67. data/src/main/java/processing/data/TableRow.java +16 -0
  68. data/src/main/java/processing/data/XML.java +1041 -956
  69. data/src/main/java/processing/event/TouchEvent.java +1 -1
  70. data/src/main/java/processing/opengl/FontTexture.java +2 -2
  71. data/src/main/java/processing/opengl/PGraphicsOpenGL.java +28 -31
  72. data/src/main/java/processing/opengl/PJOGL.java +8 -7
  73. data/src/main/java/processing/opengl/PShader.java +1 -6
  74. data/src/main/java/processing/opengl/PShapeOpenGL.java +23 -24
  75. data/src/main/java/processing/opengl/PSurfaceJOGL.java +6 -6
  76. data/src/main/java/processing/pdf/PGraphicsPDF.java +581 -0
  77. data/src/main/java/processing/svg/PGraphicsSVG.java +378 -0
  78. data/src/main/{java/processing/opengl → resources}/cursors/arrow.png +0 -0
  79. data/src/main/{java/processing/opengl → resources}/cursors/cross.png +0 -0
  80. data/src/main/{java/processing/opengl → resources}/cursors/hand.png +0 -0
  81. data/src/main/{java/processing/opengl → resources}/cursors/license.txt +0 -0
  82. data/src/main/{java/processing/opengl → resources}/cursors/move.png +0 -0
  83. data/src/main/{java/processing/opengl → resources}/cursors/text.png +0 -0
  84. data/src/main/{java/processing/opengl → resources}/cursors/wait.png +0 -0
  85. data/src/main/{java/processing/opengl → resources}/shaders/ColorFrag.glsl +0 -0
  86. data/src/main/{java/processing/opengl → resources}/shaders/ColorVert.glsl +0 -0
  87. data/src/main/{java/processing/opengl → resources}/shaders/LightFrag.glsl +0 -0
  88. data/src/main/{java/processing/opengl → resources}/shaders/LightVert.glsl +0 -0
  89. data/src/main/{java/processing/opengl → resources}/shaders/LineFrag.glsl +0 -0
  90. data/src/main/{java/processing/opengl → resources}/shaders/LineVert.glsl +0 -0
  91. data/src/main/{java/processing/opengl → resources}/shaders/MaskFrag.glsl +0 -0
  92. data/src/main/{java/processing/opengl → resources}/shaders/PointFrag.glsl +0 -0
  93. data/src/main/{java/processing/opengl → resources}/shaders/PointVert.glsl +0 -0
  94. data/src/main/{java/processing/opengl → resources}/shaders/TexFrag.glsl +0 -0
  95. data/src/main/{java/processing/opengl → resources}/shaders/TexLightFrag.glsl +0 -0
  96. data/src/main/{java/processing/opengl → resources}/shaders/TexLightVert.glsl +0 -0
  97. data/src/main/{java/processing/opengl → resources}/shaders/TexVert.glsl +0 -0
  98. data/test/test_helper.rb +1 -0
  99. data/test/vecmath_spec_test.rb +14 -3
  100. data/vendors/Rakefile +1 -1
  101. metadata +53 -53
  102. data/lib/propane-3.8.0.jar +0 -0
  103. data/src/main/java/monkstone/noise/Noise.java +0 -116
  104. data/src/main/java/monkstone/noise/NoiseGenerator.java +0 -63
  105. data/src/main/java/monkstone/noise/NoiseMode.java +0 -15
  106. data/src/main/java/monkstone/noise/SimplexNoise.java +0 -470
  107. data/src/main/java/monkstone/noise/ValueNoise.java +0 -170
@@ -0,0 +1,581 @@
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
+ }