Class DocumentLayer

java.lang.Object
com.levigo.jadice.document.DocumentLayer
All Implemented Interfaces:
Comparable<DocumentLayer>

public class DocumentLayer extends Object implements Comparable<DocumentLayer>
Class representing a layer of a Document. The layers represent the z-axis of a document. Each Page in the document consists of a stack of AbstractPageSegments which correspond to DocumentLayers. In other words, a DocumentLayer represents a virtual slot in the stack of layers that make up the document whereas the PageSegments fill these slots.

Please note: the layers pertain to the whole document, therefore not all layers of a page need to be occupied with page segments.

  • Field Details

    • ANNOTATIONS

      public static final DocumentLayer ANNOTATIONS
      A layer typically used for annotations.
    • FORM

      public static final DocumentLayer FORM
      A layer typically used for form elements.
    • OCR

      public static final DocumentLayer OCR
      A layer typically used for OCR informations, e.g. a hocr file produced by Tesseract which contains text and position information
      HINT:
      This layer is installed by default in the default layer cache. If the layer cache implementation is replaced by another layer cache, it is up to that cache implementation to provide this layer as well.
    • EMBEDDED_ANNOTATIONS

      public static final DocumentLayer EMBEDDED_ANNOTATIONS
      A layer typically used for format specific inline annotations.
      HINT:
      This layer is installed by default in the default layer cache. If the layer cache implementation is replaced by another layer cache, it is up to that cache implementation to provide this layer as well.
    • DEFAULT

      public static final DocumentLayer DEFAULT
      A layer typically used for the document itself.
    • BACKGROUND

      public static final DocumentLayer BACKGROUND
      A layer typically used for a document backdrop, e.g. a form image behind plain-text form-contents.
  • Method Details

    • get

      public static DocumentLayer get(String name)
      Return the document layer with the given name. All layers with the same name will share the same instance as long as the default DocumentLayerCache is not replaced. If the layer does not already exist, a new layer will be created with its default priority being the same as DEFAULT.
      Parameters:
      name -
      Returns:
      the document layer for the given name.
      Throws:
      IllegalArgumentException - if name is null
    • get

      public static DocumentLayer get(String name, int priority)
      Return the document layer with the given name and priority. All layers with the same name will share the same instance as long as the default DocumentLayerCache is not replaced. If the layer does not already exist, a new layer will be created the given priority. If the layer does already exist, but the requested priority differs from the one of the existing layer, an IllegalArgumentException is thrown.
      Parameters:
      name - the layer name
      priority - the default priority.
      Returns:
      the document layer for the given name.
      Throws:
      IllegalArgumentException - if name is null or there is already a document layer with the given name, but the requested priority differs from the existing one's.
    • getName

      public String getName()
      Gets the name.
      Returns:
      Returns a String
    • compareTo

      public int compareTo(DocumentLayer o)
      Compare two DocumentLayers. Comparison is done by comparing default priorities. For identical priorities the comparison falls back to the layers' names.
      Specified by:
      compareTo in interface Comparable<DocumentLayer>
      See Also:
    • toString

      public String toString()
      Return text representation of the layer.
      Overrides:
      toString in class Object
      See Also:
    • getPriority

      public int getPriority()
      Return this layer's default ordering priority.

      Ordering priorities indicate the layer position within the layer stack. Higher priorities indicating a position closer to the top of the layer stack, lower priorities positions closer to the bottom.

      Returns:
      priority the layer's ordering priority
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object