简体   繁体   English

交互式平面直线图 swing

[英]interactive planar straight line graph in swing

I am trying to draw an interactive planar straight line graph (PSLG) on a JApplet.我正在尝试在 JApplet 上绘制交互式平面直线图 (PSLG)。 I am using mouse-clicks to determine the vertices of the PSLG.我使用鼠标点击来确定 PSLG 的顶点。

Here is the algorithm which I am following for drawing edges of the PSLG 1. The point where user performs a mouse-click is added as a vertex of the PSLG.这是我为绘制 PSLG 1 的边缘而遵循的算法。用户执行鼠标单击的点被添加为 PSLG 的顶点。 2. If he clicks a second point,an edge is directly created among the point and the previously clicked-point 2. 如果他点击第二个点,则直接在该点和之前点击的点之间创建一条边

Here are certain flaws which I observed due to the use of this algorithm:由于使用此算法,我观察到以下某些缺陷:

  1. Inability to create disjoint-planar sets like say just a line segment无法创建不相交的平面集,比如只是一条线段
  2. A closed polygon is only created if the user clicks at the exact location where the start point was [Essentially, if the user clicks very close to the start point, there is no way to tell that this point is actually the start point since it appears within a certain tolerance range from the point].仅当用户在起点所在的确切位置单击时才会创建闭合多边形[本质上,如果用户单击非常靠近起点,则无法判断该点实际上是起点,因为它出现从点在一定的公差范围内]。

I've checked out some similar questions over here and people suggest to use the JFreeChart library.我在这里检查了一些类似的问题,人们建议使用JFreeChart库。 But as far as I get, the scenario in those questions was that the points of the PSLG were already known.但据我所知,这些问题的场景是 PSLG 的要点已经为人所知。 I do not know whether JFreeChart can be used for creating interactive PSLG's我不知道JFreeChart是否可以用于创建交互式 PSLG

I thought about adding points and having a button which would say add edges among points,but if that's the case selecting the 2 points will still involve the proximity problem encountered in 2.我考虑过添加点并有一个按钮会说在点之间添加边缘,但如果是这样选择2个点仍然会涉及2中遇到的邻近问题。

I was wondering if anybody could suggest me a better approach on how to handle this situation.我想知道是否有人可以建议我更好的方法来处理这种情况。

Thanks in advance提前致谢

GraphPanel could be adapted to this task, although it might benefit from a more advanced edge model for faster searching. GraphPanel可以适应这项任务,尽管它可能受益于更高级的边缘 model以加快搜索速度。 Also consider JGraph .还可以考虑JGraph

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM