Class RenderControlsJsonSerializer

java.lang.Object
com.levigo.jadice.web.client.rendercontrols.RenderControlsJsonSerializer

public class RenderControlsJsonSerializer extends Object
Utility class that is responsible to serialize RenderControls to json and the other way round, i.e. parse the json and restore RenderControls from that json.

The specification of the json file is taken from the following example:

 {
   "name": "jadice-render-presets",
   "version": 2,
   "inventoryKit": {
     "name": "<document-id>",
     "controlsKits": [
       {
         "name": "document",
         "settingsUnits": [
           {
             "name": "BaseRenderSettings",
             "parts": [
               {
                 "name": "rotation",
                 "value": "<one of com.levigo.jadice.web.shared.model.settings.BaseRenderSettings.Rotation>"
               }
             ]
           }
         ]
       },
       {
         "name": "page<index>",
         "settingsUnits": [
           {
             "name": "BaseRenderSettings",
             "parts": [
               {
                 "name": "rotation",
                 "value": "<one of com.levigo.jadice.web.shared.model.settings.BaseRenderSettings.Rotation>"
               }
             ]
           }
         ]
       }
     ]
   }
 }
 
  • Constructor Details

    • RenderControlsJsonSerializer

      public RenderControlsJsonSerializer()
  • Method Details

    • serializeRenderControls

      public static String serializeRenderControls(PageView pageView, Document document)
      Take both the RenderControls that are applied document-wide and page-wide and create a json object
      Parameters:
      pageView - the PageView that holds its RenderSettings like the rotation.
      document - the Document containing pages. We can have RenderControls that define that the whole document is rotated, but we can have those settings also individually per page. FilteredDocuments are not supported.
      Returns:
      the whole json object containing both document and page render settings / rotations.
    • serializeRenderControls

      public static String serializeRenderControls(PageView pageView, Document document, ControlsKitFilter filter)
      Take both the RenderControls that are applied document-wide and page-wide and create a json object
      Parameters:
      pageView - the PageView that holds its RenderSettings like the rotation.
      document - the Document containing pages. We can have RenderControls that define that the whole document is rotated, but we can have those settings also individually per page. FilteredDocuments are not supported.
      filter - a ControlsKitFilter to restrict the serialization output. If the filter is null, a ControlsKitAllowAllFilter will be created.
      Returns:
      the whole json object containing both document and page render settings / rotations.
    • createRenderPresets

      public static com.levigo.jadice.web.client.rendercontrols.internal.WritableRenderPresets createRenderPresets(PageView pageView, Document document, ControlsKitFilter filter)
    • serializeRenderControls

      public static String serializeRenderControls(PageView pageView, List<Page> pages)
      Take page RenderControls and create a json object for them.
      Parameters:
      pageView - the PageView that holds its RenderSettings like the rotation.
      pages - a List of pages to serialize render controls for.
      Returns:
      a json object containing all pages render settings / rotations.
    • serializeRenderControls

      public static String serializeRenderControls(PageView pageView, List<Page> pages, ControlsKitFilter filter)
      Take page RenderControls and create a json object for them.
      Parameters:
      pageView - the PageView that holds its RenderSettings like the rotation.
      pages - a List of pages to serialize render controls for.
      filter - a ControlsKitFilter to restrict the serialization output. If the filter is null, a ControlsKitAllowAllFilter will be created.
      Returns:
      a json object containing all pages render settings / rotations.
    • deSerializeRenderControls

      public static void deSerializeRenderControls(String json, PageView pageView)

      Take a json object and restore RenderControls for the whole Document currently set in PageView.

      RenderControls wil be applied to the given PageView.
      Parameters:
      json - the json string containing the RenderControls info.
      pageView - hold the document and gets RenderControls applied to.
    • deSerializeRenderControls

      public static void deSerializeRenderControls(String json, List<Page> pages, PageView pageView)

      Take a json object and restore RenderControls on the given pages currently present in PageViews Document.

      RenderControls wil be applied to the given PageView.
      Parameters:
      json - the json string containing the RenderControls info.
      pages - Pages for which the RenderControls are applied for.
      pageView - hold a document containing the given Pages and gets RenderControls applied to.