App

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mhr.appandroid.views.pathpicker.PathPickerView Class Reference

Jednoduchý picker, ketrý ze zadaného štětce vytvoří náhled stopy. More...

Inheritance diagram for mhr.appandroid.views.pathpicker.PathPickerView:

## Classes
class | PathParams
| Pomocná třída jen pro snadnou práci s parametry cesty. More...
enum | PathPickerEvent
| Výčet udávající typ události. More...
interface | PathPickerViewEventListener
| Interface pro posluchače událostí. More...
enum | redrawScope
| Udává, co všechnose má na náhledu překreslit. More...

## Public Member Functions
| PathPickerView (Context context)
| PathPickerView (Context context, AttributeSet attrs)
| PathPickerView (Context context, AttributeSet attrs, int defStyle)
void | setZoom (double zoom)
| Nastaví zoom náhledu.
double | getZoom ()
| Vrátí zoom náhledu.
void | setPathParams (PathParams params)
| Nastaví parametry aktuálně vybrané stopy.
PathParams | getNewPathParams ()
| Vrátí parametry aktuálně vybrané stopy.
PathParams | getOldPathParams ()
| Vrátí parametry předchozí stopy (poslední potvrzené).
void | setState (PathParams params)
| Nataví parametry aktuálně vybrané i předchozí stopy na params.
void | setBrush (NBitmap brush)
| Vytvoří kopii brush a tu nastaví jako masku štětce, která se použije pro náhled stopy.
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 stopy.
boolean | isLivePreviewOn ()
| Vrátí stav LivePreview.
void | setLivePreviewOn (boolean val)
| Nastaví hodnotu LivePreview.
void | setPathPickerListener (PathPickerViewEventListener l)
| Nastaví posluchače událostí.
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 | redrawPath (redrawScope scope)
| Znovu vykreslí stopu tak, aby odpovídal newParams.
boolean | initPreviewCanvas (MaskView view)
| Pokusí se o inicializaci Canvasu pro zobrazení štětce, informuje o úspěchu.
redrawScope | updateValues ()
| Nastaví newBrushParams dle hodnot na SeekBarech.
void | updateLabels ()
| Aktualizuje popisky SeekBarů dle newBrushParams.
void | updateStateFromSeekbars (redrawScope forceParam)
| Aktualizuje celkový stav třídy dle hodnot SeekBarů.
void | updateStateFromParams ()
| Aktualizuje cekový stav třídy dle hodnot newBrushParams.

## Protected Attributes
SeekBar | opacitySB
SeekBar | flowSB
SeekBar | spacingSB
CheckBox | livePreviewChB
Button | selectBtn
Button | cancelBtn
MaskView | previewMskV
TextView | opacityTV
TextView | flowTV
TextView | spacingTV
boolean | livePreviewOn
| Udává, jestli má být dynamicky vytvářen náhled stopy, 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 stopy.
NBitmap | brush = null
| Štětec, který se použije k náhledu stopy.
PathParams | oldParams = new PathParams()
| Parametry předchozí potvrzené stopy.
PathParams | newParams = new PathParams()
| Parametry aktuálně vybrané stopy.
PathPickerViewEventListener | listener = null

## Detailed Description

Jednoduchý picker, ketrý ze zadaného štětce vytvoří náhled stopy.

Definition at line 40 of file PathPickerView.java.

## Constructor & Destructor Documentation

mhr.appandroid.views.pathpicker.PathPickerView.PathPickerView | ( | Context | context | ) |
| inline

Definition at line 192 of file PathPickerView.java.

{
super(context);
init();
}

mhr.appandroid.views.pathpicker.PathPickerView.PathPickerView | ( | Context | context,
|  | AttributeSet | attrs
| ) |  |
| inline

Definition at line 197 of file PathPickerView.java.

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

mhr.appandroid.views.pathpicker.PathPickerView.PathPickerView | ( | Context | context,
|  | AttributeSet | attrs,
|  | int | defStyle
| ) |  |
| inline

Definition at line 202 of file PathPickerView.java.

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

