fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / toolkit / test / accessibility / AccessibleTreeCellRenderer.java
blob43705abb055e5d2936f29861539efc75e98c0f55
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 import java.awt.Color;
20 import java.awt.Component;
21 import java.util.ArrayList;
22 import java.util.List;
24 import javax.swing.JTree;
25 import javax.swing.tree.DefaultTreeCellRenderer;
26 import javax.swing.tree.TreePath;
29 public class AccessibleTreeCellRenderer
30 extends DefaultTreeCellRenderer
32 public Color
33 maDefaultColor,
34 maChangedColor;
35 protected ArrayList<Boolean>
36 maChangedLines;
40 public AccessibleTreeCellRenderer ()
42 maDefaultColor = Color.black;
43 maChangedColor = Color.red;
44 maChangedLines = new ArrayList<Boolean> ();
47 public Component getTreeCellRendererComponent (
48 JTree tree,
49 Object value,
50 boolean sel,
51 boolean expanded,
52 boolean leaf,
53 int row,
54 boolean hasFocus)
56 super.getTreeCellRendererComponent(
57 tree, value, sel,
58 expanded, leaf, row,
59 hasFocus);
61 if (maChangedLines.size()<=row || maChangedLines.get (row) == null)
62 setTextNonSelectionColor (maDefaultColor);
63 else
64 setTextNonSelectionColor (maChangedColor);
66 return this;
69 /** Tell the cell renderer that no changes shall be displayed anymore.
71 public void clearAllChanges ()
73 maChangedLines.clear();
76 /** Inform the cell renderer of a new changed line which to paint
77 highlighted when asked to paint it the next time.
79 public void addChangedLine (int nRow)
81 while (maChangedLines.size() <= nRow)
82 maChangedLines.add(null);
83 nRow -= 1; // row index is one to large for some reason.
84 maChangedLines.set (nRow, true);
87 /** Inform the cell renderer of a set of changed line which to paint
88 highlighted when asked to paint them the next time.
89 @param aChangedNodes
90 The set of changed nodes. Each entry is a TreePath.
91 @param aTree
92 The JTree that is used to transform the given TreePath objects
93 into rows.
95 public void addChangedNodes (List<TreePath> aChangedNodes, JTree aTree)
97 for (int i=0; i<aChangedNodes.size(); i++)
99 TreePath aPath = aChangedNodes.get (i);
100 int nRow = aTree.getRowForPath (aPath);
101 addChangedLine (nRow);