-
- All Implemented Interfaces:
-
com.androidplot.ui.BoxModelable
,com.androidplot.ui.Resizable
public abstract class Widget implements BoxModelable, Resizable
A Widget is a graphical sub-element of a Plot that can be positioned relative to the bounds of the Plot.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
Widget.Rotation
-
Field Summary
Fields Modifier and Type Field Description private Paint
borderPaint
private Paint
backgroundPaint
private boolean
clippingEnabled
private Size
size
private DisplayDimensions
widgetDimensions
private boolean
isVisible
private PositionMetrics
positionMetrics
private Widget.Rotation
rotation
-
Constructor Summary
Constructors Constructor Description Widget(LayoutManager layoutManager, SizeMetric heightMetric, SizeMetric widthMetric)
Widget(LayoutManager layoutManager, Size size)
-
Method Summary
Modifier and Type Method Description Paint
getBorderPaint()
void
setBorderPaint(Paint borderPaint)
Paint
getBackgroundPaint()
void
setBackgroundPaint(Paint backgroundPaint)
void
setClippingEnabled(boolean clippingEnabled)
Size
getSize()
void
setSize(Size size)
DisplayDimensions
getWidgetDimensions()
boolean
isVisible()
PositionMetrics
getPositionMetrics()
void
setPositionMetrics(PositionMetrics positionMetrics)
Widget.Rotation
getRotation()
void
setRotation(Widget.Rotation rotation)
Anchor
getAnchor()
void
setAnchor(Anchor anchor)
void
position(float x, HorizontalPositioning horizontalPositioning, float y, VerticalPositioning verticalPositioning)
Same as position but with the anchor parameter defaulted to the upper left corner. void
position(float x, HorizontalPositioning horizontalPositioning, float y, VerticalPositioning verticalPositioning, Anchor anchor)
void
onPostInit()
Can be overridden by subclasses to handle any final resizing etc. boolean
containsPoint(PointF point)
Determines whether or not point lies within this Widget. void
setWidth(float width)
void
setWidth(float width, SizeMode layoutType)
void
setHeight(float height)
void
setHeight(float height, SizeMode layoutType)
SizeMetric
getWidthMetric()
SizeMetric
getHeightMetric()
float
getWidthPix(float size)
float
getHeightPix(float size)
RectF
getMarginatedRect(RectF widgetRect)
Returns a RectF instance describing the inner edge of the margin layer. RectF
getPaddedRect(RectF widgetMarginRect)
Returns a RectF instance describing the inner edge of the padding layer. void
setMarginRight(float marginRight)
void
setMargins(float left, float top, float right, float bottom)
void
setPadding(float left, float top, float right, float bottom)
float
getMarginTop()
void
setMarginTop(float marginTop)
float
getMarginBottom()
float
getPaddingLeft()
void
setPaddingLeft(float paddingLeft)
float
getPaddingTop()
void
setPaddingTop(float paddingTop)
float
getPaddingRight()
void
setPaddingRight(float paddingRight)
float
getPaddingBottom()
void
setPaddingBottom(float paddingBottom)
void
setMarginBottom(float marginBottom)
float
getMarginLeft()
void
setMarginLeft(float marginLeft)
float
getMarginRight()
synchronized void
refreshLayout()
Causes the pixel dimensions used for rendering this Widgetto be recalculated. synchronized void
layout(DisplayDimensions plotDimensions)
Called when a change to the class' dimensions is made. static PointF
calculateCoordinates(float height, float width, RectF viewRect, PositionMetrics metrics)
static PointF
getAnchorOffset(float width, float height, Anchor anchor)
static PointF
getAnchorCoordinates(RectF widgetRect, Anchor anchor)
static PointF
getAnchorCoordinates(float x, float y, float width, float height, Anchor anchor)
void
draw(Canvas canvas)
boolean
isClippingEnabled()
void
setVisible(boolean visible)
-
Methods inherited from class com.androidplot.ui.BoxModelable
getMarginatedRect, getPaddedRect, setMarginBottom
-
Methods inherited from class com.androidplot.ui.Resizable
layout
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
Widget
Widget(LayoutManager layoutManager, SizeMetric heightMetric, SizeMetric widthMetric)
-
Widget
Widget(LayoutManager layoutManager, Size size)
-
-
Method Detail
-
getBorderPaint
Paint getBorderPaint()
-
setBorderPaint
void setBorderPaint(Paint borderPaint)
-
getBackgroundPaint
Paint getBackgroundPaint()
-
setBackgroundPaint
void setBackgroundPaint(Paint backgroundPaint)
-
setClippingEnabled
void setClippingEnabled(boolean clippingEnabled)
-
getWidgetDimensions
DisplayDimensions getWidgetDimensions()
-
isVisible
boolean isVisible()
-
getPositionMetrics
PositionMetrics getPositionMetrics()
-
setPositionMetrics
void setPositionMetrics(PositionMetrics positionMetrics)
-
getRotation
Widget.Rotation getRotation()
-
setRotation
void setRotation(Widget.Rotation rotation)
-
position
void position(float x, HorizontalPositioning horizontalPositioning, float y, VerticalPositioning verticalPositioning)
Same as position but with the anchor parameter defaulted to the upper left corner.
-
position
void position(float x, HorizontalPositioning horizontalPositioning, float y, VerticalPositioning verticalPositioning, Anchor anchor)
- Parameters:
x
- X-Coordinate of the top left corner of element.horizontalPositioning
- LayoutType to use when orienting this element's X-Coordinate.y
- Y_VALS_ONLY-Coordinate of the top-left corner of element.verticalPositioning
- LayoutType to use when orienting this element's Y_VALS_ONLY-Coordinate.anchor
- The point of reference used by this positioning call.
-
onPostInit
void onPostInit()
Can be overridden by subclasses to handle any final resizing etc. thatcan only be done after XML configuration etc. has completed.
-
containsPoint
boolean containsPoint(PointF point)
Determines whether or not point lies within this Widget.
-
setWidth
void setWidth(float width)
-
setHeight
void setHeight(float height)
-
getWidthMetric
SizeMetric getWidthMetric()
-
getHeightMetric
SizeMetric getHeightMetric()
-
getWidthPix
float getWidthPix(float size)
-
getHeightPix
float getHeightPix(float size)
-
getMarginatedRect
RectF getMarginatedRect(RectF widgetRect)
Returns a RectF instance describing the inner edge of the margin layer.
-
getPaddedRect
RectF getPaddedRect(RectF widgetMarginRect)
Returns a RectF instance describing the inner edge of the padding layer.
-
setMarginRight
void setMarginRight(float marginRight)
-
setMargins
void setMargins(float left, float top, float right, float bottom)
-
setPadding
void setPadding(float left, float top, float right, float bottom)
-
getMarginTop
float getMarginTop()
-
setMarginTop
void setMarginTop(float marginTop)
-
getMarginBottom
float getMarginBottom()
-
getPaddingLeft
float getPaddingLeft()
-
setPaddingLeft
void setPaddingLeft(float paddingLeft)
-
getPaddingTop
float getPaddingTop()
-
setPaddingTop
void setPaddingTop(float paddingTop)
-
getPaddingRight
float getPaddingRight()
-
setPaddingRight
void setPaddingRight(float paddingRight)
-
getPaddingBottom
float getPaddingBottom()
-
setPaddingBottom
void setPaddingBottom(float paddingBottom)
-
setMarginBottom
void setMarginBottom(float marginBottom)
-
getMarginLeft
float getMarginLeft()
-
setMarginLeft
void setMarginLeft(float marginLeft)
-
getMarginRight
float getMarginRight()
-
refreshLayout
synchronized void refreshLayout()
Causes the pixel dimensions used for rendering this Widgetto be recalculated. Should be called any time a parameter that factorsinto this Widget's size or position is altered.
-
layout
synchronized void layout(DisplayDimensions plotDimensions)
Called when a change to the class' dimensions is made. This method is responsiblefor cascading calls to update for any logical children of this class, for examplethe Plot class is responsible for updating the LayoutManager. Note that while dimsis marked final in this interface, the compiler will not enforce it. Implementors ofthis method should take care not to make changes to dims as this will affect parentResizables in likely undesired ways.
-
calculateCoordinates
static PointF calculateCoordinates(float height, float width, RectF viewRect, PositionMetrics metrics)
-
getAnchorOffset
static PointF getAnchorOffset(float width, float height, Anchor anchor)
-
getAnchorCoordinates
static PointF getAnchorCoordinates(RectF widgetRect, Anchor anchor)
-
getAnchorCoordinates
static PointF getAnchorCoordinates(float x, float y, float width, float height, Anchor anchor)
-
isClippingEnabled
boolean isClippingEnabled()
-
setVisible
void setVisible(boolean visible)
-
-
-
-