## Member Function Documentation

PathParams mhr.appandroid.views.pathpicker.PathPickerView.getNewPathParams | ( |  | ) |
| inline

Vrátí parametry aktuálně vybrané stopy.

Returns

Definition at line 369 of file PathPickerView.java.

{
return new PathParams(newParams);
}

PathParams mhr.appandroid.views.pathpicker.PathPickerView.getOldPathParams | ( |  | ) |
| inline

Vrátí parametry předchozí stopy (poslední potvrzené).

Returns

Definition at line 377 of file PathPickerView.java.

{
return new PathParams(newParams);
}

Paint mhr.appandroid.views.pathpicker.PathPickerView.getPreviewBackground | ( |  | ) |
| inline

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

Returns

Definition at line 408 of file PathPickerView.java.

{
return previewMskV.getMaskViewBackground();
}

Paint mhr.appandroid.views.pathpicker.PathPickerView.getPreviewForeground | ( |  | ) |
| inline

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

Returns

Definition at line 416 of file PathPickerView.java.

{
return previewMskV.getMaskViewForeground();
}

double mhr.appandroid.views.pathpicker.PathPickerView.getZoom | ( |  | ) |
| inline

Vrátí zoom náhledu.

Returns

Definition at line 352 of file PathPickerView.java.

{
return previewMskV.getZoom();
}

void mhr.appandroid.views.pathpicker.PathPickerView.init | ( |  | ) |
| inlineprotected

Provede inicializaci třídy.

Definition at line 133 of file PathPickerView.java.

