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.imagepresentationview.ImagePresentationView Class Reference
Inheritance diagram for mhr.appandroid.views.imagepresentationview.ImagePresentationView:

## Classes
interface | OnImagePresentationEventListener

## Public Member Functions
Rect | getLayerPreviewRect ()
Rect | getMaskPreviewRect ()
void | setImagePresentation (PDImageDataPresentation img)
void | setOnLayerEventListener (OnImagePresentationEventListener listener)
| ImagePresentationView (Context context)
| ImagePresentationView (Context context, AttributeSet attrs)
| ImagePresentationView (Context context, AttributeSet attrs, int defStyle)
void | updateFromPresentation ()
boolean | onDrag (View v, DragEvent event)
void | onLayerViewEvent (LayerView v, ImagePresentationEvent e)
void | onClick (View v)
void | onProgressChanged (SeekBar seekBar, int progress, boolean fromUser)
void | onStartTrackingTouch (SeekBar seekBar)
void | onStopTrackingTouch (SeekBar seekBar)
void | onMasterMaskEvent (MasterMaskView v, ImagePresentationEvent e)
boolean | onMenuItemClick (MenuItem item)

## Protected Member Functions
void | init ()
void | createLayer (LayerType type)
LayerView.SelectedState | getLayerStateFromImageState (ImageSelectedState state)
void | recreateFromPresentation ()

## Protected Attributes
LinearLayout | layersContainer
Button | createLayerBtn
Button | mergeLayersBtn
PDImageDataPresentation | img
Rect | layerPreviewRect
Rect | maskPreviewRect
int | dragOrigIndex
MasterMaskView | masterMaskV
TextView | layerOpacityTV
SeekBar | layerOpacitySB
LayerView | selected
OnImagePresentationEventListener | listener = null
PopupMenu | popup

## Detailed Description

Definition at line 36 of file ImagePresentationView.java.

## Constructor & Destructor Documentation

mhr.appandroid.views.imagepresentationview.ImagePresentationView.ImagePresentationView | ( | Context | context | ) |
| inline

Definition at line 66 of file ImagePresentationView.java.

{
super(context);
init();
}

mhr.appandroid.views.imagepresentationview.ImagePresentationView.ImagePresentationView | ( | Context | context,
|  | AttributeSet | attrs
| ) |  |
| inline

Definition at line 71 of file ImagePresentationView.java.

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

mhr.appandroid.views.imagepresentationview.ImagePresentationView.ImagePresentationView | ( | Context | context,
|  | AttributeSet | attrs,
|  | int | defStyle
| ) |  |
| inline

Definition at line 76 of file ImagePresentationView.java.

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

## Member Function Documentation

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.createLayer | ( | LayerType | type | ) |
| inlineprotected

Definition at line 204 of file ImagePresentationView.java.

{
int overId = -1;
int atPos = 0;
if (selected != null) {
atPos = layersContainer.indexOfChild(selected);
overId = selected.layerId;
}
LayerView lv = new LayerView(getContext());
lv.setLayerViewEventListener(this);
layersContainer.addView(lv, atPos);
if (listener != null) {
listener.onImagePresentationEvent(new ImagePresentationEvent(EventType.LAYER_CREATED, overId, type));
}
}

Rect mhr.appandroid.views.imagepresentationview.ImagePresentationView.getLayerPreviewRect | ( |  | ) |
| inline

Definition at line 48 of file ImagePresentationView.java.

{
return new Rect(layerPreviewRect);
}

LayerView.SelectedState mhr.appandroid.views.imagepresentationview.ImagePresentationView.getLayerStateFromImageState | ( | ImageSelectedState | state | ) |
| inlineprotected

Definition at line 219 of file ImagePresentationView.java.

{
switch (state) {
case SELECTED_LAYER:
return SelectedState.SELECTED_LAYER;
case SELECTED_MASK:
return SelectedState.SELECTED_MASK;
default:
return SelectedState.SELECTED_NONE;
}
}

Rect mhr.appandroid.views.imagepresentationview.ImagePresentationView.getMaskPreviewRect | ( |  | ) |
| inline

Definition at line 52 of file ImagePresentationView.java.

