1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
12 package org.simantics.trend.impl;
\r
14 import java.awt.Graphics2D;
\r
15 import java.awt.geom.AffineTransform;
\r
16 import java.awt.geom.Rectangle2D;
\r
18 import org.simantics.scenegraph.g2d.G2DNode;
\r
20 public abstract class TrendGraphicalNode extends G2DNode implements TrendLayout {
\r
22 private static final long serialVersionUID = 1L;
\r
24 Rectangle2D bounds = new Rectangle2D.Double();
\r
26 public double getWidth() {
\r
27 return bounds.getWidth();
\r
30 public double getHeight() {
\r
31 return bounds.getHeight();
\r
34 public void setSize(double w, double h) {
\r
35 if (bounds.getWidth()==w && bounds.getHeight()==h) return;
\r
36 bounds.setFrame(0, 0, w, h);
\r
39 public double getX() {
\r
40 return transform.getTranslateX();
\r
43 public double getY() {
\r
44 return transform.getTranslateY();
\r
47 public void setTranslate(double x, double y) {
\r
48 setTransform(AffineTransform.getTranslateInstance(x, y));
\r
52 public Rectangle2D getBoundsInLocal() {
\r
57 public void render(Graphics2D g2d) {
\r
58 AffineTransform at = g2d.getTransform();
\r
59 g2d.transform( transform );
\r
63 g2d.setTransform(at);
\r
67 public TrendNode getTrend() {
\r
68 return (TrendNode) getParent();
\r
71 protected abstract void doRender(Graphics2D g2d);
\r