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.9 date: 2021/01/20 13:01:55
user: cg
file: CompactHierarchicalItem.st directory: libwidg2
module: stx stc-classLibrary: libwidg2

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)
       Has been refactored in the meantime, so my superclass holds the model now.
    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:

copyright

COPYRIGHT (c) 1999 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

class initialization
o  initialize
I will pack width and height into a single integer

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  heightOn: aGC
return the height of the receiver, if it is to be displayed on aGC

o  isExpanded
(comment from inherited method)
returns true if the item is expanded

o  width
return the cached width

o  width: w height: h isExpanded: expanded
encode width and height, and isExpanded state.
Tries to use a single integer to encode all three of them,
saving a lot of memory for big trees.

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


Private classes:

    Geometry


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 17:13:55 GMT