X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felement%2Fhandler%2Fimpl%2FFixedSize.java;h=c4a0f9c81fa0efe0e2fbcbf23ab0eea7d4c3c699;hb=a43df9e895f022132f9b94dfedeae78fb4eed712;hp=e33357e750a273c448076d2af12d42536bef025a;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/FixedSize.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/FixedSize.java index e33357e75..c4a0f9c81 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/FixedSize.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/FixedSize.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.g2d.element.handler.impl; - -import java.awt.geom.Rectangle2D; - -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.element.handler.InternalSize; - -/** - * Handler for elements with fixed internal size (eg vector symbols). - * - * @author Toni Kalajainen - */ -public class FixedSize implements InternalSize { - - private static final long serialVersionUID = -3597595326131594492L; - - public static InternalSize of(double width, double height) - { - return new FixedSize(0, 0, width, height); - } - - public static InternalSize of(double minX, double minY, double width, double height) - { - return new FixedSize(minX, minY, width, height); - } - - public static InternalSize of(Rectangle2D bounds) - { - return new FixedSize(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()); - } - - final Double aspectRatio; - Rectangle2D bounds; - - FixedSize(double minX, double minY, double width, double height) - { - this.aspectRatio = width / height; - bounds = new Rectangle2D.Double(minX, minY, width, height); - } - - @Override - public Rectangle2D getBounds(IElement e, Rectangle2D s) { - if (s==null) s = new Rectangle2D.Double(); - s.setFrame(bounds); - return s; - } - - -} +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.g2d.element.handler.impl; + +import java.awt.geom.Rectangle2D; + +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.element.handler.InternalSize; + +/** + * Handler for elements with fixed internal size (eg vector symbols). + * + * @author Toni Kalajainen + */ +public class FixedSize implements InternalSize { + + private static final long serialVersionUID = -3597595326131594492L; + + public static InternalSize of(double width, double height) + { + return new FixedSize(0, 0, width, height); + } + + public static InternalSize of(double minX, double minY, double width, double height) + { + return new FixedSize(minX, minY, width, height); + } + + public static InternalSize of(Rectangle2D bounds) + { + return new FixedSize(bounds.getMinX(), bounds.getMinY(), bounds.getWidth(), bounds.getHeight()); + } + + final Double aspectRatio; + Rectangle2D bounds; + + FixedSize(double minX, double minY, double width, double height) + { + this.aspectRatio = width / height; + bounds = new Rectangle2D.Double(minX, minY, width, height); + } + + @Override + public Rectangle2D getBounds(IElement e, Rectangle2D s) { + if (s==null) s = new Rectangle2D.Double(); + s.setFrame(bounds); + return s; + } + + +}