{
return new Rect(maskPreviewRect);
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.init | ( |  | ) |
| inlineprotected

Definition at line 163 of file ImagePresentationView.java.

{
try {
((Activity) getContext()).getLayoutInflater().inflate(R.layout.view_image_presentation, 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;
}
layersContainer = (LinearLayout) findViewById(R.id.LayersContainerLL);
createLayerBtn = (Button) findViewById(R.id.ImageLayersViewCreateLayerBtn);
mergeLayersBtn = (Button) findViewById(R.id.ImageLayersViewMergeLayersBtn);
layerOpacitySB = (SeekBar) findViewById(R.id.LayerOpacityValueSB);
layerOpacityTV = (TextView) findViewById(R.id.LayerOpacityValueTV);
masterMaskV = (MasterMaskView) findViewById(R.id.ImagePresentationMasterMaskView);
masterMaskV.setMasterMaskEventListener(this);
layerOpacitySB.setOnSeekBarChangeListener(this);
layersContainer.setOnDragListener(this);
createLayerBtn.setOnClickListener(this);
mergeLayersBtn.setOnClickListener(this);
Resources r = getResources();
int size = r.getDimensionPixelSize(R.dimen.LayerThumbSize) - 2 * r.getDimensionPixelSize(R.dimen.LayerThumbPadding);
layerPreviewRect = new Rect(0, 0, size, size);
maskPreviewRect = layerPreviewRect;
popup = new PopupMenu(getContext(), createLayerBtn);
popup.inflate(R.menu.view_image_structure);
popup.setOnMenuItemClickListener(this);
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.onClick | ( | View | v | ) |
| inline

Definition at line 352 of file ImagePresentationView.java.

{
if (v == createLayerBtn) {
popup.show();
} else if (v == mergeLayersBtn) {
if (listener != null) {
listener.onImagePresentationEvent(new ImagePresentationEvent(EventType.IMAGE_MERGE_LAYERS, -1));
}
}
}

boolean mhr.appandroid.views.imagepresentationview.ImagePresentationView.onDrag | ( | View | v,
|  | DragEvent | event
| ) |  |
| inline

Definition at line 266 of file ImagePresentationView.java.

{
int action = event.getAction();
switch (event.getAction()) {
case DragEvent.ACTION_DRAG_STARTED:
dragOrigIndex = layersContainer.indexOfChild((View) event.getLocalState());
break;
case DragEvent.ACTION_DRAG_LOCATION: {
View dragged = (View) event.getLocalState();
int oldIndex = layersContainer.indexOfChild(dragged);
int h = dragged.getHeight();
int posOld = oldIndex * h + h / 2;
int posNew = (int) event.getY();
int newIndex = oldIndex + (posNew - posOld) / h;
if (oldIndex != newIndex) {
layersContainer.removeViewAt(oldIndex);
layersContainer.addView(dragged, newIndex);
}
break;
}
case DragEvent.ACTION_DROP: {
View dragged = (View) event.getLocalState();
int oldIndex = layersContainer.indexOfChild(dragged);
int h = dragged.getHeight();
int posOld = oldIndex * h + h / 2;
int posNew = (int) event.getY();
int newIndex = oldIndex + (posNew - posOld) / h;
if (oldIndex != newIndex) {
layersContainer.removeViewAt(oldIndex);
layersContainer.addView(dragged, newIndex);
}
if (newIndex != dragOrigIndex) {
if (listener != null) {
int beforeId = (newIndex > 0) ? ((LayerView) layersContainer.getChildAt(newIndex - 1)).layerId : -1;
listener.onImagePresentationEvent(new ImagePresentationEvent(EventType.LAYER_MOVED, ((LayerView) dragged).layerId, beforeId));
}
}
dragOrigIndex = -1;
}
break;
case DragEvent.ACTION_DRAG_ENDED:
if (dragOrigIndex >= 0) {
View dragged = (View) event.getLocalState();
int index = layersContainer.indexOfChild(dragged);
if (index != dragOrigIndex) {
layersContainer.removeViewAt(index);
layersContainer.addView(dragged, dragOrigIndex);
}
}
break;
default:
break;
}
return true;
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.onLayerViewEvent | ( | LayerView | v,
|  | ImagePresentationEvent | e
| ) |  |
| inline

Implements mhr.appandroid.views.imagepresentationview.LayerView.OnLayerViewEventListener.

Definition at line 324 of file ImagePresentationView.java.

{
switch (e.type) {
case LAYER_DELETED:
layersContainer.removeView(v);
break;
case LAYER_DUPLICATED:
int pos = layersContainer.indexOfChild(v);
LayerView lv = new LayerView(getContext());
lv.setLayerViewEventListener(this);
layersContainer.addView(lv, pos);
break;
case LAYER_SELECTED:
case LAYER_MASK_SELECTED:
if (selected != null && selected != v) {
masterMaskV.setState(false, masterMaskV.isApplied());
selected.setState(SelectedState.SELECTED_NONE);
selected = v;
}
break;
default:
break;
}
if (listener != null) {
listener.onImagePresentationEvent(e);
}
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.onMasterMaskEvent | ( | MasterMaskView | v,
|  | ImagePresentationEvent | e
| ) |  |
| inline

Implements mhr.appandroid.views.imagepresentationview.MasterMaskView.OnMasterMaskEventListener.

Definition at line 380 of file ImagePresentationView.java.

{
switch (e.type) {
case MASTER_MASK_APPLIED_CHANGED:
break;
case MASTER_MASK_SELECTED:
if (selected != null) {
selected.setState(SelectedState.SELECTED_NONE);
selected = null;
}
break;
default:
break;
}
if (listener != null) {
listener.onImagePresentationEvent(e);
}
}

boolean mhr.appandroid.views.imagepresentationview.ImagePresentationView.onMenuItemClick | ( | MenuItem | item | ) |
| inline

Definition at line 399 of file ImagePresentationView.java.

{
final int id = item.getItemId();
if (id == R.id.CreateRasterLayerPopUp) {
createLayer(LayerType.LAYER_RASTER);
} else if (id == R.id.CreateColorLayerPopUp) {
createLayer(LayerType.LAYER_COLOR);
} else if (id == R.id.BrightnessLUTLayerPopUp) {
createLayer(LayerType.LAYER_BRIGHTNESS);
} else if (id == R.id.ContrastLUTLayerPopUp) {
createLayer(LayerType.LAYER_CONTRAST);
} else if (id == R.id.GammaLUTLayerPopUp) {
createLayer(LayerType.LAYER_GAMMA);
} else if (id == R.id.CurvesLUTLayerPopUp) {
createLayer(LayerType.LAYER_CURVES);
} else if (id == R.id.GaussianBlurFilterLayerPopUp) {
createLayer(LayerType.LAYER_GAUSSIAN_BLUR);
} else if (id == R.id.LaplaceSharpenFilterLayerPopUp) {
createLayer(LayerType.LAYER_LAPLACE_SHARPEN);
} else if (id == R.id.GaussianSharpenFilterLayerPopUp) {
createLayer(LayerType.LAYER_GAUSSIAN_SHARPEN);
} else if (id == R.id.LaplacianOfGaussianSharpenFilterLayerPopUp) {
createLayer(LayerType.LAYER_LAPLACIAN_OF_GAUSSIAN_SHARPEN);
} else if (id == R.id.DifferenceOfGaussianSharpenFilterLayerPopUp) {
createLayer(LayerType.LAYER_DIFFERENCE_OF_GAUSSIAN_SHARPEN);
}
return true;
}

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

Definition at line 364 of file ImagePresentationView.java.

{
layerOpacityTV.setText(Integer.toString(progress));
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.onStartTrackingTouch | ( | SeekBar | seekBar | ) |
| inline

Definition at line 369 of file ImagePresentationView.java.

{
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.onStopTrackingTouch | ( | SeekBar | seekBar | ) |
| inline

Definition at line 373 of file ImagePresentationView.java.

{
if (listener != null) {
listener.onImagePresentationEvent(new ImagePresentationEvent(EventType.LAYER_OPACITY_CHANGED, selected.layerId, seekBar.getProgress() / 100.0));
}
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.recreateFromPresentation | ( |  | ) |
| inlineprotected

Neni prilis optimalizovana, je spise pro pripad, inicializace atd...

Definition at line 230 of file ImagePresentationView.java.

{
if (img == null) {
return;
}
selected = null;
layersContainer.removeAllViews();
layerOpacitySB.setEnabled(false);
synchronized (img) {
ArrayList<LayerPDInfo> layers = img.getLayers();
for (LayerPDInfo l : layers) {
LayerView v = new LayerView(getContext());
v.setLayerViewEventListener(this);
layersContainer.addView(v, 0);
v.presentLayer(l);
if (l.id == img.selectedLayerId) {
selected = v;
v.setState(getLayerStateFromImageState(img.selectedState));
layerOpacitySB.setEnabled(true);
layerOpacitySB.setProgress((int) (l.opacity * 100 + 0.5));
}
}
if (img.selectedState == ImageSelectedState.SELECTED_MASTER_MASK) {
selected = null;
masterMaskV.setState(true, img.masterMaskActive);
} else {
masterMaskV.setState(false, img.masterMaskActive);
}
APDBitmap mmsk = (APDBitmap) img.masterMask;
if (mmsk != null) {
masterMaskV.setMaskPreview(mmsk.getBitmap());
}
}
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.setImagePresentation | ( | PDImageDataPresentation | img | ) |
| inline

Definition at line 56 of file ImagePresentationView.java.

{
this.img = img;
recreateFromPresentation();
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.setOnLayerEventListener | ( | OnImagePresentationEventListener | listener | ) |
| inline

Definition at line 61 of file ImagePresentationView.java.

{
this.listener = listener;
}

void mhr.appandroid.views.imagepresentationview.ImagePresentationView.updateFromPresentation | ( |  | ) |
| inline

Definition at line 86 of file ImagePresentationView.java.

{
if (img == null) {
return;
}
if (selected != null) {
selected.setState(SelectedState.SELECTED_NONE);
}
selected = null;
layerOpacitySB.setEnabled(false);
synchronized (img) {
ArrayList<LayerPDInfo> layers = img.getLayers();
int avViewsCount = layersContainer.getChildCount();
int reqViewsCount = layers.size();
int deltaViews = avViewsCount - reqViewsCount;
if (deltaViews > 0) {
for (int i = 0; i < deltaViews; i++) {
layersContainer.removeViewAt(0); // Odeberu na začátku, tedy ty zobrazené nahoře
}
} else {
deltaViews = -deltaViews;
for (int i = 0; i < deltaViews; i++) {
LayerView v = new LayerView(getContext());
v.setLayerViewEventListener(this);
layersContainer.addView(v, 0); // Přidávám na začátek, tedy zobrazené nahoře
}
}
int inversion = layersContainer.getChildCount() - 1;
for (int i = 0; i < reqViewsCount; i++) {
LayerPDInfo inf = layers.get(i);
// LV se samo stará, jesltli se potřebuje změnit... dle id, a isChanged
// Beru od zadu, tedy předpokládám, že první inf je poslední v layersContaineru
LayerView lv = (LayerView) layersContainer.getChildAt(inversion - i);
if (inf.id == img.selectedLayerId) {
selected = lv;
lv.setState(getLayerStateFromImageState(img.selectedState));
layerOpacitySB.setEnabled(true);
layerOpacitySB.setProgress((int) (inf.opacity * 100 + 0.5));
}
lv.presentLayer(inf);
}
if (img.selectedState == ImageSelectedState.SELECTED_MASTER_MASK) {
selected = null;
masterMaskV.setState(true, img.masterMaskActive);
} else {
masterMaskV.setState(false, img.masterMaskActive);
}
APDBitmap mmsk = (APDBitmap) img.masterMask;
if (mmsk != null) {
masterMaskV.setMaskPreview(mmsk.getBitmap());
}
}
}

## Member Data Documentation

Button mhr.appandroid.views.imagepresentationview.ImagePresentationView.createLayerBtn
| protected

Definition at line 144 of file ImagePresentationView.java.

int mhr.appandroid.views.imagepresentationview.ImagePresentationView.dragOrigIndex
| protected

Definition at line 149 of file ImagePresentationView.java.

PDImageDataPresentation mhr.appandroid.views.imagepresentationview.ImagePresentationView.img
| protected

Definition at line 146 of file ImagePresentationView.java.

SeekBar mhr.appandroid.views.imagepresentationview.ImagePresentationView.layerOpacitySB
| protected

Definition at line 154 of file ImagePresentationView.java.

TextView mhr.appandroid.views.imagepresentationview.ImagePresentationView.layerOpacityTV
| protected

Definition at line 153 of file ImagePresentationView.java.

Rect mhr.appandroid.views.imagepresentationview.ImagePresentationView.layerPreviewRect
| protected

Definition at line 147 of file ImagePresentationView.java.

LinearLayout mhr.appandroid.views.imagepresentationview.ImagePresentationView.layersContainer
| protected

Definition at line 143 of file ImagePresentationView.java.

OnImagePresentationEventListener mhr.appandroid.views.imagepresentationview.ImagePresentationView.listener = null
| protected

Definition at line 157 of file ImagePresentationView.java.

Rect mhr.appandroid.views.imagepresentationview.ImagePresentationView.maskPreviewRect
| protected

Definition at line 148 of file ImagePresentationView.java.

MasterMaskView mhr.appandroid.views.imagepresentationview.ImagePresentationView.masterMaskV
| protected

Definition at line 151 of file ImagePresentationView.java.

Button mhr.appandroid.views.imagepresentationview.ImagePresentationView.mergeLayersBtn
| protected

Definition at line 145 of file ImagePresentationView.java.

PopupMenu mhr.appandroid.views.imagepresentationview.ImagePresentationView.popup
| protected

Definition at line 159 of file ImagePresentationView.java.

LayerView mhr.appandroid.views.imagepresentationview.ImagePresentationView.selected
| protected

Definition at line 156 of file ImagePresentationView.java.

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

- /home/xxx/eclipse_workspaces/app/appandroid/src/mhr/appandroid/views/imagepresentationview/ImagePresentationView.java