Top Description Methods
uk.ac.ed.ph.snuggletex.jeuclid

public Interface MathMLImageSavingCallback

Known Direct Implementers
uk.ac.ed.ph.snuggletex.jeuclid.SimpleMathMLImageSavingCallback
Imports
java.io.File, .OutputStream, net.sourceforge.jeuclid.MutableLayoutContext, org.w3c.dom.Document

Trivial callback interface used by JEuclidMathMLPostProcessor to determine where to save each generating MathML image and the URL to use in the resulting HTML as it traverses a given DOM Document.

You should implement this to do whatever is appropriate for your needs.

This can be used independently of SnuggleTeX.

Author
David McKain
Version
$Revision$
See Also
JEuclidMathMLPostProcessor

Method Summary

Modifier and TypeMethod and Description
public String
getImageContentType(int
identifies the position of the image within the document being processed, which can be used to ensure unique file names.
mathmlCounter
)

Implement to return the desired MIME type for the resulting image.

public File
getImageOutputFile(int
identifies the position of the image within the document being processed, which can be used to ensure unique file names.
mathmlCounter
)

Implement if you want the resulting image to be written to a File of your choice.

public OutputStream
getImageOutputStream(int
identifies the position of the image within the document being processed, which can be used to ensure unique file names.
mathmlCounter
)

Implement this if you want the resulting image to be written to an OutputStream of your choice.

public String
getImageURL(int
identifies the position of the image within the document being processed, which can be used to ensure unique file names.
mathmlCounter
)

Implement to return the URL String that will be put into the img src attribute to refer to the image.

public net.sourceforge.jeuclid.MutableLayoutContext
getLayoutContext(int
identifies the position of the image within the document being processed, which can be used to ensure unique file names.
mathmlCounter
)

Implement to fill in the JEuclid MutableLayoutContext specifying how you want to render this image.

public void
imageSavingFailed(Object
File or OutputStream that would have been written if successful
imageFileOrOutputStream
,
int
identifies the position of the image within the document being processed, which can be used to ensure unique file names.
mathmlCounter
,
String
content type of the saved image File
contentType
,
Throwable
cause of the failure, which may be null
exception
)

Called back if MathML image could not be saved for some reason.

public void
imageSavingSucceeded(Object
File or OutputStream written
imageFileOrOutputStream
,
int
identifies the position of the image within the document being processed, which can be used to ensure unique file names.
mathmlCounter
,
String
content type of the saved image File
contentType
)

Called back once a MathML image has been saved successfully.

Method Detail

getImageContentTypeback to summary
public String getImageContentType(int mathmlCounter)

Implement to return the desired MIME type for the resulting image.

Consult the JEuclid documentation for what is supported; you may need to add additional libraries for certain MIME types.

SnuggleTeX contains everything required to support PNG. Note that conversion to GIF does not generally work well so should be avoided...!

Parameters
mathmlCounter:int

identifies the position of the image within the document being processed, which can be used to ensure unique file names.

getImageOutputFileback to summary
public File getImageOutputFile(int mathmlCounter)

Implement if you want the resulting image to be written to a File of your choice. Return null if you want the image to be written to the result of getImageOutputStream(int) instead.

Parameters
mathmlCounter:int

identifies the position of the image within the document being processed, which can be used to ensure unique file names.

getImageOutputStreamback to summary
public OutputStream getImageOutputStream(int mathmlCounter)

Implement this if you want the resulting image to be written to an OutputStream of your choice. The method getImageOutputFile(int) is checked first, so must return null in this case.

Parameters
mathmlCounter:int

identifies the position of the image within the document being processed, which can be used to ensure unique file names.

getImageURLback to summary
public String getImageURL(int mathmlCounter)

Implement to return the URL String that will be put into the img src attribute to refer to the image.

Parameters
mathmlCounter:int

identifies the position of the image within the document being processed, which can be used to ensure unique file names.

getLayoutContextback to summary
public net.sourceforge.jeuclid.MutableLayoutContext getLayoutContext(int mathmlCounter)

Implement to fill in the JEuclid MutableLayoutContext specifying how you want to render this image.

Parameters
mathmlCounter:int

identifies the position of the image within the document being processed, which can be used to ensure unique file names.

imageSavingFailedback to summary
public void imageSavingFailed(Object imageFileOrOutputStream, int mathmlCounter, String contentType, Throwable exception)

Called back if MathML image could not be saved for some reason.

Parameters
imageFileOrOutputStream:Object

File or OutputStream that would have been written if successful

mathmlCounter:int

identifies the position of the image within the document being processed, which can be used to ensure unique file names.

contentType:String

content type of the saved image File

exception:Throwable

cause of the failure, which may be null

imageSavingSucceededback to summary
public void imageSavingSucceeded(Object imageFileOrOutputStream, int mathmlCounter, String contentType)

Called back once a MathML image has been saved successfully. Implementors can do anything they need to do at this point.

Parameters
imageFileOrOutputStream:Object

File or OutputStream written

mathmlCounter:int

identifies the position of the image within the document being processed, which can be used to ensure unique file names.

contentType:String

content type of the saved image File