App
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mhr.appandroid.views.brushpicker.RoundBrushPickerView Class Reference

Třída pro jednoduchý výběr kulatého štětce. More...

Inheritance diagram for mhr.appandroid.views.brushpicker.RoundBrushPickerView:
mhr.appandroid.views.MaskView.OnMaskCanvasChangedListener

Classes

class  RoundBrushParams
 Pouze struktura pro uchování parametrů, které vytovří daný štětec, slouží pro uchování stavu pro Cancel namísto uchovávání bitmapy. More...
 
enum  RoundBrushPickerEvent
 Výčet udávající typ události. More...
 
interface  RoundBrushPickerViewEventListener
 Interface pro posluchače událostí. More...
 

Public Member Functions

 RoundBrushPickerView (Context context)
 
 RoundBrushPickerView (Context context, AttributeSet attrs)
 
 RoundBrushPickerView (Context context, AttributeSet attrs, int defStyle)
 
void setZoom (double zoom)
 Nastaví zoom náhledu.
 
double getZoom ()
 Vrátí zoom náhledu.
 
void setSize (int size)
 Nastaví velikost aktuálně vybraného štětce.
 
int getSize ()
 Vrátí velikost aktuálně vybraného štětce.
 
void setHardness (double hardness)
 Nastaví tvrdost aktuálně vybraného štětce.
 
double getHardness ()
 Vrátí tvrdost aktuálně vybraného štětce.
 
NBitmap getOldBrush ()
 Vrátí nově vytvořený štětec dle parametrů starého štětce.
 
Paint getPreviewBackground ()
 Vrátí odkaz na Paint, který se použije pro vykreslení pozadí náhledu.
 
Paint getPreviewForeground ()
 Vrátí odkaz na Paint, který se použije pro vykreslení náhledu štětce.
 
NBitmap getNewBrush ()
 Vrátí KOPII vybraného štětce - ZA UVOLNĚNÍ PROSTŘEDKŮ ODPOVÍDÁ KLIENT.
 
void setState (int size, double hardness)
 Nastaví stav - dle daných parametrů vytvoří jak nový štětec, tak je nastaví jako parametry starého štětce.
 
boolean isLivePreviewOn ()
 Vrátí stav LivePreview.
 
void setLivePreview (boolean val)
 Nastaví hodnotu LivePreview.
 
void setRoundBrushPickerListener (RoundBrushPickerViewEventListener l)
 Nastaví posluchače událostí.
 
void doSelectAction ()
 Slouží k simulaci stisknutí tlačítka Select.
 
void doCancelAction ()
 Slouží k simulaci stisknutí tlačítka cancel.
 
void onProgressChanged (SeekBar seekBar, int progress, boolean fromUser)
 
void onStartTrackingTouch (SeekBar seekBar)
 
void onStopTrackingTouch (SeekBar seekBar)
 
void onMaskCanvasChanged (MaskView v)
 Voláno v okamžiku, kdy BrushView z jakéhokoliv důvodu musí změnit velikost bitmapy, kterou používá k vykreslování. Voláno také když je View poprvé připraven.
 
void onCheckedChanged (CompoundButton buttonView, boolean isChecked)
 
void onClick (View v)
 

Protected Member Functions

void init ()
 Provede inicializaci třídy.
 
void onDetachedFromWindow ()
 Voláno v okamžiku, kdy již View nemá kam kreslit - není spojen s oknem.
 
void updateSeekBars ()
 Nastaví SeekBary tak, aby odpovídaly newBrushParams.
 
void updateLabels ()
 Aktualizuje popisky SeekBarů dle newBrushParams.
 
void recreateBrush ()
 Znovu vytvoří štětec tak, aby odpovídal newBrushParams.
 
void redrawBrush ()
 Znovu vykreslí štětec.
 
boolean initPreviewCanvas (MaskView view)
 Pokusí se o inicializaci Canvasu (jeho získání) pro zobrazení štětce, informuje o úspěchu.
 
void updateValues ()
 Nastaví newBrushParams dle hodnot na SeekBarech.
 
void updateStateFromSeekBars ()
 Aktualizuje celkový stav třídy dle hodnot SeekBarů.
 
void updateStateFromParams ()
 Aktualizuje cekový stav třídy dle hodnot newBrushParams.
 

