]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/AdditionalColorImpl.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / AdditionalColorImpl.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.AdditionalColor;
20 import org.simantics.g2d.element.handler.LifeCycle;
21
22 /**
23  * 
24  * @See {@link Color}
25  * @author Toni Kalajainen
26  */
27 public class AdditionalColorImpl implements AdditionalColor, LifeCycle {
28         
29         /**
30          * 
31          */
32         private static final long serialVersionUID = -5597731950979011697L;
33         public static final AdditionalColorImpl BLACK = new AdditionalColorImpl(java.awt.Color.BLACK);
34         public static final AdditionalColorImpl WHITE = new AdditionalColorImpl(java.awt.Color.WHITE);
35         public static final AdditionalColorImpl RED = new AdditionalColorImpl(java.awt.Color.RED);
36         public static final AdditionalColorImpl BLUE = new AdditionalColorImpl(java.awt.Color.BLUE);
37         public static final AdditionalColorImpl GREEN = new AdditionalColorImpl(java.awt.Color.GREEN);
38         public static final AdditionalColorImpl GRAY = new AdditionalColorImpl(java.awt.Color.GRAY);
39                 
40         public synchronized static AdditionalColorImpl handlerOf(java.awt.Color c)
41         {
42                 return new AdditionalColorImpl(c);
43         }
44         
45         java.awt.Color defaultColor = java.awt.Color.BLACK;
46         
47         public AdditionalColorImpl() {}
48         public AdditionalColorImpl(java.awt.Color defaultColor) {
49                 this.defaultColor = defaultColor;
50         }
51         
52         @Override
53         public java.awt.Color getAdditionalColor(IElement e) {          
54                 return e.getHint(ElementHints.KEY_ADDITIONAL_COLOR);
55         }
56
57         @Override
58         public void setAdditionalColor(IElement e, java.awt.Color c) {
59                 e.setHint(ElementHints.KEY_ADDITIONAL_COLOR, c);
60         }
61         
62         @Override
63         public void onElementActivated(IDiagram d, IElement e) {
64         }
65         @Override
66         public void onElementCreated(IElement e) {
67                 e.setHint(ElementHints.KEY_ADDITIONAL_COLOR, defaultColor);
68         }
69         @Override
70         public void onElementDeactivated(IDiagram d, IElement e) {
71         }
72         @Override
73         public void onElementDestroyed(IElement e) {
74         }
75 }