Normand Briere
2019-09-29 255bcc8ac2faaf412e78e231eaa8e4a560621668
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
 
import javax.swing.event.*;
import javax.swing.tree.*;
 
class cTreeModel implements TreeModel
{
    Object3D root;
 
    public cTreeModel(Object3D owner)
    {
        root = owner;
    }
 
    public void addTreeModelListener(TreeModelListener l)
    {
    }
 
    public Object getChild(Object parent, int index)
    {
        Object3D /*Composite*/ group = (Object3D /*Composite*/) parent;
 
        return group./*children.*/get(index);
    }
 
    public int getChildCount(Object parent)
    {
        //if (parent instanceof Composite)
        {
            return ((Object3D /*Composite*/) parent)/*.children*/.Size();
        }
 
        //return 0;
    }
 
    public int getIndexOfChild(Object parent, Object child)
    {
        Object3D /*Composite*/ group = (Object3D /*Composite*/) parent;
 
        return group./*GetObject().*/indexOf(child);
    }
 
    public Object getRoot()
    {
        return root;
    }
 
    public boolean isLeaf(Object node)
    {
        return ((Object3D) node).Size() == 0; // !(node instanceof Composite);
    }
 
    public void removeTreeModelListener(TreeModelListener l)
    {
    }
 
    public void valueForPathChanged(TreePath path, Object newValue)
    {
    }
 
    static class Renderer extends DefaultTreeCellRenderer
    {
        public Renderer()
        {
        }
 
        public java.awt.Component getTreeCellRendererComponent(
                javax.swing.JTree tree,
                Object value,
                boolean sel,
                boolean expanded,
                boolean leaf,
                int row,
                boolean hasFocus)
        {
            //System.out.println(value.getClass());
            super.getTreeCellRendererComponent(tree, value, sel,
                    expanded, leaf, row, hasFocus);
            String stringValue = tree.convertValueToText(value, sel,
                    expanded, leaf, row, hasFocus);
 
            //this.tree = tree;
            this.hasFocus = hasFocus;
            setText(stringValue);
 
            Object3D obj = (Object3D) value;
 
            int r = 0, g = 0, b = 0;
 
            if (obj.live)
            {
                g = 192;
            }
 
            if (obj.hide)
            {
                r = 192;
            }
 
            if (obj.Link2Support())
            {
                b = 192;
            }
 
            java.awt.Color fg = new java.awt.Color(r, g, b);
 
//        isDropCell = false;
//        JTree.DropLocation dropLocation = tree.getDropLocation();
//
//        if (dropLocation != null
//                && dropLocation.getChildIndex() == -1
//                && tree.getRowForPath(dropLocation.getPath()) == row) {
//
//            Color col = UIManager.getColor("Tree.dropCellForeground");
//            if (col != null) {
//                fg = col;
//            } else {
//                fg = getTextSelectionColor();
//            }
//
//            isDropCell = true;
//        } else if (sel) {
//            fg = getTextSelectionColor();
//        } else {
//            fg = getTextNonSelectionColor();
//        }
 
//        setBackground(fg);
            setForeground(fg);
 
            // There needs to be a way to specify disabled icons.
//        if (!tree.isEnabled()) {
//            setEnabled(false);
//
//            if (leaf) {
//                setDisabledIcon(getLeafIcon());
//            } else if (expanded) {
//                setDisabledIcon(getOpenIcon());
//            } else {
//                setDisabledIcon(getClosedIcon());
//            }
//        }
//        else {
//            setEnabled(true);
//
//            if (leaf) {
//                setIcon(getLeafIcon());
//            } else if (expanded) {
//                setIcon(getOpenIcon());
//            } else {
//                setIcon(getClosedIcon());
//            }
//        }
 
            setComponentOrientation(tree.getComponentOrientation());
 
            selected = sel;
 
            //Object3D obj = (Object3D) value;
 
            if (obj.material == null)
            {
                setIcon(null);
            }
 
            setToolTipText("This book is in the Tutorial series.");
 
            return this;
        }
 
        public void setText(String text)
        {
            //System.out.println(text);
            super.setText(text);
        }
    }
}