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.g2d.element.handler.impl;
14 import java.awt.geom.Rectangle2D;
16 import org.simantics.g2d.element.IElement;
17 import org.simantics.g2d.element.handler.InternalSize;
20 * Handler for elements with fixed internal size (eg vector symbols).
22 * @author Toni Kalajainen
24 public class FixedSize implements InternalSize {
26 private static final long serialVersionUID = -3597595326131594492L;
28 public static InternalSize of(double width, double height)
30 return new FixedSize(0, 0, width, height);
33 public static InternalSize of(double minX, double minY, double width, double height)
35 return new FixedSize(minX, minY, width, height);
38 public static InternalSize of(Rectangle2D bounds)
40 return new FixedSize(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight());
43 final Double aspectRatio;
46 FixedSize(double minX, double minY, double width, double height)
48 this.aspectRatio = width / height;
49 bounds = new Rectangle2D.Double(minX, minY, width, height);
53 public Rectangle2D getBounds(IElement e, Rectangle2D s) {
54 if (s==null) s = new Rectangle2D.Double();