SelectionHighlightPopUp

data class SelectionHighlightPopUp(val backgroundColor: Color = Color.White, val backgroundAlpha: Float = 0.7f, val backgroundCornerRadius: CornerRadius = CornerRadius(5f), val backgroundColorFilter: ColorFilter? = null, val backgroundBlendMode: BlendMode = DrawScope.DefaultBlendMode, val backgroundStyle: DrawStyle = Fill, val paddingBetweenPopUpAndPoint: Dp = 20.dp, val labelSize: TextUnit = 14.sp, val labelColor: Color = Color.Black, val labelAlignment: Paint.Align = Paint.Align.CENTER, val labelTypeface: Typeface = Typeface.DEFAULT, val popUpLabel: (Float, Float) -> String = { x, y -> val xLabel = "x : ${x.toInt()} " val yLabel = "y : ${String.format("%.2f", y)}" "$xLabel $yLabel" }, val draw: DrawScope.(Offset, Point) -> Unit = { selectedOffset, identifiedPoint -> val highlightTextPaint = TextPaint().apply { textSize = labelSize.toPx() color = labelColor.toArgb() textAlign = labelAlignment typeface = labelTypeface } val label = popUpLabel(identifiedPoint.x, identifiedPoint.y) drawContext.canvas.nativeCanvas.apply { val background = getTextBackgroundRect( selectedOffset.x, selectedOffset.y, label, highlightTextPaint ) drawRoundRect( color = backgroundColor, topLeft = Offset( background.left.toFloat(), background.top.toFloat() - paddingBetweenPopUpAndPoint.toPx() ), size = Size(background.width().toFloat(), background.height().toFloat()), alpha = backgroundAlpha, cornerRadius = backgroundCornerRadius, colorFilter = backgroundColorFilter, blendMode = backgroundBlendMode, style = backgroundStyle ) drawText( label, selectedOffset.x, selectedOffset.y - paddingBetweenPopUpAndPoint.toPx(), highlightTextPaint ) } })

SelectionHighlightPopUp is a data class used to draw the pop on the given selected point on a line to identify the dimensions of the selected point.All the styling related params are included here

Parameters

backgroundColor

: Defines the background color of the popup.

backgroundAlpha

: Defines the alpha of the background color.

backgroundCornerRadius

: Defines the corner radius of the background.

backgroundColorFilter

: ColorFilter to apply to the color when drawn into the destination.

backgroundBlendMode

:Blending algorithm to be applied to the path when it is drawn.

backgroundStyle

: Whether or not the path is stroked or filled in.

labelSize

: The size of the popUp label in TextUnit.

labelColor

: The color of the label text.

labelAlignment

: The alignment of the label text.

labelTypeface

: The style of the label text.

paddingBetweenPopUpAndPoint

: The padding between the anchor position/ popup start position and the selected point on the line.

popUpLabel

: The text that can be shown on the popup given 2 input params x and y values

draw

: Draw the popUp marker on the selected point with 2 inputs Offset i.e selectedPoint and Point i.e the input data w.r.t selected point

Constructors

Link copied to clipboard
constructor(backgroundColor: Color = Color.White, backgroundAlpha: Float = 0.7f, backgroundCornerRadius: CornerRadius = CornerRadius(5f), backgroundColorFilter: ColorFilter? = null, backgroundBlendMode: BlendMode = DrawScope.DefaultBlendMode, backgroundStyle: DrawStyle = Fill, paddingBetweenPopUpAndPoint: Dp = 20.dp, labelSize: TextUnit = 14.sp, labelColor: Color = Color.Black, labelAlignment: Paint.Align = Paint.Align.CENTER, labelTypeface: Typeface = Typeface.DEFAULT, popUpLabel: (Float, Float) -> String = { x, y -> val xLabel = "x : ${x.toInt()} " val yLabel = "y : ${String.format("%.2f", y)}" "$xLabel $yLabel" }, draw: DrawScope.(Offset, Point) -> Unit = { selectedOffset, identifiedPoint -> val highlightTextPaint = TextPaint().apply { textSize = labelSize.toPx() color = labelColor.toArgb() textAlign = labelAlignment typeface = labelTypeface } val label = popUpLabel(identifiedPoint.x, identifiedPoint.y) drawContext.canvas.nativeCanvas.apply { val background = getTextBackgroundRect( selectedOffset.x, selectedOffset.y, label, highlightTextPaint ) drawRoundRect( color = backgroundColor, topLeft = Offset( background.left.toFloat(), background.top.toFloat() - paddingBetweenPopUpAndPoint.toPx() ), size = Size(background.width().toFloat(), background.height().toFloat()), alpha = backgroundAlpha, cornerRadius = backgroundCornerRadius, colorFilter = backgroundColorFilter, blendMode = backgroundBlendMode, style = backgroundStyle ) drawText( label, selectedOffset.x, selectedOffset.y - paddingBetweenPopUpAndPoint.toPx(), highlightTextPaint ) } })

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard