org.mt4j.components.visibleComponents.shapes
Class MTRectangle

java.lang.Object
  extended by org.mt4j.components.MTComponent
      extended by org.mt4j.components.visibleComponents.AbstractVisibleComponent
          extended by org.mt4j.components.visibleComponents.shapes.AbstractShape
              extended by org.mt4j.components.visibleComponents.shapes.MTCSSStylableShape
                  extended by org.mt4j.components.visibleComponents.shapes.MTPolygon
                      extended by org.mt4j.components.visibleComponents.shapes.MTRectangle
All Implemented Interfaces:
CSSStylableComponent, IMTComponent, IMTComponent3D, IMTInputEventListener, ILassoable, IGestureEventListener
Direct Known Subclasses:
AngelCodeFontCharacter, MTClipRectangle, MTColorPicker, MTImageButton, MTSlider, MTTextArea

public class MTRectangle
extends MTPolygon

    

A simple rectangular shape.

Author:
Christopher Ruff

Nested Class Summary
static class MTRectangle.PositionAnchor
          The Enum PositionAnchor.
 
Field Summary
 
Fields inherited from class org.mt4j.components.visibleComponents.shapes.AbstractShape
BOUNDS_CHECK_THEN_GEOMETRY_CHECK, BOUNDS_DONT_USE, BOUNDS_ONLY_CHECK, createDefaultGestures
 
Constructor Summary
MTRectangle(float x, float y, float z, float width, float height, processing.core.PApplet pApplet)
          Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.
MTRectangle(float x, float y, float width, float height, processing.core.PApplet pApplet)
          Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.
MTRectangle(float width, float height, processing.core.PApplet pApplet)
          Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.
MTRectangle(processing.core.PApplet pApplet, float width, float height)
          Instantiates a new mT rectangle with the upper left corner at 0,0,0
MTRectangle(processing.core.PApplet pApplet, float x, float y, float width, float height)
          Instantiates a new mT rectangle.
MTRectangle(processing.core.PApplet pApplet, float x, float y, float z, float width, float height)
          Instantiates a new mT rectangle.
MTRectangle(processing.core.PApplet applet, processing.core.PImage texture)
          Instantiates a new mT rectangle.
MTRectangle(processing.core.PApplet pApplet, Vertex upperLeft, float width, float height)
          Instantiates a new mT rectangle.
MTRectangle(processing.core.PApplet pApplet, Vertex upperLeft, float width, float height, int textureMaxX, int textureMaxY)
           
MTRectangle(processing.core.PImage texture, processing.core.PApplet applet)
          Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.
MTRectangle(Vertex upperLeft, float width, float height, processing.core.PApplet pApplet)
          Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.
 
Method Summary
 double get2DPolygonArea()
          Calculates the area of a 2D polygon using its transformed world coordinates
NOTE: works only if the last vertex is equal to the first (polygon is closed correctly).
 MTRectangle.PositionAnchor getAnchor()
          Gets the Position anchor.
 Vector3D getCenterOfMass2DLocal()
          Calculates the center of mass of the polygon.
 Vector3D getCenterPointLocal()
          Gets the center point in local object space.
 Vector3D getPosition(TransformSpace transformSpace)
          Gets the position.
 void setAnchor(MTRectangle.PositionAnchor anchor)
          Sets the anchor.
 void setHeightLocal(float height)
          Sets the height locally, meaning that not the transformation of the rectangle is changed, (as setSize/setWidth, scale etc. would do) but the vertices of the rectangle themselves.
 void setPositionGlobal(Vector3D position)
          Sets the global position of the component.
 void setPositionRelativeToParent(Vector3D position)
          Sets the position of the component, relative to its parent coordinate frame.
 void setSizeLocal(float width, float height)
          Sets the size locally, meaning that not the transformation of the rectangle is changed, (as setSize/setWidth, scale etc. would do) but the vertices of the rectangle themselves.
 void setTexture(processing.core.PImage newTexImage)
          Sets a texture for this shape.
 void setUseDirectGL(boolean drawPureGL)
          If set to true - which is the default if using the OpenGL render mode - this shape will bypass processings rendering pipeline and use the OpenGL context directly for performance increases.
 void setWidthLocal(float width)
          Sets the width locally, meaning that not the transformation of the rectangle is changed, (as setSize/setWidth, scale etc. would do) but the vertices of the rectangle themselves.
 
Methods inherited from class org.mt4j.components.visibleComponents.shapes.MTPolygon
drawComponent, getGeometryIntersectionLocal, getNormal, isGeometryContainsPointLocal, setGeometryInfo, setHeightXYGlobal, setHeightXYRelativeToParent, setSizeXYGlobal, setSizeXYRelativeToParent, setVertices, setWidthXYGlobal, setWidthXYRelativeToParent
 
Methods inherited from class org.mt4j.components.visibleComponents.shapes.MTCSSStylableShape
applyStyleSheet, disableCSS, enableCSS, getCssHelper, isCssForceDisabled, isCSSStyled, setCssForceDisable
 
Methods inherited from class org.mt4j.components.visibleComponents.shapes.AbstractShape
destroy, disableAndDeleteDisplayLists, generateAndUseDisplayLists, generateDisplayLists, getCenterPointGlobal, getCenterPointRelativeToParent, getGeometryInfo, getHeightXY, getHeightXYVectLocal, getIntersectionLocal, getTexture, getTextureMode, getVertexCount, getVerticesGlobal, getVerticesLocal, getWidthXY, getWidthXYVectLocal, isBoundsAutoCompute, isSelected, isTextureEnabled, isUseDirectGL, isUseDisplayList, isUseVBOs, setBoundsAutoCompute, setBoundsBehaviour, setFillColor, setMatricesDirty, setPositionRelativeToOther, setSelected, setStrokeColor, setTextureEnabled, setTextureMode, setUseDisplayList, setUseVBOs, tweenTranslate, tweenTranslate, tweenTranslate, tweenTranslateTo, tweenTranslateTo
 
Methods inherited from class org.mt4j.components.visibleComponents.AbstractVisibleComponent
getFillColor, getFillDrawMode, getFillPaint, getLineStipple, getMaterial, getStrokeColor, getStrokeWeight, getStyleInfo, isDrawSmooth, isNoFill, isNoStroke, postDraw, postDrawChildren, preDraw, setDrawSmooth, setFillDrawMode, setFillPaint, setLineStipple, setMaterial, setNoFill, setNoStroke, setStrokeWeight, setStyleInfo
 
Methods inherited from class org.mt4j.components.MTComponent
addChild, addChild, addChildren, addGestureListener, addInputListener, addStateChangeListener, attachCamera, containsChild, containsDirectChild, containsPointGlobal, getAttachedCamera, getBoundingShape, getBounds, getChildbyID, getChildByIndex, getChildByName, getChildClip, getChildCount, getChildIndexOf, getChildren, getClip, getController, getCSSID, getGestureListeners, getGlobalInverseMatrix, getGlobalMatrix, getGlobalVecToParentRelativeSpace, getID, getInputListeners, getInputProcessors, getIntersectionGlobal, getIntersectionGlobal, getLight, getLocalInverseMatrix, getLocalMatrix, getLocalVecToParentRelativeSpace, getName, getParent, getRenderer, getRoot, getStateChangeListeners, getTransformToDestinationLocalSpace, getTransformToDestinationParentSpace, getUserData, getViewingCamera, globalToLocal, globalToLocal, hasBounds, isBoundingShapeSet, isComposite, isContainedIn, isDepthBufferDisabled, isEnabled, isGestureAllowed, isPickable, isVisible, localToGlobal, localToParent, parentToLocal, pick, pick, processGestureEvent, processInputEvent, registerInputProcessor, removeAllChildren, removeAllGestureEventListeners, removeAllGestureEventListeners, removeChild, removeChild, removeFromParent, removeGestureEventListener, removeInputListener, removeStateChangeListener, reOrthogonalize, rotateX, rotateX, rotateXGlobal, rotateY, rotateY, rotateYGlobal, rotateZ, rotateZ, rotateZGlobal, scale, scale, scaleGlobal, sendToFront, setBoundingShape, setBounds, setChildClip, setClip, setComposite, setController, setCSSID, setDepthBufferDisabled, setEnabled, setGestureAllowance, setLight, setLocalMatrix, setName, setPickable, setUserData, setVisible, toString, transform, translate, translate, translateGlobal, unregisterAllInputProcessors, unregisterInputProcessor, updateComponent
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.mt4j.components.interfaces.IMTComponent3D
getIntersectionGlobal, getViewingCamera, isPickable, rotateXGlobal, rotateYGlobal, setPickable
 
Methods inherited from interface org.mt4j.components.interfaces.IMTComponent
containsPointGlobal, getID, getName, getRenderer, getRoot, isEnabled, isGestureAllowed, isVisible, processInputEvent, rotateZGlobal, scaleGlobal, setEnabled, setName, setVisible, translateGlobal, updateComponent
 

Constructor Detail

MTRectangle

public MTRectangle(processing.core.PImage texture,
                   processing.core.PApplet applet)
Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.

Instantiates a new mT rectangle.

Parameters:
texture - the texture
applet - the applet

MTRectangle

public MTRectangle(processing.core.PApplet applet,
                   processing.core.PImage texture)
Instantiates a new mT rectangle.

Parameters:
applet - the applet
texture - the texture

MTRectangle

public MTRectangle(float width,
                   float height,
                   processing.core.PApplet pApplet)
Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.

Instantiates a new mT rectangle.

Parameters:
width - the width
height - the height
pApplet - the applet

MTRectangle

public MTRectangle(processing.core.PApplet pApplet,
                   float width,
                   float height)
Instantiates a new mT rectangle with the upper left corner at 0,0,0

Parameters:
pApplet - the applet
width - the width
height - the height

MTRectangle

public MTRectangle(float x,
                   float y,
                   float width,
                   float height,
                   processing.core.PApplet pApplet)
Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.

Instantiates a new mT rectangle.

Parameters:
x - the x
y - the y
width - the width
height - the height
pApplet - the applet

MTRectangle

public MTRectangle(processing.core.PApplet pApplet,
                   float x,
                   float y,
                   float width,
                   float height)
Instantiates a new mT rectangle.

Parameters:
pApplet - the applet
x - the x
y - the y
width - the width
height - the height

MTRectangle

public MTRectangle(float x,
                   float y,
                   float z,
                   float width,
                   float height,
                   processing.core.PApplet pApplet)
Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.

Instantiates a new mT rectangle.

Parameters:
x - the x
y - the y
z - the z
width - the width
height - the height
pApplet - the applet

MTRectangle

public MTRectangle(processing.core.PApplet pApplet,
                   float x,
                   float y,
                   float z,
                   float width,
                   float height)
Instantiates a new mT rectangle.

Parameters:
pApplet - the applet
x - the x
y - the y
z - the z
width - the width
height - the height

MTRectangle

public MTRectangle(Vertex upperLeft,
                   float width,
                   float height,
                   processing.core.PApplet pApplet)
Deprecated. constructor will be deleted! Please , use the constructor with the PApplet instance as the first parameter.

Instantiates a new mT rectangle.

Parameters:
upperLeft - the upper left
width - the width
height - the height
pApplet - the applet

MTRectangle

public MTRectangle(processing.core.PApplet pApplet,
                   Vertex upperLeft,
                   float width,
                   float height)
Instantiates a new mT rectangle.

Parameters:
pApplet - the applet
upperLeft - the upper left
width - the width
height - the height

MTRectangle

public MTRectangle(processing.core.PApplet pApplet,
                   Vertex upperLeft,
                   float width,
                   float height,
                   int textureMaxX,
                   int textureMaxY)
Method Detail

setUseDirectGL

public void setUseDirectGL(boolean drawPureGL)
Description copied from class: AbstractShape
If set to true - which is the default if using the OpenGL render mode - this shape will bypass processings rendering pipeline and use the OpenGL context directly for performance increases.
Setting this to false forces the use of the processing renderer.

If this is set to true, and additionally, setUseVBOs() is set to true, the shape is drawn by using vertex buffer objects (VBO).
By calling setUseDisplayList(true) it is drawn using display lists.

