com.levigo.jadice.document.render
Class RenderControlInventory

java.lang.Object
  extended by com.levigo.jadice.document.render.RenderControlInventory

public abstract class RenderControlInventory
extends Object

Implementations of RenderControlInventory handle document and page specific render controls belonging to a certain document instance.

Instances of this interface allow to get access to document and page specific render settings which is especially useful when the keep render settings mode is enabled.

This interface allows to get access to document and page specific render settings. With that it allows to change the render settings, too. To support multi viewer usage of one single document instance, viewers always works on snapshots of document render control inventories. As a consequence changes may not be reflected by any viewer which holds this document currently.

Therefore it is strongly recommended that developers do not change any of the render settings while the associated document is hold by any viewer instance, if and only if the render control instance is retrieved by a call of get(Document) or get(Document, boolean). Ignoring this recommendation would cause undesirable failures and inconsistencies may happen.


Nested Class Summary
static interface RenderControlInventory.Synchronizer
           
 
Constructor Summary
RenderControlInventory()
           
 
Method Summary
abstract  void addInventoryRenderSettingsListener(InventoryRenderSettingsListener listener)
          Adds a InventoryRenderSettingsListener for receiving render settings change events.
static RenderControlInventory bindInventoryToDocument(Document doc, RenderControlInventory inv)
          Binds the given inventory to the document.
static RenderControlInventory.Synchronizer createDefaultSynchronizer()
          Returns a default synchronizer which reflects document render settings changes into all page render controls.
abstract  RenderControlInventory createSnapshot()
          Creates a snapshot copy of this inventory instance.
static RenderControlInventory get()
          Creates and returns an empty RenderControlInventory.
static RenderControlInventory get(Document document)
          Returns the RenderControlInventory for the given document.
static RenderControlInventory get(Document document, boolean create)
          Creates and returns a RenderControlInventory for given document.
abstract  RenderControls getDocumentRenderControl()
          Return the documents render control
abstract  List<InventoryRenderSettingsListener> getInventoryRenderSettingsListeners()
          Returns a list of the registered InventoryRenderSettingsListener.
abstract  RenderControls getPageRenderControl(Page page)
          Return the page render control for the given page.
abstract  RenderControls getPageRenderControl(Page page, boolean create)
          Return the page render control for the given page.
abstract  boolean hasPageRenderControl(Page page)
          Return whether the page has specific render control settings.
abstract  void removeInventoryRenderSettingsListener(InventoryRenderSettingsListener listener)
          Removes a InventoryRenderSettingsListener.
abstract  void setSettingsSynchronizer(RenderControlInventory.Synchronizer handler)
          The default synchronizer reflects document render settings changes into all page render controls.
static RenderControlInventory unbindInventoryFromDocument(Document doc)
          Unbinds any inventory from the document.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenderControlInventory

public RenderControlInventory()
Method Detail

get

public static RenderControlInventory get(Document document)
Returns the RenderControlInventory for the given document. If no RenderControlInventory exists for given document, null will be returned.

Parameters:
document - the document for which the RenderControlInventory is demanded
Returns:
RenderControlInventory for given document or null if not available.
See Also:
get(), get(Document, boolean)

get

public static RenderControlInventory get(Document document,
                                         boolean create)
Creates and returns a RenderControlInventory for given document. If no RenderControlInventory exists for given document, the boolean parameter decides whether a new one will be created, will be bound to the document and will be returned.

Parameters:
document - the document for which the RenderControlInventory is demanded
create - if no inventory exist for given document:
  • true creates a new inventory, bind it to the document and return it,
  • false null will be returned
Returns:
RenderControlInventory for given document or null.
See Also:
get(), get(Document), bindInventoryToDocument(Document, RenderControlInventory)

get

public static RenderControlInventory get()
Creates and returns an empty RenderControlInventory. This inventory is not bound to any document. It can be used to store render controls settings temporarily.

Returns:
an empty RenderControlInventory
See Also:
get(Document), get(Document, boolean), bindInventoryToDocument(Document, RenderControlInventory)

