But I think it's difficult.
Yes, it is not an easy task.
First of all, you need to define a good data structure.
You have Points, Lines, PolyLines, Rectangles, Polygon etc.
A Point has two coordinates.
A Line has or four coordinates or two Points.
If you use two Points to define a Line you should use indexes for the Points and not directly their coordinates.
A same single Point can belong to more than one line, and if you modify it, all parent object are modified.
All this needs to be taken into account, and it is only the short story.
Then you need a physical coordinate system with a scale to transform physical coordinates to screen coordinates.
Then, some comments to your program.
I remember having seen Erels program, but is a relatively ancient one, lots of things have changed in the meantime.
- Fist suggestion is to switch to B4XPages, and use B4XObjects like B4XView, B4XCanvas etc.
But, maybe you could stay with B4J only, in that case you could have a look at the jCanvasExt libary which extends the standard Canvas.
- You define the user interface in the code, you should do it in the Designer.
- Add a third Canvas for the cursor to show it on the screen with a cross and display its coordinates.
- In the Touch event routine you should
Then to select any object you need to check if the cursor is close to one of its components.
For a Point it is easy, go through all shapes and check for each point if the difference between its coordinates and the cursor coordinates is smaller than the snap distance.
For a line you need to check if the cursor is in the rectangle formed by the two points and then if the distance between the cursor and the line is smaller than the snap distance.
For a shape it depends on its components and on the data structure.
Searching for a circle is different from searching for a rectangle.
For a circle you need to check if the cursor is either near to the center or check if the distance between the cursor and the center is close to the circle radius.
For a rectangle you must check the four points and the four lines.
Etc, etc...
Unfortunately, for the search functions the current data structure is not appropriate.
Impossible to know the shape type nor get the coordinates.
This means that you need to first define the right data structure.
When you have done it i could help further.
It is a long story, explaining some subjects of the problem, I can only encourage to go further.