org.apache.fop.afp.modca

## Class GraphicsObject

- java.lang.Object
- - org.apache.fop.afp.modca.AbstractAFPObject
  - - org.apache.fop.afp.modca.AbstractStructuredObject
    - - org.apache.fop.afp.modca.AbstractTripletStructuredObject
      - - org.apache.fop.afp.modca.AbstractNamedAFPObject
        - - org.apache.fop.afp.modca.AbstractDataObject
          - - org.apache.fop.afp.modca.GraphicsObject

- All Implemented Interfaces:
    Completable, Startable, Streamable

      public class GraphicsObject
      extends AbstractDataObject

  Top-level GOCA graphics object. Acts as container and factory of all other graphic objects

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.fop.afp.modca.AbstractAFPObject

      `AbstractAFPObject.Category, AbstractAFPObject.Type`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected List<GraphicsData>` | `objects` list of objects contained within this container

    - ### Fields inherited from class org.apache.fop.afp.modca.AbstractDataObject

      `factory, objectEnvironmentGroup`

    - ### Fields inherited from class org.apache.fop.afp.modca.AbstractNamedAFPObject

      `name`

    - ### Fields inherited from class org.apache.fop.afp.modca.AbstractTripletStructuredObject

      `triplets`

    - ### Fields inherited from class org.apache.fop.afp.modca.AbstractAFPObject

      `LOG, SF_CLASS, SF_HEADER_LENGTH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GraphicsObject(Factory factory, String name)` Default constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addBox(int[] coords)` Adds a box at the given coordinates
    `void` | `addFillet(int[] coords)` Adds a fillet (curve) at the given coordinates
    `void` | `addFillet(int[] coords, boolean relative)` Adds a fillet (curve) at the given coordinates
    `void` | `addFullArc(int x, int y, int mh, int mhr)` Adds a full arc
    `void` | `addImage(int x, int y, int width, int height, byte[] imgData)` Adds an image
    `void` | `addLine(int[] coords)` Adds a line at the given x/y coordinates
    `void` | `addLine(int[] coords, boolean relative)` Adds a line at the given x/y coordinates
    `void` | `addObject(StructuredData object)`
    `void` | `addString(String str, int x, int y, CharacterSet charSet)` Adds a string
    `void` | `beginArea()` Begins a graphics area (start of fill)
    `void` | `endArea()` Ends a graphics area (end of fill)
    `void` | `endProlog()` Ends the prolog.
    `void` | `newSegment()` Creates a new graphics segment
    `void` | `setArcParams(int xmaj, int ymin, int xmin, int ymaj)` Sets the arc parameters
    `void` | `setCharacterSet(int characterSet)` Sets the character set to use
    `void` | `setColor(Color color)` Sets the current color
    `void` | `setColorConverter(org.apache.xmlgraphics.java2d.color.ColorConverter colorConverter)` Sets the color converter
    `void` | `setComplete(boolean complete)` Sets whether or not this object is complete or not
    `void` | `setCurrentPosition(int[] coords)` Sets the current position
    `void` | `setFill(boolean fill)` Sets whether the following shape is to be filled.
    `void` | `setLineType(byte lineType)` Sets the line type
    `void` | `setLineWidth(float lineWidth)` Sets the line width
    `void` | `setLineWidth(int lineWidth)` Sets the line width
    `void` | `setPatternSymbol(byte patternSymbol)` Sets the fill pattern of the next shape.
    `void` | `setViewport(AFPDataObjectInfo dataObjectInfo)` Sets the object view port (area position and size).
    `String` | `toString()`
    `protected void` | `writeContent(OutputStream os)` Helper method to write the contents of the Object.
    `protected void` | `writeEnd(OutputStream os)` Helper method to write the end of the Object.
    `protected void` | `writeStart(OutputStream os)` Helper method to write the start of the Object.

    - ### Methods inherited from class org.apache.fop.afp.modca.AbstractDataObject

      `getObjectEnvironmentGroup, isComplete, isStarted, setStarted`

    - ### Methods inherited from class org.apache.fop.afp.modca.AbstractNamedAFPObject

      `copySF, getName, getNameBytes, getNameLength, setName`

    - ### Methods inherited from class org.apache.fop.afp.modca.AbstractTripletStructuredObject

      `addTriplet, addTriplets, getFullyQualifiedName, getTripletDataLength, getTriplets, hasTriplet, hasTriplets, setComment, setFullyQualifiedName, setFullyQualifiedName, setObjectClassification, writeTriplets`

    - ### Methods inherited from class org.apache.fop.afp.modca.AbstractStructuredObject

      `writeToStream`

    - ### Methods inherited from class org.apache.fop.afp.modca.AbstractAFPObject

      `copySF, truncate, writeChunksToStream, writeObjects`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### objects

          protected List<GraphicsData> objects

      list of objects contained within this container

  - ### Constructor Detail

    - #### GraphicsObject

          public GraphicsObject(Factory factory,
                                String name)

      Default constructor
      Parameters:
        `factory` - the object factory
        `name` - the name of graphics object

  - ### Method Detail

    - #### setViewport

          public void setViewport(AFPDataObjectInfo dataObjectInfo)

      Sets the object view port (area position and size).
      Overrides:
        `setViewport` in class `AbstractDataObject`
      Parameters:
        `dataObjectInfo` - the object area info

    - #### addObject

          public void addObject(StructuredData object)

      Parameters:
        `object` - the structured data

    - #### setColor

          public void setColor(Color color)

      Sets the current color
      Parameters:
        `color` - the active color to use

    - #### setColorConverter

          public void setColorConverter(org.apache.xmlgraphics.java2d.color.ColorConverter colorConverter)

      Sets the color converter
      Parameters:
        `colorConverter` - ColorConverter to filter the color when creating a GraphicsSetProcessColor.

    - #### setCurrentPosition

          public void setCurrentPosition(int[] coords)

      Sets the current position
      Parameters:
        `coords` - the x and y coordinates of the current position

    - #### setLineWidth

          public void setLineWidth(int lineWidth)

      Sets the line width
      Parameters:
        `lineWidth` - the line width multiplier

    - #### setLineWidth

          public void setLineWidth(float lineWidth)

      Sets the line width
      Parameters:
        `lineWidth` - the line width multiplier

    - #### setLineType

          public void setLineType(byte lineType)

      Sets the line type
      Parameters:
        `lineType` - the line type

    - #### setFill

          public void setFill(boolean fill)

      Sets whether the following shape is to be filled.
      Parameters:
        `fill` - true if the following shape is to be filled

    - #### setPatternSymbol

          public void setPatternSymbol(byte patternSymbol)

      Sets the fill pattern of the next shape.
      Parameters:
        `patternSymbol` - the fill pattern of the next shape

    - #### setCharacterSet

          public void setCharacterSet(int characterSet)

      Sets the character set to use
      Parameters:
        `characterSet` - the character set (font) reference

    - #### addLine

          public void addLine(int[] coords)

      Adds a line at the given x/y coordinates
      Parameters:
        `coords` - the x/y coordinates (can be a series)

    - #### addLine

          public void addLine(int[] coords,
                              boolean relative)

      Adds a line at the given x/y coordinates
      Parameters:
        `coords` - the x/y coordinates (can be a series)
        `relative` - relative true for a line at current position (relative to)

    - #### addBox

          public void addBox(int[] coords)

      Adds a box at the given coordinates
      Parameters:
        `coords` - the x/y coordinates

    - #### addFillet

          public void addFillet(int[] coords)

      Adds a fillet (curve) at the given coordinates
      Parameters:
        `coords` - the x/y coordinates

    - #### addFillet

          public void addFillet(int[] coords,
                                boolean relative)

      Adds a fillet (curve) at the given coordinates
      Parameters:
        `coords` - the x/y coordinates
        `relative` - relative true for a fillet (curve) at current position (relative to)

    - #### setArcParams

          public void setArcParams(int xmaj,
                                   int ymin,
                                   int xmin,
                                   int ymaj)

      Sets the arc parameters
      Parameters:
        `xmaj` - the maximum value of the x coordinate
        `ymin` - the minimum value of the y coordinate
        `xmin` - the minimum value of the x coordinate
        `ymaj` - the maximum value of the y coordinate

    - #### addFullArc

          public void addFullArc(int x,
                                 int y,
                                 int mh,
                                 int mhr)

      Adds a full arc
      Parameters:
        `x` - the x coordinate
        `y` - the y coordinate
        `mh` - the integer portion of the multiplier
        `mhr` - the fractional portion of the multiplier

    - #### addImage

          public void addImage(int x,
                               int y,
                               int width,
                               int height,
                               byte[] imgData)

      Adds an image
      Parameters:
        `x` - the x coordinate
        `y` - the y coordinate
        `width` - the image width
        `height` - the image height
        `imgData` - the image data

    - #### addString

          public void addString(String str,
                                int x,
                                int y,
                                CharacterSet charSet)

      Adds a string
      Parameters:
        `str` - the string
        `x` - the x coordinate
        `y` - the y coordinate
        `charSet` - the character set associated with the string

    - #### beginArea

          public void beginArea()

      Begins a graphics area (start of fill)

    - #### endArea

          public void endArea()

      Ends a graphics area (end of fill)

    - #### endProlog

          public void endProlog()

      Ends the prolog.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `AbstractNamedAFPObject`

    - #### newSegment

          public void newSegment()

      Creates a new graphics segment

    - #### setComplete

          public void setComplete(boolean complete)

      Sets whether or not this object is complete or not
      Specified by:
        `setComplete` in interface `Completable`
      Overrides:
        `setComplete` in class `AbstractDataObject`
      Parameters:
        `complete` - true if this object is complete

    - #### writeStart

          protected void writeStart(OutputStream os)
                             throws IOException

      Helper method to write the start of the Object.
      Overrides:
        `writeStart` in class `AbstractDataObject`
      Parameters:
        `os` - The stream to write to
      Throws:
        `IOException` - throws an I/O exception if one occurred

    - #### writeContent

          protected void writeContent(OutputStream os)
                               throws IOException

      Helper method to write the contents of the Object.
      Overrides:
        `writeContent` in class `AbstractDataObject`
      Parameters:
        `os` - The stream to write to
      Throws:
        `IOException` - throws an I/O exception if one occurred

    - #### writeEnd

          protected void writeEnd(OutputStream os)
                           throws IOException

      Helper method to write the end of the Object.
      Overrides:
        `writeEnd` in class `AbstractStructuredObject`
      Parameters:
        `os` - The stream to write to
      Throws:
        `IOException` - an I/O exception if one occurred

Copyright © 2025 Apache Software Foundation. All rights reserved.