com.androidplot.ui.widget
Class Widget

java.lang.Object
  extended by com.androidplot.ui.widget.Widget
All Implemented Interfaces:
BoxModelable, Resizable
Direct Known Subclasses:
EmptyWidget, PieWidget, TextLabelWidget, XYGraphWidget, XYLegendWidget

public abstract class Widget
extends Object
implements BoxModelable, Resizable

A Widget is a graphical sub-element of a Plot that can be positioned relative to the bounds of the Plot.


Constructor Summary
Widget(LayoutManager layoutManager, SizeMetrics sizeMetrics)
           
Widget(LayoutManager layoutManager, SizeMetric heightMetric, SizeMetric widthMetric)
           
 
Method Summary
 boolean containsPoint(android.graphics.PointF point)
          Determines whether or not point lies within this Widget.
 void draw(android.graphics.Canvas canvas, android.graphics.RectF widgetRect)
           
 AnchorPosition getAnchor()
           
static android.graphics.PointF getAnchorCoordinates(float x, float y, float width, float height, AnchorPosition anchorPosition)
           
static android.graphics.PointF getAnchorCoordinates(android.graphics.RectF widgetRect, AnchorPosition anchorPosition)
           
static android.graphics.PointF getAnchorOffset(float width, float height, AnchorPosition anchorPosition)
           
 android.graphics.Paint getBackgroundPaint()
           
 android.graphics.Paint getBorderPaint()
           
 android.graphics.PointF getElementCoordinates(float height, float width, android.graphics.RectF viewRect, PositionMetrics metrics)
           
 SizeMetric getHeightMetric()
           
 float getHeightPix(float size)
           
 android.graphics.RectF getMarginatedRect(android.graphics.RectF widgetRect)
          Returns a RectF instance describing the inner edge of the margin layer.
 float getMarginBottom()
           
 float getMarginLeft()
           
 float getMarginRight()
           
 float getMarginTop()
           
 android.graphics.RectF getPaddedRect(android.graphics.RectF widgetMarginRect)
          Returns a RectF instance describing the inner edge of the padding layer.
 float getPaddingBottom()
           
 float getPaddingLeft()
           
 float getPaddingRight()
           
 float getPaddingTop()
           
 PositionMetrics getPositionMetrics()
           
 DisplayDimensions getWidgetDimensions()
           
 SizeMetric getWidthMetric()
           
 float getWidthPix(float size)
           
 boolean isClippingEnabled()
           
 boolean isVisible()
           
 void layout(DisplayDimensions plotDimensions)
          Called when a change to the class' dimensions is made.
 void onPostInit()
          Can be overridden by subclasses to handle any final resizing etc.
 void position(float x, XLayoutStyle xLayoutStyle, float y, YLayoutStyle yLayoutStyle)
          Same as position(float, com.androidplot.ui.XLayoutStyle, float, com.androidplot.ui.YLayoutStyle, com.androidplot.ui.AnchorPosition) but with the anchor parameter defaulted to the upper left corner.
 void position(float x, XLayoutStyle xLayoutStyle, float y, YLayoutStyle yLayoutStyle, AnchorPosition anchor)
           
 void refreshLayout()
          Causes the pixel dimensions used for rendering this Widget to be recalculated.
 void setAnchor(AnchorPosition anchor)
           
 void setBackgroundPaint(android.graphics.Paint backgroundPaint)
           
 void setBorderPaint(android.graphics.Paint borderPaint)
           
 void setClippingEnabled(boolean clippingEnabled)
           
 void setHeight(float height)
           
 void setHeight(float height, SizeLayoutType layoutType)
           
 void setMarginBottom(float marginBottom)
           
 void setMarginLeft(float marginLeft)
           
 void setMarginRight(float marginRight)
           
 void setMargins(float left, float top, float right, float bottom)
           
 void setMarginTop(float marginTop)
           
 void setPadding(float left, float top, float right, float bottom)
           
 void setPaddingBottom(float paddingBottom)
           
 void setPaddingLeft(float paddingLeft)
           
 void setPaddingRight(float paddingRight)
           
 void setPaddingTop(float paddingTop)
           
 void setPositionMetrics(PositionMetrics positionMetrics)
           
 void setSize(SizeMetrics sizeMetrics)
           
 void setVisible(boolean visible)
           
 void setWidth(float width)
           
 void setWidth(float width, SizeLayoutType layoutType)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Widget

