1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 import com.sun.star.accessibility.XAccessible;
23 import com.sun.star.accessibility.AccessibleEventObject;
24 import com.sun.star.uno.UnoRuntime;
25 
26 import java.io.PrintStream;
27 import java.util.LinkedList;
28 
29 class GeometryEventHandler
30     extends EventHandler
31 {
GeometryEventHandler(AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel)32     public GeometryEventHandler (AccessibleEventObject aEvent, AccessibilityTreeModel aTreeModel)
33     {
34         super (aEvent, aTreeModel);
35     }
36 
PrintOldAndNew(PrintStream out)37     public void PrintOldAndNew (PrintStream out)
38     {
39         out.println ("   children not relevant");
40     }
41 
Process()42     public void Process ()
43     {
44         AccTreeNode aNode = maTreeModel.updateNode (mxEventSource,
45             AccessibleComponentHandler.class,
46             AccessibleExtendedComponentHandler.class);
47 
48         // Update the graphical representation of aNode in the Canvas.
49         Canvas aCanvas = maTreeModel.getCanvas();
50         if (aCanvas != null)
51         {
52             // Iterate over all nodes in the sub-tree rooted in aNode.
53             LinkedList aShapeQueue = new LinkedList();
54             aShapeQueue.addLast (aNode);
55             while (aShapeQueue.size() > 0)
56             {
57                 // Remove the first node from the queue and update its
58                 // graphical representation.
59                 AccTreeNode aShapeNode = (AccTreeNode) aShapeQueue.getFirst();
60                 aShapeQueue.removeFirst();
61                 aCanvas.updateNodeGeometry (aShapeNode);
62 
63                 // Add the node's children to the queue.
64                 int nChildCount = maTreeModel.getChildCount (aShapeNode);
65                 for (int i=0; i<nChildCount; i++)
66                 {
67                     Object aTreeNode = maTreeModel.getChildNoCreate (aShapeNode, i);
68                     if (aTreeNode instanceof AccTreeNode)
69                         aShapeQueue.addLast (aTreeNode);
70                 }
71             }
72             aCanvas.repaint ();
73         }
74     }
75 }
76