01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08: *
09: * 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.bpel.design.decoration.components;
21:
22: import java.awt.BasicStroke;
23: import java.awt.Color;
24: import java.awt.Graphics2D;
25: import java.awt.Paint;
26: import java.awt.Shape;
27: import java.awt.geom.AffineTransform;
28: import java.awt.geom.Area;
29: import java.awt.geom.Rectangle2D;
30: import java.awt.geom.RoundRectangle2D;
31:
32: /**
33: *
34: * @author aa160298
35: */
36: public class RemoveIcon2D extends Icon2D {
37:
38: protected void paint(Graphics2D g2) {
39: g2.setPaint(FILL_PAINT);
40: g2.fill(SHAPE);
41: g2.setPaint(STROKE_PAINT);
42: g2.setStroke(STROKE);
43: g2.draw(SHAPE);
44: }
45:
46: protected double getDesignOriginX() {
47: return DESIGN_SIZE / 2;
48: }
49:
50: protected double getDesignOriginY() {
51: return DESIGN_SIZE / 2;
52: }
53:
54: protected double getDesignWidth() {
55: return DESIGN_SIZE;
56: }
57:
58: protected double getDesignHeight() {
59: return DESIGN_SIZE;
60: }
61:
62: private static final Paint FILL_PAINT = Color.RED;
63: private static final Paint STROKE_PAINT = new Color(0x990000);
64: private static final BasicStroke STROKE = new BasicStroke(1,
65: BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
66:
67: private static final double DESIGN_SIZE = 10;
68:
69: private static final Shape SHAPE;
70: private static final double W = 10;
71: private static final double H = 2.2;
72:
73: static {
74: double arc = Math.min(W, H);
75: Area a = new Area(new RoundRectangle2D.Double(-W / 2, -H / 2,
76: W, H, arc, arc));
77: a.add(new Area(new RoundRectangle2D.Double(-H / 2, -W / 2, H,
78: W, arc, arc)));
79:
80: double rot = Math.PI / 4;
81: a = a.createTransformedArea(AffineTransform
82: .getRotateInstance(rot));
83:
84: Rectangle2D bounds = a.getBounds2D();
85: double sx = (DESIGN_SIZE - STROKE.getLineWidth())
86: / bounds.getWidth();
87: double sy = (DESIGN_SIZE - STROKE.getLineWidth())
88: / bounds.getHeight();
89: a = a.createTransformedArea(AffineTransform.getScaleInstance(
90: sx, sy));
91:
92: SHAPE = a;
93: }
94: }
|