如何避免过度张贴(重叠)标签?

发布于 2024-11-07 19:22:50 字数 702 浏览 3 评论 0原文

我必须在屏幕上显示多个标签而不重叠。标签位置应尽可能接近它们所描述的特征。这些特征可以是屏幕上的点、线或多边形(想象任何种类的地图)。 我必须在我的应用程序中满足以下要求:

  • 标签的位置必须避免与其他标签重叠(重叠)
  • 标签的位置必须避免与其他要素(多边形和线段)重叠
  • 标签的最佳位置是上方和下方他们在下面描述的功能的右侧
  • 和右侧不太可接受,
  • 最不可接受的位置是左侧,

我需要想出一种方法来做到这一点。

在我开始随机尝试这样做之前,我希望这里有人可能已经这样做了,并且能够给我一些关于从哪里开始的建议。

基本上,通过标签,我可以使用边界框将它们相互比较。虽然我不知道有什么好的方法可以做到这一点。通过屏幕上标记的线段和多边形,我真的不知道应该做什么来避免重叠。我希望除了避免标签本身的重叠之外,不需要付出太多的努力。

我认为如果我只需要处理与其他标签重叠的标签,排斥就会起作用。但是,如果我在屏幕的一半上绘制了一条线段,我不知道如何使用排斥技术避免与该线段重叠。

我使用的语言是 Actionscript 3 和 Flex 框架。我不相信 Flex 有任何像 Java Spring 中那样的布局管理器类可以为我完成这项工作。

无论如何,欢迎提供链接或建议。我可以允许一些蛮力;否则我不知道如何才能做到这一点。谢谢你!

PS 我相信这个问题的技术术语是“过度发布”。

I have to display a multitude of labels on-screen without overlap. The label positions should be as close as possible to the features they describe. The features may be points, lines, or polygons on-screen (imagine any variety of map).
I have to satisfy the following requirements in my application:

  • labels must be positioned to avoid overposting (overlap) with other labels
  • labels must be positioned to avoid overlapping with other features (polygons and line segments)
  • optimum position for a label is above and to the right of the feature they describe
  • below and to the right is less acceptable
  • least acceptable positions are to the left

I need to come up with a method for doing this.

Before I just start attempting to do this at random, I am hoping someone here may have already done this and be able to give me some advice as to where to start.

Basically, with the labels, I could use bounding boxes to compare them to each other. Although I don't know a good way to do this. With the line segments and polygons onscreen that they are labeling, I really don't have a clue what I should do to avoid overlap. I am hoping it won't require much more effort on top of avoiding the overlap of the labels themselves.

I think repulsion would work if I only had to deal with labels overlapping other labels. But if I have a line segment drawn across half the screen, I don't know how I can avoid overlap with that using the repulsion technique.

The language I am using is Actionscript 3 and the Flex framework. I don't believe Flex has any layout manager classes like there are in Java Spring that can do this work for me.

Anyway, links or suggestions would be welcome. I can allow for some brute force; I don't see how I can accomplish this otherwise. Thank you!

PS I believe the technical term for this problem is "overposting".

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

青巷忧颜 2024-11-14 19:22:50

如果不参考所有标签和您需要避免的其他形状/线条,我看不出有什么方法可以实现此目的。假设您有这些引用,只需绑定到 Flex 框架方法即可。

在 updateDisplayList() 中循环标签;并将它们与屏幕上的其他所有内容一起放置。您可以使用 getExplicitOrMeasuredWidth() 和 getExplicitOrMeasuredHeight() 方法来确定相关项目所需的空间。

如果您使用内置的 Flex 容器(例如 VBox 或 HBox),标签和其他线条将相互定位。或者,如果您使用 Spark,VGroup 或 HGroup 将提供相同的功能。

I don't see any way to accomplish this without having a reference to all the labels and the other shapes / lines you need to avoid. Assuming you have those references, just tie into the Flex Framework methods.

In updateDisplayList() loop over your labels; and position them in conjunction with to everything else on screen. You can use the getExplicitOrMeasuredWidth() and getExplicitOrMeasuredHeight() methods to determine the space needed for the item in question.

If you use a built in Flex Container, such as a VBox or HBox the labels and other lines will be positioned in accordance to each other. Or, if you're using Spark a VGroup or HGroup will offer the same functionality.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文