1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.scenegraph.g2d.nodes;
14 import java.awt.BasicStroke;
15 import java.awt.Color;
16 import java.awt.Composite;
17 import java.awt.Graphics2D;
18 import java.awt.geom.AffineTransform;
19 import java.awt.geom.Rectangle2D;
21 public class BorderDecoratorNode extends TransformNode {
25 private static final long serialVersionUID = -4982578347433716440L;
27 protected Composite composite;
28 protected Boolean visible = Boolean.TRUE;
29 protected Rectangle2D bounds = null;
30 protected float border = 1.0f;
32 @SyncField("composite")
33 public void setComposite(Composite composite) {
34 this.composite = composite;
38 public void setVisible(Boolean visible) {
39 this.visible = visible;
42 @PropertySetter("Stroke Width")
44 public void setBorderWidth(Float borderWidth) {
45 this.border = borderWidth != null ? borderWidth : 1.0f;
48 public boolean isVisible() {
52 @PropertySetter("Bounds")
54 public void setBounds(Rectangle2D bounds) {
59 public Rectangle2D getBoundsInLocal() {
64 public void render(Graphics2D g) {
66 if(composite != null) {
67 g.setComposite(composite);
70 if(this.border > 0.0f && bounds != null) {
71 AffineTransform ot = g.getTransform();
72 g.transform(transform);
73 g.setStroke(new BasicStroke(this.border));
74 g.setColor(Color.BLACK);