Protected Attributes

SeekBar sizeSB
 
SeekBar hardnessSB
 
CheckBox livePreviewChB
 
Button selectBtn
 
Button cancelBtn
 
MaskView previewMskV
 
TextView sizeTV
 
TextView hardnessTV
 
boolean livePreview
 Udává, jestli má být dynamicky vytvářen náhled štětce, nebo má být náhled vytvořen až po dokončení volby uživatelem.
 
NBitmap previewCanvas = null
 Canvas odpovídajícího MaskView, které zobrazuje náhled štětce.
 
NBitmap newBrush = null
 Uživatelem právě vybraný štětec.
 
RoundBrushParams oldParams = new RoundBrushParams()
 Parametry starého štětce, na které se uživatel vrátí, pokud stiskne cancelBtn.
 
RoundBrushParams newParams = new RoundBrushParams()
 Parametry právě vybraného štětce.
 
RoundBrushPickerViewEventListener listener = null
 

Detailed Description

Třída pro jednoduchý výběr kulatého štětce.

Definition at line 32 of file RoundBrushPickerView.java.

Constructor & Destructor Documentation

mhr.appandroid.views.brushpicker.RoundBrushPickerView.RoundBrushPickerView ( Context  context)
inline

Definition at line 156 of file RoundBrushPickerView.java.

{
super(context);
init();
}
mhr.appandroid.views.brushpicker.RoundBrushPickerView.RoundBrushPickerView ( Context  context,
AttributeSet  attrs 
)
inline

Definition at line 161 of file RoundBrushPickerView.java.

{
super(context, attrs);
init();
}
mhr.appandroid.views.brushpicker.RoundBrushPickerView.RoundBrushPickerView ( Context  context,
AttributeSet  attrs,
int  defStyle 
)
inline

Definition at line 166 of file RoundBrushPickerView.java.

{
super(context, attrs, defStyle);
init();
}

Member Function Documentation

void mhr.appandroid.views.brushpicker.RoundBrushPickerView.doCancelAction ( )
inline

Slouží k simulaci stisknutí tlačítka cancel.

Definition at line 404 of file RoundBrushPickerView.java.

void mhr.appandroid.views.brushpicker.RoundBrushPickerView.doSelectAction ( )
inline

Slouží k simulaci stisknutí tlačítka Select.

Definition at line 396 of file RoundBrushPickerView.java.

double mhr.appandroid.views.brushpicker.RoundBrushPickerView.getHardness ( )
inline

Vrátí tvrdost aktuálně vybraného štětce.

Returns

Definition at line 315 of file RoundBrushPickerView.java.

{
}
NBitmap mhr.appandroid.views.brushpicker.RoundBrushPickerView.getNewBrush ( )
inline

Vrátí KOPII vybraného štětce - ZA UVOLNĚNÍ PROSTŘEDKŮ ODPOVÍDÁ KLIENT.

Returns

Definition at line 347 of file RoundBrushPickerView.java.

{
if (newBrush != null) {
return new NBitmap(newBrush);
} else {
return BrushGenerator.createRoundBrush(newParams.size, newParams.hardness, Depth.DEPTH_8_BIT);
}
}
NBitmap mhr.appandroid.views.brushpicker.RoundBrushPickerView.getOldBrush ( )
inline

Vrátí nově vytvořený štětec dle parametrů starého štětce.

Returns

Definition at line 323 of file RoundBrushPickerView.java.

{
return BrushGenerator.createRoundBrush(oldParams.size, oldParams.hardness, Depth.DEPTH_8_BIT);
}
Paint mhr.appandroid.views.brushpicker.RoundBrushPickerView.getPreviewBackground ( )
inline

Vrátí odkaz na Paint, který se použije pro vykreslení pozadí náhledu.

Returns

Definition at line 331 of file RoundBrushPickerView.java.

Paint mhr.appandroid.views.brushpicker.RoundBrushPickerView.getPreviewForeground ( )
inline

Vrátí odkaz na Paint, který se použije pro vykreslení náhledu štětce.

Returns

Definition at line 339 of file RoundBrushPickerView.java.

int mhr.appandroid.views.brushpicker.RoundBrushPickerView.getSize ( )
inline

Vrátí velikost aktuálně vybraného štětce.

