picrate 2.1.1-java → 2.4.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.mvn/extensions.xml +1 -1
- data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
- data/.mvn/wrapper/maven-wrapper.properties +2 -2
- data/CHANGELOG.md +11 -1
- data/README.md +3 -2
- data/Rakefile +2 -1
- data/docs/_includes/footer.html +1 -1
- data/docs/_layouts/post.html +1 -1
- data/docs/_methods/noise_mode.md +88 -0
- data/docs/_posts/2018-05-06-install_jruby.md +3 -3
- data/docs/_posts/2018-11-18-building-gem.md +3 -1
- data/docs/_posts/2020-05-11-getting_started_manjaro.md +19 -7
- data/docs/classes.md +2 -2
- data/docs/editors.md +2 -2
- data/docs/gems.md +3 -3
- data/docs/index.html +1 -1
- data/docs/libraries.md +2 -2
- data/docs/live.md +2 -2
- data/docs/magic.md +2 -2
- data/docs/methods.md +2 -2
- data/docs/modules.md +3 -3
- data/docs/objects.md +2 -2
- data/lib/picrate.rb +2 -1
- data/lib/picrate/app.rb +3 -2
- data/lib/picrate/helper_methods.rb +1 -1
- data/lib/picrate/native_folder.rb +1 -3
- data/lib/picrate/runner.rb +4 -4
- data/lib/picrate/version.rb +1 -1
- data/library/jcomplex/jcomplex.rb +1 -0
- data/library/pdf/pdf.rb +7 -0
- data/library/svg/svg.rb +7 -0
- data/mvnw +2 -2
- data/mvnw.cmd +2 -2
- data/picrate.gemspec +5 -3
- data/pom.rb +31 -9
- data/pom.xml +41 -6
- data/src/main/java/monkstone/FastNoiseModuleJava.java +127 -0
- data/src/main/java/monkstone/PicrateLibrary.java +3 -1
- data/src/main/java/monkstone/SmoothNoiseModuleJava.java +127 -0
- data/src/main/java/monkstone/complex/JComplex.java +252 -0
- data/src/main/java/monkstone/fastmath/DegLutTables.java +111 -0
- data/src/main/java/monkstone/fastmath/Deglut.java +41 -93
- data/src/main/java/monkstone/noise/OpenSimplex2F.java +914 -0
- data/src/main/java/monkstone/noise/OpenSimplex2S.java +1138 -0
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/ShimAWT.java +260 -94
- data/src/main/java/processing/core/PApplet.java +14664 -13450
- data/src/main/java/processing/core/PConstants.java +5 -5
- data/src/main/java/processing/core/PFont.java +1 -1
- data/src/main/java/processing/core/PGraphics.java +200 -201
- data/src/main/java/processing/core/PImage.java +539 -549
- data/src/main/java/processing/core/PShape.java +18 -18
- data/src/main/java/processing/core/PVector.java +23 -23
- data/src/main/java/processing/data/Table.java +4 -4
- data/src/main/java/processing/net/Client.java +13 -13
- data/src/main/java/processing/net/Server.java +5 -5
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +4 -4
- data/src/main/java/processing/pdf/PGraphicsPDF.java +529 -0
- data/src/main/java/processing/svg/PGraphicsSVG.java +378 -0
- data/test/deglut_spec_test.rb +2 -2
- data/test/respond_to_test.rb +0 -2
- data/vendors/Rakefile +31 -22
- data/vendors/geany.rb +3 -3
- metadata +26 -13
- data/src/main/java/monkstone/noise/SimplexNoise.java +0 -465
@@ -119,7 +119,7 @@ public class Server implements Runnable {
|
|
119
119
|
*
|
120
120
|
* Disconnect a particular client.
|
121
121
|
*
|
122
|
-
|
122
|
+
|
123
123
|
* @brief Disconnect a particular client.
|
124
124
|
* @webref server:server
|
125
125
|
* @param client the client to disconnect
|
@@ -191,7 +191,7 @@ public class Server implements Runnable {
|
|
191
191
|
* Returns true if this server is still active and hasn't run
|
192
192
|
* into any trouble.
|
193
193
|
*
|
194
|
-
|
194
|
+
|
195
195
|
* @webref server:server
|
196
196
|
* @brief Return true if this server is still active.
|
197
197
|
*/
|
@@ -220,7 +220,7 @@ public class Server implements Runnable {
|
|
220
220
|
*
|
221
221
|
* Returns the next client in line with a new message.
|
222
222
|
*
|
223
|
-
|
223
|
+
|
224
224
|
* @brief Returns the next client in line with a new message.
|
225
225
|
* @webref server
|
226
226
|
* @usage application
|
@@ -258,7 +258,7 @@ public class Server implements Runnable {
|
|
258
258
|
*
|
259
259
|
* Disconnects all clients and stops the server.
|
260
260
|
*
|
261
|
-
|
261
|
+
|
262
262
|
* <h3>Advanced</h3>
|
263
263
|
* Use this to shut down the server if you finish using it while your applet
|
264
264
|
* is still running. Otherwise, it will be automatically be shut down by the
|
@@ -337,7 +337,7 @@ public class Server implements Runnable {
|
|
337
337
|
* Writes a value to all the connected clients. It sends bytes out from the
|
338
338
|
* Server object.
|
339
339
|
*
|
340
|
-
|
340
|
+
|
341
341
|
* @webref server
|
342
342
|
* @brief Writes data to all connected clients
|
343
343
|
* @param data data to write
|
@@ -3685,7 +3685,7 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
3685
3685
|
* Ported from the implementation of textCharShapeImpl() in 1.5.1
|
3686
3686
|
*
|
3687
3687
|
* <EM>No attempt has been made to optimize this code</EM>
|
3688
|
-
*
|
3688
|
+
*
|
3689
3689
|
* TODO: Implement a FontShape class where each glyph is tessellated and
|
3690
3690
|
* stored inside a larger PShapeOpenGL object (which needs to be expanded as
|
3691
3691
|
* new glyphs are added and exceed the initial capacity in a similar way as
|
@@ -3693,18 +3693,18 @@ public class PGraphicsOpenGL extends PGraphics {
|
|
3693
3693
|
* in shape mode, then the correct sequences of vertex indices are computed
|
3694
3694
|
* (akin to the texcoords in the texture case) and used to draw only those
|
3695
3695
|
* parts of the PShape object that are required for the text.
|
3696
|
-
*
|
3696
|
+
*
|
3697
3697
|
*
|
3698
3698
|
* Some issues of the original implementation probably remain, so they are
|
3699
3699
|
* reproduced below:
|
3700
|
-
*
|
3700
|
+
*
|
3701
3701
|
* Also a problem where some fonts seem to be a bit slight, as if the
|
3702
3702
|
* control points aren't being mapped quite correctly. Probably doing
|
3703
3703
|
* something dumb that the control points don't map to P5's control
|
3704
3704
|
* points. Perhaps it's returning b-spline data from the TrueType font?
|
3705
3705
|
* Though it seems like that would make a lot of garbage rather than
|
3706
3706
|
* just a little flattening.
|
3707
|
-
*
|
3707
|
+
*
|
3708
3708
|
* There also seems to be a bug that is causing a line (but not a filled
|
3709
3709
|
* triangle) back to the origin on some letters (i.e. a capital L when
|
3710
3710
|
* tested with Akzidenz Grotesk Light). But this won't be visible
|
@@ -0,0 +1,529 @@
|
|
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
|
+
checkDir("/usr/share/fonts/", mapper);
|
162
|
+
checkDir("/usr/local/share/fonts/", mapper);
|
163
|
+
checkDir(System.getProperty("user.home") + "/.fonts", mapper);
|
164
|
+
}
|
165
|
+
return mapper;
|
166
|
+
}
|
167
|
+
|
168
|
+
static protected void checkDir(String path, DefaultFontMapper mapper) {
|
169
|
+
File folder = new File(path);
|
170
|
+
if (folder.exists()) {
|
171
|
+
mapper.insertDirectory(path);
|
172
|
+
traverseDir(folder, mapper);
|
173
|
+
}
|
174
|
+
}
|
175
|
+
|
176
|
+
/**
|
177
|
+
* Recursive walk to get all subdirectories for font fun.Patch submitted by
|
178
|
+
* Matthias
|
179
|
+
* Breuer.(<a href="http://dev.processing.org/bugs/show_bug.cgi?id=1566">Bug
|
180
|
+
* 1566</a>)
|
181
|
+
*
|
182
|
+
* @param folder
|
183
|
+
* @param mapper
|
184
|
+
*/
|
185
|
+
static protected void traverseDir(File folder, DefaultFontMapper mapper) {
|
186
|
+
File[] files = folder.listFiles();
|
187
|
+
for (File file1 : files) {
|
188
|
+
if (file1.isDirectory()) {
|
189
|
+
mapper.insertDirectory(file1.getPath());
|
190
|
+
traverseDir(new File(file1.getPath()), mapper);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
}
|
194
|
+
|
195
|
+
// endDraw() needs to be overridden so that the endDraw() from
|
196
|
+
// PGraphicsJava2D is not inherited (it calls loadPixels).
|
197
|
+
// http://dev.processing.org/bugs/show_bug.cgi?id=1169
|
198
|
+
@Override
|
199
|
+
public void endDraw() {
|
200
|
+
// Also need to pop the matrix since the matrix doesn't reset on each run
|
201
|
+
// http://dev.processing.org/bugs/show_bug.cgi?id=1227
|
202
|
+
popMatrix();
|
203
|
+
}
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Call to explicitly go to the next page from within a single draw().
|
207
|
+
*/
|
208
|
+
public void nextPage() {
|
209
|
+
PStyle savedStyle = getStyle();
|
210
|
+
endDraw();
|
211
|
+
g2.dispose();
|
212
|
+
|
213
|
+
try {
|
214
|
+
// writer.setPageEmpty(false); // maybe useful later
|
215
|
+
document.newPage(); // is this bad if no addl pages are made?
|
216
|
+
} catch (Exception e) {
|
217
|
+
}
|
218
|
+
g2 = createGraphics();
|
219
|
+
beginDraw();
|
220
|
+
style(savedStyle);
|
221
|
+
}
|
222
|
+
|
223
|
+
protected Graphics2D createGraphics() {
|
224
|
+
if (textMode == SHAPE) {
|
225
|
+
return new PdfGraphics2D(content, width, height);
|
226
|
+
} else if (textMode == MODEL) {
|
227
|
+
return new PdfGraphics2D(content, width, height, getMapper());
|
228
|
+
}
|
229
|
+
// Should not be reachable...
|
230
|
+
throw new RuntimeException("Invalid textMode() selected for PDF.");
|
231
|
+
}
|
232
|
+
|
233
|
+
@Override
|
234
|
+
public void dispose() {
|
235
|
+
if (document != null) {
|
236
|
+
g2.dispose();
|
237
|
+
document.close(); // can't be done in finalize, not always called
|
238
|
+
document = null;
|
239
|
+
}
|
240
|
+
//new Exception().printStackTrace(System.out);
|
241
|
+
}
|
242
|
+
|
243
|
+
/**
|
244
|
+
* Don't open a window for this renderer, it won't be used.
|
245
|
+
* @return
|
246
|
+
*/
|
247
|
+
@Override
|
248
|
+
public boolean displayable() {
|
249
|
+
return false;
|
250
|
+
}
|
251
|
+
|
252
|
+
@Override
|
253
|
+
protected void imageImpl(PImage image,
|
254
|
+
float x1, float y1, float x2, float y2,
|
255
|
+
int u1, int v1, int u2, int v2) {
|
256
|
+
pushMatrix();
|
257
|
+
translate(x1, y1);
|
258
|
+
int imageWidth = image.width;
|
259
|
+
int imageHeight = image.height;
|
260
|
+
scale((x2 - x1) / imageWidth,
|
261
|
+
(y2 - y1) / imageHeight);
|
262
|
+
if (u2 - u1 == imageWidth && v2 - v1 == imageHeight) {
|
263
|
+
g2.drawImage((Image) image.getNative(), 0, 0, null);
|
264
|
+
} else {
|
265
|
+
PImage tmp = image.get(u1, v1, u2 - u1, v2 - v1);
|
266
|
+
g2.drawImage((Image) tmp.getNative(), 0, 0, null);
|
267
|
+
}
|
268
|
+
popMatrix();
|
269
|
+
}
|
270
|
+
|
271
|
+
//////////////////////////////////////////////////////////////
|
272
|
+
@Override
|
273
|
+
public void textFont(PFont which) {
|
274
|
+
super.textFont(which);
|
275
|
+
checkFont();
|
276
|
+
}
|
277
|
+
|
278
|
+
/**
|
279
|
+
* Change the textMode() to either SHAPE or MODEL. This resets all renderer
|
280
|
+
* settings, and therefore must be called
|
281
|
+
* <EM>before</EM> any other commands that set the fill() or the textFont()
|
282
|
+
* or anything. Unlike other renderers, use textMode() directly after the
|
283
|
+
* size() command.
|
284
|
+
*/
|
285
|
+
@Override
|
286
|
+
public void textMode(int mode) {
|
287
|
+
if (textMode != mode) {
|
288
|
+
switch (mode) {
|
289
|
+
case SHAPE:
|
290
|
+
textMode = SHAPE;
|
291
|
+
g2.dispose();
|
292
|
+
g2 = createGraphics();
|
293
|
+
break;
|
294
|
+
case MODEL:
|
295
|
+
textMode = MODEL;
|
296
|
+
g2.dispose();
|
297
|
+
g2 = createGraphics();
|
298
|
+
break;
|
299
|
+
case SCREEN:
|
300
|
+
throw new RuntimeException("textMode(SCREEN) not supported with PDF");
|
301
|
+
default:
|
302
|
+
throw new RuntimeException("That textMode() does not exist");
|
303
|
+
}
|
304
|
+
}
|
305
|
+
}
|
306
|
+
|
307
|
+
@Override
|
308
|
+
protected void textLineImpl(char buffer[], int start, int stop,
|
309
|
+
float x, float y) {
|
310
|
+
checkFont();
|
311
|
+
super.textLineImpl(buffer, start, stop, x, y);
|
312
|
+
}
|
313
|
+
|
314
|
+
//////////////////////////////////////////////////////////////
|
315
|
+
@Override
|
316
|
+
public void loadPixels() {
|
317
|
+
nope("loadPixels");
|
318
|
+
}
|
319
|
+
|
320
|
+
@Override
|
321
|
+
public void updatePixels() {
|
322
|
+
nope("updatePixels");
|
323
|
+
}
|
324
|
+
|
325
|
+
@Override
|
326
|
+
public void updatePixels(int x, int y, int c, int d) {
|
327
|
+
nope("updatePixels");
|
328
|
+
}
|
329
|
+
|
330
|
+
//
|
331
|
+
@Override
|
332
|
+
public int get(int x, int y) {
|
333
|
+
nope("get");
|
334
|
+
return 0; // not reached
|
335
|
+
}
|
336
|
+
|
337
|
+
@Override
|
338
|
+
public PImage get(int x, int y, int c, int d) {
|
339
|
+
nope("get");
|
340
|
+
return null; // not reached
|
341
|
+
}
|
342
|
+
|
343
|
+
@Override
|
344
|
+
public PImage get() {
|
345
|
+
nope("get");
|
346
|
+
return null; // not reached
|
347
|
+
}
|
348
|
+
|
349
|
+
@Override
|
350
|
+
public void set(int x, int y, int argb) {
|
351
|
+
nope("set");
|
352
|
+
}
|
353
|
+
|
354
|
+
@Override
|
355
|
+
public void set(int x, int y, PImage image) {
|
356
|
+
nope("set");
|
357
|
+
}
|
358
|
+
|
359
|
+
//
|
360
|
+
/**
|
361
|
+
*
|
362
|
+
* @param alpha
|
363
|
+
*/
|
364
|
+
@Override
|
365
|
+
public void mask(int alpha[]) {
|
366
|
+
nope("mask");
|
367
|
+
}
|
368
|
+
|
369
|
+
@Override
|
370
|
+
public void mask(PImage alpha) {
|
371
|
+
nope("mask");
|
372
|
+
}
|
373
|
+
|
374
|
+
/**
|
375
|
+
*
|
376
|
+
* @param kind
|
377
|
+
*/
|
378
|
+
@Override
|
379
|
+
public void filter(int kind) {
|
380
|
+
nope("filter");
|
381
|
+
}
|
382
|
+
|
383
|
+
@Override
|
384
|
+
public void filter(int kind, float param) {
|
385
|
+
nope("filter");
|
386
|
+
}
|
387
|
+
|
388
|
+
//
|
389
|
+
@Override
|
390
|
+
protected void blendModeImpl() {
|
391
|
+
if (blendMode != REPLACE && blendMode != BLEND) {
|
392
|
+
showMissingWarning("blendMode");
|
393
|
+
}
|
394
|
+
}
|
395
|
+
|
396
|
+
//
|
397
|
+
@Override
|
398
|
+
public void copy(int sx1, int sy1, int sx2, int sy2,
|
399
|
+
int dx1, int dy1, int dx2, int dy2) {
|
400
|
+
nope("copy");
|
401
|
+
}
|
402
|
+
|
403
|
+
/**
|
404
|
+
*
|
405
|
+
* @param src
|
406
|
+
* @param sx1
|
407
|
+
* @param sy1
|
408
|
+
* @param sx2
|
409
|
+
* @param sy2
|
410
|
+
* @param dx1
|
411
|
+
* @param dy1
|
412
|
+
* @param dx2
|
413
|
+
* @param dy2
|
414
|
+
*/
|
415
|
+
@Override
|
416
|
+
public void copy(PImage src,
|
417
|
+
int sx1, int sy1, int sx2, int sy2,
|
418
|
+
int dx1, int dy1, int dx2, int dy2) {
|
419
|
+
nope("copy");
|
420
|
+
}
|
421
|
+
|
422
|
+
//
|
423
|
+
public void blend(int sx, int sy, int dx, int dy, int mode) {
|
424
|
+
nope("blend");
|
425
|
+
}
|
426
|
+
|
427
|
+
public void blend(PImage src,
|
428
|
+
int sx, int sy, int dx, int dy, int mode) {
|
429
|
+
nope("blend");
|
430
|
+
}
|
431
|
+
|
432
|
+
@Override
|
433
|
+
public void blend(int sx1, int sy1, int sx2, int sy2,
|
434
|
+
int dx1, int dy1, int dx2, int dy2, int mode) {
|
435
|
+
nope("blend");
|
436
|
+
}
|
437
|
+
|
438
|
+
@Override
|
439
|
+
public void blend(PImage src,
|
440
|
+
int sx1, int sy1, int sx2, int sy2,
|
441
|
+
int dx1, int dy1, int dx2, int dy2, int mode) {
|
442
|
+
nope("blend");
|
443
|
+
}
|
444
|
+
|
445
|
+
//
|
446
|
+
@Override
|
447
|
+
public boolean save(String filename) {
|
448
|
+
nope("save");
|
449
|
+
return false;
|
450
|
+
}
|
451
|
+
|
452
|
+
//////////////////////////////////////////////////////////////
|
453
|
+
/**
|
454
|
+
* On Linux or any other platform, you'll need to add the directories by
|
455
|
+
* hand. (If there are actual standards here that we can use as a starting
|
456
|
+
* point, please file a bug to make a note of it)
|
457
|
+
*
|
458
|
+
* @param directory
|
459
|
+
*/
|
460
|
+
public void addFonts(String directory) {
|
461
|
+
mapper.insertDirectory(directory);
|
462
|
+
}
|
463
|
+
|
464
|
+
/**
|
465
|
+
* Check whether the specified font can be used with the PDF library.
|
466
|
+
*
|
467
|
+
*/
|
468
|
+
protected void checkFont() {
|
469
|
+
Font awtFont = (Font) textFont.getNative();
|
470
|
+
if (awtFont == null) { // always need a native font or reference to it
|
471
|
+
throw new RuntimeException("Use createFont() instead of loadFont() "
|
472
|
+
+ "when drawing text using the PDF library.");
|
473
|
+
} else if (textMode != SHAPE) {
|
474
|
+
if (textFont.isStream()) {
|
475
|
+
throw new RuntimeException("Use textMode(SHAPE) with PDF when loading "
|
476
|
+
+ ".ttf and .otf files with createFont().");
|
477
|
+
} else if (mapper.getAliases().get(textFont.getName()) == null) {
|
478
|
+
//System.out.println("alias for " + name + " = " + mapper.getAliases().get(name));
|
479
|
+
// System.err.println("Use PGraphicsPDF.listFonts() to get a list of " +
|
480
|
+
// "fonts that can be used with PDF.");
|
481
|
+
// throw new RuntimeException("The font “" + textFont.getName() + "” " +
|
482
|
+
// "cannot be used with PDF Export.");
|
483
|
+
if (textFont.getName().equals("Lucida Sans")) {
|
484
|
+
throw new RuntimeException("Use textMode(SHAPE) with the default "
|
485
|
+
+ "font when exporting to PDF.");
|
486
|
+
} else {
|
487
|
+
throw new RuntimeException("Use textMode(SHAPE) with "
|
488
|
+
+ "“" + textFont.getName() + "” "
|
489
|
+
+ "when exporting to PDF.");
|
490
|
+
}
|
491
|
+
}
|
492
|
+
}
|
493
|
+
}
|
494
|
+
|
495
|
+
/**
|
496
|
+
* List the fonts known to the PDF renderer.This is like PFont.list(),
|
497
|
+
* however not all those fonts are available by default.
|
498
|
+
*
|
499
|
+
* @return
|
500
|
+
*/
|
501
|
+
static public String[] listFonts() {
|
502
|
+
if (fontList == null) {
|
503
|
+
HashMap<?, ?> map = getMapper().getAliases();
|
504
|
+
// Set entries = map.entrySet();
|
505
|
+
// fontList = new String[entries.size()];
|
506
|
+
fontList = new String[map.size()];
|
507
|
+
int count = 0;
|
508
|
+
for (Object key : map.keySet()) {
|
509
|
+
// for (Object entry : map.entrySet()) {
|
510
|
+
// fontList[count++] = (String) ((Map.Entry) entry).getKey();
|
511
|
+
fontList[count++] = (String) key;
|
512
|
+
}
|
513
|
+
// Iterator it = entries.iterator();
|
514
|
+
// int count = 0;
|
515
|
+
// while (it.hasNext()) {
|
516
|
+
// Map.Entry entry = (Map.Entry) it.next();
|
517
|
+
// //System.out.println(entry.getKey() + "-->" + entry.getValue());
|
518
|
+
// fontList[count++] = (String) entry.getKey();
|
519
|
+
// }
|
520
|
+
Arrays.sort(fontList);
|
521
|
+
}
|
522
|
+
return fontList;
|
523
|
+
}
|
524
|
+
|
525
|
+
//////////////////////////////////////////////////////////////
|
526
|
+
protected void nope(String function) {
|
527
|
+
throw new RuntimeException("No " + function + "() for " + getClass().getSimpleName());
|
528
|
+
}
|
529
|
+
}
|