Marmot
Public Member Functions
Marmot::Common::Page::Page Class Reference

Logical page. More...

List of all members.

Public Member Functions

def __init__
def setPageNum
 Set page number attribute of current page.
def getPageNum
 See getPageNum.
def setPageType
 Set page type attribute of current page.
def getPageType
 See setPageType.
def setCropBox
 Set display area of current page.
def getCropBox
 See setCropBox.
def getByLid
 Return content with a certain lid.
def getByPid
 Return leaf content with a certain pid.
def getByLabel
 Return contents with a certain label.
def count
def create
 Create a new content object.
def delete
 Wipe the object with logical ID lid out of this page.
def attach
 Attach children to parent.
def detach
 Detach children from parent.
def update
 Update a content node.
def lidToPids
 Maps logical ID of an object to physical ID's contained in it.
def labelToPids
 Maps label to pids, no order garanteed.
def lidToAncestors
 Given a logical id, return a content list of its ancestors.

Detailed Description

Logical page.

This class is a container of contents.

Remarks:
Contents are created _inside_ the Page object, and should be deleted _inside_ the Page object.
An instance of Page class stores the

lidIndex: {lid: content}
pidIndex: {pid: content}
labelIndex: {label: [lid]}

relations.


Member Function Documentation

def Marmot::Common::Page::Page::setPageNum (   self,
  pgno 
)

Set page number attribute of current page.

def Marmot::Common::Page::Page::getPageNum (   self)

See getPageNum.

def Marmot::Common::Page::Page::setPageType (   self,
  pgtype 
)

Set page type attribute of current page.

def Marmot::Common::Page::Page::getPageType (   self)

See setPageType.

def Marmot::Common::Page::Page::setCropBox (   self,
  cropbox 
)

Set display area of current page.

Remarks:
The origin is the left-bottom corner of display area.
def Marmot::Common::Page::Page::getCropBox (   self)

See setCropBox.

def Marmot::Common::Page::Page::getByLid (   self,
  lid 
)

Return content with a certain lid.

Parameters:
lidlogical ID of object
Returns:
content object with lid as logical ID; If such object is not found, None is returned.
def Marmot::Common::Page::Page::getByPid (   self,
  pid 
)

Return leaf content with a certain pid.

Only for Leaf objects.

Parameters:
pidphysical ID of object
Returns:
Leaf content object with pid as physical ID.
If such object is not found, None is returned.
def Marmot::Common::Page::Page::getByLabel (   self,
  label 
)

Return contents with a certain label.

Parameters:
labellabel of the desired contents.
Returns:
a list of content objects.
def Marmot::Common::Page::Page::count (   self)
Returns:
Number of content objects in the page.
def Marmot::Common::Page::Page::create (   self,
  label,
  pid = None,
  lid = None,
  plid = None,
  clids = None,
  box = None 
)

Create a new content object.

Parameters:
labelLabel of new object
pidPhysical ID of new object
lidLogical ID of new object
plidParent's logical ID
clidsA list of clids children's logical ID's
boxbounding box of new object
Returns:
A new Leaf or Composite object.
Remarks:
Whether the returned object is Leaf or Compsite is decided by the label parameter.
If label doesn't appear in tupples LABEL_LEAF or LABEL_COMPOSITE in Labels.py, LabelError is raised.
If an object with same pid is already in the page, DupPidError is raised.
If an object with same lid is already in the page, DupLidError is raised.
If the lid parameter is 0 or None, a proper ID is generated. This should never lead to DupLidError.

If the object is created successfully, it can be indexed through its logical ID.

def Marmot::Common::Page::Page::delete (   self,
  lid 
)

Wipe the object with logical ID lid out of this page.

Parameters:
lidLogical ID of target object
Remarks:
If no object can be indexed by lid, DeleteNotExistError is raised.
If the object being deleted is not detached from its parent or children, DeleteBeforeDetachError is raised.
def Marmot::Common::Page::Page::attach (   self,
  plid,
  clids 
)

Attach children to parent.

Parameters:
plidparent's ID
clidschildren's ID's
Remarks:
If A, B, C, D are all ID's, and B is A's child,
after self.attach(A, [C, D]), A is parent of B, C and D.
If a child is attached to a different parent, AttachBeforeDetachError is raised.
def Marmot::Common::Page::Page::detach (   self,
  plid,
  clids 
)

Detach children from parent.

Parameters:
plidparent's ID.
clidschildren's ID's
Remarks:
After detaching, children's plid become 0, and clids are removed from parent's list of children's ID's.
def Marmot::Common::Page::Page::update (   self,
  lid 
)

Update a content node.

Parameters:
lidlogical ID of the node/object
Remarks:
For now, only bounding box is updated.
The update action propagates to its ancestors.
def Marmot::Common::Page::Page::lidToPids (   self,
  lid 
)

Maps logical ID of an object to physical ID's contained in it.

Parameters:
lidlogical ID of an object
Returns:
a list of physical ID's contained in corresponding object, no order garanteed.
def Marmot::Common::Page::Page::labelToPids (   self,
  label 
)

Maps label to pids, no order garanteed.

Parameters:
labellabel of desired objects
Returns:
a list of physical ID's contained in corresponing objecs with this label, no order garanteed.
def Marmot::Common::Page::Page::lidToAncestors (   self,
  lid 
)

Given a logical id, return a content list of its ancestors.

Parameters:
lidlogical ID of an object
Returns:
a list of contents consisting of the object's ancestors.

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