{
try {
((Activity) getContext()).getLayoutInflater().inflate(R.layout.view_path_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
opacitySB = (SeekBar) findViewById(R.id.OpacityValueSB);
flowSB = (SeekBar) findViewById(R.id.FlowValueSB);
spacingSB = (SeekBar) findViewById(R.id.SpacingValueSB);
livePreviewChB = (CheckBox) findViewById(R.id.PathLivePreviewChckB);
opacityTV = (TextView) findViewById(R.id.OpacityValueTV);
flowTV = (TextView) findViewById(R.id.FlowValueTV);
spacingTV = (TextView) findViewById(R.id.SpacingValueTV);
previewMskV = (MaskView) findViewById(R.id.PathPreviewMskV);
selectBtn = (Button) findViewById(R.id.PathPickerSelectBtn);
cancelBtn = (Button) findViewById(R.id.PathPickerCancelBtn);
// Inicializace stavu třídy
livePreviewOn = livePreviewChB.isChecked();
// Nastavení vzhledu komponent
BitmapShader bsh = new BitmapShader(BitmapFactory.decodeResource(getResources(), R.drawable.checkboard), TileMode.REPEAT, TileMode.REPEAT);
previewMskV.getMaskViewBackground().setShader(bsh);
// Nastavení sebe jako posluchačů příslušných událostí.
opacitySB.setOnSeekBarChangeListener(this);
flowSB.setOnSeekBarChangeListener(this);
spacingSB.setOnSeekBarChangeListener(this);
previewMskV.setOnMaskCanvasChangedListener(this);
livePreviewChB.setOnCheckedChangeListener(this);
selectBtn.setOnClickListener(this);
cancelBtn.setOnClickListener(this);
updateLabels();
updateSeekBars();
brush = BrushGenerator.createRoundBrush(10, 0.5, Depth.DEPTH_8_BIT);
}

boolean mhr.appandroid.views.pathpicker.PathPickerView.initPreviewCanvas | ( | MaskView | view | ) |
| inlineprotected

Pokusí se o inicializaci Canvasu 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 266 of file PathPickerView.java.

{
if (previewCanvas != null) {
previewCanvas.dispose();
previewCanvas = null;
}
APDBitmap maskCanvas = view.getMaskCanvas();
if (maskCanvas == null) {
return false;
} else {
previewCanvas = new NBitmap(maskCanvas);
return true;
}
}

boolean mhr.appandroid.views.pathpicker.PathPickerView.isLivePreviewOn | ( |  | ) |
| inline

Vrátí stav LivePreview.

Returns

Definition at line 424 of file PathPickerView.java.

{
return livePreviewOn;
}

void mhr.appandroid.views.pathpicker.PathPickerView.onCheckedChanged | ( | CompoundButton | buttonView,
|  | boolean | isChecked
| ) |  |
| inline

Definition at line 486 of file PathPickerView.java.

{
livePreviewOn = isChecked;
if (listener != null) {
listener.onPathPickerEvent(PathPickerEvent.EVENT_LIVE_PREVIEW_STATE_CHANGED, this);
}
}

void mhr.appandroid.views.pathpicker.PathPickerView.onClick | ( | View | v | ) |
| inline

Definition at line 494 of file PathPickerView.java.

{
if (v == selectBtn) {
oldParams = new PathParams(newParams);
if (listener != null) {
listener.onPathPickerEvent(PathPickerEvent.EVENT_SELECTED, this);
}
} else if (v == cancelBtn) {
newParams = new PathParams(oldParams);
updateSeekBars();
updateStateFromSeekbars(redrawScope.REDRAW_ALL);
if (listener != null) {
listener.onPathPickerEvent(PathPickerEvent.EVENT_CHANGED, this);
}
if (listener != null) {
listener.onPathPickerEvent(PathPickerEvent.EVENT_CANCELED, this);
}
}
}

void mhr.appandroid.views.pathpicker.PathPickerView.onDetachedFromWindow | ( |  | ) |
| inlineprotected

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

Definition at line 180 of file PathPickerView.java.

{
if (previewCanvas != null) {
previewCanvas.dispose();
previewCanvas = null;
}
if (brush != null) {
brush.dispose();
brush = null;
}
}

void mhr.appandroid.views.pathpicker.PathPickerView.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 480 of file PathPickerView.java.

{
initPreviewCanvas(previewMskV);
redrawPath(redrawScope.REDRAW_ALL);
}

void mhr.appandroid.views.pathpicker.PathPickerView.onProgressChanged | ( | SeekBar | seekBar,
|  | int | progress,
|  | boolean | fromUser
| ) |  |
| inline

Definition at line 446 of file PathPickerView.java.

{
if (fromUser) {
if (livePreviewOn) {
updateStateFromSeekbars(null);
} else {
updateValues();
updateLabels();
}
if (listener != null) {
listener.onPathPickerEvent(PathPickerEvent.EVENT_CHANGED, this);
}
}
}

void mhr.appandroid.views.pathpicker.PathPickerView.onStartTrackingTouch | ( | SeekBar | seekBar | ) |
| inline

Definition at line 461 of file PathPickerView.java.

{
// Nepouzity callback
}

void mhr.appandroid.views.pathpicker.PathPickerView.onStopTrackingTouch | ( | SeekBar | seekBar | ) |
| inline

Definition at line 466 of file PathPickerView.java.

{
if (!livePreviewOn) {
if (seekBar == opacitySB) {
updateStateFromSeekbars(redrawScope.REDRAW_JUST_OPACITY); // Hypoteticky může zbytečně překreslit stejnou stoupu
} else {
updateStateFromSeekbars(redrawScope.REDRAW_ALL);
}
if (listener != null) {
listener.onPathPickerEvent(PathPickerEvent.EVENT_CHANGED, this);
}
}
}

void mhr.appandroid.views.pathpicker.PathPickerView.redrawPath | ( | redrawScope | scope | ) |
| inlineprotected

Znovu vykreslí stopu tak, aby odpovídal newParams.

Definition at line 222 of file PathPickerView.java.

{
if (brush == null) {
return;
}
if (previewCanvas == null) {
if (!initPreviewCanvas(previewMskV)) {
return;
}
}
if (scope == redrawScope.REDRAW_NONE) {
return;
}
previewMskV.getMaskViewForeground().setAlpha((int) (newParams.opacity * 255 / 100.0 + 0.5));
if (scope == redrawScope.REDRAW_JUST_OPACITY) {
previewMskV.invalidate();
return;
}
previewCanvas.fill(previewCanvas.getRect(), 0x00);
int cw = previewCanvas.getWidth();
int tly = (previewCanvas.getHeight() - brush.getHeight()) / 2;
int bw = brush.getWidth();
int space = (int) (bw * newParams.spacing / 100.0 + 0.5);
if (space < 1) {
space = 1;
}
Rect brushRect = brush.getRect();
double flow = newParams.flow / 100.0;
int iMax = cw - bw;
for (int i = 0; i <= iMax; i += space) {
Blender.addTo(previewCanvas, brush, brushRect, i, tly, flow);
}
previewMskV.invalidate();
}

void mhr.appandroid.views.pathpicker.PathPickerView.setBrush | ( | NBitmap | brush | ) |
| inline

Vytvoří kopii brush a tu nastaví jako masku štětce, která se použije pro náhled stopy.

Parameters

  brush |

Definition at line 395 of file PathPickerView.java.

{
if (this.brush != null) {
this.brush.dispose();
this.brush = null;
}
this.brush = new NBitmap(brush);
redrawPath(redrawScope.REDRAW_ALL);
}

void mhr.appandroid.views.pathpicker.PathPickerView.setLivePreviewOn | ( | boolean | val | ) |
| inline

Nastaví hodnotu LivePreview.

Parameters

  val |

Definition at line 432 of file PathPickerView.java.

{
livePreviewOn = val;
livePreviewChB.setChecked(val);
}

void mhr.appandroid.views.pathpicker.PathPickerView.setPathParams | ( | PathParams | params | ) |
| inline

Nastaví parametry aktuálně vybrané stopy.

Parameters

  params |

Definition at line 360 of file PathPickerView.java.

{
newParams = new PathParams(params);
updateStateFromParams();
}

void mhr.appandroid.views.pathpicker.PathPickerView.setPathPickerListener | ( | PathPickerViewEventListener | l | ) |
| inline

Nastaví posluchače událostí.

Parameters

  l |

Definition at line 441 of file PathPickerView.java.

{
listener = l;
}

void mhr.appandroid.views.pathpicker.PathPickerView.setState | ( | PathParams | params | ) |
| inline

Nataví parametry aktuálně vybrané i předchozí stopy na params.

Parameters

  params |

Definition at line 385 of file PathPickerView.java.

{
newParams = new PathParams(params);
oldParams = new PathParams(params);
updateStateFromParams();
}

void mhr.appandroid.views.pathpicker.PathPickerView.setZoom | ( | double | zoom | ) |
| inline

Nastaví zoom náhledu.

Parameters

  zoom |

Definition at line 344 of file PathPickerView.java.

{
previewMskV.setZoom(zoom);
}

void mhr.appandroid.views.pathpicker.PathPickerView.updateLabels | ( |  | ) |
| inlineprotected

Aktualizuje popisky SeekBarů dle newBrushParams.

Definition at line 309 of file PathPickerView.java.

{
opacityTV.setText(Integer.toString(newParams.opacity));
flowTV.setText(Integer.toString(newParams.flow));
spacingTV.setText(Integer.toString(newParams.spacing));
}

void mhr.appandroid.views.pathpicker.PathPickerView.updateSeekBars | ( |  | ) |
| inlineprotected

Nastaví SeekBary tak, aby odpovídaly newBrushParams.

Definition at line 213 of file PathPickerView.java.

{
opacitySB.setProgress(newParams.opacity);
flowSB.setProgress(newParams.flow);
spacingSB.setProgress((int) ((500.0 / 3.0) * Math.log10(newParams.spacing) + 0.5));
}

void mhr.appandroid.views.pathpicker.PathPickerView.updateStateFromParams | ( |  | ) |
| inlineprotected

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

Definition at line 332 of file PathPickerView.java.

{
updateSeekBars();
redrawPath(redrawScope.REDRAW_ALL);
updateLabels();
}

void mhr.appandroid.views.pathpicker.PathPickerView.updateStateFromSeekbars | ( | redrawScope | forceParam | ) |
| inlineprotected

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

Definition at line 318 of file PathPickerView.java.

{
if (forceParam != null) {
updateValues();
redrawPath(forceParam);
updateLabels();
} else {
redrawPath(updateValues());
updateLabels();
}
}

redrawScope mhr.appandroid.views.pathpicker.PathPickerView.updateValues | ( |  | ) |
| inlineprotected

Nastaví newBrushParams dle hodnot na SeekBarech.

Definition at line 283 of file PathPickerView.java.

{
redrawScope scope = redrawScope.REDRAW_NONE;
int tmp;
tmp = newParams.opacity;
newParams.opacity = opacitySB.getProgress();
if (tmp != newParams.opacity) {
scope = redrawScope.REDRAW_JUST_OPACITY;
}
tmp = newParams.flow;
newParams.flow = flowSB.getProgress();
if (tmp != newParams.flow) {
scope = redrawScope.REDRAW_ALL;
}
tmp = newParams.spacing;
newParams.spacing = (int) (Math.pow(500, spacingSB.getProgress() / 500.0) + 0.5);
if (tmp != newParams.spacing) {
scope = redrawScope.REDRAW_ALL;
}
return scope;
}

## Member Data Documentation

NBitmap mhr.appandroid.views.pathpicker.PathPickerView.brush = null
| protected

Štětec, který se použije k náhledu stopy.

Definition at line 119 of file PathPickerView.java.

Button mhr.appandroid.views.pathpicker.PathPickerView.cancelBtn
| protected

Definition at line 108 of file PathPickerView.java.

SeekBar mhr.appandroid.views.pathpicker.PathPickerView.flowSB
| protected

Definition at line 104 of file PathPickerView.java.

TextView mhr.appandroid.views.pathpicker.PathPickerView.flowTV
| protected

Definition at line 112 of file PathPickerView.java.

PathPickerViewEventListener mhr.appandroid.views.pathpicker.PathPickerView.listener = null
| protected

Definition at line 124 of file PathPickerView.java.

CheckBox mhr.appandroid.views.pathpicker.PathPickerView.livePreviewChB
| protected

Definition at line 106 of file PathPickerView.java.

boolean mhr.appandroid.views.pathpicker.PathPickerView.livePreviewOn
| protected

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

Definition at line 115 of file PathPickerView.java.

PathParams mhr.appandroid.views.pathpicker.PathPickerView.newParams = new PathParams()
| protected

Parametry aktuálně vybrané stopy.

Definition at line 122 of file PathPickerView.java.

PathParams mhr.appandroid.views.pathpicker.PathPickerView.oldParams = new PathParams()
| protected

Parametry předchozí potvrzené stopy.

Definition at line 121 of file PathPickerView.java.

SeekBar mhr.appandroid.views.pathpicker.PathPickerView.opacitySB
| protected

Definition at line 103 of file PathPickerView.java.

TextView mhr.appandroid.views.pathpicker.PathPickerView.opacityTV
| protected

Definition at line 111 of file PathPickerView.java.

NBitmap mhr.appandroid.views.pathpicker.PathPickerView.previewCanvas = null
| protected

Canvas odpovídajícího MaskView, které zobrazuje náhled stopy.

Definition at line 117 of file PathPickerView.java.

MaskView mhr.appandroid.views.pathpicker.PathPickerView.previewMskV
| protected

Definition at line 110 of file PathPickerView.java.

Button mhr.appandroid.views.pathpicker.PathPickerView.selectBtn
| protected

Definition at line 107 of file PathPickerView.java.

SeekBar mhr.appandroid.views.pathpicker.PathPickerView.spacingSB
| protected

Definition at line 105 of file PathPickerView.java.

TextView mhr.appandroid.views.pathpicker.PathPickerView.spacingTV
| protected

Definition at line 113 of file PathPickerView.java.

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

- /home/xxx/eclipse_workspaces/app/appandroid/src/mhr/appandroid/views/pathpicker/PathPickerView.java