]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.graphviz/src/org/simantics/graphviz/internal/xdot/SetStyle.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.graphviz / src / org / simantics / graphviz / internal / xdot / SetStyle.java
diff --git a/bundles/org.simantics.graphviz/src/org/simantics/graphviz/internal/xdot/SetStyle.java b/bundles/org.simantics.graphviz/src/org/simantics/graphviz/internal/xdot/SetStyle.java
new file mode 100644 (file)
index 0000000..1ecddaa
--- /dev/null
@@ -0,0 +1,41 @@
+/*******************************************************************************\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.graphviz.internal.xdot;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Graphics2D;\r
+\r
+public class SetStyle implements DrawCommand {\r
+\r
+    private static final BasicStroke SOLID = new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, null, 0.0f);\r
+    private static final BasicStroke DASHED = new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] {5f, 5f}, 0.0f);\r
+    private static final BasicStroke DOTTED = new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] {0f, 2f}, 0.0f);\r
+    \r
+    String styleName;\r
+    \r
+       public SetStyle(String styleName) {\r
+           this.styleName = styleName;\r
+       }\r
+\r
+       @Override\r
+       public void draw(Graphics2D g) {\r
+               if(styleName.equals("solid"))\r
+                   g.setStroke(SOLID);\r
+               else if(styleName.equals("dashed"))\r
+                   g.setStroke(DASHED);\r
+               else if(styleName.equals("dotted"))\r
+            g.setStroke(DOTTED);\r
+               else\r
+                   System.out.println("Unknown style: " + styleName);\r
+       }\r
+\r
+}\r