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 org.simantics.g2d.diagram.IDiagram;
15 import org.simantics.g2d.element.ElementHints;
16 import org.simantics.g2d.element.IElement;
17 import org.simantics.g2d.element.handler.LifeCycle;
18 import org.simantics.g2d.element.handler.TextColor;
22 * @See {@link TextColor}
23 * @author Toni Kalajainen
25 public class TextColorImpl implements TextColor, LifeCycle {
27 private static final long serialVersionUID = -3684758508037189899L;
29 public static final TextColorImpl UNSET = new TextColorImpl(null);
30 public static final TextColorImpl BLACK = new TextColorImpl(java.awt.Color.BLACK);
31 public static final TextColorImpl WHITE = new TextColorImpl(java.awt.Color.WHITE);
32 public static final TextColorImpl RED = new TextColorImpl(java.awt.Color.RED);
33 public static final TextColorImpl BLUE = new TextColorImpl(java.awt.Color.BLUE);
35 public synchronized static TextColorImpl handlerOf(java.awt.Color c)
37 return new TextColorImpl(c);
40 java.awt.Color defaultColor = java.awt.Color.BLACK;
42 public TextColorImpl() {}
43 public TextColorImpl(java.awt.Color defaultColor) {
44 this.defaultColor = defaultColor;
48 public java.awt.Color getTextColor(IElement e) {
49 return e.getHint(ElementHints.KEY_TEXT_COLOR);
53 public void setTextColor(IElement e, java.awt.Color c) {
54 e.setHint(ElementHints.KEY_TEXT_COLOR, c);
58 public void onElementActivated(IDiagram d, IElement e) {
61 public void onElementCreated(IElement e) {
62 if (defaultColor!=null)
63 e.setHint(ElementHints.KEY_TEXT_COLOR, defaultColor);
66 public void onElementDeactivated(IDiagram d, IElement e) {
69 public void onElementDestroyed(IElement e) {