1 package net.logAnalyzer.utils.gui.treetable;
2 import java.awt.Color;
3 import java.awt.Dimension;
4 import java.awt.Graphics;
5 import java.awt.Rectangle;
6
7 import javax.accessibility.Accessible;
8 import javax.swing.JComponent;
9 import javax.swing.JTree;
10 import javax.swing.plaf.TreeUI;
11 import javax.swing.tree.TreePath;
12
13 public class TableTreeUI extends TreeUI {
14
15 private final TreeUI actualUI;
16
17 private Color lineColor;
18
19 public TableTreeUI(TreeUI actualUI, Color lineColor) {
20 if ( actualUI == null ) {
21 throw new IllegalArgumentException("Actual TreeUI is <null>");
22 }
23
24 if ( lineColor == null ) {
25 throw new IllegalArgumentException("Line color is <null>");
26 }
27
28 this.actualUI = actualUI;
29 this.lineColor = lineColor;
30 }
31
32 private void drawBottomLine(Graphics g) {
33 Rectangle bounds = g.getClipBounds();
34 int bottomY = (int)( bounds.getMaxY() - 1 );
35 g.setColor( this.lineColor );
36 g.drawLine( 0, bottomY, (int)bounds.getWidth(), bottomY);
37 }
38
39 public void paint(Graphics g, JComponent c) {
40 this.actualUI.paint( g, c );
41 this.drawBottomLine( g );
42 }
43
44 public void update(Graphics g, JComponent c) {
45 this.actualUI.update( g, c );
46 this.drawBottomLine( g );
47 }
48
49 public void cancelEditing(JTree arg0) {
50 this.actualUI.cancelEditing( arg0 );
51 }
52
53 public boolean contains(JComponent arg0, int arg1, int arg2) {
54 return this.actualUI.contains( arg0, arg1, arg2 );
55 }
56
57 public Accessible getAccessibleChild(JComponent arg0, int arg1) {
58 return this.actualUI.getAccessibleChild( arg0, arg1 );
59 }
60
61 public int getAccessibleChildrenCount(JComponent arg0) {
62 return this.actualUI.getAccessibleChildrenCount( arg0 );
63 }
64
65 public TreePath getClosestPathForLocation(JTree arg0, int arg1, int arg2) {
66 return this.actualUI.getClosestPathForLocation( arg0, arg1, arg2 );
67 }
68
69 public TreePath getEditingPath(JTree arg0) {
70 return this.actualUI.getEditingPath( arg0 );
71 }
72
73 public Dimension getMaximumSize(JComponent arg0) {
74 return this.actualUI.getMaximumSize( arg0 );
75 }
76
77 public Dimension getMinimumSize(JComponent arg0) {
78 return this.actualUI.getMinimumSize( arg0 );
79 }
80
81 public Rectangle getPathBounds(JTree arg0, TreePath arg1) {
82 return this.actualUI.getPathBounds( arg0, arg1 );
83 }
84
85 public TreePath getPathForRow(JTree arg0, int arg1) {
86 return this.actualUI.getPathForRow( arg0, arg1 );
87 }
88
89 public Dimension getPreferredSize(JComponent arg0) {
90 return this.actualUI.getPreferredSize( arg0 );
91 }
92
93 public int getRowCount(JTree arg0) {
94 return this.actualUI.getRowCount( arg0 );
95 }
96
97 public int getRowForPath(JTree arg0, TreePath arg1) {
98 return this.actualUI.getRowForPath( arg0, arg1 );
99 }
100
101 public void installUI(JComponent arg0) {
102 this.actualUI.installUI( arg0 );
103 }
104
105 public boolean isEditing(JTree arg0) {
106 return this.actualUI.isEditing( arg0 );
107 }
108
109 public void startEditingAtPath(JTree arg0, TreePath arg1) {
110 this.actualUI.startEditingAtPath( arg0, arg1 );
111 }
112
113 public boolean stopEditing(JTree arg0) {
114 return this.actualUI.stopEditing( arg0 );
115 }
116
117 public void uninstallUI(JComponent arg0) {
118 this.actualUI.uninstallUI( arg0 );
119 }
120 public void setLineColor(Color color){
121 this.lineColor = color;
122 }
123 }