org.apache.fop.render.awt
Class AWTRenderer

java.lang.Object
  extended byorg.apache.fop.render.AbstractRenderer
      extended byorg.apache.fop.render.awt.AWTRenderer
All Implemented Interfaces:
java.awt.print.Pageable, java.awt.print.Printable, Renderer

public class AWTRenderer
extends AbstractRenderer
implements java.awt.print.Printable, java.awt.print.Pageable

Author:
Juergen Verwohlt, Rainer Steinkuhle, Stanislav Gorkhover, Mark Lillywhite

Nested Class Summary
protected  class AWTRenderer.MUserAgent
           
 
Field Summary
protected  float currentBlue
           
protected  java.lang.String currentFontName
          The current (internal) font name
protected  int currentFontSize
          The current font size in millipoints
protected  float currentGreen
           
protected  float currentRed
          The current colour's red, green and blue component
protected  java.util.Map fontNames
           
protected  java.util.Map fontStyles
           
protected  java.awt.Graphics2D graphics
           
protected  java.awt.Color lastColor
           
protected  java.awt.Font lastFont
          Used to make the last font and color available to renderInlineSpace() to render text decorations.
protected  java.util.Map options
          options
protected  int pageHeight
           
protected  java.util.Vector pageList
           
protected  int pageNumber
           
protected  int pageWidth
           
protected  java.awt.Component parent
          The parent component, used to set up the font.
protected  ProgressListener progressListener
           
protected  Translator res
           
protected  java.awt.Color saveColor
           
protected  double scaleFactor
           
 
Fields inherited from class org.apache.fop.render.AbstractRenderer
currentAreaContainerXPosition, currentXPosition, currentYPosition, idReferences, log
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Fields inherited from interface java.awt.print.Pageable
UNKNOWN_NUMBER_OF_PAGES
 
Constructor Summary
AWTRenderer(Translator aRes)
           
 
Method Summary
protected  void addFilledRect(int x, int y, int w, int h, ColorType col)
          Add a filled rectangle to the current stream This default implementation calls addRect using the same color for fill and border.
protected  void addLine(int x1, int y1, int x2, int y2, int th, float r, float g, float b)
          add a line to the current stream
protected  void addRect(int x, int y, int w, int h, boolean drawAsOutline)
          draw a filled rectangle in the current color
protected  void addRect(int x, int y, int w, int h, float r, float g, float b)
          draw a rectangle
protected  void addRect(int x, int y, int w, int h, float r, float g, float b, float fr, float fg, float fb)
          draw a filled rectangle
static java.awt.Color colorType2Color(ColorType ct)
           
protected  void doFrame(Area area)
           
protected  void drawFrame()
           
protected  void drawImageClipped(int x, int y, int clipX, int clipY, int clipW, int clipH, FopImage image, FontState fs)
          Renders an image, clipping it as specified.
protected  void drawImageScaled(int x, int y, int w, int h, FopImage image, FontState fs)
          Renders an image, scaling it to the given width and height.
protected  java.awt.geom.Rectangle2D getBounds(Area a)
           
 java.awt.image.BufferedImage getLastRenderedPage()
           
 int getNumberOfPages()
           
 int getPageCount()
          Retrieve the number of pages in this document.
 java.awt.print.PageFormat getPageFormat(int pageIndex)
           
 int getPageNumber()
           
 java.awt.print.Printable getPrintable(int pageIndex)
           
 double getScaleFactor()
           
 int print(java.awt.Graphics g, java.awt.print.PageFormat pageFormat, int pageIndex)
           
 void removePage(int page)
           
 void render(int aPageNumber)
           
 void render(Page page)
           
 void render(Page page, java.io.OutputStream stream)
          render the given area tree to the given stream
 void renderDisplaySpace(DisplaySpace space)
          render the given display space
 void renderForeignObjectArea(ForeignObjectArea area)
          Draws an image.
 void renderImageArea(ImageArea area)
          Render an image area.
 void renderInlineSpace(InlineSpace space)
          render the given inline space
 void renderLeaderArea(LeaderArea area)
          render leader area into AWT
 void renderPage(Page page)
          render the given page
 void renderSVGArea(SVGArea area)
          render the given SVG area
protected  void renderSVGDocument(org.w3c.dom.Document doc, int x, int y)
           
protected  void renderTextDecoration(int x, int bl, int width, java.awt.Font font, java.lang.String text, boolean underline, boolean overline, boolean linethrough)
           
 void renderWordArea(WordArea area)
          render the given inline area
 void setComponent(java.awt.Component parent)
          Sets parent component which is used to set up the font.
 void setOptions(java.util.Map options)
          set up renderer options
 void setPageNumber(int aValue)
           
 void setProducer(java.lang.String producer)
          set the producer of the rendering
 void setProgressListener(ProgressListener l)
           
 void setScaleFactor(double newScaleFactor)
           
 void setupFontInfo(FontInfo fontInfo)
          set up the given FontInfo
 void startRenderer(java.io.OutputStream outputStream)
           
 void stopRenderer(java.io.OutputStream outputStream)
           
 void transform(java.awt.Graphics2D g2d, double zoomPercent, double angle)
          To configure before print.
 