Overrides:
setUseDirectGL in class MTPolygon
Parameters:
drawPureGL - the draw pure gl

setTexture

public void setTexture(processing.core.PImage newTexImage)
Description copied from class: AbstractShape
Sets a texture for this shape.
Uses the texture coordinates in the provided vertices for drawing.
If openGL mode is used, it also creates a GLTexture object.
For best compatibility, power of two texture dimensions should be provided. If the provided texture is non power of two and you are in opengl mode, we try to use the RECTANGULAR texture extension.
If textures were disabled for this component, they are being enabled again.

Overrides:
setTexture in class AbstractShape
Parameters:
newTexImage - the new tex image

getAnchor

public MTRectangle.PositionAnchor getAnchor()
Gets the Position anchor.

Returns:
the anchor

setAnchor

public void setAnchor(MTRectangle.PositionAnchor anchor)
Sets the anchor. The Anchor determines which reference point is used at set/getPosition(). The default anchor point is the rectangle's center.

Parameters:
anchor - the new anchor

setPositionGlobal

public void setPositionGlobal(Vector3D position)
Description copied from class: AbstractShape
Sets the global position of the component. (In global coordinates)

Overrides:
setPositionGlobal in class AbstractShape
Parameters:
position - the pos

setPositionRelativeToParent

public void setPositionRelativeToParent(Vector3D position)
Description copied from class: AbstractShape
Sets the position of the component, relative to its parent coordinate frame.

Overrides:
setPositionRelativeToParent in class AbstractShape
Parameters:
position - the pos

getPosition

public Vector3D getPosition(TransformSpace transformSpace)
Gets the position. The position is dependant on the set PositionAnchor. The default is the PositionAnchor.CENTER.

Parameters:
transformSpace - the transform space
Returns:
the position

get2DPolygonArea

public double get2DPolygonArea()
Description copied from class: MTPolygon
Calculates the area of a 2D polygon using its transformed world coordinates
NOTE: works only if the last vertex is equal to the first (polygon is closed correctly).

Overrides:
get2DPolygonArea in class MTPolygon
Returns:
the area as double

getCenterOfMass2DLocal

public Vector3D getCenterOfMass2DLocal()
Description copied from class: MTPolygon
Calculates the center of mass of the polygon. NOTE: works only if the last vertex is equal to the first (polygon is closed correctly) NOTE: polygon needs to be coplanar and in the X,Y plane!

Overrides:
getCenterOfMass2DLocal in class MTPolygon
Returns:
the center or mass as a Vector3D

getCenterPointLocal

public Vector3D getCenterPointLocal()
Description copied from class: AbstractShape
Gets the center point in local object space. This should always return a COPY of the centerpoint of the implementing shape since the point may get transformed afterwards.

Overrides:
getCenterPointLocal in class MTPolygon
Returns:
the center point of this shape in untransformed local object coordinates.

setSizeLocal

public void setSizeLocal(float width,
                         float height)
Sets the size locally, meaning that not the transformation of the rectangle is changed, (as setSize/setWidth, scale etc. would do) but the vertices of the rectangle themselves. This is useful if we dont want the rectangles children to be scaled as well, for example.
Note: The scaling is done from the rectangles upper left corner - not the center!

Parameters:
width - the width
height - the height

setHeightLocal

public void setHeightLocal(float height)
Sets the height locally, meaning that not the transformation of the rectangle is changed, (as setSize/setWidth, scale etc. would do) but the vertices of the rectangle themselves. This is useful if we dont want the rectangles children to be scaled as well, for example.
Note: The scaling is done from the rectangles upper left corner - not the center!

Parameters:
height - the new height local

setWidthLocal

public void setWidthLocal(float width)
Sets the width locally, meaning that not the transformation of the rectangle is changed, (as setSize/setWidth, scale etc. would do) but the vertices of the rectangle themselves. This is useful if we dont want the rectangles children to be scaled as well, for example.
Note: The scaling is done from the rectangles upper left corner - not the center!

Parameters:
width - the new width local