MiG InfoCom MiG Calendar Tutorial User Manual

Page 17

Advertising
background image

MiG InfoCom AB

SVG (Scalable Vector Graphics) format and

AShape.

SVG is

broader in context but

AShape

has more flexible layout support and

is more geared towards Java and Java2D.

AShape

has the ability for

non uniform scaling, a functionality that SVG currently lacks.

There are many concrete classes that implements the

AShape

interface.

VectorShape

,

TextShape

,

ImageShape

and

FeatherShape

(for blurring) are some of them. It is also very easy

to write your own

AShape

s if the built in ones don't cover your

particular use case. The

AbstractShape

implements most of the

boiler plate and all you have to do is extend it and provide the painting
code.

The layout idea behind

AShape

is that you provide it (actually the

ARootShape

) with a reference rectangle and then tell it to paint itself

relative to that rectangle. The

AShape

itself decides how it should

relate to that rectangle, but it will probably in most cases just cover the
whole of it. Sub shapes of a shape are then placed according to the
bounds that the parent shape actually used. The placement relative to
the

Rectangle

bounds is normally specified with a

PlaceRect

, or

rather one of the concrete classes that implement that interface
(

AbsRect

or

AlignRect

).

A

PlaceRect

describes how one

Rectangle

relates to another

Rectangle

, optionally with a reference

Dimension

(i.e. size). The

PlaceRect

handling and a lot of other boiler plate is done in

AbstractShape

so you don't have to bother with it normally. That

is also why almost every

xxxShape

takes a

PlaceRect

as

argument in its constructor.

The sub shapes can freely relate to its parent's bounds and since the

PlaceRect

implementations have a very flexible coordinating

system they can do this in a very advanced and dynamic fashion. It is
for instance quite easy to describe something like: 'use the right 50%
of the parent's bounds but no more than 10 pixels, right justified if
constrained'.

But how does siblings interact? With

ShapeLayout

s. Every

AShape

has a

ShapeLayout

that actually gives the sub shapes

theirs reference rectangle. If no layout is specified explicitly the

DefaultShapeLayout

is used which will layout all sub shapes

with the exact bounds of the parent (on which it is installed). All sibling
will thus get the same reference bounds to used for placing
themselves and there are no sibling cooperation.

RowShapeLayout

and

DockingShapeLayout

are delivered by

default and how they work and are supposed to be used is specified in

MiG Calendar Tutorial

Page 17 / 24

Advertising