GeomConverter/src/org/lcsim/geometry/compact
diff -u -r1.2 -r1.3
--- VisAttributes.java 17 Sep 2006 01:05:43 -0000 1.2
+++ VisAttributes.java 13 Oct 2006 22:31:51 -0000 1.3
@@ -1,12 +1,15 @@
package org.lcsim.geometry.compact;
+import java.awt.Color;
+
import org.jdom.DataConversionException;
import org.jdom.Element;
public class VisAttributes
{
- double rgba[] = new double[4];
- String name;
+ double[] rgba = {1.0,1.0,1.0,1.0};
+ Color color = null;
+ String name = null;
String linestyle = "unbroken";
String drawingstyle = "wireframe";
boolean visible = true;
@@ -15,11 +18,36 @@
protected VisAttributes(Element node)
{
try {
- name = node.getAttributeValue("name");
- rgba[0] = node.getAttribute("r").getDoubleValue();
- rgba[1] = node.getAttribute("g").getDoubleValue();
- rgba[2] = node.getAttribute("b").getDoubleValue();
- rgba[3] = node.getAttribute("alpha").getDoubleValue();
+ this.name = node.getAttributeValue("name");
+
+ // Create a Java Color from the input RGBA values.
+ if (node.getAttribute("r") != null)
+ {
+ this.rgba[0] = node.getAttribute("r").getDoubleValue();
+ }
+
+ if (node.getAttribute("g") != null)
+ {
+ this.rgba[1] = node.getAttribute("g").getDoubleValue();
+ }
+
+ if (node.getAttribute("b") != null)
+ {
+ this.rgba[2] = node.getAttribute("b").getDoubleValue();
+ }
+
+ if (node.getAttribute("alpha") != null)
+ {
+ this.rgba[3] = node.getAttribute("alpha").getDoubleValue();
+ }
+
+ // Create the Java Color from the RGBA input values.
+ this.color = new Color((float)(rgba[0]),(float)(rgba[1]),(float)(rgba[2]),(float)(rgba[3]));
+
+ //float[] x = {0,0,0,0};
+ //x = this.color.getColorComponents(x);
+ //System.out.println("JAVA COLOR --> " + x[0] + ", " + ", " + x[1] + "," + x[2] + ", " + x[3]);
+ //System.out.println(color.toString());
if (node.getAttribute("lineStyle") != null)
{
@@ -47,9 +75,9 @@
}
}
- public double[] getRGBA()
+ public Color getColor()
{
- return rgba;
+ return this.color;
}
public boolean getVisible()
@@ -74,6 +102,11 @@
public String getName()
{
- return name;
+ return this.name;
+ }
+
+ public double[] getRGBA()
+ {
+ return this.rgba;
}
}
\ No newline at end of file
GeomConverter/src/org/lcsim/geometry/subdetector
diff -u -r1.7 -r1.8
--- AbstractSubdetector.java 12 Sep 2006 02:42:48 -0000 1.7
+++ AbstractSubdetector.java 13 Oct 2006 22:31:51 -0000 1.8
@@ -7,7 +7,6 @@
package org.lcsim.geometry.subdetector;
-/* JDOM dependence from org.lcsim.geometry.compact.Subdetector */
import hep.graphics.heprep.HepRep;
import hep.graphics.heprep.HepRepFactory;
import hep.graphics.heprep.HepRepType;
@@ -35,11 +34,6 @@
super(node);
}
-// public SubdetectorIDDecoder getSubdetectorIDDecoder()
-// {
-// return (SubdetectorIDDecoder)(getReadout().getIDDecoder() );
-// }
-
/** HepRepProvider: optional impl for subclass */
/** FIXME: Should live in org.lcsim.geometry.heprep or equivalent. */
public void appendHepRep(HepRepFactory factory, HepRep heprep)
@@ -59,9 +53,7 @@
{
if ( getVisAttributes() != null )
{
- double rgba[] = getVisAttributes().getRGBA();
- String c = rgba[0] + "," + rgba[1] + "," + rgba[2] + "," + rgba[3];
- type.addAttValue("color", c);
+ type.addAttValue("color", getVisAttributes().getColor());
}
}
}
\ No newline at end of file