createDefaultSynchronizer

public static RenderControlInventory.Synchronizer createDefaultSynchronizer()
Returns a default synchronizer which reflects document render settings changes into all page render controls.

Returns:
RenderControlInventory.Synchronizer

bindInventoryToDocument

public static RenderControlInventory bindInventoryToDocument(Document doc,
                                                             RenderControlInventory inv)
Binds the given inventory to the document. If the document is already bound to another inventory, the older binding is replaced with the new one.

Parameters:
doc -
inv -
Returns:
Returns the previous inventory the document was bound to or null if the document was not bind to another inventory before
See Also:
get(Document), unbindInventoryFromDocument(Document)

unbindInventoryFromDocument

public static RenderControlInventory unbindInventoryFromDocument(Document doc)
Unbinds any inventory from the document.

Parameters:
doc -
Returns:
Returns the previous inventory the document was bound to or null if the document was not bind to another inventory before
See Also:
get(Document), bindInventoryToDocument(Document, RenderControlInventory)

getDocumentRenderControl

public abstract RenderControls getDocumentRenderControl()
Return the documents render control

Returns:
document specific render control

getPageRenderControl

public abstract RenderControls getPageRenderControl(Page page)
Return the page render control for the given page. If no page render control exist, null will be returned.

Parameters:
page - the page for which the page render control lookup is demanded
Returns:
the page specific render control or null if no page render control is available

getPageRenderControl

public abstract RenderControls getPageRenderControl(Page page,
                                                    boolean create)
Return the page render control for the given page. If no page render control exist, the value of the create parameter decides whether a page render control should be created.

Parameters:
page - the page for which the page render control lookup is demanded
create - boolean flag. If no page render control for given page is available, true means a new one will be created and returned otherwise if the create parameter is false, null will be returned.
Returns:
the page specific render control, or null if no page render control is available and the create parameter is false.

hasPageRenderControl

public abstract boolean hasPageRenderControl(Page page)
Return whether the page has specific render control settings.

Parameters:
page - the page for which the page render control lookup is demanded
Returns:
whether the page has specific render control settings

createSnapshot

public abstract RenderControlInventory createSnapshot()
Creates a snapshot copy of this inventory instance. As a snapshot the returned copy presents the current state of this inventory, but is not bound to an inventory or to a document. This means changes of this inventory made after the snapshot creation are not reflected in the snapshot copy and vice versa. The copy just store the current settings state at the moment of snapshot creation.

Returns:
a snapshot copy of this inventory

setSettingsSynchronizer

public abstract void setSettingsSynchronizer(RenderControlInventory.Synchronizer handler)
The default synchronizer reflects document render settings changes into all page render controls. To change this default behavior use this method to register a customized handler. The handler have to be a RenderControlInventory.Synchronizer which will be called whenever a change of the document render control happened.

To restore the default behavior use a default synchronizer which can be obtained by a call of createDefaultSynchronizer().

If no synchronization should happen set null as RenderControlInventory.Synchronizer.

Parameters:
handler - to synchronize document render settings changes into page render settings

addInventoryRenderSettingsListener

public abstract void addInventoryRenderSettingsListener(InventoryRenderSettingsListener listener)
Adds a InventoryRenderSettingsListener for receiving render settings change events.

Parameters:
listener - the listener to register

removeInventoryRenderSettingsListener

public abstract void removeInventoryRenderSettingsListener(InventoryRenderSettingsListener listener)
Removes a InventoryRenderSettingsListener.

Parameters:
listener - the listener to remove

getInventoryRenderSettingsListeners

public abstract List<InventoryRenderSettingsListener> getInventoryRenderSettingsListeners()
Returns a list of the registered InventoryRenderSettingsListener.

It is up to the implementation whether to return the internal listener collection or a copy of this. Therefore changes made to the returned list must not be reflected in the internal listener collection. Addition or removal of listeners should always be done with a call of addInventoryRenderSettingsListener(InventoryRenderSettingsListener) or removeInventoryRenderSettingsListener(InventoryRenderSettingsListener).



Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.