viper.descriptors.attributes
Class Attribute_polygon

java.lang.Object
  extended byviper.descriptors.attributes.AbstractAttribute
      extended byviper.descriptors.attributes.Attribute
          extended byviper.descriptors.attributes.Attribute_polygon
All Implemented Interfaces:
java.lang.Cloneable, Filterable
Direct Known Subclasses:
Attribute_bbox, Attribute_obox

public class Attribute_polygon
extends Attribute

This attribute represents a polygon


Nested Class Summary
protected static class Attribute_polygon.Sizer
          Checks that the current value's size.
 
Nested classes inherited from class viper.filters.Filterable
Filterable.Rule
 
Field Summary
 
Fields inherited from class viper.descriptors.attributes.Attribute
composition, compositionTolerance, compositionType, errors, value
 
Constructor Summary
Attribute_polygon()
          Constructs a new static polygon-valued attribute.
Attribute_polygon(Attribute old)
          Copies the old attribute.
Attribute_polygon(boolean dynamic)
          Constructs a new polygon valued attribute.
 
Method Summary
 java.lang.Object clone()
          Returns a clone of this Attribute.
 Filterable.Rule convertRule(java.lang.String unparsedRule, java.util.List unparsedValues, ErrorWriter err)
          This converts a string into a rule, writing out errors in the format to err.
 Rational getArea()
          Gets the area of the polygon.
 Rational getAreaOfIntersectionWith(Attribute_polygon other)
          Gets the area of the polygon shared with the other polygon.
 java.lang.String getType()
          Returns the Attribute type, eg lvalue or bbox.
 boolean isValidRule(java.lang.String ruleName)
          Tell if a name is a valid rule or not
 void setArchetype(org.w3c.dom.Element E)
          Sets the archetype associated with this descriptor.
 void setArchetype(java.lang.String value)
          Sets the archetype associated with this descriptor.
 
Methods inherited from class viper.descriptors.attributes.Attribute
compareTo, compose, crop, getCompositionType, getExtraConfig, getStaticValue, getValue, getValues, getValueToString, getXMLFormat, getXMLFormat, isCompositionType, isType, nullXML, nullXML, parseExtraConfig, passes, possibleValueOf, possibleValueOf, setCompositionType, setDefaultValue, setDefaultValue, setExtraConfig, setFrameSpan, setName, setOutputWidth, setStaticValue, setValue, setValue, setValue, setValue, setValue, toString
 
Methods inherited from class viper.descriptors.attributes.AbstractAttribute
getArchetype, getDefault, getExtraConfigInXML, getExtraConfigString, getName, isDynamic, loadAttributeType, named, named, parseAnInt, resetDefault, setArchetype, setDynamic
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Attribute_polygon

public Attribute_polygon()
Constructs a new static polygon-valued attribute.


Attribute_polygon

public Attribute_polygon(boolean dynamic)
Constructs a new polygon valued attribute.

Parameters:
dynamic - if the attribute can take on different values at different frames

Attribute_polygon

public Attribute_polygon(Attribute old)
Copies the old attribute.

Parameters:
old - the old attribute
Method Detail

getType

public java.lang.String getType()
Description copied from class: AbstractAttribute
Returns the Attribute type, eg lvalue or bbox.

Overrides:
getType in class Attribute
Returns:
"polygon"

clone

public java.lang.Object clone()
Description copied from class: Attribute
Returns a clone of this Attribute.

Overrides:
clone in class Attribute
Returns:
a reference to a new Attribute with all the values of the original

setArchetype

public void setArchetype(java.lang.String value)
                  throws BadDataException
Description copied from class: AbstractAttribute
Sets the archetype associated with this descriptor.

Overrides:
setArchetype in class AbstractAttribute
Parameters:
value - the description
Throws:
BadDataException

setArchetype

public void setArchetype(org.w3c.dom.Element E)
                  throws BadDataException
Description copied from class: AbstractAttribute
Sets the archetype associated with this descriptor.

Overrides:
setArchetype in class AbstractAttribute
Parameters:
E - the description
Throws:
BadDataException

getArea

public Rational getArea()
Gets the area of the polygon. For dynamic polygons, gets the sum of the area on all frames.

Returns:
the area

getAreaOfIntersectionWith

public Rational getAreaOfIntersectionWith(Attribute_polygon other)
Gets the area of the polygon shared with the other polygon.

Parameters:
other - the other polygon
Returns:
the approximate area of the intersection

isValidRule

public boolean isValidRule(java.lang.String ruleName)
Description copied from interface: Filterable
Tell if a name is a valid rule or not

Specified by:
isValidRule in interface Filterable
Overrides:
isValidRule in class Attribute
Returns:
true when it is "==" or "!="

convertRule

public Filterable.Rule convertRule(java.lang.String unparsedRule,
                                   java.util.List unparsedValues,
                                   ErrorWriter err)
                            throws BadDataException
This converts a string into a rule, writing out errors in the format to err.

Specified by:
convertRule in interface Filterable
Overrides:
convertRule in class Attribute
Parameters:
unparsedRule - A string containing a single rule.
unparsedValues - A string containing values.
err - A place to log the errors.
Returns:
A List containing a rule (String) and value (Object) pair.
Throws:
BadDataException