geomerative
Class RGroup

java.lang.Object
  extended by geomerative.RGeomElem
      extended by geomerative.RGroup

public class RGroup
extends RGeomElem

RGroup is a holder for a group of geometric element that can be drawn and transformed, such as Shapes, Polygons or Meshes.


Field Summary
 RGeomElem[] elements
          Array of RGeomElem objects holding the elements of the group.
 int type
           
 
Fields inherited from class geomerative.RGeomElem
COMMAND, CONTOUR, GROUP, height, MESH, name, POLYGON, SHAPE, SUBSHAPE, TRISTRIP, UNKNOWN, width
 
Constructor Summary
RGroup()
          Use this method to create a new empty group.
RGroup(RGroup grp)
          Use this method to create a copy of a group.
 
Method Summary
 void adapt(RGroup grp)
           
 void adapt(RGroup grp, float wght, float lngthOffset)
          Use this method to adapt a group of of figures to a group.
 void adapt(RShape shp)
           
 void adapt(RShape shp, float wght, float lngthOffset)
           
 void addElement(RGeomElem elem)
          Use this method to add a new element.
 void addGroup(RGroup grupo)
          Use this method to add a new element.
 boolean contains(RPoint p)
          Use this to return a specific tangent on the curve.
 int countElements()
          Use this method to count the number of elements in the group.
 void draw(processing.core.PApplet a)
           
 void draw(processing.core.PGraphics g)
          Use this method to draw the group.
 RPoint getCentroid()
          Use this method to get the centroid of the element.
 RPoint[] getHandles()
          Use this to return the points of the group.
 RPoint[][] getHandlesInPaths()
           
 RPoint getPoint(float t)
           
 RPoint[] getPoints()
          Use this to return the points of the group.
 RPoint[][] getPointsInPaths()
          Use this to return the points of each path of the group.
 RPoint getTangent(float t)
           
 RPoint[] getTangents()
          Use this to return the points of the group.
 RPoint[][] getTangentsInPaths()
           
 int getType()
          Use this method to get the type of element this is.
 void insertHandleInPaths(float t)
          Use this to insert a split point into each command of the group.
 void polygonize()
           
 void print()
           
 void removeElement(int i)
          Use this method to remove an element.
 RGroup[] split(float t)
           
 RGroup[] splitPaths(float t)
           
 RMesh toMesh()
           
 RGroup toMeshGroup()
          Use this method to get a new group whose elements are the corresponding Meshes of the elemnts in the current group.
 RPolygon toPolygon()
           
 RGroup toPolygonGroup()
          Use this method to get a new group whose elements are the corresponding Polygons of the elemnts in the current group.
 RShape toShape()
           
 RGroup toShapeGroup()
          Use this method to get a new group whose elements are all the corresponding Shapes of the elemnts in the current group.
 
Methods inherited from class geomerative.RGeomElem
centerIn, centerIn, centerIn, contains, contains, containsBounds, containsHandles, draw, getArea, getBottomLeft, getBottomRight, getBounds, getBoundsPoints, getCenter, getCenteringTransf, getCenteringTransf, getCenteringTransf, getCurveLength, getCurveLengths, getHeight, getOrigHeight, getOrigWidth, getStyle, getTopLeft, getTopRight, getWidth, getX, getY, intersects, intersects, intersectsBounds, intersectsHandles, isIn, isIn, rotate, rotate, rotate, scale, scale, scale, scale, scale, scale, setAlpha, setAlpha, setAlpha, setFill, setFill, setFill, setFillAlpha, setFillAlpha, setName, setStroke, setStroke, setStroke, setStrokeAlpha, setStrokeAlpha, setStrokeCap, setStrokeJoin, setStrokeWeight, setStrokeWeight, setStyle, shear, skewX, skewY, transform, transform, transform, translate, translate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

public int type

elements

public RGeomElem[] elements
Array of RGeomElem objects holding the elements of the group. When accessing theses elements we must cast them to their class in order to get all the functionalities of each representation. e.g. RShape s = group.elements[i].toShape() If the element cannot be converted to the target class it will throw a RuntimeException, to ignore these, use try-catch syntax.

Constructor Detail

RGroup

public RGroup()
Use this method to create a new empty group.


RGroup

public RGroup(RGroup grp)
Use this method to create a copy of a group.

Method Detail

getCentroid

public RPoint getCentroid()
Use this method to get the centroid of the element.

Overrides:
getCentroid in class RGeomElem
Returns:
RPoint, the centroid point of the element

countElements

public int countElements()
Use this method to count the number of elements in the group.

Returns:
int, the number elements in the group.

print

public void print()
Overrides:
print in class RGeomElem

draw

public void draw(processing.core.PGraphics g)
Use this method to draw the group. This will draw each element at a time, without worrying about intersections or holes. This is the main difference between having a shape with multiple paths and having a group with multiple shapes.

Specified by:
draw in class RGeomElem
Parameters:
g - PGraphics, the graphics object on which to draw the group

draw

