org.foray.graphic
Class MathGraphic4a

java.lang.Object
  extended by org.foray.graphic.Graphic4a
      extended by org.foray.graphic.MathGraphic4a
All Implemented Interfaces:
org.axsl.graphic.Graphic, org.axsl.graphic.MathGraphic

public class MathGraphic4a
extends Graphic4a
implements org.axsl.graphic.MathGraphic

A MathML Graphic. The current approach to handling MathML is that it is treated internally as SVG.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.axsl.graphic.Graphic
org.axsl.graphic.Graphic.Compression, org.axsl.graphic.Graphic.Type
 
Field Summary
 
Fields inherited from class org.foray.graphic.Graphic4a
BIT_DEPTH_4, BIT_DEPTH_COLOR, BIT_DEPTH_GRAYSCALE, BIT_DEPTH_MONOCHROME
 
Constructor Summary
MathGraphic4a(GraphicServer4a server, org.w3c.dom.mathml.MathMLDocument mathDocument)
          Constructor for the case of a parsed MathMLDocument.
MathGraphic4a(GraphicServer4a server, URL url, BufferedInputStream bis)
          Constructor for the case of an unparsed URL.
 
Method Summary
 int absoluteHeightReal()
          Returns the absolute height, in millipoints, of the graphic.
 int absoluteWidthReal()
          Returns the absolute width, in millipoints, of the graphic.
 ColorSpace getColorSpace()
           
 org.axsl.graphic.Graphic.Compression getCompressionType()
           
 org.axsl.graphic.Graphic.Type getGraphicType()
           
 org.w3c.dom.mathml.MathMLDocument getMathDocument()
           
 String getMimeType()
           
 String getName()
           
 byte[] getRawSamples()
           
 SVGGraphic getSvgGraphic()
          Returns the wrapped SVGGraphic instance.
 Color getTransparentColor()
           
 boolean isInverted()
           
 boolean isTransparent()
           
 void loadImage()
          Load image data and initialize its properties.
 void parseBasics()
          This abstract method is implemented in subclasses to initiate parsing of enough of the image for it to be used in layout.
 int pixelHeight()
           
 int pixelWidth()
           
 
Methods inherited from class org.foray.graphic.Graphic4a
absoluteHeight, absoluteWidth, canMakeGraphicOutput, close, getBitDepth, getBitsPerComponent, getContent, getContentSize, getGraphicOutput, getInputStream, getLinks, getLogger, getRawColorSpace, getServer, getUrl, isImageLoaded, isValid, loadImageWrapper, maxBytesToParseBasics, parseBasicsWrapper, setBasicsParsed, setBitDepth, setContent, setImageLoaded, setInputStream, setLinks, setValid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.axsl.graphic.Graphic
absoluteHeight, absoluteWidth, canMakeGraphicOutput, close, getBitsPerComponent, getContent, getContentSize, getGraphicOutput, getLinks, getUrl
 

Constructor Detail

MathGraphic4a

public MathGraphic4a(GraphicServer4a server,
                     URL url,
                     BufferedInputStream bis)
Constructor for the case of an unparsed URL.

Parameters:
server - The parent graphic server.
url - The URL which contains the graphic content.
bis - The reusable input stream containing the bytes from url.

MathGraphic4a

public MathGraphic4a(GraphicServer4a server,
                     org.w3c.dom.mathml.MathMLDocument mathDocument)
              throws org.axsl.graphic.GraphicException
Constructor for the case of a parsed MathMLDocument.

Parameters:
server - The parent graphic server.
mathDocument - The parsed MathMLDocument. This must not be null.
Throws:
org.axsl.graphic.GraphicException - For error creating an SVG for the MathML document.
Method Detail

loadImage

public void loadImage()
               throws org.axsl.graphic.GraphicException
Description copied from class: Graphic4a
Load image data and initialize its properties. Subclasses need to implement this method.

Specified by:
loadImage in class Graphic4a
Throws:
org.axsl.graphic.GraphicException - an error occured during loading

