Class JaxoLatexText
- java.lang.Object
-
- net.sf.jaxodraw.graph.object.AbstractJaxoObject
-
- net.sf.jaxodraw.graph.object.text.AbstractTextObject
-
- net.sf.jaxodraw.graph.object.text.JaxoLatexText
-
- All Implemented Interfaces:
PropertyChangeListener
,Serializable
,EventListener
,JaxoObject
,JaxoRotationObject
public class JaxoLatexText extends AbstractTextObject
Defines a JaxoObject which is a LaTeX text.- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JaxoLatexText.Align
Specify the alignment of a latex text with respect to the text coordinate.static class
JaxoLatexText.TextSize
Specify the latex text size.-
Nested classes/interfaces inherited from interface net.sf.jaxodraw.graph.object.JaxoObject
JaxoObject.EditMode, JaxoObject.Handle
-
-
Field Summary
-
Fields inherited from class net.sf.jaxodraw.graph.object.AbstractJaxoObject
SERIAL_VERSION_UID
-
-
Constructor Summary
Constructors Constructor Description JaxoLatexText()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static JaxoLatexText.Align
alignForInt(int pos)
Return the enum as a function of its position in the class declaration.static JaxoLatexText.Align
alignForString(String pos)
Return the enum as a function of its LaTeX text representation.JaxoObject
copy()
Returns a new instance which is an exact copy of this JaxoObject.void
copyFrom(JaxoObject o)
Sets all parameters from the given object to the current one.protected void
copyFrom(JaxoLatexText temp)
Sets all parameters from the given object to the current one.JaxoLatexText.Align
getAllign()
Returns the allign property of this text object.Rectangle
getBounds()
Returns the bounding box of this JaxoObject.JaxoLatexText.TextSize
getLatexTextSize()
Returns the latex font size of this text object.float
getScaleFactor()
Return the scale factor.boolean
isCopy(JaxoObject obj)
Determines if this JaxoObject is a copy of the specified one.boolean
isValid()
Check if the current text String is valid.void
paint(Graphics2D g2)
The method that paints the JaxoObject.void
prepareEditPanel(JaxoObjectEditPanel editPanel)
Initializes the given editPanel to edit properties of this JaxoObject.void
scale(Point origin, float scaleX, float scaleY)
Rescale the click-points of this JaxoObject by a scale factor, keeping the point origin fixed.void
setAllign(JaxoLatexText.Align newAllign)
Sets the allign property of this text object.void
setLatexTextSize(JaxoLatexText.TextSize newLatexfs)
Sets the latex font size of this text object.void
setPreferences()
Applies default values to this JaxoObject.void
setScaleFactor(float newScale)
Set the latex font scale factor.static JaxoLatexText.TextSize
textSizeForInt(int size)
Return the enum as a function of its position in the class declaration.static JaxoLatexText.TextSize
textSizeForString(String command)
Return the enum as a function of its LaTeX text representation.-
Methods inherited from class net.sf.jaxodraw.graph.object.text.AbstractTextObject
copyFrom, getRotationAngle, getTextString, isPaintable, setRotationAngle, setTextString
-
Methods inherited from class net.sf.jaxodraw.graph.object.AbstractJaxoObject
addPropertyChangeListener, canBeSelected, copyFrom, equal, equal, firePropertyChange, getColor, getGeneralPath, getLastClickPoint, getPoint, getPoint1, getPointCount, getPoints, getSelectedHandle, getX, getY, hasClickPoint, hasHandle, isAround, isMarked, paintVisualAid, propertyChange, removePropertyChangeListener, setAsMarked, setColor, setLocation, setPoint, setPoint1, setPoints, setTransient, setX, setXPosition, setY, setYPosition, translate, zero
-
-
-
-
Method Detail
-
alignForInt
public static JaxoLatexText.Align alignForInt(int pos)
Return the enum as a function of its position in the class declaration.- Parameters:
pos
- an int.- Returns:
- an Align enum or null, if nothing corresponds.
-
alignForString
public static JaxoLatexText.Align alignForString(String pos)
Return the enum as a function of its LaTeX text representation.- Parameters:
pos
- the latex position string.- Returns:
- an Align enum or null, if nothing corresponds.
-
textSizeForInt
public static JaxoLatexText.TextSize textSizeForInt(int size)
Return the enum as a function of its position in the class declaration.- Parameters:
size
- an int.- Returns:
- a TextSize enum or null, if nothing corresponds.
-
textSizeForString
public static JaxoLatexText.TextSize textSizeForString(String command)
Return the enum as a function of its LaTeX text representation.- Parameters:
command
- the latex command of the text size.- Returns:
- a TextSize enum or null, if nothing corresponds.
-
getAllign
public JaxoLatexText.Align getAllign()
Returns the allign property of this text object.- Returns:
- The allign property of this text object.
-
setAllign
public void setAllign(JaxoLatexText.Align newAllign)
Sets the allign property of this text object.- Parameters:
newAllign
- The allign property of this text object.
-
getLatexTextSize
public JaxoLatexText.TextSize getLatexTextSize()
Returns the latex font size of this text object.- Returns:
- The latex font size of this text object.
-
setLatexTextSize
public void setLatexTextSize(JaxoLatexText.TextSize newLatexfs)
Sets the latex font size of this text object.- Parameters:
newLatexfs
- The latex font size of this text object.
-
getScaleFactor
public float getScaleFactor()
Return the scale factor.- Returns:
- the scale factor.
-
setScaleFactor
public void setScaleFactor(float newScale)
Set the latex font scale factor.- Parameters:
newScale
- the new scale factor.
-
isValid
public boolean isValid()
Check if the current text String is valid.- Returns:
- true if the current text String is valid.
-
copy
public JaxoObject copy()
Returns a new instance which is an exact copy of this JaxoObject.The copy has to fulfill the general contract as described in
isCopy(JaxoObject)
.- Returns:
- A copy of this JaxoObject.
- See Also:
JaxoObject.isCopy(net.sf.jaxodraw.graph.object.JaxoObject)
-
isCopy
public boolean isCopy(JaxoObject obj)
Determines if this JaxoObject is a copy of the specified one.Two JaxoObjects are copies of each other if all their editable properties are equal. This method should be synchronized with
JaxoObject.copy()
such that for any non-null JaxoObjectob
, a call likeisCopy(ob.copy())
must return true.Finally, this method implements an equivalence relation on non-null object references, it should satisfy the same constraints as the
Object.equals(java.lang.Object)
method.- Specified by:
isCopy
in interfaceJaxoObject
- Overrides:
isCopy
in classAbstractTextObject
- Parameters:
obj
- The JaxoObject to compare against. May be null in which case false is returned.- Returns:
- True if this JaxoObject is a copy of the given one, false otherwise.
- See Also:
JaxoObject.copy()
-
copyFrom
protected void copyFrom(JaxoLatexText temp)
Sets all parameters from the given object to the current one.- Parameters:
temp
- The object to copy from.
-
copyFrom
public void copyFrom(JaxoObject o)
Sets all parameters from the given object to the current one.This throws an UnsupportedOperationException if the given JaxoObject is not a super- or sub-type of this JaxoObject.
- Parameters:
o
- The object to copy from. This has to be a super- or sub-type of this JaxoObject, otherwise an UnsupportedOperationException is thrown.
-
paint
public void paint(Graphics2D g2)
The method that paints the JaxoObject.- Parameters:
g2
- The graphics context where the object has to be painted.
-
getBounds
public Rectangle getBounds()
Returns the bounding box of this JaxoObject.- Returns:
- a Rectangle that completely contains this JaxoObject. May be null if this JaxoObject has no points set.
- See Also:
JaxoObject.getPoint(net.sf.jaxodraw.graph.object.JaxoObject.Handle)
,JaxoObject.setPoint(net.sf.jaxodraw.graph.object.JaxoObject.Handle, java.awt.Point)
-
scale
public void scale(Point origin, float scaleX, float scaleY)
Rescale the click-points of this JaxoObject by a scale factor, keeping the point origin fixed.- Specified by:
scale
in interfaceJaxoObject
- Overrides:
scale
in classAbstractJaxoObject
- Parameters:
origin
- The coordinate of the fixed point.scaleX
- The scale parameter in x direction.scaleY
- The scale parameter in y direction.
-
setPreferences
public void setPreferences()
Applies default values to this JaxoObject.All fields except location points are initialized with values taken from the
preferences
.- Specified by:
setPreferences
in interfaceJaxoObject
- Overrides:
setPreferences
in classAbstractTextObject
-
prepareEditPanel
public void prepareEditPanel(JaxoObjectEditPanel editPanel)
Initializes the given editPanel to edit properties of this JaxoObject.- Parameters:
editPanel
- the panel to prepare.
-
-