Class AbstractRM2DShape

All Implemented Interfaces:
Archivable, DeepChangeListener, RMPropertyChanger, RMTypes, Unexpandable, PropertyChangeListener, Cloneable, EventListener
Direct Known Subclasses:
RMBarcode, RMScriptableChart

public abstract class AbstractRM2DShape extends RMParentShape implements Unexpandable
To create RM vector images, we add RMShape nodes to a root node. This class serves as that root node for extending classes. Inorder to be able to add children, the class needed to extend from RMParentShape. The existing AbstractJ2DShape extends from RMShape and does not support having children nodes. This class therefore contains a near copy of AbstractJ2DShape but extending from RMParentShape instead of RMShape.

The "copy" is then extended with methods and properties to enable the creation of RM vector images; and the switching between raster and vector output.
  • Field Details

  • Constructor Details

    • AbstractRM2DShape

      public AbstractRM2DShape()
  • Method Details

    • render

      protected abstract void render(Graphics2D g, int width, int height)
      This is where implementations of AbstractRM2DShape actual paint themselves to a graphics context, to produce either a vector or raster graphic.
    • getDefaultColorCodes

      public static String[] getDefaultColorCodes()
    • getDefaultColors

      public static Color[] getDefaultColors()
    • setIsRpg

      public void setIsRpg(boolean isRpg)
    • isRpg

      protected boolean isRpg()
    • setRenderContext

      public void setRenderContext(RenderContext renderContext)
    • getRenderContext

      public RenderContext getRenderContext()
    • useImageForVector

      protected boolean useImageForVector()
    • setUseRaster

      public void setUseRaster(boolean useRaster)
    • getUseRaster

      public boolean getUseRaster()
    • getUserRasterInternal

      protected boolean getUserRasterInternal()
      This is the accessor for the useRaster variable. This might diverge from the getUserRaster() public property if that's overridden.
    • setDirty

      protected void setDirty()
    • getDisplayedFill

      public RMFill getDisplayedFill()
      Overrides:
      getDisplayedFill in class RMShape
    • generateVectorShapes

      public void generateVectorShapes()
      This method is only active when RenderContext.useImageForVector() is set to true. When called will add RMShapes to the root node.

      In the current use case, it's paired with disposeVectorShapes(). The main purpose of these methods is to minimize memory usage when generating vector output. This method creates the RMShapes needed to generate the vector output, and disposeVectorShapes() removes these RMShapes when they are no longer needed.

      An example to further clarify: let's say we have a Report containing a Table followed by a Barcode and then a XYChart. As we write the report to vector (PDF or printing), we write the Table first, then when we hit the Barcode, we call this method to create the RMShapes used to render the Barcode. Once we finish writing these RMShapes to vector, we call disposeVectorShapes() to remove these RMShapes from the root node. We then move on to the XYChart, and repeat the above process. So at any given time, we only have the RMShapes needed to render the current element being written to vector.

    • disposeVectorShapes

      public void disposeVectorShapes()
      This method is only active when RenderContext.useImageForVector() is set to true. When called will clear the root node of its child RMShapes.
    • clone

      @Nonnull public RMParentShape clone()
      Description copied from class: RMParentShape
      Standard implementation of Object clone. Null's out shape's parent and children.
      Overrides:
      clone in class RMParentShape
    • toXML

      public RXElement toXML(RXArchiver archiver)
      Description copied from class: RMParentShape
      XML Archival generic - break toXML into toXMLShape and toXMLShapeChildren.
      Specified by:
      toXML in interface Archivable
      Overrides:
      toXML in class RMParentShape
    • fromXML

      public RMShape fromXML(RXArchiver archiver, RXElement element)
      Description copied from class: RMParentShape
      XML unarchival generic - break fromXML into fromXMLShape and fromXMLShapeChildren.
      Specified by:
      fromXML in interface Archivable
      Overrides:
      fromXML in class RMParentShape