X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Felement%2Fhandler%2Fimpl%2FTextFontImpl.java;h=2d6c2b069c1e61a09ccb376ae95b2770de42da65;hb=1cd631466bc35e05bc585999b2f325f148cd5629;hp=b4e7b21c096153e71bcb284149df2d37866ca255;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/TextFontImpl.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/TextFontImpl.java index b4e7b21c0..2d6c2b069 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/TextFontImpl.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/TextFontImpl.java @@ -1,89 +1,89 @@ -/******************************************************************************* - * 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.Font; - -import org.simantics.g2d.diagram.IDiagram; -import org.simantics.g2d.element.ElementHints; -import org.simantics.g2d.element.IElement; -import org.simantics.g2d.element.handler.LifeCycle; -import org.simantics.g2d.element.handler.TextFont; -import org.simantics.utils.ObjectUtils; - -/** - * - * @See {@link TextFont} - * @author Marko Luukkainen - */ -public class TextFontImpl implements TextFont, LifeCycle { - - private static final long serialVersionUID = -6254972866736454459L; - - public static TextFontImpl DEFAULT = new TextFontImpl(); - - - public synchronized static TextFontImpl handlerOf(java.awt.Font f) - { - return new TextFontImpl(f); - } - - java.awt.Font defaultFont; - - public TextFontImpl() { - this.defaultFont = new Font("Arial", Font.PLAIN, 12); - } - public TextFontImpl(java.awt.Font defaultFont) { - this.defaultFont = defaultFont; - } - - @Override - public java.awt.Font getFont(IElement e) { - return e.getHint(ElementHints.KEY_FONT); - } - - @Override - public void setFont(IElement e, java.awt.Font f) { - e.setHint(ElementHints.KEY_FONT, f); - } - - @Override - public void onElementActivated(IDiagram d, IElement e) { - } - @Override - public void onElementCreated(IElement e) { - if (defaultFont!=null) - e.setHint(ElementHints.KEY_FONT, defaultFont); - } - @Override - public void onElementDeactivated(IDiagram d, IElement e) { - } - @Override - public void onElementDestroyed(IElement e) { - } - - @Override - public int hashCode() { - return ObjectUtils.hashCode(defaultFont); - } - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - TextFontImpl other = (TextFontImpl) obj; - return ObjectUtils.objectEquals(defaultFont, other.defaultFont); - } -} +/******************************************************************************* + * 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.Font; + +import org.simantics.g2d.diagram.IDiagram; +import org.simantics.g2d.element.ElementHints; +import org.simantics.g2d.element.IElement; +import org.simantics.g2d.element.handler.LifeCycle; +import org.simantics.g2d.element.handler.TextFont; +import org.simantics.utils.ObjectUtils; + +/** + * + * @See {@link TextFont} + * @author Marko Luukkainen + */ +public class TextFontImpl implements TextFont, LifeCycle { + + private static final long serialVersionUID = -6254972866736454459L; + + public static TextFontImpl DEFAULT = new TextFontImpl(); + + + public synchronized static TextFontImpl handlerOf(java.awt.Font f) + { + return new TextFontImpl(f); + } + + java.awt.Font defaultFont; + + public TextFontImpl() { + this.defaultFont = new Font("Arial", Font.PLAIN, 12); + } + public TextFontImpl(java.awt.Font defaultFont) { + this.defaultFont = defaultFont; + } + + @Override + public java.awt.Font getFont(IElement e) { + return e.getHint(ElementHints.KEY_FONT); + } + + @Override + public void setFont(IElement e, java.awt.Font f) { + e.setHint(ElementHints.KEY_FONT, f); + } + + @Override + public void onElementActivated(IDiagram d, IElement e) { + } + @Override + public void onElementCreated(IElement e) { + if (defaultFont!=null) + e.setHint(ElementHints.KEY_FONT, defaultFont); + } + @Override + public void onElementDeactivated(IDiagram d, IElement e) { + } + @Override + public void onElementDestroyed(IElement e) { + } + + @Override + public int hashCode() { + return ObjectUtils.hashCode(defaultFont); + } + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + TextFontImpl other = (TextFontImpl) obj; + return ObjectUtils.objectEquals(defaultFont, other.defaultFont); + } +}