KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > design > view > widget > OperationWidget


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 package org.netbeans.modules.websvc.design.view.widget;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.GradientPaint JavaDoc;
24 import java.awt.Graphics2D JavaDoc;
25 import java.awt.Paint JavaDoc;
26 import java.awt.Polygon JavaDoc;
27 import java.awt.Rectangle JavaDoc;
28 import org.netbeans.api.visual.widget.LabelWidget;
29 import org.netbeans.api.visual.widget.Scene;
30 import org.netbeans.api.visual.widget.Widget;
31 import org.netbeans.modules.websvc.api.jaxws.wsdlmodel.WsdlOperation;
32
33 /**
34  *
35  * @author Ajit Bhate
36  */

37 public class OperationWidget extends Widget{
38     
39     private static final Color JavaDoc FILL_COLOR_DARK = new Color JavaDoc(102,255,255);
40     private static final Color JavaDoc FILL_COLOR_LIGHT = new Color JavaDoc(204,255,255);
41     private static final Color JavaDoc BORDER_COLOR = new Color JavaDoc(153,204,255);
42     private LabelWidget label;
43
44     /**
45      * Creates a new instance of OperationWidget
46      * @param scene
47      * @param operation
48      */

49     public OperationWidget(Scene scene, WsdlOperation operation) {
50         super(scene);
51         label = new LabelWidget(scene,operation.getName());
52         addChild(label);
53     }
54     
55     protected Rectangle JavaDoc calculateClientArea() {
56         Rectangle JavaDoc labelBounds = label.getBounds();
57         return new Rectangle JavaDoc(
58                 labelBounds.x - labelBounds.height, // x
59
labelBounds.y - labelBounds.height/2,// y
60
labelBounds.width + 2*labelBounds.height, //width
61
2*labelBounds.height //height
62
);
63     }
64     
65     protected void paintWidget() {
66         Rectangle JavaDoc bounds = getBounds();
67         Polygon JavaDoc polygon = new Polygon JavaDoc();
68         polygon.addPoint(bounds.x+bounds.height/2, bounds.y);
69         polygon.addPoint(bounds.x+bounds.width-bounds.height/2, bounds.y);
70         polygon.addPoint(bounds.x+bounds.width, bounds.y+bounds.height/2);
71         polygon.addPoint(bounds.x+bounds.width-bounds.height/2, bounds.y+bounds.height);
72         polygon.addPoint(bounds.x+bounds.height/2, bounds.y+bounds.height);
73         polygon.addPoint(bounds.x, bounds.y+bounds.height/2);
74         Graphics2D JavaDoc g = getGraphics();
75         Paint JavaDoc oldPaint = g.getPaint();
76         g.setPaint(new GradientPaint JavaDoc(bounds.x, bounds.y, FILL_COLOR_DARK,
77                 bounds.x, bounds.y + bounds.height, FILL_COLOR_LIGHT));
78         g.fillPolygon(polygon);
79         g.setPaint(BORDER_COLOR);
80         g.drawPolygon(polygon);
81         g.setPaint(oldPaint);
82     }
83     
84 }
85
Popular Tags