de.lehmannet.om
Class Lens

java.lang.Object
  extended by de.lehmannet.om.SchemaElement
      extended by de.lehmannet.om.Lens
All Implemented Interfaces:
ILens, ISchemaElement

public class Lens
extends SchemaElement
implements ILens

A Lens describes a lens used to extend or reduce a focal length. Implementations of Lens can be Barlow lenses or Shapley lenses depending on the given factor. The model name and the factor are mandatory fields which have to be set.

Since:
1.7
Author:
doergn@users.sourceforge.net

Field Summary
 
Fields inherited from interface de.lehmannet.om.ILens
XML_ELEMENT_FACTOR, XML_ELEMENT_LENS, XML_ELEMENT_MODEL, XML_ELEMENT_VENDOR
 
Fields inherited from interface de.lehmannet.om.ISchemaElement
XML_ELEMENT_ATTRIBUTE_ID
 
Constructor Summary
Lens(org.w3c.dom.Node lens)
          Constructs a new instance of a Lens from an given XML Schema Node.
Lens(java.lang.String model, float factor)
          Constructs a new instance of a Lens.
 
Method Summary
 org.w3c.dom.Element addAsLinkToXmlElement(org.w3c.dom.Element element)
          Adds the lens link to an given XML DOM Element The lens element itself will be attached to given elements ownerDocument.
 org.w3c.dom.Element addToXmlElement(org.w3c.dom.Element element)
          Adds this Lens to a given parent XML DOM Element.
 java.lang.String getDisplayName()
          Returns a display name for this element.
 float getFactor()
          Returns the focal length factor of this lens.
 java.lang.String getModel()
          Returns the model name of the lens.
 java.lang.String getVendor()
          Returns the vendor name of the lens.
 void setFactor(float factor)
          Sets the focal length factor of the lens.
 void setModel(java.lang.String modelname)
          Sets the model name for the lens.
 void setVendor(java.lang.String vendorname)
          Sets the vendor name of the lens.
 java.lang.String toString()
          Overwrittes toString() method from java.lang.Object.
 
Methods inherited from class de.lehmannet.om.SchemaElement
equals, getID, setID
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface de.lehmannet.om.ISchemaElement
getID
 

Constructor Detail

Lens

public Lens(org.w3c.dom.Node lens)
     throws SchemaException,
            java.lang.IllegalArgumentException
Constructs a new instance of a Lens from an given XML Schema Node.
Normally this constructor is only used by de.lehmannet.om.util.SchemaLoader

Parameters:
lens - The XML Schema element that represents this lens
Throws:
java.lang.IllegalArgumentException - if parameter is null,
SchemaException - if the given Node does not match the XML Schema specifications

Lens

public Lens(java.lang.String model,
            float factor)
     throws java.lang.IllegalArgumentException
Constructs a new instance of a Lens.

Parameters:
model - The lens model name
factor - The focal length factor of the lens
Factors > 1 represent barlow lenses
Factors < 1 represent shapley lenses
Factors <= 0 are not allowed
Throws:
java.lang.IllegalArgumentException - if model is null or factor is Float.NaN or <= 0
Method Detail

getDisplayName

public java.lang.String getDisplayName()
Returns a display name for this element.
The method differs from the toString() method as toString() shows more technical information about the element. Also the formating of toString() can spread over several lines.
This method returns a string (in one line) that can be used as displayname in e.g. a UI dropdown box.

Specified by:
getDisplayName in interface ISchemaElement
Specified by:
getDisplayName in class SchemaElement
Returns:
Returns a String with a one line display name
See Also:
java.lang.Object.toString();

toString

public java.lang.String toString()
Overwrittes toString() method from java.lang.Object.
Returns all fields of the class lens (unset fields will be ignored). The result string will look like this:
Example:
Lens Model: Powermate
Vendor: TeleVue Focal length factor: 5.0

Overrides:
toString in class java.lang.Object
Returns:
A string representing the lens
See Also:
Object

addToXmlElement

public org.w3c.dom.Element addToXmlElement(org.w3c.dom.Element element)
Adds this Lens to a given parent XML DOM Element. The Lens element will be set as a child element of the passed element.

Specified by:
addToXmlElement in interface ILens
Parameters:
parent - The parent element for this Lens
Returns:
Returns the element given as parameter with this Lens as child element.
Might return null if parent was null.
See Also:
Element

addAsLinkToXmlElement

public org.w3c.dom.Element addAsLinkToXmlElement(org.w3c.dom.Element element)
Adds the lens link to an given XML DOM Element The lens element itself will be attached to given elements ownerDocument. If the ownerDocument has no lens container, it will be created.
Example:
<parameterElement>
<lensLink>123</lensLink>
</parameterElement>
More stuff of the xml document goes here
<lensContainer>
<lens id="123">
lens description goes here
</lens>
</lensContainer>

Specified by:
addAsLinkToXmlElement in interface ILens
Parameters:
element - The element under which the the lens link is created
Returns:
Returns the Element given as parameter with a additional lens link, and the lens element under the lens container of the ownerDocument Might return null if element was null.
See Also:
Element

getFactor

public float getFactor()
Returns the focal length factor of this lens.
Factors > 1 represent barlow lenses
Factors < 1 represent shapley lenses
Factors <= 0 are not allowed

Specified by:
getFactor in interface ILens
Returns:
Returns the focal length factor of the lens.

getModel

public java.lang.String getModel()
Returns the model name of the lens.

Specified by:
getModel in interface ILens
Returns:
Returns a String representing the lens model name.

getVendor

public java.lang.String getVendor()
Returns the vendor name of the lens.

Specified by:
getVendor in interface ILens
Returns:
Returns a String representing the lens vendor name.
If null is returned the vendor name was never set.

setFactor

public void setFactor(float factor)
               throws java.lang.IllegalArgumentException
Sets the focal length factor of the lens.

Specified by:
setFactor in interface ILens
Parameters:
factor - The new focal length factor to be set.
Throws:
java.lang.IllegalArgumentException - if factor was Float.NaN or <= 0

setModel

public void setModel(java.lang.String modelname)
              throws java.lang.IllegalArgumentException
Sets the model name for the lens.

Specified by:
setModel in interface ILens
Parameters:
modelname - The new model name to be set.
Throws:
java.lang.IllegalArgumentException - if modelname was null

setVendor

public void setVendor(java.lang.String vendorname)
Sets the vendor name of the lens.

Specified by:
setVendor in interface ILens
Parameters:
vendorname - The new vendor name to be set.