Methods inherited from class org.apache.fop.render.AbstractRenderer
doBackground, drawImage, getIDReferences, renderAreaContainer, renderBlockArea, renderBodyAreaContainer, renderLineArea, renderRegionAreaContainer, renderRegions, renderSpanArea, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

pageWidth

protected int pageWidth

pageHeight

protected int pageHeight

scaleFactor

protected double scaleFactor

pageNumber

protected int pageNumber

pageList

protected java.util.Vector pageList

progressListener

protected ProgressListener progressListener

res

protected Translator res

fontNames

protected java.util.Map fontNames

fontStyles

protected java.util.Map fontStyles

saveColor

protected java.awt.Color saveColor

graphics

protected java.awt.Graphics2D graphics

currentFontName

protected java.lang.String currentFontName
The current (internal) font name


currentFontSize

protected int currentFontSize
The current font size in millipoints


currentRed

protected float currentRed
The current colour's red, green and blue component


currentGreen

protected float currentGreen

currentBlue

protected float currentBlue

lastFont

protected java.awt.Font lastFont
Used to make the last font and color available to renderInlineSpace() to render text decorations.


lastColor

protected java.awt.Color lastColor

parent

protected java.awt.Component parent
The parent component, used to set up the font. This is needed as FontSetup needs a live AWT component in order to generate valid font measures.


options

protected java.util.Map options
options

Constructor Detail

AWTRenderer

public AWTRenderer(Translator aRes)
Method Detail

setOptions

public void setOptions(java.util.Map options)
set up renderer options

Specified by:
setOptions in interface Renderer

setComponent

public void setComponent(java.awt.Component parent)
Sets parent component which is used to set up the font. This is needed as FontSetup needs a live AWT component in order to generate valid font measures.

Parameters:
parent - the live AWT component reference

getPageNumber

public int getPageNumber()

setPageNumber

public void setPageNumber(int aValue)

setScaleFactor

public void setScaleFactor(double newScaleFactor)

getScaleFactor

public double getScaleFactor()

getLastRenderedPage

public java.awt.image.BufferedImage getLastRenderedPage()

addLine

protected void addLine(int x1,
                       int y1,
                       int x2,
                       int y2,
                       int th,
                       float r,
                       float g,
                       float b)
add a line to the current stream

Parameters:
x1 - the start x location in millipoints
y1 - the start y location in millipoints
x2 - the end x location in millipoints
y2 - the end y location in millipoints
th - the thickness in millipoints
r - the red component
g - the green component
b - the blue component

addRect

protected void addRect(int x,
                       int y,
                       int w,
                       int h,
                       float r,
                       float g,
                       float b)
draw a rectangle

Parameters:
x - the x position of left edge in millipoints
y - the y position of top edge in millipoints
w - the width in millipoints
h - the height in millipoints
r - the red component
g - the green component
b - the blue component

addRect

protected void addRect(int x,
                       int y,
                       int w,
                       int h,
                       float r,
                       float g,
                       float b,
                       float fr,
                       float fg,
                       float fb)
draw a filled rectangle

Parameters:
x - the x position of left edge in millipoints
y - the y position of top edge in millipoints
w - the width in millipoints
h - the height in millipoints
r - the red component of edges
g - the green component of edges
b - the blue component of edges
fr - the red component of the fill
fg - the green component of the fill
fb - the blue component of the fill

addRect

protected void addRect(int x,
                       int y,
                       int w,
                       int h,
                       boolean drawAsOutline)
draw a filled rectangle in the current color

Parameters:
x - the x position of left edge in millipoints
y - the y position of top edge in millipoints
w - the width in millipoints
h - the height in millipoints
drawAsOutline - true for draw, false for fill

addFilledRect

protected void addFilledRect(int x,
                             int y,
                             int w,
                             int h,
                             ColorType col)
Description copied from class: AbstractRenderer
Add a filled rectangle to the current stream This default implementation calls addRect using the same color for fill and border.

Specified by:
addFilledRect in class AbstractRenderer
Parameters:
x - the x position of left edge in millipoints
y - the y position of top edge in millipoints
w - the width in millipoints
h - the height in millipoints

transform

public void transform(java.awt.Graphics2D g2d,
                      double zoomPercent,
                      double angle)
To configure before print. Choose pages Zoom factor Page format / Landscape or Portrait


drawFrame

protected void drawFrame()

getPageCount

public int getPageCount()
Retrieve the number of pages in this document.

Returns:
the number of pages

removePage

public void removePage(int page)

render

public void render(int aPageNumber)

render

public void render(Page page,
                   java.io.OutputStream stream)
            throws java.io.IOException
Description copied from interface: Renderer
render the given area tree to the given stream

Specified by:
render in interface Renderer
Throws:
java.io.IOException

render

public void render(Page page)
            throws java.io.IOException
Throws:
java.io.IOException

renderPage

public void renderPage(Page page)
Description copied from interface: Renderer
render the given page

