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