App
Classes | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
mhr.appcore.image.layers.Layer Class Referenceabstract

Abstraktná třída definující obecné vlastnosti vrstvy. More...

Inheritance diagram for mhr.appcore.image.layers.Layer:
mhr.appcore.image.layers.ColorLayer mhr.appcore.image.layers.filter.FilterLayer mhr.appcore.image.layers.lut.LUTLayer mhr.appcore.image.layers.RasterLayer mhr.appcore.image.layers.filter.DifferenceOfGaussianSharpenFilterLayer mhr.appcore.image.layers.filter.GaussianBlurFilterLayer mhr.appcore.image.layers.filter.GaussianSharpenFilterLayer mhr.appcore.image.layers.filter.LaplaceSharpenFilterLayer mhr.appcore.image.layers.filter.LaplacianOfGaussianSharpenFilterLayer mhr.appcore.image.layers.lut.BrightnessLUTLayer mhr.appcore.image.layers.lut.ContrastLUTLayer mhr.appcore.image.layers.lut.CurvesLUTLayer mhr.appcore.image.layers.lut.GammaLUTLayer

Classes

class  FileConstants
 

Public Member Functions

 Layer (Image owner, int id)
 Defaultní konstruktor.
 
 Layer (Image owner, Element i, ImageFile f)
 
int dispose ()
 Provede uvolnění prostředků zabraných vrstvou.
 
abstract Layer duplicate (int newId)
 
void resizeTo (int nWidth, int nHeight, InterpolatorType iType, double force) throws BitmapAllocationException
 
void cropTo (Rect r)
 
void fillLayerElement (Document d, ImageFile f, Element e)
 
abstract LayerType getType ()
 Vrací typ vrstvy.
 
int getExtraMargin ()
 Vrací velikost okraje, který odpovídá okolí vrstvy, ze kterého vrstva při své aplikaci bere data.
 
int getId ()
 Vrací id vrstvy.
 
Depth getDepth ()
 Vrací bitovou hloubku vrstvy.
 
int getWidth ()
 Vrací šířku vrstvy v px.
 
int getHeight ()
 Vrací výšku vrstvy v px.
 
boolean isVisible ()
 Vrací viditelnost vrstvy.
 
void setVisible (boolean visible)
 nastavuje viditelnost vrstvy.
 
double getOpacity ()
 Vrací průhlednost vrstvy.
 
void setOpacity (double opacity)
 Nastavuje průhlednost vrstvy z intervalu 0..1.
 
NBitmap getMask (boolean forceCreate) throws UnsupportedBitmapException, BitmapAllocationException
 Vrací masku vrstvy.
 
boolean isMaskActive () throws IllegalStateException
 Vrací true, pokud je maska vrstvy aktivní.
 
void setMaskActive (boolean maskActive) throws UnsupportedBitmapException, BitmapAllocationException
 Zapne/vypne masku. Pokud maska zatím neexistuje, bude vytvořena.
 
void updateInfo (LayerPDInfo info)
 Vrstva nastaví paramtry v info tak, že ji budou reprezentovat.
 
abstract void updateFromSpecificPresentation (LayerPDInfo presentation)
 Odvozená třída v této metodě upraví svoje specifická data tak, aby odpovídala reprezentaci.
 
abstract int applyTo (NBitmap dst)
 Aplikuje vrstvu na danou bitmapu.
 
abstract int applyTo (NBitmap dst, Rect srcRect, int srcOrigX, int srcOrigY)
 Aplikuje výřez z vrstvy určený obdélníkem srcRect na odpovídající oblast bitmapy s počátkem v srcOrig.
 
abstract int applyTo (NBitmap dst, Rect srcRect, int srcOrigX, int srcOrigY, NBitmap mask)
 Aplikuje výřezz vrstvy určený obdélníkem srcRect na odpovídající oblast bitmapy s počátkem v srcOrig. Pokud vrstva vyžaduje použití masky, použije se jako náhrada maska mask.
 

Static Public Attributes

static final double opacityAsFull = 0.9999
 Maximální hodnota opacity, která se ještě aplikuje, vyšší je považované za 1 a volá se optimalizovaná funkce.
 
static final double opacityAsNone = 0.0001
 Minimální hodnota opacity, která se ještě aplikuje, nižší je považované za 0 a vrstva se neaplikuje.
 

Protected Member Functions

