View Javadoc

1   package org.lcsim.geometry.compact.converter.lcdd.util;
2   
3   import org.jdom.Element;
4   
5   public class VisAttributes extends RefElement
6   {	
7       public VisAttributes(String name)
8       {
9           super("vis",name);
10          
11          this.setAttribute("line_style","unbroken");
12          this.setAttribute("drawing_style","wireframe");
13          this.setAttribute("show_daughters","true");
14          this.setAttribute("visible","true");
15          
16          Element color = new Element("color");
17          color.setAttribute("R","1.0");
18          color.setAttribute("G","1.0");
19          color.setAttribute("B","1.0");
20          color.setAttribute("alpha","1.0");  
21          this.addContent(color);             
22      }
23      
24  	enum LineStyle
25  	{
26  		UNBROKEN("unbroken"),
27  		DASHED("dashed"),
28  		DOTTED("dotted");
29  		
30  		private String s;
31  		
32  		LineStyle(String s)
33  		{
34  			this.s = s;
35  		}
36  		
37  		public String toString()
38  		{
39  			return s;
40  		}
41  	}
42  	
43  	enum DrawingStyle
44  	{
45  		WIREFRAME("wireframe"),
46  		SOLID("solid");
47  		
48  		private String s;
49  		
50  		DrawingStyle(String s)
51  		{
52  			this.s = s;
53  		}
54  		
55  		public String toString()
56  		{
57  			return s;
58  		}
59  	}
60  		
61  	public final void setColor(float r, float g, float b, float a)
62  	{
63  		Element color = this.getChild("color");
64  		color.setAttribute("R",String.valueOf(r));
65  		color.setAttribute("G",String.valueOf(g));
66  		color.setAttribute("B",String.valueOf(b));
67  		color.setAttribute("alpha",String.valueOf(a));
68  	}
69  	
70  	public final void setShowDaughters(boolean b)
71  	{
72  		this.setAttribute("show_daughters",Boolean.toString(b));
73  	}
74  	
75  	public final void setDrawingStyle(DrawingStyle s)
76  	{
77  		this.setAttribute("drawing_style",s.toString());
78  	}
79  	
80  	public final void setDrawingStyle(String s)
81  	{
82  		this.setAttribute("drawing_style",s);
83  	}
84  	
85  	public final void setLineStyle(LineStyle s)
86  	{
87  		this.setAttribute("line_style",s.toString());
88  	}		
89  	
90  	public final void setLineStyle(String s)
91  	{
92  		this.setAttribute("line_style",s);
93  	}
94  	
95  	public final void setVisible(boolean v)
96  	{
97  		this.setAttribute("visible",Boolean.toString(v));
98  	}	
99  }