public class RatioKeyline extends java.lang.Object implements RhythmSpecLayer
Modifier and Type | Class and Description |
---|---|
static class |
RatioKeyline.Factory
A default factory that creates new
RatioKeyline layers from config lines according to the docs |
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_FILL_COLOR |
protected static int |
DEFAULT_LABEL_HEIGHT |
static int |
DEFAULT_TEXT_COLOR |
static int |
DEFAULT_TEXT_SIZE |
static int |
DEFAULT_THICKNESS |
protected android.graphics.Paint |
mBackgroundPaint |
protected int |
mLabelHeight |
protected android.graphics.Path |
mLabelPath |
protected int |
mLabelRectWidth |
protected int |
mLabelSideWidth |
protected int |
mRatioX |
protected int |
mRatioY |
protected android.graphics.Rect |
mTempRect |
protected java.lang.String |
mText |
protected android.text.TextPaint |
mTextPaint |
protected int |
mThickness |
Modifier | Constructor and Description |
---|---|
protected |
RatioKeyline(android.util.DisplayMetrics metrics) |
|
RatioKeyline(int ratioX,
int ratioY,
android.util.DisplayMetrics metrics) |
Modifier and Type | Method and Description |
---|---|
void |
draw(android.graphics.Canvas canvas,
android.graphics.Rect drawableBounds)
Draw itself to the provided canvas within provided bounds according to internal configuration (if any)
|
RatioKeyline |
setKeylineColor(int color)
Set the color of ratio keyline and label background
|
RatioKeyline |
setRatio(int ratioX,
int ratioY)
Set ratio of the box this keyline should define, in form of two terms
|
RatioKeyline |
setText(java.lang.String text)
Set arbitrary label text to this ratio keyline.
|
RatioKeyline |
setTextColor(int color)
Set ratio keyline label text color
|
RatioKeyline |
setThickness(int thickness)
Set ratio keyline thickness
|
public static final int DEFAULT_FILL_COLOR
public static final int DEFAULT_TEXT_COLOR
public static final int DEFAULT_THICKNESS
public static final int DEFAULT_TEXT_SIZE
protected static final int DEFAULT_LABEL_HEIGHT
protected int mRatioX
protected int mRatioY
protected int mThickness
protected java.lang.String mText
protected android.graphics.Paint mBackgroundPaint
protected android.text.TextPaint mTextPaint
protected android.graphics.Rect mTempRect
protected android.graphics.Path mLabelPath
protected int mLabelRectWidth
protected int mLabelHeight
protected int mLabelSideWidth
public RatioKeyline(int ratioX, int ratioY, android.util.DisplayMetrics metrics)
protected RatioKeyline(android.util.DisplayMetrics metrics)
public RatioKeyline setRatio(int ratioX, int ratioY)
ratioX
- antecedent, horizontal component of the ratio (e.g. 16 in 16:9)ratioY
- consequent, vertical component of the ratio (e.g. 9 in 16:9)public RatioKeyline setText(@Nullable java.lang.String text)
text
- Text to display in keyline label. Set null to reset the label to display ratio.public RatioKeyline setThickness(int thickness)
thickness
- Ratio keyline thickness, in pixels. At the moment, ratio keyline will be drawn within enclosed
bounds, so that regardless of thickness it doesn't cover pixels not within ratio box.public RatioKeyline setKeylineColor(int color)
color
- Ratio keyline color, in #AARRGGBB format as usualpublic RatioKeyline setTextColor(int color)
color
- Label text color, in #AARRGGBB format as usualpublic void draw(android.graphics.Canvas canvas, android.graphics.Rect drawableBounds)
RhythmSpecLayer
draw
in interface RhythmSpecLayer
canvas
- Canvas for the layer to draw itself todrawableBounds
- Bounds where this layer should draw itself. Since these are the bounds of a RhythmDrawable
connected to the view, they are usually the same as the view’s bounds, so
you can use this parameter to get the view’s dimensions should you need them.