Returns

Definition at line 298 of file RoundBrushPickerView.java.

{
return newParams.size;
}
double mhr.appandroid.views.brushpicker.RoundBrushPickerView.getZoom ( )
inline

Vrátí zoom náhledu.

Returns

Definition at line 281 of file RoundBrushPickerView.java.

{
return previewMskV.getZoom();
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.init ( )
inlineprotected

Provede inicializaci třídy.

Definition at line 97 of file RoundBrushPickerView.java.

{
try {
((Activity) getContext()).getLayoutInflater().inflate(R.layout.view_brush_picker, this, true);
} catch (ClassCastException exc) {
// Tento kod probehne, pokud je poroblem s pretypovanim, napriklad pro nahled v Eclipse
TextView tv = new TextView(getContext());
tv.setText("Prewiew not available, requires Activity to be Context.");
addView(tv);
return;
}
// Nalezení potomků pro rychlý přístup
sizeSB = (SeekBar) findViewById(R.id.SizeValueSB);
hardnessSB = (SeekBar) findViewById(R.id.HardnessValueSB);
livePreviewChB = (CheckBox) findViewById(R.id.RoundBrushLivePreviewChckB);
sizeTV = (TextView) findViewById(R.id.SizeValueTV);
hardnessTV = (TextView) findViewById(R.id.HardnessValueTV);
previewMskV = (MaskView) findViewById(R.id.RoundBrushPreviewMskV);
selectBtn = (Button) findViewById(R.id.RoundBrushPickerSelectBtn);
cancelBtn = (Button) findViewById(R.id.RoundBrushPickerCancelBtn);
// Inicializace stavu třídy
livePreview = livePreviewChB.isChecked();
// Nastavení vzhledu komponent
BitmapShader bsh = new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.checkboard), TileMode.REPEAT, TileMode.REPEAT);
// Nastavení sebe jako posluchačů příslušných událostí.
sizeSB.setOnSeekBarChangeListener(this);
hardnessSB.setOnSeekBarChangeListener(this);
livePreviewChB.setOnCheckedChangeListener(this);
selectBtn.setOnClickListener(this);
cancelBtn.setOnClickListener(this);
}
boolean mhr.appandroid.views.brushpicker.RoundBrushPickerView.initPreviewCanvas ( MaskView  view)
inlineprotected

Pokusí se o inicializaci Canvasu (jeho získání) pro zobrazení štětce, informuje o úspěchu.

Parameters
view
Returns
Vrací true, pokud se podařilo získat Canvas, v opačném případě false, může být způsobeno např. view.GONE atd...

Definition at line 226 of file RoundBrushPickerView.java.

{
if (previewCanvas != null) {
previewCanvas = null;
}
APDBitmap maskCanvas = view.getMaskCanvas();
if (maskCanvas == null) {
return false;
} else {
previewCanvas = new NBitmap(maskCanvas);
return true;
}
}
boolean mhr.appandroid.views.brushpicker.RoundBrushPickerView.isLivePreviewOn ( )
inline

Vrátí stav LivePreview.

Returns

Definition at line 372 of file RoundBrushPickerView.java.