void finalize () throws Throwable
 
 Layer (Layer l, int newId)
 
void initMask () throws UnsupportedBitmapException, BitmapAllocationException
 Inicializuje masku vrstvy, pokud ještě neexistuje, bude vytvořena.
 
void appendLeafElement (Document d, Element parent, String eName, String eContetnt)
 
abstract void updateSpecificData (LayerPDInfo info)
 Odvozená třída musí v této metodě inicializovat specifická data své reprezentace tak, aby jí odpovídaly.
 
abstract void fillSpecificElement (Document d, ImageFile f, Element e)
 
void onCrop (Rect r)
 
void onResize (int nWidth, int nHeight, InterpolatorType iType, double force)
 

Protected Attributes

int id
 Id vrstvy, unikátní v rámci obrazu.
 
Image owner
 Obraz, který vlastní vrstvu.
 
Depth depth
 Barevná hloubka vrstvy, měla by odpovídat barevné hloubce obrazu...
 
int width
 Výška vrstvy v pixelech.
 
int height
 Šířka vrstvy v pixelech.
 
double opacity = 1
 Dodatečná alpha z intervalu 0..1.
 
boolean visible = true
 Viditelnost vrstvy.
 
NBitmap mask = null
 Maska vrstvy, vytvoří se až při prvním použití.
 
boolean maskActive = false
 Informace o tom, jestli je maska zapnutá.
 

Detailed Description

Abstraktná třída definující obecné vlastnosti vrstvy.

Definition at line 28 of file Layer.java.

Constructor & Destructor Documentation

mhr.appcore.image.layers.Layer.Layer ( Layer  l,
int  newId 
)
inlineprotected

Definition at line 79 of file Layer.java.

{
this.id = newId;
this.owner = l.owner;
this.depth = l.depth;
this.width = l.width;
this.height = l.height;
this.opacity = l.opacity;
this.visible = l.visible;
this.maskActive = l.maskActive;
if (l.mask != null) {
this.mask = new NBitmap(l.mask);
}
}
mhr.appcore.image.layers.Layer.Layer ( Image  owner,
int  id 
)
inline

Defaultní konstruktor.

   Defaultní konstruktor. Konstruktor, se stejnou signaturou musí implementovat všechny odvozené třídy a musí být schopen vytvořit vrstvu s defaultními parametry. Vrstva
   s defaultními parametry musí být neutrální, tedy její aplikací se nesmí změnit obraz.
Parameters
owner
id

Definition at line 102 of file Layer.java.

{
this.id = id;
this.owner = owner;
this.depth = owner.getDepth();
this.width = owner.getWidth();
}
mhr.appcore.image.layers.Layer.Layer ( Image  owner,
Element  i,
ImageFile  f 
)
inline

Definition at line 110 of file Layer.java.

{
FileConstants c = new FileConstants();
this.owner = owner;
this.depth = owner.getDepth();
boolean hasMask = false;
try {
id = Integer.parseInt(i.getElementsByTagName(c.ID_NODE).item(0).getTextContent());
width = Integer.parseInt(i.getElementsByTagName(c.WIDTH_NODE).item(0).getTextContent());
height = Integer.parseInt(i.getElementsByTagName(c.HEIGHT_NODE).item(0).getTextContent());
opacity = Double.parseDouble(i.getElementsByTagName(c.OPACITY_NODE).item(0).getTextContent());
visible = Boolean.parseBoolean(i.getElementsByTagName(c.LAYER_VISIBLE_NODE).item(0).getTextContent());
hasMask = Boolean.parseBoolean(i.getElementsByTagName(c.HAS_MASK_NODE).item(0).getTextContent());
} catch (NullPointerException e) {
throw new LayerCreationException(e);
}
PDBitmap tmpMask = null;
NBitmap tmp = null;
if (hasMask) {
try {
// initMask();
// tmpMask = f.loadMask(Integer.toString(id) + c.MASK_FILE_SUFFIX);
// tmp = new NBitmap(tmpMask);
// tmp.copyTo(mask, mask.getRect(), 0, 0);
// tmp.dispose();
// tmpMask.dispose();
// maskActive = Boolean.parseBoolean(i.getElementsByTagName(c.MASK_ACTIVE_NODE).item(0).getTextContent());
tmpMask = f.loadBitmap(Integer.toString(id) + c.MASK_FILE_SUFFIX);
tmp = new NBitmap(tmpMask);
mask = tmp.getChannel(3);
tmp.dispose();
tmpMask.dispose();
maskActive = Boolean.parseBoolean(i.getElementsByTagName(c.MASK_ACTIVE_NODE).item(0).getTextContent());
} catch (Exception e) {
if (tmp != null) {
tmp.dispose();
}
if (tmpMask != null) {
tmpMask.dispose();
}
throw new LayerCreationException(e);
}
}
}

