App
Public Member Functions | Public Attributes | List of all members
mhr.appcore.utils.Rect Class Reference

Třída pro snadnou reprezentaci obdélníka a provádění elementárních operací s obdélníky. More...

Public Member Functions

 Rect ()
 Vytvoří obdélník s nulovou plochou v počátku.
 
 Rect (int tlx, int tly, int brx, int bry)
 vytvoří obdélník se zadanými parametry.
 
 Rect (int width, int height)
 Vytvoří obdélník s levým horním rohem v počátku a se zadanou výškou a šířkou.
 
 Rect (Rect other)
 kopírovací konstruktor.
 
int getWidth ()
 Vrátí šířku obdélníka.
 
int getHeight ()
 Vrátí výšku obdélníka.
 
Rect moveBy (int offsetX, int offsetY)
 Posune obdélník tak, že přičte daný offset k odpovídajícím souřadnicím. Vrací ukazatel na sebe.
 
Rect cover (Rect other)
 Rozšíří obdélník tak, že pokryje i obdélník other. Vrací ukazatel na sebe.
 
Rect cropBy (Rect other)
 Ořeže obdélník tak, že nebude přesahovat hranici obdélníka other. Vrací ukazatel na sebe.
 
Rect growBy (int dim)
 Zvětší obdélník o rozměr dim. na každé straně, vrátí ukazatel na sebe.
 
long getArea ()
 spočítá plochu obdélníka.
 

Public Attributes

int tlx
 Souřadnice levého horního rohu.
 
int tly
 Souřadnice levého horního rohu.
 
int brx
 Souřadnice pravého dolního rohu.
 
int bry
 Souřadnice pravého dolního rohu.
 

Detailed Description

Třída pro snadnou reprezentaci obdélníka a provádění elementárních operací s obdélníky.

Author
xxx

Definition at line 8 of file Rect.java.

Constructor & Destructor Documentation

mhr.appcore.utils.Rect.Rect ( )
inline

Vytvoří obdélník s nulovou plochou v počátku.

Definition at line 17 of file Rect.java.

{
tlx = 0;
tly = 0;
brx = 0;
bry = 0;
}
mhr.appcore.utils.Rect.Rect ( int  tlx,
int  tly,
int  brx,
int  bry 
)
inline

vytvoří obdélník se zadanými parametry.

Parameters
tlx
tly
brx
bry

Definition at line 31 of file Rect.java.

{
this.tlx = tlx;
this.tly = tly;
this.brx = brx;
this.bry = bry;
}
mhr.appcore.utils.Rect.Rect ( int  width,
int  height 
)
inline

Vytvoří obdélník s levým horním rohem v počátku a se zadanou výškou a šířkou.

Parameters
width
height

Definition at line 43 of file Rect.java.

{
tlx = 0;
tly = 0;
brx = width;
bry = height;
}
mhr.appcore.utils.Rect.Rect ( Rect  other)
inline

kopírovací konstruktor.

Parameters
other

Definition at line 54 of file Rect.java.

{
this.tlx = other.tlx;
this.tly = other.tly;
this.brx = other.brx;
this.bry = other.bry;
}

Member Function Documentation

Rect mhr.appcore.utils.Rect.cover ( Rect  other)
inline

Rozšíří obdélník tak, že pokryje i obdélník other. Vrací ukazatel na sebe.

Parameters
other
Returns

Definition at line 96 of file Rect.java.

{
tlx = (tlx < other.tlx) ? tlx : other.tlx;
tly = (tly < other.tly) ? tly : other.tly;
brx = (brx > other.brx) ? brx : other.brx;
bry = (bry > other.bry) ? bry : other.bry;
return this;
}
Rect mhr.appcore.utils.Rect.cropBy ( Rect  other)
inline

Ořeže obdélník tak, že nebude přesahovat hranici obdélníka other. Vrací ukazatel na sebe.

Parameters
other
Returns

Definition at line 109 of file Rect.java.

{
tlx = (tlx > other.tlx) ? tlx : other.tlx;
tly = (tly > other.tly) ? tly : other.tly;
brx = (brx < other.brx) ? brx : other.brx;
bry = (bry < other.bry) ? bry : other.bry;
return this;
}
long mhr.appcore.utils.Rect.getArea ( )
inline

spočítá plochu obdélníka.

Returns

Definition at line 134 of file Rect.java.

{
return getWidth() * getHeight();
}
int mhr.appcore.utils.Rect.getHeight ( )
inline

Vrátí výšku obdélníka.

Returns

Definition at line 73 of file Rect.java.

{
return bry - tly;
}
int mhr.appcore.utils.Rect.getWidth ( )
inline

Vrátí šířku obdélníka.

Returns

Definition at line 65 of file Rect.java.

{
return brx - tlx;
}
Rect mhr.appcore.utils.Rect.growBy ( int  dim)
inline

Zvětší obdélník o rozměr dim. na každé straně, vrátí ukazatel na sebe.

Parameters
dim
Returns

Definition at line 122 of file Rect.java.

{
tlx -= dim;
tly -= dim;
brx += dim;
bry += dim;
return this;
}
Rect mhr.appcore.utils.Rect.moveBy ( int  offsetX,
int  offsetY 
)
inline

Posune obdélník tak, že přičte daný offset k odpovídajícím souřadnicím. Vrací ukazatel na sebe.

Parameters
offsetX
offsetY
Returns

Definition at line 83 of file Rect.java.

{
tlx += offsetX;
tly += offsetY;
brx += offsetX;
bry += offsetY;
return this;
}

Member Data Documentation

int mhr.appcore.utils.Rect.brx

Souřadnice pravého dolního rohu.

Definition at line 11 of file Rect.java.

int mhr.appcore.utils.Rect.bry

Souřadnice pravého dolního rohu.

Definition at line 12 of file Rect.java.

int mhr.appcore.utils.Rect.tlx

Souřadnice levého horního rohu.

Definition at line 9 of file Rect.java.

int mhr.appcore.utils.Rect.tly

Souřadnice levého horního rohu.

Definition at line 10 of file Rect.java.


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