voytech / tabulate

Kotlin library for exporting collections of object into tabular formats.
Apache License 2.0
2 stars 0 forks source link

Introduce component library (document, page, pane, image, text, table) #160

Closed voytech closed 1 year ago

voytech commented 2 years ago

A drastic change. Documents should be top level API that can include 'Aggregate Root' model sub apis ( sub projects, sub models, sub operations , sub states)

Document API should be different module - or even different project that holds general contracts. Responsibilities should be:

Api should provide currently minimum set of components:

When above feature will be available, tabulate eventually becomes document DSL library.

Sub-tasks:

voytech commented 2 years ago

TemplateContext should not have generic type for RenderingContext. RenderingContext is export scope property and can be moved to export parameter list. This will allow to drop casts on TemplateContext.

voytech commented 2 years ago

Attribute merging strategy:

  1. AggregateModel should be replaced with Model. Model maintains AttributeGroups (attributes with categories they belong ) and defines set of ownedAttributeCategories ( attributes that are recognized by its ExportTemplate)
  2. When building TemplateContext a template must discover all downstream Models and collect its ownedAttributeCategories to compute all categories of attributes that must be merged from parent AggregateModel (AggregateModel is now model that have child Models). Above requires a generic methods on AggregateModel to access its AttributesGroups as well as to access childModels.
  3. Logic for merging and passing attribute groups should be done whe TemplateContext is created.
  4. Only AggregateModel have childModels and ownedAttributeGroups, Model has only ownedAttributeGroups.
voytech commented 2 years ago

Layouting.

  1. Layouting state should be associated with RenderingContext, as different context uses different units for coordinate system.
  2. Layout engine should be generic but operate on RenderingContext specific coordinate system.
  3. Layouts should not be controlled by client code, instead each operation dispatched from ExportTemplate should be first wrapped by something like LayoutProxy or LayoutInterceptor to recieve layout directives from rendered context models and attributes.
  4. LayoutProxy, after receiving layout directives from rendered context models and attributes, should alter global layout parameters. Global layout parameters needs to be present on RenderingContext.
  5. Units conversion must be possible as long as attributes may have defined different units.
  6. What about auto size offered by third party rendering libraries - is a feedback from renderer required ? What about default column widths e.g.? Should be read by rendering context ... should I perform default metrics detection from underlying engine?
  7. Should be possible to define default metrics : default row height, default column width,
voytech commented 2 years ago

Drop loading of ExportTemples using ServiceLoader. It is not required complexity. It is enough that each model declares method:

getExportTemplate

ServiceLoder should be used only for DocumentFormat related infrastructure as this is only pluggable.

As long as we have model we should already know how to export it by its type.