MiG InfoCom MiG Calendar AShape Developer Manual User Manual

Page 22

Advertising
background image

MiG InfoCom AB

the same

Component

that the

AShape

itself is painted on.

AShapes in JComponents
Also for this, reversed, use case there exist a special class,

AShapeComponent

. It is a

JComponent

that:

Forwards

InputEvent

s (

MouseEvent

s and

KeyEvent

s to

the “wrapped”

AShape

's

Interactor(

s) for processing

before itself handles them (if not consumed).

Adapts the Swing repaint cycle to migrate to that of the

AShape

's.

Registers itself to listen for

InteractionEvent

s on the

AShape

and when they occur re-dispatches them to

listeners added to the

AShapeComponent

.

Installs the normal types of

Interactor

s on the wrapped

AShape

, if desired.

Handles the actual

JComponent

to be positioned relative

to. This means that

AShapeComponent

can be used as

any type of renderer component, for instance a

Component

returned by

TableCellRenderer

or

TreeCellRenderer

. This opens up for having

AShape

s

in

JTree

s and

JTable

s!

Cursors
Mouse cursors is a property of the

Component

class. Every

AShape

can have a

Cursor

attribute set on it with the key

AShape.A_MOUSE_CURSOR

.

Interactions have to be installed on the

AShape

s to actually

transfer this set

Cursor

to the

Component

on which it is

rendered. It can be done manually but calling

AShapeUtil.enableMouseOverCursor(RootAShape
root)

is the easiest way. It installs

Interaction

s to set

the

Cursor

depending of which sub shape the mouse is over.

Since there is no way in Swing to know which is the default

Cursor

for a certain point in the

Component

the cursor can

not be restored when it leaves the shape. You must listen for

MouseEntered

events in the

Component

that is drawing the

AShapes

and set the

Cursor

to the desired one. The

AShape

framework will send synthesized

MouseEntered

and

MouseExited

events to the

Component

when the mouse

exit and enter the hit area of a

AShape

.

AShape Developer Manual

Page 22 / 24

Note!

Advertising