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