public void draw(processing.core.PApplet a)
Specified by:
draw in class RGeomElem

addElement

public void addElement(RGeomElem elem)
Use this method to add a new element.

Parameters:
elem - RGeomElem, any kind of RGeomElem to add. It accepts the classes RShape, RPolygon and RMesh.

addGroup

public void addGroup(RGroup grupo)
Use this method to add a new element.

Parameters:
grupo - RGroup, A group of elements to add to this group.

removeElement

public void removeElement(int i)
                   throws java.lang.RuntimeException
Use this method to remove an element.

Parameters:
i - int, the index of the element to remove from the group.
Throws:
java.lang.RuntimeException

toMeshGroup

public RGroup toMeshGroup()
                   throws java.lang.RuntimeException
Use this method to get a new group whose elements are the corresponding Meshes of the elemnts in the current group. This can be used for increasing performance in exchange of losing abstraction.

Returns:
RGroup, the new group made of RMeshes
Throws:
java.lang.RuntimeException

toPolygonGroup

public RGroup toPolygonGroup()
                      throws java.lang.RuntimeException
Use this method to get a new group whose elements are the corresponding Polygons of the elemnts in the current group. At this moment there is no implementation for transforming aMesh to a Polygon so applying this method to groups holding Mesh elements will generate an exception.

Returns:
RGroup, the new group made of RPolygons
Throws:
java.lang.RuntimeException

toShapeGroup

public RGroup toShapeGroup()
                    throws java.lang.RuntimeException
Use this method to get a new group whose elements are all the corresponding Shapes of the elemnts in the current group. At this moment there is no implementation for transforming a Mesh or a Polygon to a Shape so applying this method to groups holding Mesh or Polygon elements will generate an exception.

Returns:
RGroup, the new group made of RShapes
Throws:
java.lang.RuntimeException

toMesh

public RMesh toMesh()
             throws java.lang.RuntimeException
Overrides:
toMesh in class RGeomElem
Throws:
java.lang.RuntimeException

toPolygon

public RPolygon toPolygon()
                   throws java.lang.RuntimeException
Overrides:
toPolygon in class RGeomElem
Throws:
java.lang.RuntimeException

toShape

public RShape toShape()
               throws java.lang.RuntimeException
Specified by:
toShape in class RGeomElem
Throws:
java.lang.RuntimeException

getHandles

public RPoint[] getHandles()
Use this to return the points of the group. It returns the points in the way of an array of RPoint.

Specified by:
getHandles in class RGeomElem
Returns:
RPoint[], the points returned in an array.

getPoint

public RPoint getPoint(float t)
Specified by:
getPoint in class RGeomElem

getPoints

public RPoint[] getPoints()
Use this to return the points of the group. It returns the points in the way of an array of RPoint.

Specified by:
getPoints in class RGeomElem
Returns:
RPoint[], the points returned in an array.

getTangent

public RPoint getTangent(float t)
Specified by:
getTangent in class RGeomElem

getTangents

public RPoint[] getTangents()
Use this to return the points of the group. It returns the points in the way of an array of RPoint.

Specified by:
getTangents in class RGeomElem
Returns:
RPoint[], the points returned in an array.

getPointsInPaths

public RPoint[][] getPointsInPaths()
Use this to return the points of each path of the group. It returns the points in the way of an array of array of RPoint.

Specified by:
getPointsInPaths in class RGeomElem
Returns:
RPoint[], the points returned in an array.

getHandlesInPaths

public RPoint[][] getHandlesInPaths()
Specified by:
getHandlesInPaths in class RGeomElem

getTangentsInPaths

public RPoint[][] getTangentsInPaths()
Specified by:
getTangentsInPaths in class RGeomElem

contains

public boolean contains(RPoint p)
Use this to return a specific tangent on the curve. It returns true if the point passed as a parameter is inside the group.

Specified by:
contains in class RGeomElem
Parameters:
p - the point for which to test containement..
Returns:
boolean, true if the point is in the path.

getType

public int getType()
Use this method to get the type of element this is.

Specified by:
getType in class RGeomElem
Returns:
int, will allways return RGeomElem.POLYGON

split

public RGroup[] split(float t)

splitPaths

public RGroup[] splitPaths(float t)

insertHandleInPaths

public void insertHandleInPaths(float t)
Use this to insert a split point into each command of the group.

Parameters:
t - float, the parameter of advancement on the curve. t must have values between 0 and 1.

adapt

public void adapt(RGroup grp,
                  float wght,
                  float lngthOffset)
           throws java.lang.RuntimeException
Use this method to adapt a group of of figures to a group.

Parameters:
grp - the path to which to adapt
Throws:
java.lang.RuntimeException

adapt

public void adapt(RGroup grp)
           throws java.lang.RuntimeException
Throws:
java.lang.RuntimeException

adapt

public void adapt(RShape shp)

adapt

public void adapt(RShape shp,
                  float wght,
                  float lngthOffset)

polygonize

public void polygonize()


Geomerative by Ricard Marxer, http://www.ricardmarxer.com/geomerative/