getMathDocument

public org.w3c.dom.mathml.MathMLDocument getMathDocument()
                                                  throws org.axsl.graphic.GraphicException
Specified by:
getMathDocument in interface org.axsl.graphic.MathGraphic
Throws:
org.axsl.graphic.GraphicException

getGraphicType

public org.axsl.graphic.Graphic.Type getGraphicType()
Specified by:
getGraphicType in interface org.axsl.graphic.Graphic

getCompressionType

public org.axsl.graphic.Graphic.Compression getCompressionType()
Specified by:
getCompressionType in interface org.axsl.graphic.Graphic

getMimeType

public String getMimeType()
Specified by:
getMimeType in interface org.axsl.graphic.Graphic

parseBasics

public void parseBasics()
                 throws IOException
Description copied from class: Graphic4a

This abstract method is implemented in subclasses to initiate parsing of enough of the image for it to be used in layout. This method is responsible to:

  1. store the image's intrinsic width in Graphic.pixelWidth()
  2. store the image's intrinsic height in Graphic.pixelHeight()

The housekeeping work related to resetting the buffer, handling IOExceptions, and managing whether this method should be run are handled elsewhere. In short, this method does not need to address the details handled there.

Specified by:
parseBasics in class Graphic4a
Throws:
IOException - For IO errors during reading of the file.

getName

public String getName()
Specified by:
getName in interface org.axsl.graphic.Graphic

getRawSamples

public byte[] getRawSamples()
                     throws org.axsl.graphic.GraphicException
Specified by:
getRawSamples in interface org.axsl.graphic.Graphic
Throws:
org.axsl.graphic.GraphicException

absoluteWidthReal

public int absoluteWidthReal()
                      throws org.axsl.graphic.GraphicException
Description copied from class: Graphic4a
Returns the absolute width, in millipoints, of the graphic.

Specified by:
absoluteWidthReal in class Graphic4a
Returns:
The absolute width, in millipoints, of this graphic, if known. If not known, returns -1.
Throws:
org.axsl.graphic.GraphicException - For errors during reading of image file.

absoluteHeightReal

public int absoluteHeightReal()
                       throws org.axsl.graphic.GraphicException
Description copied from class: Graphic4a
Returns the absolute height, in millipoints, of the graphic.

Specified by:
absoluteHeightReal in class Graphic4a
Returns:
The absolute height, in millipoints, of this graphic, if known. If not known, returns -1.
Throws:
org.axsl.graphic.GraphicException - For errors during reading of image file.

isInverted

public boolean isInverted()
Specified by:
isInverted in interface org.axsl.graphic.Graphic

getColorSpace

public ColorSpace getColorSpace()
                         throws org.axsl.graphic.GraphicException
Specified by:
getColorSpace in interface org.axsl.graphic.Graphic
Throws:
org.axsl.graphic.GraphicException

isTransparent

public boolean isTransparent()
                      throws org.axsl.graphic.GraphicException
Specified by:
isTransparent in interface org.axsl.graphic.Graphic
Throws:
org.axsl.graphic.GraphicException

getTransparentColor

public Color getTransparentColor()
                          throws org.axsl.graphic.GraphicException
Specified by:
getTransparentColor in interface org.axsl.graphic.Graphic
Throws:
org.axsl.graphic.GraphicException

pixelWidth

public int pixelWidth()
               throws org.axsl.graphic.GraphicException
Specified by:
pixelWidth in interface org.axsl.graphic.Graphic
Throws:
org.axsl.graphic.GraphicException

pixelHeight

public int pixelHeight()
                throws org.axsl.graphic.GraphicException
Specified by:
pixelHeight in interface org.axsl.graphic.Graphic
Throws:
org.axsl.graphic.GraphicException

getSvgGraphic

public SVGGraphic getSvgGraphic()
Returns the wrapped SVGGraphic instance.

Returns:
The wrapped SVG.


Copyright © 2017. All rights reserved.