]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/BorderColorImpl.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / BorderColorImpl.java
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
8  *\r
9  * Contributors:\r
10  *     VTT Technical Research Centre of Finland - initial API and implementation\r
11  *******************************************************************************/\r
12 package org.simantics.g2d.element.handler.impl;\r
13 \r
14 import java.awt.Color;\r
15 \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
21 \r
22 /**\r
23  * \r
24  * @See {@link Color}\r
25  * @author Toni Kalajainen\r
26  */\r
27 public class BorderColorImpl implements BorderColor, LifeCycle {\r
28         \r
29         /**\r
30          * \r
31          */\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
38                 \r
39         public synchronized static BorderColorImpl handlerOf(java.awt.Color c)\r
40         {\r
41                 return new BorderColorImpl(c);\r
42         }\r
43         \r
44         java.awt.Color defaultColor = java.awt.Color.BLACK;\r
45         \r
46         public BorderColorImpl() {}\r
47         public BorderColorImpl(java.awt.Color defaultColor) {\r
48                 this.defaultColor = defaultColor;\r
49         }\r
50         \r
51         @Override\r
52         public java.awt.Color getBorderColor(IElement e) {              \r
53                 return e.getHint(ElementHints.KEY_BORDER_COLOR);\r
54         }\r
55 \r
56         @Override\r
57         public void setBorderColor(IElement e, java.awt.Color c) {\r
58                 e.setHint(ElementHints.KEY_BORDER_COLOR, c);\r
59         }\r
60         \r
61         @Override\r
62         public void onElementActivated(IDiagram d, IElement e) {\r
63         }\r
64         @Override\r
65         public void onElementCreated(IElement e) {\r
66                 if (defaultColor!=null)\r
67                         e.setHint(ElementHints.KEY_BORDER_COLOR, defaultColor);\r
68         }\r
69         @Override\r
70         public void onElementDeactivated(IDiagram d, IElement e) {\r
71         }\r
72         @Override\r
73         public void onElementDestroyed(IElement e) {\r
74         }\r
75 }\r