Class DecoratedTextFactory


  • public class DecoratedTextFactory
    extends java.lang.Object
    Factory method to create a decorated text from a template.
    Author:
    Andi Hotz, (c) Sahits GmbH, 2014 Created on Nov 10, 2014
    • Constructor Summary

      Constructors 
      Constructor Description
      DecoratedTextFactory​(int leftInset, int topInset, int wrappingWidth)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      DecoratedText createDecoratedText​(java.lang.String template, java.lang.String styleClass, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Create a decorated text from the template string.
      DecoratedText createDecoratedText​(java.lang.String template, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Create a decorated text from the template string.
      javafx.scene.control.Label createLabel​(java.lang.String template)  
      javafx.scene.layout.VBox createMultiParagraphContainer()  
      DecoratedText createSimpleDecoratedText​(java.lang.String template)  
      java.lang.String replaceTextParameters​(java.lang.String template, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Replace the placeholders in the template with the values from the parameters object
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DecoratedTextFactory

        public DecoratedTextFactory​(int leftInset,
                                    int topInset,
                                    int wrappingWidth)
    • Method Detail

      • createMultiParagraphContainer

        public javafx.scene.layout.VBox createMultiParagraphContainer()
      • createDecoratedText

        public DecoratedText createDecoratedText​(java.lang.String template,
                                                 java.util.Map<java.lang.String,​java.lang.Object> parameters)
        Create a decorated text from the template string. The template string can contain placeholders, that are replaced through objects in the parameters Map. The normal replacement uses the toString() method on the map entry's value. There are some special cases where a specific Node is created to represent the placeholder.
        Special placeholders:
        • icon:Coin: Coin icon followed by the amount passed in as parameter ([icon:Coin coinAmount])
        • icon:Barrel: Barrel icon followed by the amount passed in as a parameter ([icon:Barrel amount])
        • icon:Bale: Bale icon followed by the amount passed in as a parameter ([icon:Bale amount])
        • icon:Generic: generic icon that is passed as parameter([icon:Generic icons/64/cannonball_icon]). The icon is scaled so it matches the line hight.
        • image:Segment: segmented image split up in 9 segments and only the specified parts are visible ([image:Segment mapSegment1.png visibleSegments])
        • image: centered image ([image imageName])
        The amounts for Coin Barrel and Bale may also be already provided, e.g replaced as part of the message retrevial. In this case it is important that the amount is an unformatted integer. ([icon:Coin{0, number, #}]).
        Parameters:
        template - template string
        parameters - Map containing the parameters.
        Returns:
        new Decorated instance based on a template and parameters
      • createLabel

        public javafx.scene.control.Label createLabel​(java.lang.String template)
      • createSimpleDecoratedText

        public DecoratedText createSimpleDecoratedText​(java.lang.String template)
      • createDecoratedText

        public DecoratedText createDecoratedText​(java.lang.String template,
                                                 java.lang.String styleClass,
                                                 java.util.Map<java.lang.String,​java.lang.Object> parameters)
        Create a decorated text from the template string. The template string can contain placeholders, that are replaced through objects in the parameters Map. The normal replacement uses the toString() method on the map entry's value. There are some special cases where a specific Node is created to represent the placeholder.
        Special placeholders:
        • icon:Coin: Coin icon followed by the amount passed in as parameter ([icon:Coin coinAmount])
        • icon:Barrel: Barrel icon followed by the amount passed in as a parameter ([icon:Barrel amount])
        • icon:Bale: Bale icon followed by the amount passed in as a parameter ([icon:Bale amount])
        • image:Segment: segmented image split up in 9 segments and only the specified parts are visible ([image:Segment mapSegment1.png visibleSegments])
        • image: centered image ([image imageName])
        The amounts for Coin Barrel and Bale may also be already provided, e.g replaced as part of the message retrevial. In this case it is important that the amount is an unformatted integer. ([icon:Coin{0, number, #}]).
        Parameters:
        template - template string
        styleClass - style class from the base.css to be applied on the Decorated Text.
        parameters - Map containing the parameters.
        Returns:
        new instance of decorated text based on a template and parameters and styled with the style class.
      • replaceTextParameters

        public java.lang.String replaceTextParameters​(java.lang.String template,
                                                      java.util.Map<java.lang.String,​java.lang.Object> parameters)
        Replace the placeholders in the template with the values from the parameters object
        Parameters:
        template - string containing placeholders
        parameters - to replace the parameters
        Returns:
        finalized string