KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > abe > GradientShadePanel


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
23  *
24  * $Id: GradientShadePanel.java,v 1.4 2007/02/22 21:32:16 samaresh Exp $
25  */

26
27
28 /*
29  * GradientShadePanel.java
30  *
31  * Created on May 23, 2006, 10:19 AM
32  *
33  * To change this template, choose Tools | Template Manager
34  * and open the template in the editor.
35  */

36
37 package org.netbeans.modules.xml.schema.abe;
38
39 import java.awt.Color JavaDoc;
40 import java.awt.GradientPaint JavaDoc;
41 import java.awt.Graphics JavaDoc;
42 import java.awt.Graphics2D JavaDoc;
43 import java.awt.Rectangle JavaDoc;
44 import java.awt.dnd.DropTargetDragEvent JavaDoc;
45 import java.awt.dnd.DropTargetDropEvent JavaDoc;
46 import java.awt.dnd.DropTargetEvent JavaDoc;
47 import java.awt.event.MouseAdapter JavaDoc;
48 import java.awt.event.MouseEvent JavaDoc;
49
50 /**
51  *
52  * @author girix
53  */

54 public abstract class GradientShadePanel extends ABEBaseDropPanel{
55     private static final long serialVersionUID = 7526472295622776147L;
56     /** Creates a new instance of GradientShadePanel */
57     public GradientShadePanel(InstanceUIContext context) {
58         super(context);
59     }
60     /**
61      *
62      *
63      */

64     public void paintComponent(Graphics JavaDoc g){
65         super.paintComponent(g);
66         
67         Graphics2D JavaDoc g2d = (Graphics2D JavaDoc) g;
68         Rectangle JavaDoc rect = g2d.getClipBounds();
69         
70         Color JavaDoc start = normalTopGradientColor;
71         Color JavaDoc end = normalBottomGradientColor;
72         if(draging){
73             start = dragTopGradientColor;
74             end = dragBottomGradientColor;
75         }else if(context.getComponentSelectionManager().isSelected(this)){
76             start = selectedTopGradientColor;
77             end = selectedBottomGradientColor;
78         }
79         
80         GradientPaint JavaDoc fill=new GradientPaint JavaDoc(
81                 (float)rect.x, (float)rect.y, start,
82                 (float)rect.x, (float)rect.height, end);
83         
84         g2d.setPaint(fill);
85         g2d.fill(rect);
86         
87         
88     }
89     
90     public void dragExit(DropTargetEvent JavaDoc event) {
91         draging = false;
92         repaint();
93     }
94     
95     public void dragOver(DropTargetDragEvent JavaDoc event) {
96         draging = true;
97         repaint();
98     }
99     
100     public void dragEnter(DropTargetDragEvent JavaDoc event) {
101         draging = true;
102         repaint();
103     }
104     
105     public void drop(DropTargetDropEvent JavaDoc event) {
106         draging = false;
107         repaint();
108     }
109     
110     protected boolean draging = false;
111     
112     protected Color JavaDoc selectedTopGradientColor = Color.WHITE;
113     protected Color JavaDoc selectedBottomGradientColor = InstanceDesignConstants.DARK_BLUE;
114     
115     protected Color JavaDoc dragTopGradientColor = Color.WHITE;
116     protected Color JavaDoc dragBottomGradientColor = InstanceDesignConstants.XP_ORANGE;
117     
118     protected Color JavaDoc normalTopGradientColor = Color.WHITE;
119     protected Color JavaDoc normalBottomGradientColor = Color.LIGHT_GRAY.brighter();
120     
121 }
122
Popular Tags