]> gerrit.simantics Code Review - simantics/platform.git/blob - 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
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.graphviz.internal.xdot;\r
13 \r
14 import java.awt.BasicStroke;\r
15 import java.awt.Graphics2D;\r
16 \r
17 public class SetStyle implements DrawCommand {\r
18 \r
19     private static final BasicStroke SOLID = new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, null, 0.0f);\r
20     private static final BasicStroke DASHED = new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] {5f, 5f}, 0.0f);\r
21     private static final BasicStroke DOTTED = new BasicStroke(1f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[] {0f, 2f}, 0.0f);\r
22     \r
23     String styleName;\r
24     \r
25         public SetStyle(String styleName) {\r
26             this.styleName = styleName;\r
27         }\r
28 \r
29         @Override\r
30         public void draw(Graphics2D g) {\r
31                 if(styleName.equals("solid"))\r
32                     g.setStroke(SOLID);\r
33                 else if(styleName.equals("dashed"))\r
34                     g.setStroke(DASHED);\r
35                 else if(styleName.equals("dotted"))\r
36             g.setStroke(DOTTED);\r
37                 else\r
38                     System.out.println("Unknown style: " + styleName);\r
39         }\r
40 \r
41 }\r