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