public Widget(LayoutManager layoutManager,
              SizeMetric heightMetric,
              SizeMetric widthMetric)

Widget

public Widget(LayoutManager layoutManager,
              SizeMetrics sizeMetrics)
Method Detail

getWidgetDimensions

public DisplayDimensions getWidgetDimensions()

getAnchor

public AnchorPosition getAnchor()

setAnchor

public void setAnchor(AnchorPosition anchor)

position

public void position(float x,
                     XLayoutStyle xLayoutStyle,
                     float y,
                     YLayoutStyle yLayoutStyle)
Same as position(float, com.androidplot.ui.XLayoutStyle, float, com.androidplot.ui.YLayoutStyle, com.androidplot.ui.AnchorPosition) but with the anchor parameter defaulted to the upper left corner.

Parameters:
x -
xLayoutStyle -
y -
yLayoutStyle -

position

public void position(float x,
                     XLayoutStyle xLayoutStyle,
                     float y,
                     YLayoutStyle yLayoutStyle,
                     AnchorPosition anchor)
Parameters:
x - X-Coordinate of the top left corner of element. When using RELATIVE, must be a value between 0 and 1.
xLayoutStyle - LayoutType to use when orienting this element's X-Coordinate.
y - Y_VALS_ONLY-Coordinate of the top-left corner of element. When using RELATIVE, must be a value between 0 and 1.
yLayoutStyle - LayoutType to use when orienting this element's Y_VALS_ONLY-Coordinate.
anchor - The point of reference used by this positioning call.

onPostInit

public void onPostInit()
Can be overridden by subclasses to handle any final resizing etc. that can only be done after XML configuration etc. has completed.


containsPoint

public boolean containsPoint(android.graphics.PointF point)
Determines whether or not point lies within this Widget.

Parameters:
point -
Returns:

setSize

public void setSize(SizeMetrics sizeMetrics)

setWidth

public void setWidth(float width)

setWidth

public void setWidth(float width,
                     SizeLayoutType layoutType)

setHeight

public void setHeight(float height)

setHeight

public void setHeight(float height,
                      SizeLayoutType layoutType)

getWidthMetric

public SizeMetric getWidthMetric()

getHeightMetric

public SizeMetric getHeightMetric()

getWidthPix

public float getWidthPix(float size)

getHeightPix

public float getHeightPix(float size)

getMarginatedRect

public android.graphics.RectF getMarginatedRect(android.graphics.RectF widgetRect)
Description copied from interface: BoxModelable
Returns a RectF instance describing the inner edge of the margin layer.

Specified by:
getMarginatedRect in interface BoxModelable
Returns:

getPaddedRect

public android.graphics.RectF getPaddedRect(android.graphics.RectF widgetMarginRect)
Description copied from interface: BoxModelable
Returns a RectF instance describing the inner edge of the padding layer.

Specified by:
getPaddedRect in interface BoxModelable
Returns:

setMarginRight

public void setMarginRight(float marginRight)
Specified by:
setMarginRight in interface BoxModelable

setMargins

public void setMargins(float left,
                       float top,
                       float right,
                       float bottom)
Specified by:
setMargins in interface BoxModelable

setPadding

public void setPadding(float left,
                       float top,
                       float right,
                       float bottom)
Specified by:
setPadding in interface BoxModelable

getMarginTop

public float getMarginTop()
Specified by:
getMarginTop in interface BoxModelable