Member Function Documentation

void mhr.appcore.image.layers.Layer.appendLeafElement ( Document  d,
Element  parent,
String  eName,
String  eContetnt 
)
inlineprotected

Definition at line 181 of file Layer.java.

{
Element e = d.createElement(eName);
e.setTextContent(eContetnt);
parent.appendChild(e);
}
abstract int mhr.appcore.image.layers.Layer.applyTo ( NBitmap  dst)
pure virtual
abstract int mhr.appcore.image.layers.Layer.applyTo ( NBitmap  dst,
Rect  srcRect,
int  srcOrigX,
int  srcOrigY 
)
pure virtual

Aplikuje výřez z vrstvy určený obdélníkem srcRect na odpovídající oblast bitmapy s počátkem v srcOrig.

Parameters
dst
srcRect
srcOrigX
srcOrigY
Returns

Implemented in mhr.appcore.image.layers.RasterLayer, mhr.appcore.image.layers.ColorLayer, mhr.appcore.image.layers.lut.LUTLayer, and mhr.appcore.image.layers.filter.FilterLayer.

abstract int mhr.appcore.image.layers.Layer.applyTo ( NBitmap  dst,
Rect  srcRect,
int  srcOrigX,
int  srcOrigY,
NBitmap  mask 
)
pure virtual

Aplikuje výřezz vrstvy určený obdélníkem srcRect na odpovídající oblast bitmapy s počátkem v srcOrig. Pokud vrstva vyžaduje použití masky, použije se jako náhrada maska mask.

Parameters
dst
srcRect
srcOrigX
srcOrigY
mask
Returns

Implemented in mhr.appcore.image.layers.RasterLayer, mhr.appcore.image.layers.ColorLayer, mhr.appcore.image.layers.filter.FilterLayer, and mhr.appcore.image.layers.lut.LUTLayer.

void mhr.appcore.image.layers.Layer.cropTo ( Rect  r)
inline

Definition at line 222 of file Layer.java.

{
if (mask != null) {
} else {
Rect crop = new Rect(r);
crop.cropBy(new Rect(width, height));
width = crop.getWidth();
height = crop.getHeight();
}
onCrop(r);
}
int mhr.appcore.image.layers.Layer.dispose ( )
inline

Provede uvolnění prostředků zabraných vrstvou.

Returns

Definition at line 159 of file Layer.java.

{
if (mask != null) {
mask = null;
}
return 0;
}
abstract Layer mhr.appcore.image.layers.Layer.duplicate ( int  newId)
pure virtual
void mhr.appcore.image.layers.Layer.fillLayerElement ( Document  d,
ImageFile  f,
Element  e 
)
inline

Definition at line 236 of file Layer.java.

{
FileConstants c = new FileConstants();
appendLeafElement(d, e, c.LAYER_TYPE_NODE, getType().toString());
Element li = d.createElement(c.LAYER_INFO_NODE);
e.appendChild(li);
appendLeafElement(d, li, c.ID_NODE, Integer.toString(id));
appendLeafElement(d, li, c.WIDTH_NODE, Integer.toString(width));
appendLeafElement(d, li, c.HEIGHT_NODE, Integer.toString(height));
appendLeafElement(d, li, c.OPACITY_NODE, Double.toString(opacity));
appendLeafElement(d, li, c.LAYER_VISIBLE_NODE, Boolean.toString(visible));
appendLeafElement(d, li, c.HAS_MASK_NODE, Boolean.toString(mask != null));
if (mask != null) {
PDBitmap tmpBitmap = f.createBitmap(new BitmapInfo(width, height, ChannelCount.SINGLE_CHANNEL, depth, ColorMode.MONO, false));
NBitmap tmpWrap = new NBitmap(tmpBitmap);
mask.copyTo(tmpWrap, mask.getRect(), 0, 0);
tmpWrap.dispose();
f.writeMask(tmpBitmap, Integer.toString(id) + c.MASK_FILE_SUFFIX);
tmpBitmap.dispose();
appendLeafElement(d, li, c.MASK_ACTIVE_NODE, Boolean.toString(maskActive));
}
Element lsd = d.createElement(c.LAYER_SPECIFIC_DATA_NODE);
e.appendChild(lsd);
fillSpecificElement(d, f, lsd);
}
abstract void mhr.appcore.image.layers.Layer.fillSpecificElement ( Document  d,
ImageFile  f,
Element  e 
)
protectedpure virtual
void mhr.appcore.image.layers.Layer.finalize ( ) throws Throwable
inlineprotected

