]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/TextColorImpl.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.g2d / src / org / simantics / g2d / element / handler / impl / TextColorImpl.java
diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/TextColorImpl.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/element/handler/impl/TextColorImpl.java
new file mode 100644 (file)
index 0000000..b74f85e
--- /dev/null
@@ -0,0 +1,71 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.g2d.element.handler.impl;\r
+\r
+import org.simantics.g2d.diagram.IDiagram;\r
+import org.simantics.g2d.element.ElementHints;\r
+import org.simantics.g2d.element.IElement;\r
+import org.simantics.g2d.element.handler.LifeCycle;\r
+import org.simantics.g2d.element.handler.TextColor;\r
+\r
+/**\r
+ * \r
+ * @See {@link TextColor}\r
+ * @author Toni Kalajainen\r
+ */\r
+public class TextColorImpl implements TextColor, LifeCycle {\r
+       \r
+    private static final long serialVersionUID = -3684758508037189899L;\r
+\r
+    public static final TextColorImpl UNSET = new TextColorImpl(null);\r
+    public static final TextColorImpl BLACK = new TextColorImpl(java.awt.Color.BLACK);\r
+    public static final TextColorImpl WHITE = new TextColorImpl(java.awt.Color.WHITE);\r
+    public static final TextColorImpl RED = new TextColorImpl(java.awt.Color.RED);\r
+    public static final TextColorImpl BLUE = new TextColorImpl(java.awt.Color.BLUE);\r
+\r
+    public synchronized static TextColorImpl handlerOf(java.awt.Color c)\r
+    {\r
+        return new TextColorImpl(c);\r
+    }\r
+\r
+    java.awt.Color defaultColor = java.awt.Color.BLACK;\r
+\r
+    public TextColorImpl() {}\r
+    public TextColorImpl(java.awt.Color defaultColor) {\r
+        this.defaultColor = defaultColor;\r
+    }\r
+\r
+    @Override\r
+    public java.awt.Color getTextColor(IElement e) {           \r
+        return e.getHint(ElementHints.KEY_TEXT_COLOR);\r
+    }\r
+\r
+    @Override\r
+    public void setTextColor(IElement e, java.awt.Color c) {\r
+        e.setHint(ElementHints.KEY_TEXT_COLOR, c);\r
+    }\r
+\r
+    @Override\r
+    public void onElementActivated(IDiagram d, IElement e) {\r
+    }\r
+    @Override\r
+    public void onElementCreated(IElement e) {\r
+        if (defaultColor!=null)\r
+            e.setHint(ElementHints.KEY_TEXT_COLOR, defaultColor);\r
+    }\r
+    @Override\r
+    public void onElementDeactivated(IDiagram d, IElement e) {\r
+    }\r
+    @Override\r
+    public void onElementDestroyed(IElement e) {\r
+    }\r
+}\r