setMarginTop

public void setMarginTop(float marginTop)
Specified by:
setMarginTop in interface BoxModelable

getMarginBottom

public float getMarginBottom()
Specified by:
getMarginBottom in interface BoxModelable

getPaddingLeft

public float getPaddingLeft()
Specified by:
getPaddingLeft in interface BoxModelable

setPaddingLeft

public void setPaddingLeft(float paddingLeft)
Specified by:
setPaddingLeft in interface BoxModelable

getPaddingTop

public float getPaddingTop()
Specified by:
getPaddingTop in interface BoxModelable

setPaddingTop

public void setPaddingTop(float paddingTop)
Specified by:
setPaddingTop in interface BoxModelable

getPaddingRight

public float getPaddingRight()
Specified by:
getPaddingRight in interface BoxModelable

setPaddingRight

public void setPaddingRight(float paddingRight)
Specified by:
setPaddingRight in interface BoxModelable

getPaddingBottom

public float getPaddingBottom()
Specified by:
getPaddingBottom in interface BoxModelable

setPaddingBottom

public void setPaddingBottom(float paddingBottom)
Specified by:
setPaddingBottom in interface BoxModelable

setMarginBottom

public void setMarginBottom(float marginBottom)

getMarginLeft

public float getMarginLeft()
Specified by:
getMarginLeft in interface BoxModelable

setMarginLeft

public void setMarginLeft(float marginLeft)
Specified by:
setMarginLeft in interface BoxModelable

getMarginRight

public float getMarginRight()
Specified by:
getMarginRight in interface BoxModelable

refreshLayout

public void refreshLayout()
Causes the pixel dimensions used for rendering this Widget to be recalculated. Should be called any time a parameter that factors into this Widget's size or position is altered.


layout

public void layout(DisplayDimensions plotDimensions)
Description copied from interface: Resizable
Called when a change to the class' dimensions is made. This method is responsible for cascading calls to update for any logical children of this class, for example the Plot class is responsible for updating the LayoutManager. Note that while dims is marked final in this interface, the compiler will not enforce it. Implementors of this method should take care not to make changes to dims as this will affect parent Resizables in likely undesired ways.

Specified by:
layout in interface Resizable

getElementCoordinates

public android.graphics.PointF getElementCoordinates(float height,
                                                     float width,
                                                     android.graphics.RectF viewRect,
                                                     PositionMetrics metrics)

getAnchorOffset

public static android.graphics.PointF getAnchorOffset(float width,
                                                      float height,
                                                      AnchorPosition anchorPosition)

getAnchorCoordinates

public static android.graphics.PointF getAnchorCoordinates(android.graphics.RectF widgetRect,
                                                           AnchorPosition anchorPosition)

getAnchorCoordinates

public static android.graphics.PointF getAnchorCoordinates(float x,
                                                           float y,
                                                           float width,
                                                           float height,
                                                           AnchorPosition anchorPosition)

draw

public void draw(android.graphics.Canvas canvas,
                 android.graphics.RectF widgetRect)
          throws PlotRenderException
Throws:
PlotRenderException

getBorderPaint

public android.graphics.Paint getBorderPaint()

setBorderPaint

public void setBorderPaint(android.graphics.Paint borderPaint)

getBackgroundPaint

public android.graphics.Paint getBackgroundPaint()

setBackgroundPaint

public void setBackgroundPaint(android.graphics.Paint backgroundPaint)

isClippingEnabled

public boolean isClippingEnabled()

setClippingEnabled

public void setClippingEnabled(boolean clippingEnabled)

isVisible

public boolean isVisible()

setVisible

public void setVisible(boolean visible)

getPositionMetrics

public PositionMetrics getPositionMetrics()

setPositionMetrics

public void setPositionMetrics(PositionMetrics positionMetrics)


Copyright © 2010-2013 androidplot.com. All Rights Reserved.