Definition at line 74 of file Layer.java.

{
super.finalize();
}
Depth mhr.appcore.image.layers.Layer.getDepth ( )
inline

Vrací bitovou hloubku vrstvy.

Returns

Definition at line 287 of file Layer.java.

{
return depth;
}
int mhr.appcore.image.layers.Layer.getExtraMargin ( )
inline

Vrací velikost okraje, který odpovídá okolí vrstvy, ze kterého vrstva při své aplikaci bere data.

Returns

Definition at line 271 of file Layer.java.

{
return 0;
}
int mhr.appcore.image.layers.Layer.getHeight ( )
inline

Vrací výšku vrstvy v px.

Returns

Definition at line 303 of file Layer.java.

{
return height;
}
int mhr.appcore.image.layers.Layer.getId ( )
inline

Vrací id vrstvy.

Returns

Definition at line 279 of file Layer.java.

{
return id;
}
NBitmap mhr.appcore.image.layers.Layer.getMask ( boolean  forceCreate) throws UnsupportedBitmapException, BitmapAllocationException
inline

Vrací masku vrstvy.

Parameters
forceCreateParametr, jestli se má maska vytvořit, pokud neexistuje.
Returns
Exceptions
UnsupportedBitmapException
BitmapAllocationException

Definition at line 347 of file Layer.java.

{
if (forceCreate) {
}
return mask;
}
double mhr.appcore.image.layers.Layer.getOpacity ( )
inline

Vrací průhlednost vrstvy.

Returns

Definition at line 327 of file Layer.java.

{
return opacity;
}
abstract LayerType mhr.appcore.image.layers.Layer.getType ( )
pure virtual
int mhr.appcore.image.layers.Layer.getWidth ( )
inline

Vrací šířku vrstvy v px.

Returns

Definition at line 295 of file Layer.java.

{
return width;
}
void mhr.appcore.image.layers.Layer.initMask ( ) throws UnsupportedBitmapException, BitmapAllocationException
inlineprotected

Inicializuje masku vrstvy, pokud ještě neexistuje, bude vytvořena.

Exceptions
UnsupportedBitmapException
BitmapAllocationException

Definition at line 174 of file Layer.java.

{
if (mask == null) {
mask = new NBitmap(new BitmapInfo(width, height, ChannelCount.SINGLE_CHANNEL, depth, ColorMode.MONO, false));
mask.fill(mask.getRect(), 0x00);
}
}
boolean mhr.appcore.image.layers.Layer.isMaskActive ( ) throws IllegalStateException
inline

Vrací true, pokud je maska vrstvy aktivní.

Returns
Exceptions
IllegalStateException

Definition at line 359 of file Layer.java.

{
if (mask != null && maskActive) {
return true;
} else if (!maskActive) {
return false;
} else {
throw new IllegalStateException("Mask on but doesn't exist.");
}
}
boolean mhr.appcore.image.layers.Layer.isVisible ( )
inline

Vrací viditelnost vrstvy.

Returns

Definition at line 311 of file Layer.java.

{
return visible;
}
void mhr.appcore.image.layers.Layer.onCrop ( Rect  r)
inlineprotected

Definition at line 196 of file Layer.java.

{
}
void mhr.appcore.image.layers.Layer.onResize ( int  nWidth,
int  nHeight,
InterpolatorType  iType,
double  force 
)
inlineprotected

Definition at line 200 of file Layer.java.

{
}
void mhr.appcore.image.layers.Layer.resizeTo ( int  nWidth,
int  nHeight,
InterpolatorType  iType,
double  force 
) throws BitmapAllocationException
inline

Definition at line 207 of file Layer.java.

