beautypg.com

MiG InfoCom MiG Calendar Getting Started Guide User Manual

Page 27

background image

MiG InfoCom AB

global map. Look at the JavaDoc for

DefaultAShapeProvider

for how to do this. Then just

set the

paintContext

on the activities to the same

context as you mapped in in the renderer and everything

will be handled automatically. You can even use the static

method

DefaultAShapeProvider.setShapeGlobally(..)

to

set it, which is the simplest solution. The

null

context in

the global map will give you the global fall back shape and

the only installed by default. That one can be exchanged

to make the mapping for the whole application.

There are quite a few different ways to inject your own

RootAShape

that should be used for painting those

activities. Which way you choose depends on how late in the

decision process you want to inject it. Earlier gives you more

choice on the actual implementation and later gives you

more help from the framework, and you have to used a

RootAShape

.

Here is the outline of the process of painting the

ActivityView

s, as short as possible:

The

GridDecorator

that is installed in the

DefaultDateArea

to paint the activities is a

ActivityViewDecorator

. It is using a

AShapeRenderer

to do the actual painting. That renderer gets the

RootAShape

to use from its

DefaultAShapeProvider

.

That factory always has a default

RootAShape

to return

(from the global map with

paintContext

null

), and you

can even change that one. On the actual

DefaultAShapeProvider

you can change the mapping

between a

paintContext

and a

RootAShape

, you can also

change it globally with a static method.
At last, some code. First #2:

DefaultDateArea dateArea = (DefaultDateArea) container.getDateArea();
AShapeRenderer r = (AShapeRenderer) dateArea.getActivityViewRenderer();
r.getShapeProvider().settShape(root, null);
container.getDateArea().recreateActivityViews(); // The views caches the shapes..

or

DefaultAShapeProvider.setShapeGlobally(root, null); // Changes for ALL

This will add the

root

shape we created a bit up. It will be a

blue rectangle filling the exact bounds of the date range it

represents. It can not be interacted with since we haven't set

MiG Calendar Getting Started Guide

Page 27 / 31

Explanatio

n