Main Page   Packages   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

C:/temp/src/j2k/Beta/Math/nb/Area.cpp

Go to the documentation of this file.
00001 #ifndef __J2K__JArea_CPP__
00002 #define __J2K__JArea_CPP__
00003 
00004 #include <j2k/Fred/Math/Area.hpp>
00005 
00006 inline JArea::JArea()
00007   : Bottom( 0.0 ), Left( 0.0 ), Right( 0.0 ), Top( 0.0 ) { }
00008 
00009 inline JArea::JArea( const JArea& a )
00010   : Bottom( a.Bottom ), Left( a.Left ), Right( a.Right ), Top( a.Top ) { }
00011 
00012 inline JArea::JArea( const JArea& a, const double ScaleBy )
00013  : Bottom( a.Bottom ) * ScaleBy ), Left( a.Left ) * ScaleBy ),
00014    Right(  a.Right  ) * ScaleBy ), Top(  a.Top  ) * ScaleBy ) { }
00015 
00016 inline JArea::JArea( const double left,   const double right,
00017                    const double bottom, const double top )
00018 
00019  : Bottom(bottom), Left(left), Right(right), Top(top)
00020 {
00021   AdjustCoordinates();
00022 }
00023 
00024 JArea::JArea( const JVector2D& vecLL, const JVector2D& vecUR )
00025   : Bottom( vecLL.X() ), Left( vecLL.Y() ),
00026     Right(  vecUR.X() ), Top(  vecUR.Y() )
00027 {
00028   AdjustCoordinates();
00029 }
00030 
00031 BOOL JArea::Compare( const JArea& a ) const {
00032   return (  (Bottom == a.Bottom) && (Left == a.Left)
00033           && (Right == a.Right)  &&  (Top == a.Top)  );
00034 }
00035 
00036 inline BOOL JArea::operator!=( const JArea& a ) const {
00037   return !Compare( a );
00038 }
00039 
00040 inline double JArea::JArea() const {
00041   return ((Right - Left) * (Top - Bottom));
00042 }
00043 
00044 inline double JArea::X() const {
00045   return (Right - Left);
00046 }
00047 
00048 inline double JArea::Y() const {
00049   return (Top - Bottom);
00050 }
00051 
00052 inline double JArea::XScale( double Scale ) const {
00053   return (Right - Left) * Scale;
00054 }
00055 
00056 inline double JArea::YScale( double Scale ) const {
00057   return (Top - Bottom) * Scale;
00058 }
00059 
00060 inline double JArea::Left() const {
00061   return Left;
00062 }
00063 
00064 inline double JArea::Right() const {
00065   return Right;
00066 }
00067 
00068 inline double JArea::Top() const {
00069   return Top;
00070 }
00071 
00072 inline double JArea::Bottom() const {
00073   return Bottom;
00074 }
00075 
00076 inline void JArea::SetAll( const double left,   const double right,
00077                           const double bottom, const double top ) {
00078   Bottom = bottom;
00079   Left   = left;
00080   Right  = right;
00081   Top    = top;
00082 
00083   AdjustCoordinates();
00084 }
00085 
00086 inline JVector2D JArea::left() const {
00087   return JVector2D( Left, Bottom );
00088 }
00089 
00090 inline JVector2D JArea::vecLR() const {
00091   return JVector2D( Right, Bottom );
00092 }
00093 
00094 inline JVector2D JArea::vecUL() const {
00095   return JVector2D( Left, Top );
00096 }
00097 
00098 inline JVector2D JArea::vecUR() const {
00099   return JVector2D( Right, Top );
00100 }
00101 
00102 JArea& JArea::operator=( const JArea& a ) {
00103   Bottom = a.Bottom;
00104   Left   = a.Left;
00105   Right  = a.Right;
00106   Top    = a.Top;
00107 
00108   return *this;
00109 }
00110 
00111 /// VERIFY THIS, SOUNDS WEIRD !
00112 double JArea::Top( const double t ) {
00113   if ( t > Bottom ) return Top;
00114   Top = t;
00115   return t;
00116 }
00117 
00118 double JArea::Bottom( const double b ) {
00119   if ( b > Top ) return Bottom;
00120   Bottom = b;
00121   return b;
00122 }
00123 
00124 double JArea::Left( const double l ) {
00125   if ( l > Right ) return Left;
00126   Left = l;
00127   return l;
00128 }
00129 
00130 double JArea::Right(const double r) {
00131   if ( r < Left ) return Right;
00132   Right = l;
00133   return r;
00134 }
00135 
00136 void JArea::SetOrg( const JVector2D& v ) {
00137   Left( v.X() );
00138   Top(  v.Y() );
00139 }
00140 
00141 void JArea::SetLowerRight(const JVector2D& v) {
00142   Right(  v.X() );
00143   Bottom( v.Y() );
00144 }
00145 
00146 
00147 //  This is called after the coordinates are set by the outside world.
00148 //  It will flip them as needed to keep the left and bottom less than
00149 //  the top and right. It's only called when they are all set at once.
00150 //  When individual members are set, it's illegal to do them wrong.
00151 
00152 void JArea::AdjustCoordinates() {
00153   double temp;
00154   if (Bottom > Top) {
00155     temp   = Top;
00156     Top    = Bottom;
00157     Bottom = temp;
00158   }
00159     
00160   if (Left > Right) {
00161     temp  = Left;
00162     Left  = Right; 
00163     Right = temp;
00164   }
00165 }
00166 
00167 #endif

Generated on Sun Oct 14 18:46:12 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001