MiG InfoCom MiG Calendar AShape Developer Manual User Manual

Page 18

Advertising
background image

MiG InfoCom AB

Static overrides is a simple and very extensible way to
control overrides without the need for the Command pattern
described above. It means that you can call a static method
on the

ActivityInteractor

class to set an

OverrideFilter

that contains code that either override a

property or not. Here is some example code:

String shapeName = AshapeUtil.DEFAULT_OUTLINE_SHAPE_NAME;
ActivityInteractor.setStaticOverride(shapeName, AShape.A_PAINT, new OverrideFilter() {
public Object getOverride(Object subject, Object defaultObject)
{
Activity activity = ((ActivityView) subject).getModel();

if (activity.getStates().isStateSet(GenericStates.SELECTED_BIT))
return Color.RED;

return defaultObject;
}
});

The code adds an override filter that is checking if the
Activity is selected, and if it is, returns the color red. If the
activity isn't selected it returns the default object which is the
normal color in this case.

The code above can be altered in many ways to
programatically alter how

AShape

s look depending on some

condition of the "subject" it is decorating.

Putting it All Together
This package has a lot of different parts, and what parts that
can be combined together to make a meaningful interaction
specification is not entirely obvious. Therefore you should
probably look at the demo application and the source code
for

AShapeUtil

, which contains a lot of static

AShape

creation methods.

Listening for Mouse Events
This is new for v6.0 if MiG Calendar component. It offers the
same observer pattern for MouseEvents that Swing has. You
can easily just listen for instance for mouse over events and
change the color (or whatever) using your custom code. This
is much easier than specifyin this with

Interactor

s as you

had to do pre 6.0.

This is easier to understand with some example code:

AShape Developer Manual

Page 18 / 24

Advertising