Class FormattedTextEncoder
- java.lang.Object
-
- com._1c.g5.v8.dt.md.ui.editor.formattedtext.FormattedTextEncoder
-
public class FormattedTextEncoder extends Object
Class for encoding/decoding font and color into/from strings which are used in editors and viewers of formatted text.
-
-
Constructor Summary
Constructors Constructor Description FormattedTextEncoder(IV8Project v8Project, IMdObjectByTypeProvider objectByTypeProvider, IColorProvider colorProvider, IFontProvider fontProvider)
Creates new encoder instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Color
decodeColor(String encodedColorName, String encodedCompositeId)
Creates decoded color from encoded color name and composite Id string.Font
decodeFont(String encodedFaceName)
Creates decoded font from encoded face name.Picture
decodePicture(String encodedCompositeId)
Decodes picture from given encoded composite Id string.String
encodeColor(Color color)
Creates encoded color name from color.String
encodeCompositeId(CompositeId compositeId)
Creates encoded composite Id.String
encodeFont(Font font)
Creates encoded face name from font.static String
encodeFontParameters(String faceName, int size, String encodedCompositeId)
Creates encoded font face name from given font parameters.String
encodePicture(Picture picture)
Encodes picture into a string.String
encodePictureCompositeId(Picture picture)
Encodes composite Id of the given picture into a string.static String
encodeRgbColor(Color color)
Creates encoded color name from rgb color definition.Font
getDefaultFont()
Returns default font which can be used if no other fonts specified.PlatformColor
getStyledColor(int encodedCompositeId)
Returns styled color by given compositeId.CompositeId
getStyledColorCompositeId(Color color)
Returns color's composite Id if it is a styled color.Font
getStyledFont(int encodedCompositeId)
Returns styled font by given compositeId.boolean
isDefaultFont(Font font)
Returns whether given font is a special default font.boolean
isStyledColor(Color color)
Tells whether specified color is a styled one.void
reloadKnownPictures(IV8Project v8Project, IMdObjectByTypeProvider objectByTypeProvider)
Reloads the list of known pictures.
-
-
-
Constructor Detail
-
FormattedTextEncoder
public FormattedTextEncoder(IV8Project v8Project, IMdObjectByTypeProvider objectByTypeProvider, IColorProvider colorProvider, IFontProvider fontProvider)
Creates new encoder instance.- Parameters:
v8Project
- V8 project, cannot benull
objectByTypeProvider
- object by type provider, cannot benull
colorProvider
- the color provider, cannot benull
fontProvider
- the font provider, cannot benull
-
-
Method Detail
-
getDefaultFont
public Font getDefaultFont()
Returns default font which can be used if no other fonts specified. For now it is used when user changes font size, but does not specify font family.- Returns:
- the default font, cannot be
null
-
isDefaultFont
public boolean isDefaultFont(Font font)
Returns whether given font is a special default font.- Parameters:
font
- the font to check- Returns:
true
if font is a default font,false
otherwise- See Also:
also#getDefaultFont()
-
getStyledFont
public Font getStyledFont(int encodedCompositeId)
Returns styled font by given compositeId.- Parameters:
encodedCompositeId
- the encoded composite Id for which to get the font- Returns:
- the font found or
null
-
encodeFont
public String encodeFont(Font font)
Creates encoded face name from font.- Parameters:
font
- the font to encode- Returns:
- the encoded face name
-
encodeFontParameters
public static String encodeFontParameters(String faceName, int size, String encodedCompositeId)
Creates encoded font face name from given font parameters.- Parameters:
faceName
- font facesize
- font size in pointsencodedCompositeId
- encoded composite Id- Returns:
- the encoded face name
-
encodeCompositeId
public String encodeCompositeId(CompositeId compositeId)
Creates encoded composite Id.- Parameters:
compositeId
- composite Id to encode- Returns:
- the encoded value
-
decodeFont
public Font decodeFont(String encodedFaceName)
Creates decoded font from encoded face name.- Parameters:
encodedFaceName
- face name to decode- Returns:
- the decoded font instance
-
getStyledColor
public PlatformColor getStyledColor(int encodedCompositeId)
Returns styled color by given compositeId.- Parameters:
encodedCompositeId
- the compositeId for which to get the color- Returns:
- the color found or
null
-
getStyledColorCompositeId
public CompositeId getStyledColorCompositeId(Color color)
Returns color's composite Id if it is a styled color.- Parameters:
color
- the color to check- Returns:
- composite Id or
null
if color is not a styled color
-
isStyledColor
public boolean isStyledColor(Color color)
Tells whether specified color is a styled one.- Parameters:
color
- the color to check- Returns:
true
if given color is a styled color,false
otherwise
-
encodeColor
public String encodeColor(Color color)
Creates encoded color name from color.- Parameters:
color
-- Returns:
- the color name encoded
-
encodeRgbColor
public static String encodeRgbColor(Color color)
Creates encoded color name from rgb color definition.- Parameters:
color
- , can benull
- Returns:
- the color name encoded, never
null
-
decodeColor
public Color decodeColor(String encodedColorName, String encodedCompositeId)
Creates decoded color from encoded color name and composite Id string.- Parameters:
encodedColorName
- encoded color namecompositeId
- encoded composite Id if exists ornull
- Returns:
- the decoded color instance
-
encodePicture
public String encodePicture(Picture picture)
Encodes picture into a string.- Parameters:
picture
- the picture to encode- Returns:
- the encoded string
-
encodePictureCompositeId
public String encodePictureCompositeId(Picture picture)
Encodes composite Id of the given picture into a string.- Parameters:
picture
- the picture for which to encode composite Id- Returns:
- the encoded string or
null
if composite Id is not found
-
decodePicture
public Picture decodePicture(String encodedCompositeId)
Decodes picture from given encoded composite Id string.- Parameters:
compositeId
- the encoded composite Id string for which to get the picture- Returns:
- the picture found or
null
-
reloadKnownPictures
public void reloadKnownPictures(IV8Project v8Project, IMdObjectByTypeProvider objectByTypeProvider)
Reloads the list of known pictures.- Parameters:
v8project
- V8 project, cannot benull
objectByTypeProvider
- object by type provider, cannot benull
-
-