KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > usertasks > treetable > SortingOrderBorder


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.usertasks.treetable;
21
22 import java.awt.Component JavaDoc;
23 import java.awt.Dimension JavaDoc;
24 import java.awt.Font JavaDoc;
25 import java.awt.Graphics JavaDoc;
26 import java.awt.Image JavaDoc;
27 import java.awt.Insets JavaDoc;
28 import java.awt.Insets JavaDoc;
29 import javax.swing.Icon JavaDoc;
30 import javax.swing.ImageIcon JavaDoc;
31 import javax.swing.JLabel JavaDoc;
32 import javax.swing.JPanel JavaDoc;
33 import javax.swing.JTable JavaDoc;
34 import javax.swing.SwingConstants JavaDoc;
35 import javax.swing.UIManager JavaDoc;
36 import javax.swing.border.Border JavaDoc;
37 import javax.swing.table.DefaultTableCellRenderer JavaDoc;
38 import javax.swing.table.JTableHeader JavaDoc;
39 import javax.swing.table.TableCellRenderer JavaDoc;
40 import javax.swing.table.TableColumnModel JavaDoc;
41 import org.netbeans.modules.tasklist.core.table.SortingModel;
42
43 /**
44  * Cell renderer for sorting column header.
45  * Originally copied from org.openide.explorer.view.TreeTableView
46  */

47 public class SortingOrderBorder implements Border JavaDoc {
48     private static final long serialVersionUID = 1;
49
50     /** 0 - not sorted, 1 - ascending, 2 - descending */
51     public int status = 0;
52     
53     private static Image JavaDoc SORT_DESC_ICON =
54         org.openide.util.Utilities.loadImage(
55         "org/netbeans/modules/tasklist/usertasks/treetable/columnsSortedDesc.gif"); // NOI18N
56
private static Image JavaDoc SORT_ASC_ICON =
57         org.openide.util.Utilities.loadImage(
58         "org/netbeans/modules/tasklist/usertasks/treetable/columnsSortedAsc.gif"); // NOI18N
59

60     public void paintBorder(Component JavaDoc c, Graphics JavaDoc g, int x, int y,
61             int width, int height) {
62         Image JavaDoc img = null;
63         switch (status) {
64             case 1:
65                 img = SORT_ASC_ICON;
66                 break;
67             case 2:
68                 img = SORT_DESC_ICON;
69                 break;
70         }
71         if (img != null)
72             g.drawImage(img, width - img.getWidth(c),
73                     (height - img.getHeight(c)) / 2, null);
74     }
75
76     public Insets JavaDoc getBorderInsets(Component JavaDoc cmp) {
77         if (status == 0)
78             return new Insets JavaDoc(0, 0, 0, 0);
79         else
80             return new Insets JavaDoc(0, 0, 0, 16);
81     }
82
83     public boolean isBorderOpaque() {
84         return false;
85     }
86 }
87
88
89
Popular Tags