{
return livePreview;
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.onCheckedChanged ( CompoundButton  buttonView,
boolean  isChecked 
)
inline

Definition at line 449 of file RoundBrushPickerView.java.

{
livePreview = isChecked;
if (listener != null) {
listener.onRoundBrushPickerEvent(RoundBrushPickerEvent.EVENT_LIVE_PREVIEW_STATE_CHANGED, this);
}
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.onClick ( View  v)
inline

Definition at line 457 of file RoundBrushPickerView.java.

{
if (v == selectBtn) {
if (listener != null) {
listener.onRoundBrushPickerEvent(RoundBrushPickerEvent.EVENT_SELECTED, this);
}
} else if (v == cancelBtn) {
if (listener != null) {
listener.onRoundBrushPickerEvent(RoundBrushPickerEvent.EVENT_CHANGED, this);
}
if (listener != null) {
listener.onRoundBrushPickerEvent(RoundBrushPickerEvent.EVENT_CANCELED, this);
}
}
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.onDetachedFromWindow ( )
inlineprotected

Voláno v okamžiku, kdy již View nemá kam kreslit - není spojen s oknem.

Definition at line 144 of file RoundBrushPickerView.java.

{
if (previewCanvas != null) {
previewCanvas = null;
}
if (newBrush != null) {
newBrush = null;
}
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.onMaskCanvasChanged ( MaskView  v)
inline

Voláno v okamžiku, kdy BrushView z jakéhokoliv důvodu musí změnit velikost bitmapy, kterou používá k vykreslování. Voláno také když je View poprvé připraven.

Parameters
v

Implements mhr.appandroid.views.MaskView.OnMaskCanvasChangedListener.

Definition at line 443 of file RoundBrushPickerView.java.

void mhr.appandroid.views.brushpicker.RoundBrushPickerView.onProgressChanged ( SeekBar  seekBar,
int  progress,
boolean  fromUser 
)
inline

Definition at line 413 of file RoundBrushPickerView.java.

{
if (fromUser) {
if (livePreview) {
} else {
}
if (listener != null) {
listener.onRoundBrushPickerEvent(RoundBrushPickerEvent.EVENT_CHANGED, this);
}
}
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.onStartTrackingTouch ( SeekBar  seekBar)
inline

Definition at line 428 of file RoundBrushPickerView.java.

{
// Nepouzity callback
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.onStopTrackingTouch ( SeekBar  seekBar)
inline

Definition at line 433 of file RoundBrushPickerView.java.

{
if (!livePreview) {
}
if (listener != null) {
listener.onRoundBrushPickerEvent(RoundBrushPickerEvent.EVENT_CHANGED, this);
}
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.recreateBrush ( )
inlineprotected

Znovu vytvoří štětec tak, aby odpovídal newBrushParams.

Definition at line 192 of file RoundBrushPickerView.java.

{
if (newBrush != null) {
newBrush = null;
}
newBrush = BrushGenerator.createRoundBrush(newParams.size, newParams.hardness, Depth.DEPTH_8_BIT);
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.redrawBrush ( )
inlineprotected

Znovu vykreslí štětec.

Znovu vykreslí štětec, pokud neexistuje, pokusí se jej dle specifikací vytvořit. Pokdu neexistuje Canvas pro vykreslení, pokusí se jej získat, pokud neuspěje, zkončí.

Definition at line 206 of file RoundBrushPickerView.java.

{
if (newBrush == null) {
}
if (previewCanvas == null) {
return;
}
}
(int) ((previewCanvas.getHeight() - newBrush.getHeight()) / 2));
previewMskV.invalidate();
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.setHardness ( double  hardness)
inline

Nastaví tvrdost aktuálně vybraného štětce.

Parameters
hardness

Definition at line 306 of file RoundBrushPickerView.java.

void mhr.appandroid.views.brushpicker.RoundBrushPickerView.setLivePreview ( boolean  val)
inline

Nastaví hodnotu LivePreview.

Parameters
val

Definition at line 380 of file RoundBrushPickerView.java.

{
livePreview = val;
livePreviewChB.setChecked(val);
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.setRoundBrushPickerListener ( RoundBrushPickerViewEventListener  l)
inline

Nastaví posluchače událostí.

Parameters
l

Definition at line 389 of file RoundBrushPickerView.java.

{
listener = l;
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.setSize ( int  size)
inline

Nastaví velikost aktuálně vybraného štětce.

Parameters
size

Definition at line 289 of file RoundBrushPickerView.java.

void mhr.appandroid.views.brushpicker.RoundBrushPickerView.setState ( int  size,
double  hardness 
)
inline

Nastaví stav - dle daných parametrů vytvoří jak nový štětec, tak je nastaví jako parametry starého štětce.

Parameters
size
hardness

Definition at line 360 of file RoundBrushPickerView.java.

{
oldParams.size = size;
oldParams.hardness = hardness;
newParams.size = size;
newParams.hardness = hardness;
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.setZoom ( double  zoom)
inline

Nastaví zoom náhledu.

Parameters
zoom

Definition at line 273 of file RoundBrushPickerView.java.

{
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.updateLabels ( )
inlineprotected

Aktualizuje popisky SeekBarů dle newBrushParams.

Definition at line 184 of file RoundBrushPickerView.java.

{
sizeTV.setText(Integer.toString(newParams.size));
hardnessTV.setText(Integer.toString((int) (newParams.hardness * 100 + 0.5)));
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.updateSeekBars ( )
inlineprotected

Nastaví SeekBary tak, aby odpovídaly newBrushParams.

Definition at line 176 of file RoundBrushPickerView.java.

{
hardnessSB.setProgress((int) (100 * newParams.hardness + 0.5));
sizeSB.setProgress((int) ((1000.0 / 3.0) * Math.log10(newParams.size) + 0.5));
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.updateStateFromParams ( )
inlineprotected

Aktualizuje cekový stav třídy dle hodnot newBrushParams.

Definition at line 261 of file RoundBrushPickerView.java.

{
recreateBrush(); // Toto se volá na začátku redraw
}
void mhr.appandroid.views.brushpicker.RoundBrushPickerView.updateStateFromSeekBars ( )
inlineprotected

Aktualizuje celkový stav třídy dle hodnot SeekBarů.

Definition at line 251 of file RoundBrushPickerView.java.

void mhr.appandroid.views.brushpicker.RoundBrushPickerView.updateValues ( )
inlineprotected

Nastaví newBrushParams dle hodnot na SeekBarech.

Definition at line 243 of file RoundBrushPickerView.java.

{
newParams.size = (int) (Math.pow(1000, sizeSB.getProgress() / 1000.0) + 0.5);
newParams.hardness = hardnessSB.getProgress() / 100.0;
}

Member Data Documentation

Button mhr.appandroid.views.brushpicker.RoundBrushPickerView.cancelBtn
protected

Definition at line 74 of file RoundBrushPickerView.java.

SeekBar mhr.appandroid.views.brushpicker.RoundBrushPickerView.hardnessSB
protected

Definition at line 71 of file RoundBrushPickerView.java.

TextView mhr.appandroid.views.brushpicker.RoundBrushPickerView.hardnessTV
protected

Definition at line 77 of file RoundBrushPickerView.java.

RoundBrushPickerViewEventListener mhr.appandroid.views.brushpicker.RoundBrushPickerView.listener = null
protected

Definition at line 83 of file RoundBrushPickerView.java.

boolean mhr.appandroid.views.brushpicker.RoundBrushPickerView.livePreview
protected

Udává, jestli má být dynamicky vytvářen náhled štětce, nebo má být náhled vytvořen až po dokončení volby uživatelem.

Definition at line 78 of file RoundBrushPickerView.java.

CheckBox mhr.appandroid.views.brushpicker.RoundBrushPickerView.livePreviewChB
protected

Definition at line 72 of file RoundBrushPickerView.java.

NBitmap mhr.appandroid.views.brushpicker.RoundBrushPickerView.newBrush = null
protected

Uživatelem právě vybraný štětec.

Definition at line 80 of file RoundBrushPickerView.java.

RoundBrushParams mhr.appandroid.views.brushpicker.RoundBrushPickerView.newParams = new RoundBrushParams()
protected

Parametry právě vybraného štětce.

Definition at line 82 of file RoundBrushPickerView.java.

RoundBrushParams mhr.appandroid.views.brushpicker.RoundBrushPickerView.oldParams = new RoundBrushParams()
protected

Parametry starého štětce, na které se uživatel vrátí, pokud stiskne cancelBtn.

Definition at line 81 of file RoundBrushPickerView.java.

NBitmap mhr.appandroid.views.brushpicker.RoundBrushPickerView.previewCanvas = null
protected

Canvas odpovídajícího MaskView, které zobrazuje náhled štětce.

Definition at line 79 of file RoundBrushPickerView.java.

MaskView mhr.appandroid.views.brushpicker.RoundBrushPickerView.previewMskV
protected

Definition at line 75 of file RoundBrushPickerView.java.

Button mhr.appandroid.views.brushpicker.RoundBrushPickerView.selectBtn
protected

Definition at line 73 of file RoundBrushPickerView.java.

SeekBar mhr.appandroid.views.brushpicker.RoundBrushPickerView.sizeSB
protected

Definition at line 70 of file RoundBrushPickerView.java.

TextView mhr.appandroid.views.brushpicker.RoundBrushPickerView.sizeTV
protected

Definition at line 76 of file RoundBrushPickerView.java.


The documentation for this class was generated from the following file: