MiG InfoCom MiG Calendar Getting Started Guide User Manual
Page 26
![background image](https://www.manualsdir.com/files/798671/content/doc026.png)
MiG InfoCom AB
constrains on other parts. For a full primer on AShapes set
the
AShape Tutorial
and the
MiG Calendar Technical Specification
documents.
Rectangle shape = new Rectangle(0, 0, 1, 1);
//Ellipse2D shape = new Ellipse2D.Float(0, 0, 1, 1); // Alternative.
FillAShape box = new FillAShape("fill", shape, AbsRect.FILL, Color.BLUE, null);
RootAShape root = new RootAShape(box);
The
root
object is the shape to use. AShapes are stored in a
hierarchy with a RootAShape at the top. The root shape can
be viewed as the handle for the whole shape and must exist
at the very top of the hierarchy tree.
Notice that the
FillShape
itself doesn't impose what
geometry it should fill, that is provided in the constructor and
can be any Java2D
Shape
, including
GeneralPath
and our
own version with better, constrainable, coordinates types;
PolygonShape
.
As always, to see exactly what the arguments mean and
what the objects can do see the
MiG Calendar Technical
Specification
.
Now we need to tell our component how to use our newly
created
AShape
. As it turns out, this can be done in more
than one way.
1. Exchange the
Decorator
in
DefaultDateArea
for your
own. The most flexible solution, but much of the boiler
plate work that is handled automatically by
DefaultDateArea
has to be remade by you.
2. Exchange
ActivityViewRenderer
in the
DefaultDateArea
with a proprietary one that uses the
new shape when painting. Also very flexible but much
easier to implement since you will be provided with the
ActivityView
s to paint and the total bounds. There is
nothing '
AShape
' about this approach though, you can use
pure Java2D if you like.
3. Get the
DefaultAShapeProvider
from the the
ActivityViewRenderer
, which we know is a
AShapeRenderer
, and instruct it to use a some other
RootAShape
for some
paintContext
.
DefaultAShapeProvider
uses the
paintContext
of
the
Activity
to look up a
RootAShape
to return. There
are both a map for the actual renderer and a fall back
MiG Calendar Getting Started Guide
Page 26 / 31