KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > actions > FocusNearestCell


1 /*
2  * Authors:
3  * Stefanovic Nenad chupo@iis.ns.ac.yu
4  * Bojanic Sasa sasaboy@neobee.net
5  * Puskas Vladimir vpuskas@eunet.yu
6  * Pilipovic Goran zboniek@uns.ac.yu
7  *
8  */

9
10 package org.enhydra.jawe.actions;
11
12 import org.enhydra.jawe.*;
13
14 import java.awt.event.ActionEvent JavaDoc;
15
16 public class FocusNearestCell extends ActionBase {
17    public static final int FOCUS_UP=0;
18    public static final int FOCUS_DOWN=1;
19    public static final int FOCUS_LEFT=2;
20    public static final int FOCUS_RIGHT=3;
21
22    private int direction=0;
23
24    public FocusNearestCell (AbstractEditor editor,int direction) {
25       super(editor);
26       this.direction=direction;
27    }
28
29    public void actionPerformed(ActionEvent JavaDoc e) {
30       // gets the first selected cell
31
Object JavaDoc cell=editor.getGraph().getSelectionCell();
32       Object JavaDoc nearestCell=editor.getGraph().getWorkflowManager().
33          findNearestCell(cell,direction);
34       if (nearestCell!=null) {
35          editor.getGraph().setSelectionCell(nearestCell);
36       }
37    }
38 }
39
Popular Tags