Usage patterns – MiG InfoCom MiG Calendar AShape Developer Manual User Manual

Page 8

Advertising
background image

MiG InfoCom AB

Reference and actual bounds handling

Hit shape storing and processing

Layer and paint order handling

Interactions

The concrete

AShape

classes, such as

FillAShape

, only

have to implement the paint method that actually draws the
shape in a provided

Graphics2D

object. This means that if

you want to write your own shape classes it can easily be
done, yet they will still have all the features that

AbstractAShape

provides.

Tree Structured
The shapes are combined in a tree structure just like

Components

in Swing or SWT. There is always a

RootAShape

at the top. It has some additional information

that is used for the whole tree. Then one just add sub shapes
to the root shape, and probably sub shapes to the sub
shapes as well. A sub shape node's bounds is always relative
to it's parents bounds. Exactly what bounds a sub shape will
get is dependent on the

ActivityLayout

set on the parent

as well as its own

PlaceRect

. A

PlaceRect

is a rectangle

that denotes a difference to another rectangle, in this case to
its parent's bounds.

There are currently three different concrete implementations
of a

PlaceRect

. And that is

AbsRect

,

AlignRect

and

AspectRatioRect

. They all have a little different approach

on how to specify the relativeness to the parent's bounds.

Building simple as well as complex shapes this way is much
like how it's done in Swing. There are just different types of
layouts and Swing lacks the

PlaceRect

functionality.

In the demo directory created in the installation directory
there is a class called

AShapeCreator

. It contains a lot of

code that creates different types of

AShape

s. Some simple

and some complex ones.

Usage Patterns

Pattern #1. Like a Normal Component
This is a one-to-one relationship in that you create one

AShape Developer Manual

Page 8 / 24

Advertising