Android Question Text Position According To Coordinates

Terradrones

Active Member
Hi All

I need help again please or a kick under my Butt in the right direction.

When the Surveyor plots all the Topo Points on the screen, how can I make it that the Feature (or Name) of the Topo Point gets plotted next to the Topo Point using the coordinates of the Topo Points?

I have looked at "Drawtext", but that wants the position in Dips.

cvsDrawing.DrawText(Pnt(PntI).Name,xp,yp, Typeface.DEFAULT_BOLD, 30, Colors.Blue, "LEFT")
 

Terradrones

Active Member
To draw the Topo Points you need a scale between their physical coordinates and the screen pixel coordinates you have to apply the same scale for the text coordinates.
Hi Klaus, I have done that. I calculate the distance between the maximum and minimum coordinates on both X & Y axis. I then divide the screen width and height by the physical distance of the coordinate limits to get a Ratio between the Physical and Screen coordinates. I have also a Button where I can swap the system around...in South Africa we call the Horizontal Axis the "Y" coordinate and it increases going West and the Vertical Axis is called the "X" Axis and it increases going South....its a mirror image from what the rest of the world is using!

My problem is to show the Feature (or Name) next to each Plotted point. I had a look at "DrawText", but the position is given in "Dips". I need to position the Text according to the calculated screen coordinates.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I had a look at "DrawText", but the position is given in "Dips".
No, the coordinates are given in pixels.

Attached a small demo program showing the principle.

1689421341737.png


The upper 4 points are drawn with physical scale.

At the bottom, the "My text" display shows what you get with the rectText = cvsTest.MeasureText("My text", fnt) routine.
The blue cross represents the coordinates xt and yt you give in cvsTest.DrawText("My text", xt, yt, fnt, xui.Color_Red, "LEFT")
The green rectangle is the outer rectangle of the text.
rectTextOuter.Initialize(xt + rectText.Left, yt + rectText.Top, xt + rectText.Right, yt + rectText.Bottom)

At the right, the gray lines from top to bottom:
yt + rectText.Top, the top position (-rectText.Top is the distance between the top and the base line)
yt + rectText.CenterY, the center position (-rectText.CenterY is the distance between the center and the base line)
yt, the base line of the text
yt + rectText.Bottom, the bottom position (rectText.Bottomis the distance between the bottom and the base line)
At the bottom, the gray lines from left to right:
xt + rectText.Left, the left position, you see that there is a kind of padding
xt + rectText.CenterX, the center position
xt + rectText.Right, the right position.
 

Attachments

  • DrawText.zip
    9.7 KB · Views: 51
Upvote 0
Top