Package mgui.numbers
Class MguiFloat
java.lang.Object
mgui.numbers.MguiFloat
- All Implemented Interfaces:
java.lang.Cloneable
,java.lang.Comparable<MguiNumber>
,XMLObject
,MguiNumber
public class MguiFloat extends java.lang.Object implements MguiNumber
Implementation of
MguiNumber
for values of type float
.- Since:
- 1.0
- Version:
- 1.0
- Author:
- Andrew Reid
-
Nested Class Summary
Nested classes/interfaces inherited from interface mgui.interfaces.xml.XMLObject
XMLObject.XMLEncoding, XMLObject.XMLType
-
Field Summary
Fields Modifier and Type Field Description protected float
value
-
Constructor Summary
Constructors Constructor Description MguiFloat()
MguiFloat(double thisValue)
MguiFloat(java.lang.String thisValue)
MguiFloat(MguiNumber thisValue)
-
Method Summary
Modifier and Type Method Description MguiNumber
add(double n)
Update the value of this number by addingn
.MguiNumber
add(MguiNumber number)
Update the value of this number by addingn
.java.lang.Object
clone()
int
compareTo(double d)
int
compareTo(double value, int precision)
int
compareTo(float f)
int
compareTo(MguiNumber n)
MguiNumber
divide(double n)
Update the value of this number by dividing byn
.MguiNumber
divide(MguiNumber number)
Update the value of this number by dividing byn
.boolean
equals(java.lang.Object obj)
int
getByteSize()
java.lang.String
getDTD()
Returns the Data Type Declaration (DTD) for this object's XML representationfloat
getFloat()
Get this value as a float.java.lang.String
getLocalName()
Returns the local name associated with this XML object.java.lang.String
getShortXML(int tab)
Returns a short XML representation of this object.static java.lang.String
getString(float thisVal, int precision)
static java.lang.String
getString(float thisVal, java.lang.String pattern)
double
getValue()
Returns the value of this numberstatic float
getValue(java.lang.String s)
java.lang.String
getXML()
Returns this object's XML representation as a single string.java.lang.String
getXML(int tab)
Returns this object's XML representation as a single string.static XMLObject
getXMLInstance(org.xml.sax.Attributes attributes)
java.lang.String
getXMLSchema()
Returns the XML schema for this object's XML representationvoid
handleXMLElementEnd(java.lang.String localName)
Handles the end of an XML element.void
handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)
Handles the start of an XML element.void
handleXMLString(java.lang.String s)
Handles a string within an XML element.MguiNumber
multiply(double n)
Update the value of this number by multiplying byn
.MguiNumber
multiply(MguiNumber number)
Update the value of this number by multiplying byn
.void
setValue(double thisValue)
boolean
setValue(java.lang.String val)
void
setValue(MguiNumber val)
MguiNumber
subtract(double n)
Update the value of this number by subtractingn
.MguiNumber
subtract(MguiNumber number)
Update the value of this number by subtractingn
.java.lang.String
toString()
java.lang.String
toString(java.lang.String pattern)
Returns the value of this number as aString
, formatted withpattern
.void
writeXML(int tab, java.io.Writer writer)
Writes the XML representation of this object to file.void
writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar)
Writes the XML representation of this object to file, asXMLType.Normal
.void
writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar)
Writes the XML representation of this object to file.Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Field Details
-
value
protected float value
-
-
Constructor Details
-
MguiFloat
public MguiFloat() -
MguiFloat
public MguiFloat(double thisValue) -
MguiFloat
public MguiFloat(java.lang.String thisValue) -
MguiFloat
-
-
Method Details
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classjava.lang.Object
-
getValue
public static float getValue(java.lang.String s) -
compareTo
public int compareTo(double value, int precision)- Specified by:
compareTo
in interfaceMguiNumber
-
setValue
- Specified by:
setValue
in interfaceMguiNumber
-
setValue
public void setValue(double thisValue)- Specified by:
setValue
in interfaceMguiNumber
-
getFloat
public float getFloat()Get this value as a float.- Returns:
-
getValue
public double getValue()Description copied from interface:MguiNumber
Returns the value of this number- Specified by:
getValue
in interfaceMguiNumber
- Returns:
-
setValue
public boolean setValue(java.lang.String val)- Specified by:
setValue
in interfaceMguiNumber
-
add
Description copied from interface:MguiNumber
Update the value of this number by addingn
.- Specified by:
add
in interfaceMguiNumber
- Returns:
- this number
-
divide
Description copied from interface:MguiNumber
Update the value of this number by dividing byn
.- Specified by:
divide
in interfaceMguiNumber
- Returns:
- this number
-
subtract
Description copied from interface:MguiNumber
Update the value of this number by subtractingn
.- Specified by:
subtract
in interfaceMguiNumber
- Returns:
- this number
-
multiply
Description copied from interface:MguiNumber
Update the value of this number by multiplying byn
.- Specified by:
multiply
in interfaceMguiNumber
- Returns:
- this number
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
-
toString
public java.lang.String toString(java.lang.String pattern)Description copied from interface:MguiNumber
Returns the value of this number as aString
, formatted withpattern
.- Specified by:
toString
in interfaceMguiNumber
- Returns:
-
getString
public static java.lang.String getString(float thisVal, java.lang.String pattern) -
getString
public static java.lang.String getString(float thisVal, int precision) -
clone
public java.lang.Object clone()- Specified by:
clone
in interfaceMguiNumber
- Overrides:
clone
in classjava.lang.Object
-
compareTo
public int compareTo(float f) throws java.lang.ClassCastException- Throws:
java.lang.ClassCastException
-
compareTo
- Specified by:
compareTo
in interfacejava.lang.Comparable<MguiNumber>
- Throws:
java.lang.ClassCastException
-
compareTo
public int compareTo(double d)- Specified by:
compareTo
in interfaceMguiNumber
-
getByteSize
public int getByteSize()- Specified by:
getByteSize
in interfaceMguiNumber
-
add
Description copied from interface:MguiNumber
Update the value of this number by addingn
.- Specified by:
add
in interfaceMguiNumber
- Returns:
- this number
-
divide
Description copied from interface:MguiNumber
Update the value of this number by dividing byn
.- Specified by:
divide
in interfaceMguiNumber
- Returns:
- this number
-
multiply
Description copied from interface:MguiNumber
Update the value of this number by multiplying byn
.- Specified by:
multiply
in interfaceMguiNumber
- Returns:
- this number
-
subtract
Description copied from interface:MguiNumber
Update the value of this number by subtractingn
.- Specified by:
subtract
in interfaceMguiNumber
- Returns:
- this number
-
getDTD
public java.lang.String getDTD()Description copied from interface:XMLObject
Returns the Data Type Declaration (DTD) for this object's XML representationSee http://en.wikipedia.org/wiki/Document_Type_Definition for a description.
-
getLocalName
public java.lang.String getLocalName()Description copied from interface:XMLObject
Returns the local name associated with this XML object.- Specified by:
getLocalName
in interfaceXMLObject
- Returns:
-
getXML
public java.lang.String getXML()Description copied from interface:XMLObject
Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
getXML
public java.lang.String getXML(int tab)Description copied from interface:XMLObject
Returns this object's XML representation as a single string. NOTE: this is not feasible for larger objects and containers, thus may not be implemented for these objects. Use theXMLObject.writeXML(int,java.io.Writer,mgui.io.standard.xml.XMLOutputOptions,mgui.interfaces.ProgressUpdater)
functions to write larger objects to file. -
getXMLSchema
public java.lang.String getXMLSchema()Description copied from interface:XMLObject
Returns the XML schema for this object's XML representation- Specified by:
getXMLSchema
in interfaceXMLObject
- Returns:
-
handleXMLElementEnd
public void handleXMLElementEnd(java.lang.String localName)Description copied from interface:XMLObject
Handles the end of an XML element.- Specified by:
handleXMLElementEnd
in interfaceXMLObject
- Parameters:
localName
- Local name of the element
-
handleXMLElementStart
public void handleXMLElementStart(java.lang.String localName, org.xml.sax.Attributes attributes, XMLObject.XMLType type)Description copied from interface:XMLObject
Handles the start of an XML element.- Specified by:
handleXMLElementStart
in interfaceXMLObject
- Parameters:
localName
- Local name of the elementattributes
- Set of element attributestype
- TheXMLType
of this element
-
handleXMLString
public void handleXMLString(java.lang.String s)Description copied from interface:XMLObject
Handles a string within an XML element.- Specified by:
handleXMLString
in interfaceXMLObject
- Parameters:
s
- String to handle
-
getXMLInstance
-
writeXML
public void writeXML(int tab, java.io.Writer writer) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Ascii
will be used. -
writeXML
public void writeXML(int tab, java.io.Writer writer, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file, asXMLType.Normal
. The default format ofXMLFormat.Ascii
will be used. The basic contract for this method is that it should not write a newline character at its start or end. -
writeXML
public void writeXML(int tab, java.io.Writer writer, XMLOutputOptions options, ProgressUpdater progress_bar) throws java.io.IOExceptionDescription copied from interface:XMLObject
Writes the XML representation of this object to file. The basic contract for this method is that it should not write a newline character at its start or end. The default format ofXMLFormat.Ascii
will be used. -
getShortXML
public java.lang.String getShortXML(int tab)Description copied from interface:XMLObject
Returns a short XML representation of this object.- Specified by:
getShortXML
in interfaceXMLObject
- Returns:
-