{
if (mask != null) {
NBitmap tmp = new NBitmap(new BitmapInfo(nWidth, nHeight, ChannelCount.SINGLE_CHANNEL, depth, ColorMode.MONO, false));
Interpolator.resampleTo(mask, tmp, iType, force);
mask = tmp;
}
width = nWidth;
height = nHeight;
onResize(nWidth, nHeight, iType, force);
}
void mhr.appcore.image.layers.Layer.setMaskActive ( boolean  maskActive) throws UnsupportedBitmapException, BitmapAllocationException
inline

Zapne/vypne masku. Pokud maska zatím neexistuje, bude vytvořena.

Parameters
maskActive
Exceptions
UnsupportedBitmapException
BitmapAllocationException

Definition at line 375 of file Layer.java.

{
if (maskActive) {
} else {
}
}
void mhr.appcore.image.layers.Layer.setOpacity ( double  opacity)
inline

Nastavuje průhlednost vrstvy z intervalu 0..1.

Parameters
opacity

Definition at line 335 of file Layer.java.

{
this.opacity = opacity;
}
void mhr.appcore.image.layers.Layer.setVisible ( boolean  visible)
inline

nastavuje viditelnost vrstvy.

Parameters
visible

Definition at line 319 of file Layer.java.

{
this.visible = visible;
}
abstract void mhr.appcore.image.layers.Layer.updateFromSpecificPresentation ( LayerPDInfo  presentation)
pure virtual
void mhr.appcore.image.layers.Layer.updateInfo ( LayerPDInfo  info)
inline

Vrstva nastaví paramtry v info tak, že ji budou reprezentovat.

Parameters
info

Definition at line 388 of file Layer.java.

{
info.id = id;
info.type = getType();
info.opacity = opacity;
info.visible = visible;
info.maskActive = maskActive;
info.isChanged = true;
if (mask != null) {
NBitmap mskThumbWrap = new NBitmap(info.getMaskThumb(true));
Interpolator.resampleTo(mask, mskThumbWrap);
mskThumbWrap.dispose();
}
}
abstract void mhr.appcore.image.layers.Layer.updateSpecificData ( LayerPDInfo  info)
protectedpure virtual

Member Data Documentation

Depth mhr.appcore.image.layers.Layer.depth
protected

Barevná hloubka vrstvy, měla by odpovídat barevné hloubce obrazu...

Definition at line 52 of file Layer.java.

int mhr.appcore.image.layers.Layer.height
protected

Šířka vrstvy v pixelech.

Definition at line 54 of file Layer.java.

int mhr.appcore.image.layers.Layer.id
protected

Id vrstvy, unikátní v rámci obrazu.

Definition at line 50 of file Layer.java.

NBitmap mhr.appcore.image.layers.Layer.mask = null
protected

Maska vrstvy, vytvoří se až při prvním použití.

Definition at line 66 of file Layer.java.

boolean mhr.appcore.image.layers.Layer.maskActive = false
protected

Informace o tom, jestli je maska zapnutá.

Definition at line 67 of file Layer.java.

double mhr.appcore.image.layers.Layer.opacity = 1
protected

Dodatečná alpha z intervalu 0..1.

Definition at line 55 of file Layer.java.

final double mhr.appcore.image.layers.Layer.opacityAsFull = 0.9999
static

Maximální hodnota opacity, která se ještě aplikuje, vyšší je považované za 1 a volá se optimalizovaná funkce.

Hodnota je více než dostačující pro 8bit. alphu, ale už plně nevystihuje rozlišovací schopnost 16bit. alphy.Macímální hodnota opacity, který se ještě aplikuje, vyžší je považované za 1

Definition at line 64 of file Layer.java.

final double mhr.appcore.image.layers.Layer.opacityAsNone = 0.0001
static

Minimální hodnota opacity, která se ještě aplikuje, nižší je považované za 0 a vrstva se neaplikuje.

Definition at line 65 of file Layer.java.

Image mhr.appcore.image.layers.Layer.owner
protected

Obraz, který vlastní vrstvu.

Definition at line 51 of file Layer.java.

boolean mhr.appcore.image.layers.Layer.visible = true
protected

Viditelnost vrstvy.

Definition at line 56 of file Layer.java.

int mhr.appcore.image.layers.Layer.width
protected

Výška vrstvy v pixelech.

Definition at line 53 of file Layer.java.


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