Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| PDF Clown 0.1.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.pdfclown.documents.contents
Class ContentScanner

    java.lang.Object
      org.pdfclown.documents.contents.ContentScanner

    public final class ContentScanner

extends Object

Content objects scanner.

It wraps a `content objects collection` to scan its graphics state through an oriented cursor.

Scanning is performed at an arbitrary depth, according to the content objects nesting: each depth level corresponds to a scan level so that at any time it's possible to seamlessly navigate across the levels (see `getParentLevel()`, `getChildLevel()`).

Scanning can be either "dry" (simulation of graphics state stacking without actual rendering) or "wet" (`rendering over a given device context`).

Since:
  0.0.4
Version:
  0.1.2, 08/23/12
Author:
  Stefano Chizzolini (http://www.stefanochizzolini.it)

Nested Class Summary
`static class` | `ContentScanner.GraphicsObjectWrapper<TDataObject extends ContentObject>` Object information.
`static class` | `ContentScanner.GraphicsState` Graphics state [PDF:1.6:4.3].
`static interface` | `ContentScanner.IListener` Content scanner listener.
`static class` | `ContentScanner.InlineImageWrapper` Inline image information.
`static class` | `ContentScanner.TextStringWrapper` Text string information.
`static class` | `ContentScanner.TextWrapper` Text information.
`static class` | `ContentScanner.XObjectWrapper` External object information.

Constructor Summary
`ContentScanner(Contents contents)` Instantiates a top-level content scanner.
`ContentScanner(FormXObject formXObject, ContentScanner parentLevel)` Instantiates a child-level content scanner for `external form`.
`ContentScanner(IContentContext contentContext)` Instantiates a top-level content scanner.

Method Summary
`void` | `addListener(ContentScanner.IListener listener)` Adds the specified listener.
`Dimension2D` | `getCanvasSize()` Gets the size of the current imageable area.
`ContentScanner` | `getChildLevel()` Gets the current child scan level.
`IContentContext` | `getContentContext()` Gets the content context associated to the content objects collection.
`Contents` | `getContents()` Gets the content objects collection this scanner is inspecting.
`ContentObject` | `getCurrent()` Gets the current content object.
`ContentScanner.GraphicsObjectWrapper<?>` | `getCurrentWrapper()` Gets the current content object's information.
`int` | `getIndex()` Gets the current position.
`CompositeObject` | `getParent()` Gets the current parent object.
`ContentScanner` | `getParentLevel()` Gets the parent scan level.
`Graphics2D` | `getRenderContext()` Gets the rendering context.
`Shape` | `getRenderObject()` Gets the rendering object.
`ContentScanner` | `getRootLevel()` Gets the root scan level.
`ContentScanner.GraphicsState` | `getState()` Gets the graphics state applied to the current content object.
`void` | `insert(Collection<? extends ContentObject> objects)` Inserts content objects at the current position.
`void` | `insert(ContentObject object)` Inserts a content object at the current position.
`boolean` | `isRootLevel()` Gets whether this level is the root of the hierarchy.
`boolean` | `move(int index)` Moves to the object at the given position.
`void` | `moveEnd()` Moves after the last object.
`boolean` | `moveFirst()` Moves to the first object.
`boolean` | `moveLast()` Moves to the last object.
`boolean` | `moveNext()` Moves to the next object.
`void` | `moveStart()` Moves before the first object.
`protected void` | `notifyStart()` Notifies the scan start to listeners.
`ContentObject` | `remove()` Removes the content object at the current position.
`boolean` | `removeListener(ContentScanner.IListener listener)` Removes the specified listener.
`void` | `render(Graphics2D renderContext, Dimension2D renderSize)` Renders the contents into the specified context.
`void` | `render(Graphics2D renderContext, Dimension2D renderSize, Shape renderObject)` Renders the contents into the specified object.
`ContentObject` | `setCurrent(ContentObject value)` Replaces the content object at the current position.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ContentScanner

    public ContentScanner(Contents contents)

  Instantiates a top-level content scanner.

  Parameters:
    `contents` - Content objects collection to scan.

### ContentScanner

    public ContentScanner(IContentContext contentContext)

  Instantiates a top-level content scanner.

  Parameters:
    `contentContext` - Content context containing the content objects collection to scan.

### ContentScanner

    public ContentScanner(FormXObject formXObject,
                          ContentScanner parentLevel)

  Instantiates a child-level content scanner for `external form`.

  Parameters:
    `formXObject` - External form.
    `parentLevel` - Parent scan level.

Method Detail

### addListener

    public void addListener(ContentScanner.IListener listener)

  Adds the specified listener.

  Parameters:
    `listener` - Listener to add.

### getCanvasSize

    public Dimension2D getCanvasSize()

  Gets the size of the current imageable area.

  It can be either the user-space area (dry scanning) or the device-space area (wet scanning).

### getChildLevel

    public ContentScanner getChildLevel()

  Gets the current child scan level.

  See Also:
    `getParentLevel()`, `getRootLevel()`

### getContentContext

    public IContentContext getContentContext()

  Gets the content context associated to the content objects collection.

### getContents

    public Contents getContents()

  Gets the content objects collection this scanner is inspecting.

### getCurrent

    public ContentObject getCurrent()

  Gets the current content object.

  See Also:
    `getIndex()`, `getParent()`

### getCurrentWrapper

    public ContentScanner.GraphicsObjectWrapper<?> getCurrentWrapper()

  Gets the current content object's information.

  See Also:
    `getCurrent()`

### getIndex

    public int getIndex()

  Gets the current position.

  See Also:
    `getCurrent()`

### getParent

    public CompositeObject getParent()

  Gets the current parent object.

  See Also:
    `getCurrent()`

### getParentLevel

    public ContentScanner getParentLevel()

  Gets the parent scan level.

  See Also:
    `getChildLevel()`, `getRootLevel()`

### getRenderContext

    public Graphics2D getRenderContext()

  Gets the rendering context.

  Returns:
    `null` in case of dry scanning.

### getRenderObject

    public Shape getRenderObject()

  Gets the rendering object.

  Returns:
    `null` in case of scanning outside a shape.

### getRootLevel

    public ContentScanner getRootLevel()

  Gets the root scan level.

  See Also:
    `getChildLevel()`, `getParentLevel()`

### getState

    public ContentScanner.GraphicsState getState()

  Gets the graphics state applied to the current content object.

### insert

    public void insert(ContentObject object)

  Inserts a content object at the current position.

### insert

    public void insert(Collection<? extends ContentObject> objects)

  Inserts content objects at the current position.

  After the insertion is complete, the lastly-inserted content object is at the current position.

### isRootLevel

    public boolean isRootLevel()

  Gets whether this level is the root of the hierarchy.

### move

    public boolean move(int index)

  Moves to the object at the given position.

  Parameters:
    `index` - New position.
  Returns:
    Whether the object was successfully reached.

### moveEnd

    public void moveEnd()

  Moves after the last object.

### moveFirst

    public boolean moveFirst()

  Moves to the first object.

  Returns:
    Whether the first object was successfully reached.

### moveLast

    public boolean moveLast()

  Moves to the last object.

  Returns:
    Whether the last object was successfully reached.

### moveNext

    public boolean moveNext()

  Moves to the next object.

  Returns:
    Whether the next object was successfully reached.

### moveStart

    public void moveStart()

  Moves before the first object.

### remove

    public ContentObject remove()

  Removes the content object at the current position.

  Returns:
    Removed object.

### removeListener

    public boolean removeListener(ContentScanner.IListener listener)

  Removes the specified listener.

  Parameters:
    `listener` - Listener to remove.
  Returns:
    Whether the specified listener has been removed.

### render

    public void render(Graphics2D renderContext,
                       Dimension2D renderSize)

  Renders the contents into the specified context.

  Parameters:
    `renderContext` - Rendering context.
    `renderSize` - Rendering canvas size.
  Since:
    0.1.0

### render

    public void render(Graphics2D renderContext,
                       Dimension2D renderSize,
                       Shape renderObject)

  Renders the contents into the specified object.

  Parameters:
    `renderContext` - Rendering context.
    `renderSize` - Rendering canvas size.
    `renderObject` - Rendering object.
  Since:
    0.1.0

### setCurrent

    public ContentObject setCurrent(ContentObject value)

  Replaces the content object at the current position.

  Returns:
    Replaced object.

### notifyStart

    protected void notifyStart()

  Notifies the scan start to listeners.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| PDF Clown 0.1.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Project home page
Copyright © 2006-2013 Stefano Chizzolini. Some Rights Reserved.
This documentation is available under the terms of the GNU Free Documentation License.