eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'CompactHierarchicalItem':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: CompactHierarchicalItem


Inheritance:

   Object
   |
   +--AbstractHierarchicalItem
      |
      +--AbstractHierarchicalItemWithModel
         |
         +--CompactHierarchicalItem

Package:
stx:libwidg2
Category:
Views-Support
Version:
rev: 1.6 date: 2018/07/29 08:16:12
user: cg
file: CompactHierarchicalItem.st directory: libwidg2
module: stx stc-classLibrary: libwidg2
Author:
Claus Gittinger

Description:


Compact Hierarchical Items are a new, tuned and optimized version of the original
hierarchical item, which suffers various problems:
    1) the old item did not store the model, which in many situations leads to very
       poor performance (it walks along the super-item hierarchy to find the model,
       which makes many algorithms O(n^2) instead of O(n)
    2) it keeps individual width/height information, where this could be shared if
       many items have the same extent.
    3) it uses separate width/height instvars, where this information can be stored more compact
       in single integer (using bit-masks)
    4) it uses a separate boolean for the isExpanded, which could be encoded more space efficient as a single bit

Problems 2-4 only apply to huge trees with (say 100s of thousands of items). Such big trees are encountered
for example in the expecco activity log.

This class solves those issues:
    - it uses a compact width/height representation (bit masks in an integer), for
      items within a reasonable size (0 to 64k pixels wide, 0 to 16k pixels high).
    - falls back to a separate width/height holding object, if ever exceeded (which is unlikely)

    - it encodes the expanded state in a single bit

    - it uses the saved slot to allow for the model to be kept locally

Notice, that in order to be backward compatible, the cached width and height fields can
take integer values AND nil. Nil is typically used to mark an invalid cached value.
Here, the nil case is encoded in the bitField as all-ones (max value).

Before changing the superclass of your existing HierarchicalItem subclass, make sure that the subclass does not access 
the instvars isExpanded, width and heigh directly.
Instead, use the getters isExpanded, width and height and the setters setExpanded:, width: and height:


Related information:

    HierarchicalItem

Class protocol:

class initialization
o  initialize
self assert:(ShiftHeight + (MaskHeight highBit)) < 31.

queries
o  isAbstract
Return if this class is an abstract class.
True is returned here for myself only; false for subclasses.
Abstract subclasses must redefine this again.


Instance protocol:

private
o  makeWidthAndHeightUnknown
invalidate any cached with/height information

o  setExpanded: aBoolean
set expanded flag without any computation or notification

protocol-displaying
o  getWidthAndHeightOn: aGC
fetch the width and height from my label, if it is to be displayed on aGC

o  height
return the cached height

o  height: h
encode the cached height, preserving the isExpanded state

o  heightOn: aGC
return the height of the receiver, if it is to be displayed on aGC

o  isExpanded

o  width
return the cached width

o  width: w
encode the cached width, preserving the isExpanded state

o  width: w height: h
encode width and height, preserving the isExpanded state

o  width: w height: h isExpanded: expanded
encode width and height, and isExpanded state

o  widthOn: aGC
return the width of the receiver, if it is to be displayed on aGC


Private classes:

    Geometry


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 29 Mar 2024 12:42:32 GMT