Q
- The pixel typeI
- The concrete image typepublic class FontSimulator<Q,I extends Image<Q,I>> extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
FontSimulator.FontSimListener<I>
This is an interface for objects that are interested in listening
for when the
FontSimulator creates an image during one of its
runs. |
Constructor and Description |
---|
FontSimulator(String textString)
Create a font simulator that will output the given text string.
|
Modifier and Type | Method and Description |
---|---|
void |
addFontToAvoid(String f)
Avoid the font with the given name.
|
I |
generate(I imgExample)
Generates a render of the text string in some random font with some
random transform.
|
double |
getAngleJitter()
Get the amount of angle jitter in use.
|
int |
getFontPointSize()
Get the size of the font that is being drawn
|
List<String> |
getFontsToAvoid()
Get the list of fonts to avoid.
|
GeneralFont |
getJitteredFont(GeneralFont font)
Returns a font that is somewhat randomised from the
initial font.
|
GeneralFontStyle<Q> |
getJitteredFontStyle(GeneralFontStyle<Q> gfs)
Get a jittered font style
|
Jama.Matrix |
getJitterTransform(I img)
Returns an affine transform matrix based on the jitter
specifications.
|
int |
getnChars()
Get the number of characters being generated.
|
int |
getPadding()
Get the amount of padding around the image.
|
double |
getPerspectiveJitter()
Get the amount of perspective jitter being simulated
|
double |
getShearJitter()
Get the amount of shear jitter in use.
|
double |
getSizeJitter()
Get the amount of size jitter in use.
|
String |
getTextString()
Get the text string in use.
|
boolean |
isTypeJitter()
Get whether the font type is being randomised.
|
static void |
main(String[] args)
Simple main that runs a simulation of 5 runs with the text "ABC" or
text supplied on the command line.
|
void |
makeRuns(int nRuns,
FontSimulator.FontSimListener<I> fsl,
I imgExample)
Make a number of runs of creating text renders
|
GeneralFont |
pickRandomFont()
Picks a random font from your system and returns it.
|
void |
setAngleJitter(double angleJitter)
Set the amount of angle jitter to use.
|
void |
setFontPointSize(int fontPointSize)
Set the point size of the font to draw
|
void |
setFontsToAvoid(List<String> fontsToAvoid)
Set the list of fonts to avoid.
|
void |
setnChars(int nChars)
Set the number of characters to randomly generate.
|
void |
setPadding(int padding)
Set the padding around the outside of the image.
|
void |
setPerspectiveJitter(double perspectiveJitter)
Set the amount of perspective jitter to use.
|
void |
setShearJitter(double shearJitter)
Set the amount of shear jitter
|
void |
setSizeJitter(double sizeJitter)
Set the amount of size jitter to use.
|
void |
setTextString(String textString)
Set the text string to use.
|
void |
setTypeJitter(boolean typeJitter)
Set whether to jitter the font type or not.
|
public FontSimulator(String textString)
textString
- The text string to drawpublic void makeRuns(int nRuns, FontSimulator.FontSimListener<I> fsl, I imgExample)
nRuns
- The number of runs to makefsl
- The listener that will receive the imagesimgExample
- An example of the type of image public I generate(I imgExample)
imgExample
- An example of the image to which to draw the text.public GeneralFont pickRandomFont()
public GeneralFont getJitteredFont(GeneralFont font)
font
- The font to jitterpublic Jama.Matrix getJitterTransform(I img)
img
- image to get bounds frompublic GeneralFontStyle<Q> getJitteredFontStyle(GeneralFontStyle<Q> gfs)
gfs
- The input font stylepublic void setTextString(String textString)
textString
- the text string to usepublic String getTextString()
public void setSizeJitter(double sizeJitter)
sizeJitter
- the amount of size jitter to usepublic double getSizeJitter()
public void setAngleJitter(double angleJitter)
angleJitter
- the amount of angle jitter to usepublic double getAngleJitter()
public void setShearJitter(double shearJitter)
shearJitter
- the amount of shear jitter to usepublic double getShearJitter()
public void setPerspectiveJitter(double perspectiveJitter)
perspectiveJitter
- the amount of perspective jitter to usepublic double getPerspectiveJitter()
public void setFontsToAvoid(List<String> fontsToAvoid)
fontsToAvoid
- the list of fonts to avoidpublic List<String> getFontsToAvoid()
public void addFontToAvoid(String f)
f
- The font to avoidpublic void setnChars(int nChars)
nChars
- the number of chars to generatepublic int getnChars()
public void setTypeJitter(boolean typeJitter)
typeJitter
- Whether to jitter the font typepublic boolean isTypeJitter()
public void setFontPointSize(int fontPointSize)
fontPointSize
- the font point size to usepublic int getFontPointSize()
public void setPadding(int padding)
padding
- the padding amountpublic int getPadding()