is updating one-segment line possible?

Hi,

I am trying to draw a graph with draggable vertices, i use circles for vertices and lines for edges. The thing is that i want to update the edge when a vertex is dragged to another position, but seems like there is not any easy way. I wish it was as simple as changing the values of x1, y1, x2, y2. The only solution i can think of is scaling and rotating the line, which seems a little overkill. I would appreciate it if someone could give some directions. [import]uid: 130412 topic_id: 34166 reply_id: 334166[/import]

Hello,
One-segment lines can’t be modified per-vertex, so I suggest that you simply delete and re-draw the line. I’ve done this in a few apps and it’s really fast; no performance hit whatsoever, even when constantly deleting/creating lines in a touch-drag listener.

Brent [import]uid: 200026 topic_id: 34166 reply_id: 135902[/import]

Thanks for the reply. I thought about that but I am concerned about vertices with high degrees. Will it be still performing well when constantly deleting/creating, for example 10 lines? [import]uid: 130412 topic_id: 34166 reply_id: 135963[/import]

Hi again,
In this case (say, 10 lines being constantly deleted and redrawn), you might consider trying to build a “recycle” system, wherein you create a bunch of lines, store them in a holding table, and then swap them in and out as you need them, placing them in the correct location. Ultimately, this is the best approach to any mobile app where you’re doing alot of object drawing/redrawing. In your case, I don’t know if the lines will vary in height/width/angle or whatever… that could get more complex for a recycling system… but if you can attempt to do this instead of redrawing all the lines each cycle, it’ll perform better. One line being “refreshed” each time won’t hit your performance, but 10 of them might have a slight effect on older devices especially.

Best regards,
Brent [import]uid: 200026 topic_id: 34166 reply_id: 136006[/import]

Hello,
One-segment lines can’t be modified per-vertex, so I suggest that you simply delete and re-draw the line. I’ve done this in a few apps and it’s really fast; no performance hit whatsoever, even when constantly deleting/creating lines in a touch-drag listener.

Brent [import]uid: 200026 topic_id: 34166 reply_id: 135902[/import]

Thanks for the reply. I thought about that but I am concerned about vertices with high degrees. Will it be still performing well when constantly deleting/creating, for example 10 lines? [import]uid: 130412 topic_id: 34166 reply_id: 135963[/import]

Hi again,
In this case (say, 10 lines being constantly deleted and redrawn), you might consider trying to build a “recycle” system, wherein you create a bunch of lines, store them in a holding table, and then swap them in and out as you need them, placing them in the correct location. Ultimately, this is the best approach to any mobile app where you’re doing alot of object drawing/redrawing. In your case, I don’t know if the lines will vary in height/width/angle or whatever… that could get more complex for a recycling system… but if you can attempt to do this instead of redrawing all the lines each cycle, it’ll perform better. One line being “refreshed” each time won’t hit your performance, but 10 of them might have a slight effect on older devices especially.

Best regards,
Brent [import]uid: 200026 topic_id: 34166 reply_id: 136006[/import]