Class JxnTextPainter
- java.lang.Object
-
- JxnAbstractPainter
-
- JxnTextPainter
-
- All Implemented Interfaces:
KmgXYPainter
public class JxnTextPainter extends JxnAbstractPainter
Defines a text object for display in aPlotFrame
.
Example:plot(1.5+j).
add
( @
JxnTextPainter
( "XYZ", 0.4, 0.6 ) )
-
-
Constructor Summary
Constructors Constructor Description JxnTextPainter(double value, double x0, double y0)
Creates an instance for display ofvalue
as text in a PlotFrame.JxnTextPainter(double value, double x0, double y0, Color textColor)
SeeJxnTextPainter
.JxnTextPainter(double value, double x0, double y0, JxnTextPainter template)
SeeJxnTextPainter
.JxnTextPainter(long value, double x0, double y0)
Creates an instance for display ofvalue
as text in a PlotFrame.JxnTextPainter(long value, double x0, double y0, Color textColor)
SeeJxnTextPainter
.JxnTextPainter(long value, double x0, double y0, JxnTextPainter template)
SeeJxnTextPainter
.JxnTextPainter(String text, double x0, double y0)
JxnTextPainter(String text, double x0, double y0, Color textColor)
SeeJxnTextPainter
.JxnTextPainter(String text, double x0, double y0, JxnTextPainter template)
SeeJxnTextPainter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description KmgDoubleBounds
getKmgDoubleBounds()
Returns the bounds of the graphical object (called internally).void
paint(KmgGraphicsScaler sk)
Paints the graphical object (called internally).JxnTextPainter
setAnchor(int anchor)
Deprecated.UsesetShift(int anchor)
.JxnTextPainter
setBackground()
Shows text without background.JxnTextPainter
setBackground(Color backgroundColor)
Changes the background color of the text (default is white) for this instance.
Example:JxnTextPainter
setFont(Font f)
Changes the text font.JxnTextPainter
setShift(double xShift, double yShift)
Shifts the text position.JxnTextPainter
setShift(int anchor)
Shifts the text position using constants from classKmgGraphicsScaler
.JxnTextPainter
setSpace(double space)
Sets additional space.JxnTextPainter
setSpace(int iSpace)
Sets additional space.String
toString()
Returns text and position as String.-
Methods inherited from class JxnAbstractPainter
applyStroke, applyStroke, lw, plot, plot90, setColor, setIgnoreBounds, setIgnoreBounds, setLineWidth, setLineWidthDefault, setStroke
-
-
-
-
Constructor Detail
-
JxnTextPainter
public JxnTextPainter(String text, double x0, double y0)
-
JxnTextPainter
public JxnTextPainter(String text, double x0, double y0, Color textColor)
SeeJxnTextPainter
.
-
JxnTextPainter
public JxnTextPainter(String text, double x0, double y0, JxnTextPainter template)
SeeJxnTextPainter
.
-
JxnTextPainter
public JxnTextPainter(double value, double x0, double y0)
Creates an instance for display ofvalue
as text in a PlotFrame.
Use@
JxnTextPainter
(
format
( value, nDec ), x0, y0 )
to showvalue
withnDec
decimals.
-
JxnTextPainter
public JxnTextPainter(long value, double x0, double y0)
Creates an instance for display ofvalue
as text in a PlotFrame.
-
JxnTextPainter
public JxnTextPainter(double value, double x0, double y0, Color textColor)
SeeJxnTextPainter
.
-
JxnTextPainter
public JxnTextPainter(long value, double x0, double y0, Color textColor)
SeeJxnTextPainter
.
-
JxnTextPainter
public JxnTextPainter(double value, double x0, double y0, JxnTextPainter template)
SeeJxnTextPainter
.
-
JxnTextPainter
public JxnTextPainter(long value, double x0, double y0, JxnTextPainter template)
SeeJxnTextPainter
.
-
-
Method Detail
-
toString
public String toString()
Returns text and position as String.
-
setBackground
public JxnTextPainter setBackground(Color backgroundColor)
Changes the background color of the text (default is white) for this instance.
Example:pf =
plot
( cos 2 PI t, sin 2 PI t, BLACK, 0, 2., 0. ) pf.setFont( @Font
( "", 0, 20 ) ) pf.add
( @JxnTextPainter
( "abc", -0.7, 0.7 ) ) ! default: black on white background pf.add( @JxnTextPainter
( "def", 0.7, 0.7, B ).setBackground()
) ! no background pf.add( @JxnTextPainter( "ghi", -0.7, -0.7, R ).setBackground( @Color
( 1., 1., 1., 0.875 ) ) ) ! ! white background with alpha (opaqueness) pf.add( @JxnTextPainter( "jkl", 0.7, -0.7, G ).setBackground(Color.pink
) ) ! pink background- Returns:
- this
-
setBackground
public JxnTextPainter setBackground()
Shows text without background.- Returns:
- this
-
setFont
public JxnTextPainter setFont(Font f)
Changes the text font. Seejava.awt.
Font
for details.- Returns:
- this
-
setShift
public JxnTextPainter setShift(double xShift, double yShift)
Shifts the text position.
Example:setShift(0.5,0.5)
moves the text, so that the lower left corner is at the position (x0,y0
) defined inJxnTextPainter
- Parameters:
xShift
- shifts text horizontal in units of the text widthyShift
- shifts text vertical in units of the text height- Returns:
- this
-
setShift
public JxnTextPainter setShift(int anchor)
Shifts the text position using constants from classKmgGraphicsScaler
.
Example:setShift( KmgGraphicsScaler.NORTHEAST )
is equivalent tosetShift
(0.5,0.5)
- Returns:
- this
-
setAnchor
public JxnTextPainter setAnchor(int anchor)
Deprecated.UsesetShift(int anchor)
.- Returns:
- this
-
setSpace
public JxnTextPainter setSpace(int iSpace)
Sets additional space. Relevant only together withsetShift
.- Parameters:
iSpace
- additional shift byiSpace
pixels in the direction defined bysetShift
- Returns:
- this
-
setSpace
public JxnTextPainter setSpace(double space)
Sets additional space. Relevant only together withsetShift
.
Note:setSpace(double space)
overrules a value set bysetSpace(int iSpace)
- Parameters:
space
- additional shift in units of the text height in the direction defined bysetShift
- Returns:
- this
-
getKmgDoubleBounds
public KmgDoubleBounds getKmgDoubleBounds()
Description copied from interface:KmgXYPainter
Returns the bounds of the graphical object (called internally).- Specified by:
getKmgDoubleBounds
in interfaceKmgXYPainter
- Overrides:
getKmgDoubleBounds
in classJxnAbstractPainter
-
paint
public void paint(KmgGraphicsScaler sk)
Description copied from interface:KmgXYPainter
Paints the graphical object (called internally).
-
-