DLZone.h

Go to the documentation of this file.
00001 #ifndef _DLZONE_H_
00002 #define _DLZONE_H_
00003 
00004 #include "DLPage.h"
00005 #include "DLTagList.h"
00006 #include "DLImage.h"
00007 #include "DLPoint.h"
00008 #include "DLConst.h"
00009 #include "DLException.h"
00010 #include "DLLogger.h"
00011 
00012 #include <list>
00013 #include <string>
00014 
00015 using namespace std;
00016 
00017 class DLPage;
00018 
00074 class DLZone
00075 {
00076    friend class DLPage;
00077 
00078    public:
00079 
00086    typedef std::list <DLZone*>::iterator DLChildZonePtrIterator;
00087 
00092    DLChildZonePtrIterator begin() { return childZones.begin(); }
00093 
00101    DLChildZonePtrIterator end() { return childZones.end(); }
00102 
00107    bool dlIsZoneIteratorValid 
00108      (DLChildZonePtrIterator zoneIter)  ;
00109 
00113    DLZone();
00114 
00122    DLZone(int x, int y, int w, int h);
00123 
00129    DLZone(const DLPoint & upperleft, const DLPoint & lowerright);
00130 
00139    DLZone(const string &zoneID, int x, int y, int w, int h);
00140 
00158    DLZone(DLPage *parentPage, DLZone *parentZone, const string &zoneID, int x, int y, int w, int h);
00159 
00169    DLZone(const DLZone &right);
00170 
00174    virtual ~DLZone();
00175 
00182    virtual bool operator == (const DLZone &right) const;
00183 
00190    virtual bool operator < (const DLZone &right) const;
00191 
00202    virtual DLZone& operator=(const DLZone &right);
00203 
00208    string dlGetZoneID() const { return zoneID; };
00209 
00214    void dlSetZoneID(const string &ID) { zoneID = ID; };
00215 
00220    int dlGetZoneWidth() const { return width; };
00221 
00226    int dlGetZoneHeight() const { return height; };
00227 
00232    int  dlGetPageWidth() const;
00233 
00238    int  dlGetPageHeight() const;
00239 
00245    int  dlGetNumChildZones() const  { return static_cast<int>(childZones.size()); };
00246 
00251    bool dlHasChildZones() const { return (!childZones.empty()); };
00252 
00256    DLPoint dlGetZoneOrigin() const { return origin; };
00257 
00263    void dlSetZoneOrigin (int x, int y);
00264 
00271    void dlSetZoneOrigin (const DLPoint & origin);
00272 
00277    void dlSetZoneWidth(int w);
00278 
00283    void dlSetZoneHeight(int h);
00284 
00302    virtual void dlAppendChildZone(DLZone *childZone);
00303 
00310    virtual void dlAppendChildZoneCopy(const DLZone &childZone);
00311 
00320    virtual void dlAppendChildZoneList(list <DLZone*> childZoneList);
00321 
00330    virtual void dlInsertChildZone(DLChildZonePtrIterator childIter, DLZone *childZone);
00331 
00341    virtual void dlInsertChildZone(int cursorPosition, DLZone *childZone);
00342 
00348    virtual void dlInsertChildZoneCopy(DLChildZonePtrIterator childIter, const DLZone &childZone);
00349 
00356    virtual void dlInsertChildZoneCopy(int cursorPosition, const DLZone &childZone);
00357 
00363    virtual void dlInsertChildZoneList(DLChildZonePtrIterator childIter, list <DLZone*> childZoneList);
00364 
00373    virtual void dlInsertChildZoneList(int cursorPosition, list <DLZone*> childZoneList);
00374 
00379    virtual void dlDeleteChildZone(DLChildZonePtrIterator childIter);
00380 
00385    virtual void dlDeleteChildZone(int cursorPosition);
00386 
00392    virtual void dlDeleteChildZone(DLZone *deletedChildZone);
00393 
00397    virtual void dlClearChildZones();
00398 
00411    virtual DLZone* dlMergeZones(DLZone *Zone1, const string &newZoneID);
00412 
00421    virtual void dlMergeChildZones(DLZone *childZone1, DLZone *childZone2, const string &newZoneID);
00422 
00435    virtual void dlSplitZone(int offset, int direction, const string &childZoneID1, const string &childZoneID2);
00436 
00442    DLImage dlGetPageImage() const;
00443 
00449    DLImage dlGetZoneImage() const;
00450 
00457    DLZone * const dlGetParentZonePointer() const        {       return (DLZone * const)parentZone; };
00458 
00460 
00461 
00467    string dlGetTag(string tagKey) const;
00468 
00479    void dlSetTag(string tagKey, string tagValue, bool overwriteEnabled = false);
00480 
00485    void dlDeleteTag(string tagKey);
00486 
00490    void dlClearTags() { zoneTags.tagMap.clear(); };
00491 
00497    bool dlIsTagSet(string tagKey) const;
00498 
00502    bool dlIsTagListEmpty()  const { return zoneTags.tagMap.empty(); };
00503 
00508    DLTagList::iterator dlFindTag ( string tagKey ) { return zoneTags.tagMap.find(tagKey); }
00509  
00511 
00512    protected:
00513 
00514    string zoneID;
00515 
00516    DLPoint origin;
00517    int width, height;
00518 
00519    // list of attributes
00520    DLTagList zoneTags;
00521 
00522    // pointer to its page
00523    DLPage *zonePage;
00524 
00525    // pointer to parent zone, null if there is none
00526    DLZone *parentZone;
00527 
00528    // list of direct child zones
00529    list <DLZone*> childZones;
00530 
00531    // list of child zones whose DLZone *parentZone points to this zone
00532    // this enables the DLZone to keep track of its immediate child DLZones when its destructor is invoked
00533    list <DLZone*> childZoneBackPointers;
00534 
00542    DLZone* dlClone();
00543 
00554    void dlSetPagePointer(DLPage *parentPage);
00555 
00565    bool dlCheckZoneBoundaries(DLPoint zOrigin, int zWidth, int zHeight) const;
00566 
00574    bool dlCheckPagePointer() const;
00575 
00582    bool dlIsWithinPageBoundaries (int pageWidth, int pageHeight) const;
00583 
00584 }; //end class
00585 
00586 #endif // _DLZONE_H_

DOCLIB is being developed under contract by a collaboration between:
The Laboratory for Language and Media Processing
Unviersity of Maryland, College Park
and
Booz | Allen | Hamilton

All Rights Reserved, 2003-2007