/** * Get a particular element based on its SVG ID. When editing SVG by hand, * this is the id="" tag on any SVG element. When editing from Illustrator, * these IDs can be edited by expanding the layers palette. The names used * in the layers palette, both for the layers or the shapes and groups * beneath them can be used here. * <PRE> * // This code grabs "Layer 3" and the shapes beneath it. * PShape layer3 = svg.getChild("Layer 3"); * </PRE> */ @Override public PShape getChild(String name) { PShape found = super.getChild(name); if (found == null) { // Otherwise try with underscores instead of spaces // (this is how Illustrator handles spaces in the layer names). found = super.getChild(name.replace(' ', '_')); } // Set bounding box based on the parent bounding box if (found != null) { // found.x = this.x; // found.y = this.y; found.width = this.width; found.height = this.height; } return found; }
static public void copyGroup(PGraphicsOpenGL pg, PShape src, PShape dest) { copyMatrix(src, dest); copyStyles(src, dest); copyImage(src, dest); for (int i = 0; i < src.getChildCount(); i++) { PShape c = createShape(pg, src.getChild(i)); dest.addChild(c); } }
static public void copyGroup(PGraphicsOpenGL pg, PShape src, PShape dest) { copyMatrix(src, dest); copyStyles(src, dest); copyImage(src, dest); for (int i = 0; i < src.getChildCount(); i++) { PShape c = createShape(pg, src.getChild(i)); dest.addChild(c); } }
/** * Get a particular element based on its SVG ID. When editing SVG by hand, * this is the id="" tag on any SVG element. When editing from Illustrator, * these IDs can be edited by expanding the layers palette. The names used * in the layers palette, both for the layers or the shapes and groups * beneath them can be used here. * <PRE> * // This code grabs "Layer 3" and the shapes beneath it. * PShape layer3 = svg.getChild("Layer 3"); * </PRE> */ @Override public PShape getChild(String name) { PShape found = super.getChild(name); if (found == null) { // Otherwise try with underscores instead of spaces // (this is how Illustrator handles spaces in the layer names). found = super.getChild(name.replace(' ', '_')); } // Set bounding box based on the parent bounding box if (found != null) { // found.x = this.x; // found.y = this.y; found.width = this.width; found.height = this.height; } return found; }
PShape line = plot.getChild(i);
/** * @param target the name of the shape to get */ public PShape getChild(String target) { if (name != null && name.equals(target)) { return this; } if (nameTable != null) { PShape found = nameTable.get(target); if (found != null) return found; } for (int i = 0; i < childCount; i++) { PShape found = children[i].getChild(target); if (found != null) return found; } return null; }
PShape line = plot.getChild(i);
/** * @param target the name of the shape to get */ public PShape getChild(String target) { if (name != null && name.equals(target)) { return this; } if (nameTable != null) { PShape found = nameTable.get(target); if (found != null) return found; } for (int i = 0; i < childCount; i++) { PShape found = children[i].getChild(target); if (found != null) return found; } return null; }
PShape line = plot.getChild(i);
/** * Same as getChild(name), except that it first walks all the way up the * hierarchy to the eldest grandparent, so that children can be found anywhere. */ public PShape findChild(String target) { if (parent == null) { return getChild(target); } else { return parent.findChild(target); } }
/** * Same as getChild(name), except that it first walks all the way up the * hierarchy to the eldest grandparent, so that children can be found anywhere. */ public PShape findChild(String target) { if (parent == null) { return getChild(target); } else { return parent.findChild(target); } }
size(1200, 480,OPENGL);//the catch is, even though we use PMatrix2D, PShape's applyMatrix() only seems to work with the P3D or OpenGL renderer PShape usa = loadShape("usa-wikipedia.svg"); ohio = (PShape)usa.getChild("OH");