001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019:
020: package org.netbeans.modules.bpel.design.model.elements;
021:
022: import java.awt.Color;
023: import java.awt.Graphics2D;
024: import java.awt.Paint;
025: import java.awt.RenderingHints;
026: import java.awt.TexturePaint;
027: import java.awt.geom.Line2D;
028: import java.awt.geom.Rectangle2D;
029: import org.netbeans.modules.bpel.design.GUtils;
030: import org.netbeans.modules.bpel.design.geometry.FInsets;
031: import org.netbeans.modules.bpel.design.geometry.FRectangle;
032: import org.netbeans.modules.bpel.design.geometry.FShape;
033: import org.netbeans.modules.bpel.design.geometry.FStroke;
034: import org.netbeans.modules.bpel.design.model.elements.icons.Icon2D;
035:
036: /**
037: *
038: * @author anjeleevich
039: */
040: public class ProcessBorder extends BorderElement {
041:
042: public ProcessBorder() {
043: super (SHAPE, INSETS);
044: }
045:
046: public void paint(Graphics2D g2) {
047: FShape shape = this .shape;
048:
049: // draw background
050: Rectangle2D headerRectangle = new Rectangle2D.Float(shape.x,
051: shape.y, shape.width, 32);
052: g2.setPaint(BACKGROUND);
053: g2.fill(shape);
054: g2
055: .setPaint(new TexturePaint(GRADIENT_TEXTURE,
056: headerRectangle));
057: g2.fill(headerRectangle);
058:
059: // draw border;
060: g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
061: RenderingHints.VALUE_STROKE_NORMALIZE);
062: g2.setPaint(ContentElement.STROKE_COLOR);
063: g2.setStroke(STROKE.createStroke(g2));
064: g2.draw(shape);
065: float x = shape.x;
066: float y = shape.y + 32;
067: g2.draw(new Line2D.Float(x, y, x + shape.width, y));
068:
069: if (isPaintText()) {
070: g2.setPaint(getTextColor());
071: drawCenteredString(g2, getText(), getCenterX(),
072: getY() + 16, getWidth() - 8);
073: }
074: }
075:
076: public void paintThumbnail(Graphics2D g2) {
077: FShape shape = this .shape;
078: Rectangle2D headerRectangle = new Rectangle2D.Float(shape.x,
079: shape.y, shape.width, 32);
080:
081: g2.setPaint(BACKGROUND);
082: g2.fill(shape);
083: g2.setPaint(GRADIENT_TEXTURE_COLOR);
084: g2.fill(headerRectangle);
085:
086: g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
087: RenderingHints.VALUE_STROKE_NORMALIZE);
088: g2.setPaint(ContentElement.STROKE_COLOR);
089: g2.setStroke(STROKE.createStroke(g2));
090:
091: g2.draw(shape);
092: float x = shape.x;
093: float y = shape.y + 32;
094: g2.draw(new Line2D.Float(x, y, x + shape.width, y));
095: }
096:
097: public static final FShape SHAPE = new FRectangle(72 + 16 + 16,
098: 48 + 16);
099: public static final FInsets INSETS = new FInsets(48, 16, 16, 16);
100:
101: public static Paint BACKGROUND = new Color(0xFFFFFF);
102: private static FStroke STROKE = new FStroke(1);
103:
104: }
|