public final class ValueAndFrequencyDistribution extends Object implements XMLSerializable, XMLSerializable.OldVersionCompatible
finishedAddingValues(jebl.util.ProgressListener) has completed, after which it is thread safe.| Modifier and Type | Class and Description |
|---|---|
static class |
ValueAndFrequencyDistribution.ValueAndFrequency
Represents a value and the number of occurrences of the value
|
XMLSerializable.OldVersionCompatible, XMLSerializable.VersionSupportTypeROOT_ELEMENT_NAME| Constructor and Description |
|---|
ValueAndFrequencyDistribution()
Construct a new empty distribution.
|
ValueAndFrequencyDistribution(org.jdom.Element e)
Construct a new empty distribution from some previously serialized data.
|
ValueAndFrequencyDistribution(ValueAndFrequencyDistribution distribution1,
ValueAndFrequencyDistribution distribution2)
Constructs a new distribution by adding 2 distributions together
|
| Modifier and Type | Method and Description |
|---|---|
void |
addValue(long value,
long frequency)
Adds a new value.
|
void |
finishedAddingValues(ProgressListener progressListener)
Called to finalize and sort the data.
|
void |
fromXML(org.jdom.Element element)
Restore the object from the JDOM Element returned by
XMLSerializable.toXML(). |
long |
getMax() |
long |
getMin() |
long |
getNumberOfUniqueValues()
Get the number of unique values (the number of different values passed to
addValue(long, long) |
long |
getNumberOfValues()
Get the number of values added (the sum of the frequencies passed to
addValue(long, long) |
Iterable<ValueAndFrequencyDistribution.ValueAndFrequency> |
getValues()
Gets a sorted list of values and their frequencies.
|
Geneious.MajorVersion |
getVersionSupport(XMLSerializable.VersionSupportType versionType)
Gets either the latest version this class can serialize to via
XMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener)
or the most recent version in which the XML returned from XMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener) last changed. |
org.jdom.Element |
toXML()
Convert object to a JDOM element.
|
org.jdom.Element |
toXML(Geneious.MajorVersion majorVersion,
ProgressListener progressListener)
Serializes this class to XML format, potentially to a format readable by an earlier version of Geneious.
|
public ValueAndFrequencyDistribution()
public ValueAndFrequencyDistribution(ValueAndFrequencyDistribution distribution1, ValueAndFrequencyDistribution distribution2) throws IOException
distribution1 - the first distribution to adddistribution2 - the second distribution to addIOException - if we can't write the data to disk.public ValueAndFrequencyDistribution(org.jdom.Element e)
throws XMLSerializationException
e - the element returned frmo a previous call to toXML()XMLSerializationException - if it can't be deserialized.public Geneious.MajorVersion getVersionSupport(XMLSerializable.VersionSupportType versionType)
XMLSerializable.OldVersionCompatibleXMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener)
or the most recent version in which the XML returned from XMLSerializable.OldVersionCompatible.toXML(com.biomatters.geneious.publicapi.plugin.Geneious.MajorVersion, jebl.util.ProgressListener) last changed.getVersionSupport in interface XMLSerializable.OldVersionCompatibleversionType - specifies which version property to returnpublic org.jdom.Element toXML()
XMLSerializableXMLSerializable.fromXML(org.jdom.Element) can completely
restore the objects representation.
It is recommended that the returned element use XMLSerializable.ROOT_ELEMENT_NAME as its name,
in which case it must not define an attribute called "type". In this case,
fromXML, will be called with an element whose name may differ from the element
return from this function. This recommendation allows a more compact representation
of the XML can be stored.
This method generally should not be called directly. Instead, you should usually call
XMLSerializer.classToXML(String, XMLSerializable)
which calls this method internally.
PluginDocument implementations of this method may choose to throw an XMLSerializationException,
enclosed in a RuntimeException.toXML in interface XMLSerializablepublic org.jdom.Element toXML(Geneious.MajorVersion majorVersion, ProgressListener progressListener)
XMLSerializable.OldVersionCompatibleXMLSerializable.toXML() for a more
detailed description of what it means to serialize to XML.
All classes that implement this method must also implement XMLSerializable.toXML() and should delegate back to
this method using Geneious.getMajorVersion() and ProgressListener.EMPTY as parameters.toXML in interface XMLSerializable.OldVersionCompatiblemajorVersion - the major version of Geneious to serialize to XML for. For example "6.0" but not "6.0.0". This must be a version
returned greater or equal to a version returned from
getVersionSupport(VersionSupportType.OldestVersionSerializableTo)
and must never be greater than the current version (Geneious.getMajorVersion())progressListener - for reporting progress and cancellingpublic void fromXML(org.jdom.Element element)
throws XMLSerializationException
XMLSerializableXMLSerializable.toXML().
This method generally should not be called directly. Instead, you should usually call
XMLSerializer.classFromXML(org.jdom.Element)
or XMLSerializer.classFromXML(org.jdom.Element, Class)
which calls this method internally.
It is optional to implement this method. Instead of implementing an empty constructor and implementing
this method properly, the implementation may instead
throw an UnsupportedOperationException and implement a constructor
that takes a single Element as a parameter.
This allows for cleaner code such as support for final fields in the XMLSerializable class.
The element parameter should not be modified since it may be reused. If you need a modified version of it,
take a copy with Element.clone().fromXML in interface XMLSerializableelement - representation from a previous call to XMLSerializable.toXML()XMLSerializationException - if the Element can't be converted into this type of objectpublic void addValue(long value,
long frequency)
throws IOException
finishedAddingValues(jebl.util.ProgressListener) must be called once all values have been added.value - the value to addfrequency - the number of occurrences of the value to addIOException - if we can't write the data to disk.IllegalStateException - if finishedAddingValues(jebl.util.ProgressListener) has already been called.public void finishedAddingValues(ProgressListener progressListener) throws IOException
addValue(long, long) before many of the getter methods
can be used.progressListener - for handling progress and cancelling.IOException - if we can't write the data to disk or if the progress listener requests we cancelIllegalStateException - if this method is called more than oncepublic long getMin()
public long getMax()
public long getNumberOfUniqueValues()
addValue(long, long)addValue(long, long)getNumberOfValues()public long getNumberOfValues()
addValue(long, long)addValue(long, long)getNumberOfUniqueValues()public Iterable<ValueAndFrequencyDistribution.ValueAndFrequency> getValues()
IllegalStateException - if finishedAddingValues(jebl.util.ProgressListener) has not yet been called.