1 19 20 package org.netbeans.modules.websvc.design.view.widget; 21 22 import java.awt.Color ; 23 import java.awt.GradientPaint ; 24 import java.awt.Graphics2D ; 25 import java.awt.Paint ; 26 import java.awt.Polygon ; 27 import java.awt.Rectangle ; 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 37 public class OperationWidget extends Widget{ 38 39 private static final Color FILL_COLOR_DARK = new Color (102,255,255); 40 private static final Color FILL_COLOR_LIGHT = new Color (204,255,255); 41 private static final Color BORDER_COLOR = new Color (153,204,255); 42 private LabelWidget label; 43 44 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 calculateClientArea() { 56 Rectangle labelBounds = label.getBounds(); 57 return new Rectangle ( 58 labelBounds.x - labelBounds.height, labelBounds.y - labelBounds.height/2, labelBounds.width + 2*labelBounds.height, 2*labelBounds.height ); 63 } 64 65 protected void paintWidget() { 66 Rectangle bounds = getBounds(); 67 Polygon polygon = new Polygon (); 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 g = getGraphics(); 75 Paint oldPaint = g.getPaint(); 76 g.setPaint(new GradientPaint (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 |