Skip to content

Commit f7d6f99

Browse files
committed
clean up svgz handling, remove fake objz file format
1 parent 01443b8 commit f7d6f99

3 files changed

Lines changed: 15 additions & 62 deletions

File tree

core/src/processing/core/PGraphicsJava2D.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,25 +1753,11 @@ public void update(PImage source, boolean tint, int tintColor) {
17531753
@Override
17541754
public PShape loadShape(String filename, String options) {
17551755
String extension = PApplet.getExtension(filename);
1756-
1757-
PShapeSVG svg = null;
1758-
17591756
if (extension.equals("svg") || extension.equals("svgz")) {
1760-
svg = new PShapeSVG(parent.loadXML(filename));
1761-
1762-
// } else if (extension.equals("svgz")) {
1763-
// try {
1764-
// InputStream input = new GZIPInputStream(parent.createInput(filename));
1765-
// XML xml = new XML(PApplet.createReader(input), options);
1766-
// svg = new PShapeSVG(xml);
1767-
// } catch (Exception e) {
1768-
// e.printStackTrace();
1769-
// }
1770-
} else {
1771-
PGraphics.showWarning("Unsupported format: " + filename);
1757+
return new PShapeSVG(parent.loadXML(filename));
17721758
}
1773-
1774-
return svg;
1759+
PGraphics.showWarning("Unsupported format: " + filename);
1760+
return null;
17751761
}
17761762

17771763

core/src/processing/opengl/PGraphics2D.java

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,11 @@
2222

2323
package processing.opengl;
2424

25-
import java.io.InputStream;
26-
import java.util.zip.GZIPInputStream;
27-
28-
import processing.core.PApplet;
2925
import processing.core.PGraphics;
3026
import processing.core.PMatrix3D;
3127
import processing.core.PShape;
3228
import processing.core.PShapeSVG;
33-
import processing.data.XML;
29+
3430

3531
public class PGraphics2D extends PGraphicsOpenGL {
3632

@@ -232,6 +228,7 @@ public void shape(PShape shape, float x, float y, float z,
232228
}
233229

234230

231+
235232
//////////////////////////////////////////////////////////////
236233

237234
// SHAPE I/O
@@ -242,33 +239,17 @@ static protected boolean isSupportedExtension(String extension) {
242239
}
243240

244241

245-
static protected PShape loadShapeImpl(PGraphics pg, String filename,
246-
String extension) {
247-
PShapeSVG svg = null;
248-
249-
if (extension.equals("svg")) {
250-
svg = new PShapeSVG(pg.parent.loadXML(filename));
251-
252-
} else if (extension.equals("svgz")) {
253-
try {
254-
InputStream input =
255-
new GZIPInputStream(pg.parent.createInput(filename));
256-
XML xml = new XML(PApplet.createReader(input));
257-
svg = new PShapeSVG(xml);
258-
} catch (Exception e) {
259-
e.printStackTrace();
260-
}
261-
}
262-
263-
if (svg != null) {
264-
PShapeOpenGL p2d = PShapeOpenGL.createShape2D((PGraphicsOpenGL)pg, svg);
265-
return p2d;
266-
} else {
267-
return null;
242+
static protected PShape loadShapeImpl(PGraphics pg,
243+
String filename, String extension) {
244+
if (extension.equals("svg") || extension.equals("svgz")) {
245+
PShapeSVG svg = new PShapeSVG(pg.parent.loadXML(filename));
246+
return PShapeOpenGL.createShape2D((PGraphicsOpenGL) pg, svg);
268247
}
248+
return null;
269249
}
270250

271251

252+
272253
//////////////////////////////////////////////////////////////
273254

274255
// SHAPE CREATION

core/src/processing/opengl/PGraphics3D.java

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ protected void end2D() {
110110
}
111111

112112

113+
113114
//////////////////////////////////////////////////////////////
114115

115116
// SHAPE I/O
@@ -126,32 +127,17 @@ static protected PShape loadShapeImpl(PGraphics pg, String filename,
126127

127128
if (extension.equals("obj")) {
128129
obj = new PShapeOBJ(pg.parent, filename);
129-
130-
} else if (extension.equals("objz")) {
131-
try {
132-
// TODO: The obj file can be read from the gzip, but if it refers to
133-
// a materials file and texture images, those must be contained in the
134-
// data folder, cannot be inside the gzip.
135-
InputStream input =
136-
new GZIPInputStream(pg.parent.createInput(filename));
137-
obj = new PShapeOBJ(pg.parent, PApplet.createReader(input));
138-
} catch (Exception e) {
139-
e.printStackTrace();
140-
}
141-
}
142-
143-
if (obj != null) {
144130
int prevTextureMode = pg.textureMode;
145131
pg.textureMode = NORMAL;
146132
PShapeOpenGL p3d = PShapeOpenGL.createShape3D((PGraphicsOpenGL)pg, obj);
147133
pg.textureMode = prevTextureMode;
148134
return p3d;
149-
} else {
150-
return null;
151135
}
136+
return null;
152137
}
153138

154139

140+
155141
//////////////////////////////////////////////////////////////
156142

157143
// SHAPE CREATION

0 commit comments

Comments
 (0)