1 /*******************************************************************************
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
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.trend.impl;
14 import java.awt.Graphics2D;
15 import java.awt.geom.AffineTransform;
16 import java.awt.geom.Rectangle2D;
18 import org.simantics.scenegraph.g2d.G2DNode;
20 public abstract class TrendGraphicalNode extends G2DNode implements TrendLayout {
22 private static final long serialVersionUID = 1L;
24 Rectangle2D bounds = new Rectangle2D.Double();
26 public double getWidth() {
27 return bounds.getWidth();
30 public double getHeight() {
31 return bounds.getHeight();
34 public void setSize(double w, double h) {
35 if (bounds.getWidth()==w && bounds.getHeight()==h) return;
36 bounds.setFrame(0, 0, w, h);
39 public double getX() {
40 return transform.getTranslateX();
43 public double getY() {
44 return transform.getTranslateY();
47 public void setTranslate(double x, double y) {
48 setTransform(AffineTransform.getTranslateInstance(x, y));
52 public Rectangle2D getBoundsInLocal() {
57 public void render(Graphics2D g2d) {
58 AffineTransform at = g2d.getTransform();
59 g2d.transform( transform );
67 public TrendNode getTrend() {
68 return (TrendNode) getParent();
71 protected abstract void doRender(Graphics2D g2d);