Skip to content

Commit 6d17ef9

Browse files
committed
dealing with PStyle changes
1 parent 4834698 commit 6d17ef9

File tree

7 files changed

+127
-81
lines changed

7 files changed

+127
-81
lines changed

candy/src/processing/candy/BaseObject.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public class BaseObject extends PShape {
2121
String fillName; // id of another object
2222

2323

24-
2524
public BaseObject(BaseObject parent, XMLElement properties) {
2625
//super(GROUP);
2726

@@ -482,26 +481,6 @@ protected void styles(PGraphics g) {
482481
}
483482

484483

485-
/**
486-
* Overrides SVG-set styles and uses PGraphics styles and colors.
487-
* Identical to ignoreStyles(true).
488-
*/
489-
public void ignoreStyles() {
490-
//ignoreStyles(true);
491-
styles = false;
492-
}
493-
494-
495-
/**
496-
* Enables or disables style information (fill and stroke) set in the file.
497-
* @param state true to use user-specified stroke/fill, false for svg version
498-
*/
499-
public void ignoreStyles(boolean state) {
500-
//ignoreStyles = state;
501-
styles = !state;
502-
}
503-
504-
505484
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
506485

507486

core/src/processing/core/PApplet.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6767,6 +6767,12 @@ public void endShape(int mode) {
67676767
}
67686768

67696769

6770+
public void style(PStyle s) {
6771+
if (recorder != null) recorder.style(s);
6772+
g.style(s);
6773+
}
6774+
6775+
67706776
public void point(float x, float y) {
67716777
if (recorder != null) recorder.point(x, y);
67726778
g.point(x, y);
@@ -7338,6 +7344,18 @@ public float modelZ(float x, float y, float z) {
73387344
}
73397345

73407346

7347+
public void pushStyle() {
7348+
if (recorder != null) recorder.pushStyle();
7349+
g.pushStyle();
7350+
}
7351+
7352+
7353+
public void popStyle() {
7354+
if (recorder != null) recorder.popStyle();
7355+
g.popStyle();
7356+
}
7357+
7358+
73417359
public void colorMode(int mode) {
73427360
if (recorder != null) recorder.colorMode(mode);
73437361
g.colorMode(mode);

core/src/processing/core/PGraphics.java

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ public class PGraphics extends PImage implements PConstants {
335335
// Style stack
336336

337337
static final int STYLE_STACK_DEPTH = 64;
338-
Style[] styleStack = new Style[STYLE_STACK_DEPTH];
338+
PStyle[] styleStack = new PStyle[STYLE_STACK_DEPTH];
339339
int styleStackDepth;
340340

341341

@@ -1141,7 +1141,7 @@ public void endShape(int mode) {
11411141
// STYLE
11421142

11431143

1144-
public void style(Style s) {
1144+
public void style(PStyle s) {
11451145
if (s.smooth) {
11461146
smooth();
11471147
} else {
@@ -3268,53 +3268,14 @@ public float modelZ(float x, float y, float z) {
32683268
// STYLE
32693269

32703270

3271-
protected class Style {
3272-
public boolean smooth;
3273-
3274-
public int imageMode;
3275-
public int rectMode;
3276-
public int ellipseMode;
3277-
public int shapeMode;
3278-
3279-
public int colorMode;
3280-
public float colorModeX;
3281-
public float colorModeY;
3282-
public float colorModeZ;
3283-
public float colorModeA;
3284-
3285-
public boolean tint;
3286-
public int tintColor;
3287-
public boolean fill;
3288-
public int fillColor;
3289-
public boolean stroke;
3290-
public int strokeColor;
3291-
public float strokeWeight;
3292-
public int strokeCap;
3293-
public int strokeJoin;
3294-
3295-
// TODO these fellas are inconsistent, and may need to go elsewhere
3296-
public float ambientR, ambientG, ambientB;
3297-
public float specularR, specularG, specularB;
3298-
public float emissiveR, emissiveG, emissiveB;
3299-
public float shininess;
3300-
3301-
public PFont textFont;
3302-
public int textAlign;
3303-
public int textAlignY;
3304-
public int textMode;
3305-
public float textSize;
3306-
public float textLeading;
3307-
}
3308-
3309-
33103271
public void pushStyle() {
33113272
if (styleStackDepth == styleStack.length) {
3312-
styleStack = (Style[]) PApplet.expand(styleStack);
3273+
styleStack = (PStyle[]) PApplet.expand(styleStack);
33133274
}
33143275
if (styleStack[styleStackDepth] == null) {
3315-
styleStack[styleStackDepth] = new Style();
3276+
styleStack[styleStackDepth] = new PStyle();
33163277
}
3317-
Style s = styleStack[styleStackDepth++];
3278+
PStyle s = styleStack[styleStackDepth++];
33183279
getStyle(s);
33193280
}
33203281

@@ -3328,14 +3289,14 @@ public void popStyle() {
33283289
}
33293290

33303291

3331-
public Style getStyle() {
3332-
Style s = new Style();
3292+
public PStyle getStyle() { // ignore
3293+
PStyle s = new PStyle();
33333294
getStyle(s);
33343295
return s;
33353296
}
33363297

33373298

3338-
public void getStyle(Style s) {
3299+
public void getStyle(PStyle s) { // ignore
33393300
s.smooth = smooth;
33403301

33413302
s.imageMode = imageMode;

core/src/processing/core/PImage.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,17 +247,17 @@ public void imageMode(int mode) {
247247
// MARKING IMAGE AS MODIFIED / FOR USE w/ GET/SET
248248

249249

250-
public boolean isModified() {
250+
public boolean isModified() { // ignore
251251
return modified;
252252
}
253253

254254

255-
public void setModified() {
255+
public void setModified() { // ignore
256256
modified = true;
257257
}
258258

259259

260-
public void setModified(boolean m) {
260+
public void setModified(boolean m) { // ignore
261261
modified = m;
262262
}
263263

core/src/processing/core/PShape.java

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ abstract public class PShape implements PConstants {
5858
protected boolean fill;
5959
protected int fillColor;
6060

61-
protected boolean styles = true;
61+
protected boolean style = true;
6262

6363
//public boolean hasTransform;
6464
//protected float[] transformation;
@@ -139,6 +139,23 @@ public void setVisible(boolean visible) {
139139
}
140140

141141

142+
/**
143+
* Overrides SVG-set styles and uses PGraphics styles and colors.
144+
* Identical to ignoreStyles(true).
145+
*/
146+
public void disableStyle() {
147+
style = false;
148+
}
149+
150+
151+
/**
152+
* Enabless style information (fill and stroke) set in the shape.
153+
*/
154+
public void enableStyle() {
155+
style = true;
156+
}
157+
158+
142159
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
143160

144161

@@ -209,7 +226,7 @@ protected void pre(PGraphics g) {
209226
ellipseModeSaved = g.ellipseMode;
210227
shapeModeSaved = g.shapeMode;
211228

212-
if (styles) {
229+
if (style) {
213230
styles(g);
214231
}
215232
}
@@ -327,26 +344,35 @@ public PShape findChild(String name) {
327344
}
328345

329346

330-
// can't be 'add' because that suggests additive geometry
347+
// can't be just 'add' because that suggests additive geometry
331348
public void addChild(PShape who) {
332349
if (children == null) {
333-
children = new PShape[2];
350+
children = new PShape[1];
334351
}
335352
if (childCount == children.length) {
336353
children = (PShape[]) PApplet.expand(children);
337354
}
338355
children[childCount++] = who;
339356
who.parent = this;
340357

341-
/*
342-
String childName = who.getName();
343-
if (childName != null) {
358+
if (who.getName() != null) {
359+
addName(who.getName(), who);
360+
}
361+
}
362+
363+
364+
/**
365+
* Add a shape to the name lookup table.
366+
*/
367+
protected void addName(String nom, PShape shape) {
368+
if (parent != null) {
369+
parent.addName(nom, shape);
370+
} else {
344371
if (table == null) {
345372
table = new HashMap<String,PShape>();
346373
}
347-
table.put(childName, who);
374+
table.put(nom, shape);
348375
}
349-
*/
350376
}
351377

352378

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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) 2008 Ben Fry and Casey Reas
7+
8+
This library is free software; you can redistribute it and/or
9+
modify it under the terms of the GNU Lesser General Public
10+
License as published by the Free Software Foundation; either
11+
version 2.1 of the License, or (at your option) any later version.
12+
13+
This library is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
Lesser General Public License for more details.
17+
18+
You should have received a copy of the GNU Lesser General
19+
Public License along with this library; if not, write to the
20+
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21+
Boston, MA 02111-1307 USA
22+
*/
23+
24+
package processing.core;
25+
26+
27+
public class PStyle {
28+
public boolean smooth;
29+
30+
public int imageMode;
31+
public int rectMode;
32+
public int ellipseMode;
33+
public int shapeMode;
34+
35+
public int colorMode;
36+
public float colorModeX;
37+
public float colorModeY;
38+
public float colorModeZ;
39+
public float colorModeA;
40+
41+
public boolean tint;
42+
public int tintColor;
43+
public boolean fill;
44+
public int fillColor;
45+
public boolean stroke;
46+
public int strokeColor;
47+
public float strokeWeight;
48+
public int strokeCap;
49+
public int strokeJoin;
50+
51+
// TODO these fellas are inconsistent, and may need to go elsewhere
52+
public float ambientR, ambientG, ambientB;
53+
public float specularR, specularG, specularB;
54+
public float emissiveR, emissiveG, emissiveB;
55+
public float shininess;
56+
57+
public PFont textFont;
58+
public int textAlign;
59+
public int textAlignY;
60+
public int textMode;
61+
public float textSize;
62+
public float textLeading;
63+
}

todo.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ X video capture problems with opengl
9090
X http://dev.processing.org/bugs/show_bug.cgi?id=882
9191

9292

93-
9493
_ sketch must be saved to use a constructor
9594
_ http://dev.processing.org/bugs/show_bug.cgi?id=929
9695

0 commit comments

Comments
 (0)