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.Color;
16 import org.simantics.g2d.diagram.IDiagram;
17 import org.simantics.g2d.element.ElementHints;
18 import org.simantics.g2d.element.IElement;
19 import org.simantics.g2d.element.handler.AdditionalColor;
20 import org.simantics.g2d.element.handler.LifeCycle;
25 * @author Toni Kalajainen
27 public class AdditionalColorImpl implements AdditionalColor, LifeCycle {
32 private static final long serialVersionUID = -5597731950979011697L;
33 public static final AdditionalColorImpl BLACK = new AdditionalColorImpl(java.awt.Color.BLACK);
34 public static final AdditionalColorImpl WHITE = new AdditionalColorImpl(java.awt.Color.WHITE);
35 public static final AdditionalColorImpl RED = new AdditionalColorImpl(java.awt.Color.RED);
36 public static final AdditionalColorImpl BLUE = new AdditionalColorImpl(java.awt.Color.BLUE);
37 public static final AdditionalColorImpl GREEN = new AdditionalColorImpl(java.awt.Color.GREEN);
38 public static final AdditionalColorImpl GRAY = new AdditionalColorImpl(java.awt.Color.GRAY);
40 public synchronized static AdditionalColorImpl handlerOf(java.awt.Color c)
42 return new AdditionalColorImpl(c);
45 java.awt.Color defaultColor = java.awt.Color.BLACK;
47 public AdditionalColorImpl() {}
48 public AdditionalColorImpl(java.awt.Color defaultColor) {
49 this.defaultColor = defaultColor;
53 public java.awt.Color getAdditionalColor(IElement e) {
54 return e.getHint(ElementHints.KEY_ADDITIONAL_COLOR);
58 public void setAdditionalColor(IElement e, java.awt.Color c) {
59 e.setHint(ElementHints.KEY_ADDITIONAL_COLOR, c);
63 public void onElementActivated(IDiagram d, IElement e) {
66 public void onElementCreated(IElement e) {
67 e.setHint(ElementHints.KEY_ADDITIONAL_COLOR, defaultColor);
70 public void onElementDeactivated(IDiagram d, IElement e) {
73 public void onElementDestroyed(IElement e) {