Package geomerative
Class RGroup
- java.lang.Object
-
- geomerative.RGeomElem
-
- geomerative.RGroup
-
public class RGroup extends RGeomElem
RGroup is a holder for a group of geometric elements that can be drawn and transformed, such as shapes, polygons or meshes.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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 elements in the current group.RPolygon
toPolygon()
RGroup
toPolygonGroup()
Use this method to get a new group whose elements are the corresponding polygons of the elements 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 elements 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
-
-
-
-
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 classRGeomElem
- 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.
-
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.
-
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 elements 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 elements in the current group. At this moment there is no implementation for transforming a mesh 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 elements 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
-
toPolygon
public RPolygon toPolygon() throws java.lang.RuntimeException
-
toShape
public RShape toShape() throws java.lang.RuntimeException
-
getHandles
public RPoint[] getHandles()
Use this to return the points of the group. It returns the points as an array of RPoint.- Specified by:
getHandles
in classRGeomElem
- Returns:
- RPoint[], the points returned in an array.
-
getPoints
public RPoint[] getPoints()
Use this to return the points of the group. It returns the points as an array of RPoint.
-
getTangent
public RPoint getTangent(float t)
- Specified by:
getTangent
in classRGeomElem
-
getTangents
public RPoint[] getTangents()
Use this to return the points of the group. It returns the points as an array of RPoint.- Specified by:
getTangents
in classRGeomElem
- 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 as an array of arrays of RPoint.- Specified by:
getPointsInPaths
in classRGeomElem
- Returns:
- RPoint[], the points returned in an array.
-
getHandlesInPaths
public RPoint[][] getHandlesInPaths()
- Specified by:
getHandlesInPaths
in classRGeomElem
-
getTangentsInPaths
public RPoint[][] getTangentsInPaths()
- Specified by:
getTangentsInPaths
in classRGeomElem
-
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.
-
getType
public int getType()
Use this method to get the type of element this is.
-
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()
-
-