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 java.awt.Color;
\r
16 import org.simantics.g2d.diagram.IDiagram;
\r
17 import org.simantics.g2d.element.ElementHints;
\r
18 import org.simantics.g2d.element.IElement;
\r
19 import org.simantics.g2d.element.handler.FillColor;
\r
20 import org.simantics.g2d.element.handler.LifeCycle;
\r
24 * @See {@link Color}
\r
25 * @author Toni Kalajainen
\r
27 public class FillColorImpl implements FillColor, LifeCycle {
\r
29 private static final long serialVersionUID = 2241631816115855117L;
\r
30 public static final FillColorImpl UNSET = new FillColorImpl(null);
\r
31 public static final FillColorImpl BLACK = new FillColorImpl(java.awt.Color.BLACK);
\r
32 public static final FillColorImpl WHITE = new FillColorImpl(java.awt.Color.WHITE);
\r
33 public static final FillColorImpl RED = new FillColorImpl(java.awt.Color.RED);
\r
34 public static final FillColorImpl BLUE = new FillColorImpl(java.awt.Color.BLUE);
\r
36 public synchronized static FillColorImpl handlerOf(java.awt.Color c)
\r
38 return new FillColorImpl(c);
\r
41 java.awt.Color defaultColor = java.awt.Color.BLACK;
\r
43 public FillColorImpl() {}
\r
44 public FillColorImpl(java.awt.Color defaultColor) {
\r
45 this.defaultColor = defaultColor;
\r
49 public java.awt.Color getFillColor(IElement e) {
\r
50 return e.getHint(ElementHints.KEY_FILL_COLOR);
\r
54 public void setFillColor(IElement e, java.awt.Color c) {
\r
55 e.setHint(ElementHints.KEY_FILL_COLOR, c);
\r
59 public void onElementActivated(IDiagram d, IElement e) {
\r
62 public void onElementCreated(IElement e) {
\r
63 if (defaultColor!=null)
\r
64 e.setHint(ElementHints.KEY_FILL_COLOR, defaultColor);
\r
67 public void onElementDeactivated(IDiagram d, IElement e) {
\r
70 public void onElementDestroyed(IElement e) {
\r