The ashape classes – MiG InfoCom MiG Calendar AShape Developer Manual User Manual
Page 9
![background image](https://www.manualsdir.com/files/798676/content/doc009.png)
MiG InfoCom AB
AShape
(or rather one
AShape
hierarchy with a
RootAShape
at the top) for every entity you want to decorate i.e. a UML
package box or an
ActivityView
in a date component.
This way is simple but if there are a great number of entities
to paint there will be as many
AShape
hierarchies, which
consumes resources. This is how Swing works.
If only one or only a very small number of entities should be
painted, such as GUI buttons, this is the preferred method
since each
AShape
has it's own reference handle and can be
changed and managed directly without switching
Interactor
s during the paint process (explained below).
The
AShape
s should be created with shared (same) graphics
primitives that are immutable, such as
Font
s,
Color
s,
Paint
s and (usually)
Image
s, to save resources.
Pattern #2. Like a Stamp
This is much like
CellRenderer
s in Swing where you reuse
the same
Component
for all cells in for instance a
JTable
.
This reduces the resource strain especially regarding memory
consumption and startup time. This approach is often called
a
Flyweight Pattern
.
The drawback is that you have to manage a number of
lightweight “peer” objects, called
Interactor
s, which
contains the specific information for the entity to paint. You
don't have to do this if you don't want to but if you don't,
every entity will be painted exactly the same (but they may
have different reference bounds) with no possibility to
interact with any one of them. They will be totally generic.
The
Interactor
contains information about the state of the
entity to paint. For instance if the outline color of the
currently painted
AShape
should be darker/brighter than the
others because the mouse hovers over it. Basically you
switch in the
Interactor
s that belongs to the entity you are
just about to paint.
See Interactors further down for information on how this
works.
The AShape Classes
Below is an overview of all concrete
AShape
classes. Almost
AShape Developer Manual
Page 9 / 24
Tip!