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.BorderColor;
\r
20 import org.simantics.g2d.element.handler.LifeCycle;
\r
24 * @See {@link Color}
\r
25 * @author Toni Kalajainen
\r
27 public class BorderColorImpl implements BorderColor, LifeCycle {
\r
32 private static final long serialVersionUID = 9146714542866437248L;
\r
33 public static final BorderColorImpl UNSET = new BorderColorImpl(null);
\r
34 public static final BorderColorImpl BLACK = new BorderColorImpl(java.awt.Color.BLACK);
\r
35 public static final BorderColorImpl WHITE = new BorderColorImpl(java.awt.Color.WHITE);
\r
36 public static final BorderColorImpl RED = new BorderColorImpl(java.awt.Color.RED);
\r
37 public static final BorderColorImpl BLUE = new BorderColorImpl(java.awt.Color.BLUE);
\r
39 public synchronized static BorderColorImpl handlerOf(java.awt.Color c)
\r
41 return new BorderColorImpl(c);
\r
44 java.awt.Color defaultColor = java.awt.Color.BLACK;
\r
46 public BorderColorImpl() {}
\r
47 public BorderColorImpl(java.awt.Color defaultColor) {
\r
48 this.defaultColor = defaultColor;
\r
52 public java.awt.Color getBorderColor(IElement e) {
\r
53 return e.getHint(ElementHints.KEY_BORDER_COLOR);
\r
57 public void setBorderColor(IElement e, java.awt.Color c) {
\r
58 e.setHint(ElementHints.KEY_BORDER_COLOR, c);
\r
62 public void onElementActivated(IDiagram d, IElement e) {
\r
65 public void onElementCreated(IElement e) {
\r
66 if (defaultColor!=null)
\r
67 e.setHint(ElementHints.KEY_BORDER_COLOR, defaultColor);
\r
70 public void onElementDeactivated(IDiagram d, IElement e) {
\r
73 public void onElementDestroyed(IElement e) {
\r