Specified by:
renderPage in interface Renderer

doFrame

protected void doFrame(Area area)
Specified by:
doFrame in class AbstractRenderer

getBounds

protected java.awt.geom.Rectangle2D getBounds(Area a)

setupFontInfo

public void setupFontInfo(FontInfo fontInfo)
                   throws FOPException
Description copied from interface: Renderer
set up the given FontInfo

Specified by:
setupFontInfo in interface Renderer
Throws:
FOPException

renderDisplaySpace

public void renderDisplaySpace(DisplaySpace space)
Description copied from interface: Renderer
render the given display space

Specified by:
renderDisplaySpace in interface Renderer

drawImageScaled

protected void drawImageScaled(int x,
                               int y,
                               int w,
                               int h,
                               FopImage image,
                               FontState fs)
Renders an image, scaling it to the given width and height. If the scaled width and height is the same intrinsic size of the image, the image is not scaled.

Specified by:
drawImageScaled in class AbstractRenderer
Parameters:
x - the x position of left edge in millipoints
y - the y position of top edge in millipoints
w - the width in millipoints
h - the height in millipoints
image - the image to be rendered
fs - the font state to use when rendering text in non-bitmapped images.

drawImageClipped

protected void drawImageClipped(int x,
                                int y,
                                int clipX,
                                int clipY,
                                int clipW,
                                int clipH,
                                FopImage image,
                                FontState fs)
Renders an image, clipping it as specified.

Specified by:
drawImageClipped in class AbstractRenderer
Parameters:
x - the x position of left edge in millipoints.
y - the y position of top edge in millipoints.
clipX - the left edge of the clip in millipoints
clipY - the top edge of the clip in millipoints
clipW - the clip width in millipoints
clipH - the clip height in millipoints
fs - the font state to use when rendering text in non-bitmapped images.

renderImageArea

public void renderImageArea(ImageArea area)
Description copied from class: AbstractRenderer
Render an image area.

Specified by:
renderImageArea in interface Renderer
Overrides:
renderImageArea in class AbstractRenderer
Parameters:
area - the image area to render

renderWordArea

public void renderWordArea(WordArea area)
Description copied from interface: Renderer
render the given inline area

Specified by:
renderWordArea in interface Renderer

renderInlineSpace

public void renderInlineSpace(InlineSpace space)
Description copied from interface: Renderer
render the given inline space

Specified by:
renderInlineSpace in interface Renderer

renderTextDecoration

protected void renderTextDecoration(int x,
                                    int bl,
                                    int width,
                                    java.awt.Font font,
                                    java.lang.String text,
                                    boolean underline,
                                    boolean overline,
                                    boolean linethrough)

renderLeaderArea

public void renderLeaderArea(LeaderArea area)
render leader area into AWT

Specified by:
renderLeaderArea in interface Renderer
Parameters:
area - area to render

renderSVGArea

public void renderSVGArea(SVGArea area)
Description copied from interface: Renderer
render the given SVG area

Specified by:
renderSVGArea in interface Renderer

renderSVGDocument

protected void renderSVGDocument(org.w3c.dom.Document doc,
                                 int x,
                                 int y)

setProducer

public void setProducer(java.lang.String producer)
Description copied from interface: Renderer
set the producer of the rendering

Specified by:
setProducer in interface Renderer

print

public int print(java.awt.Graphics g,
                 java.awt.print.PageFormat pageFormat,
                 int pageIndex)
          throws java.awt.print.PrinterException
Specified by:
print in interface java.awt.print.Printable
Throws:
java.awt.print.PrinterException

getNumberOfPages

public int getNumberOfPages()
Specified by:
getNumberOfPages in interface java.awt.print.Pageable

getPageFormat

public java.awt.print.PageFormat getPageFormat(int pageIndex)
                                        throws java.lang.IndexOutOfBoundsException
Specified by:
getPageFormat in interface java.awt.print.Pageable
Throws:
java.lang.IndexOutOfBoundsException

getPrintable

public java.awt.print.Printable getPrintable(int pageIndex)
                                      throws java.lang.IndexOutOfBoundsException
Specified by:
getPrintable in interface java.awt.print.Pageable
Throws:
java.lang.IndexOutOfBoundsException

setProgressListener

public void setProgressListener(ProgressListener l)

colorType2Color

public static java.awt.Color colorType2Color(ColorType ct)

renderForeignObjectArea

public void renderForeignObjectArea(ForeignObjectArea area)
Draws an image. TODO: protect other image formats (JIMI)

Specified by:
renderForeignObjectArea in interface Renderer

startRenderer

public void startRenderer(java.io.OutputStream outputStream)
                   throws java.io.IOException
Specified by:
startRenderer in interface Renderer
Throws:
java.io.IOException

stopRenderer

public void stopRenderer(java.io.OutputStream outputStream)
                  throws java.io.IOException
Specified by:
stopRenderer in interface Renderer
Throws:
java.io.IOException


Copyright ? 1999-2003 Apache Software Foundation. All Rights Reserved.