Animations – MiG InfoCom MiG Calendar AShape Developer Manual User Manual

Page 19

Advertising
background image

MiG InfoCom AB

myAShape.addMouseListener(new MouseInteractionListener() {
public void mouseInteracted(MouseInteractionEvent e) {

if (e.getEventKey() == MouseKeyInteractor.MOUSE_OVER_CHANGE) {

String shapeName = AShapeUtil.DEFAULT_OUTLINE_SHAPE_NAME;
MouseKeyInteractor inter = e.getMouseKeyInteractor();
PropertyKey moListKey = MouseKeyInteractor.PROP_MOUSE_OVER_LIST;

if (MouseInteractionEvent.isShapeInList(shapeName, moListKey)) {
inter.addOverride(shapeName, AShape.A_PAINT, "myid", Color.RED);
} else {
inter.removeOverrideById("myid");
}
}
}
});

The code checks if the outline shape for the default shape is
in the "mouse over:ed" list. If it is; an override for the

Paint

is is set to

Red

. If not; the override is removed (if there) to

expose the original paint again effectively making a mouse
over effect. The

"myid"

is just the id of the override so we

can remove it later.

The

MouseKeyInteractor

contains references to the the

keys for the different event types as well as the keys for
retrieving the

List

(s) and values that contains state

information such as which is the topmost mouse over:ed

AShape

name.

There is a lot of state information contained in the
MouseInteractionEvent. You can listen for just about anything
and react to this with a reference to the

Interactor

that

can adjust the state (by adding an override) for that
particular

AShape

"stamp".

Animations

The Basics
The

ashapes.animation.*

package contains all that is

needed to create animated

Ashape

s. They can even be

animated when for instance the user mouse-overs it. It
consists of an

Animator

that controls an

Animation

s over a

TimeLine

to produce the result.

The framework is based on the absolute time and not delay
between frames. This but gives much better quality since
even a very slow target environment will play the animations

AShape Developer Manual

Page 19 / 24

Advertising