twaver.network
Class ImageUI

java.lang.Object
  extended by twaver.core.network.BaseUI<T>
      extended by twaver.network.UI<IImage>
          extended by twaver.network.ImageUI
All Implemented Interfaces:
twaver.core.network.IUI<IImage,Canvas,Paint>, IListener<Event>

public class ImageUI
extends UI<IImage>
implements IListener<Event>

图片UI元素,用于图片的呈现,当然并不限与静态栅格图片,也支持其他格式,比如gif动画,以及任意Drawable实现类,如NinePatchDrawable 使用IImage作为数据源,可以定制自己的IImage图形数据,更多可参考IImage

See Also:
IImage

Field Summary
 
Fields inherited from class twaver.network.UI
elementUI
 
Fields inherited from class twaver.core.network.BaseUI
anchorPoint, bodyOffsetX, bodyOffsetY, bounds, data, invalidateAnchorPointFlag, invalidateLocationFlag, invalidateRenderFlag, invalidateSizeFlag, location, stateOutline, stateOutlineColor, visible
 
Constructor Summary
ImageUI(ElementUI<?> elementUI)
          图片UI元素,用于图片的呈现,当然并不限与静态栅格图片,也支持其他格式,比如gif动画,以及任意Drawable实现类,如NinePatchDrawable 使用IImage作为数据源,可以定制自己的IImage图形数据,更多可参考IImage
 
Method Summary
 boolean beforeEvent(Event event)
          事件发生前,返回false表示中断事件,用于操作前的检测
protected  void drawBodySelection(Canvas canvas, Paint paint)
          绘制选中效果,调用IImage#drawSelection
protected  void drawImage(Canvas canvas, Paint paint)
          绘制图片,执行IImage的绘制函数
 Size getSize()
          获取图片尺寸 当size的width或者height为-1时,twaver会保持等比例缩放 如果图片原始宽高为32*16,比如下面的代码,可设置网元宽度为40,高度保持等比例为20 node.setSize(new Size(40, -1));
 boolean intersect(Point point)
          点相交
 void measure()
           
protected  void onDrawBody(Canvas canvas, Paint paint, boolean drawSelectionOnBody, boolean drawStateOutlineOnBody)
          绘制主体
 void onEvent(Event event)
          事件发生时回调
 boolean setData(IImage data)
           
 boolean setSize(Size size)
          设置图片尺寸 当size的width或者height为-1时,twaver会保持等比例缩放 如果图片原始宽高为32*16,比如下面的代码,可设置网元宽度为40,高度保持等比例为20 node.setSize(new Size(40, -1));
 
Methods inherited from class twaver.network.UI
drawBodyStateOutline, drawBodyStateOutline, getElementUI, getPosition, intersect, invalidateSize, isSendToBottom, resetPaint, setPosition, setSendToBottom
 
Methods inherited from class twaver.core.network.BaseUI
checkBackground, checkOutline, draw, drawBackgroundAndBorder, drawBody, drawStateOutline, drawStateOutline, getAnchorPoint, getAnchorPosition, getAngle, getBackgroundColor, getBounds, getCornerRadius, getData, getLocation, getMeasuredHeight, getMeasuredWidth, getOffset, getOutlineColor, getOutlineWidth, getRenderColor, getSelectionBorder, getSelectionBorderColor, getStateOutline, getStateOutlineColor, intersectPointer, invalidateAnchorPoint, invalidateLocation, invalidatePointer, invalidateRender, isDrawBackground, isDrawOutline, isDrawStateOutline, isInvalidate, isInvalidateAnchorPoint, isInvalidateLocation, isInvalidateSize, isLayoutByAnchorPoint, isRelativeLocation, isRotatable, isSelected, isShowOnTop, isVisible, measureAnchorPosition, onDraw, onDrawBackgroundAndBorder, perLocation, resetShape, setAnchorPosition, setBackgroundColor, setBackgroundShader, setBounds, setBounds, setCornerRadius, setLayoutByAnchorPoint, setLocation, setLocation, setMeasuredSize, setOffset, setOutline, setOutlineColor, setPadding, setPointerVisible, setPointerWidth, setRenderColor, setRotatable, setSelected, setSelectionBorder, setSelectionBorderColor, setShowOnTop, setStateOutline, setStateOutlineColor, setVisible, styleSelectionPaint, toAbsoluteRect, toLocalPoint, toLocalRect, validate, validateLocation, validatePointer, validateRender
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageUI

public ImageUI(ElementUI<?> elementUI)
图片UI元素,用于图片的呈现,当然并不限与静态栅格图片,也支持其他格式,比如gif动画,以及任意Drawable实现类,如NinePatchDrawable 使用IImage作为数据源,可以定制自己的IImage图形数据,更多可参考IImage

Parameters:
elementUI -
See Also:
IImage
Method Detail

setData

public boolean setData(IImage data)
Specified by:
setData in interface twaver.core.network.IUI<IImage,Canvas,Paint>
Overrides:
setData in class twaver.core.network.BaseUI<IImage>

getSize

public Size getSize()
获取图片尺寸 当size的width或者height为-1时,twaver会保持等比例缩放 如果图片原始宽高为32*16,比如下面的代码,可设置网元宽度为40,高度保持等比例为20 node.setSize(new Size(40, -1));

Returns:
图片尺寸
See Also:
Node.setSize(Size)

setSize

public boolean setSize(Size size)
设置图片尺寸 当size的width或者height为-1时,twaver会保持等比例缩放 如果图片原始宽高为32*16,比如下面的代码,可设置网元宽度为40,高度保持等比例为20 node.setSize(new Size(40, -1));

Parameters:
size - 图片尺寸
Returns:
是否设置成功
See Also:
Node.setSize(Size)

measure

public void measure()
Specified by:
measure in class twaver.core.network.BaseUI<IImage>

onDrawBody

protected void onDrawBody(Canvas canvas,
                          Paint paint,
                          boolean drawSelectionOnBody,
                          boolean drawStateOutlineOnBody)
Description copied from class: UI
绘制主体

Overrides:
onDrawBody in class UI<IImage>
drawSelectionOnBody - 是否绘制选中效果
drawStateOutlineOnBody - 是否绘制边框
See Also:
UI.drawBodySelection(Canvas, Paint), UI.drawBodyStateOutline(Canvas, Paint)

drawImage

protected void drawImage(Canvas canvas,
                         Paint paint)
绘制图片,执行IImage的绘制函数

Parameters:
canvas -
paint -
See Also:
IImage.draw(Canvas, Paint, float, float)

drawBodySelection

protected void drawBodySelection(Canvas canvas,
                                 Paint paint)
绘制选中效果,调用IImage#drawSelection

Overrides:
drawBodySelection in class UI<IImage>
See Also:
IImage.drawSelection(Canvas, Paint, float, float, float, int)

intersect

public boolean intersect(Point point)
Description copied from class: UI
点相交

Specified by:
intersect in interface twaver.core.network.IUI<IImage,Canvas,Paint>
Overrides:
intersect in class UI<IImage>
Parameters:
point - 相交点

beforeEvent

public boolean beforeEvent(Event event)
Description copied from interface: IListener
事件发生前,返回false表示中断事件,用于操作前的检测

Specified by:
beforeEvent in interface IListener<Event>
Parameters:
event - 事件
Returns:
false表示中断事件

onEvent

public void onEvent(Event event)
Description copied from interface: IListener
事件发生时回调

Specified by:
onEvent in interface IListener<Event>
Parameters:
event - 事件