问题描述
我希望通过将对象(带有绘制功能)添加到屏幕上沿形状周边的适当位置来为Shape
(AWT)创建动态轮廓.我希望每个对象之间的距离大致相等. (对这种影响的替代方法也可以.)
I wish to create a dynamic outline to a Shape
(AWT) by adding objects (with draw functions) to appropriate positions on screen along the shape's perimeter. I want a roughly even distance between each object. (An alternative approach to the same affect will be fine.)
如何获取这些对象的位置?我知道形状具有路径迭代器,但是我不知道如何使用它.
How might I acquire the locations for these objects? I know shapes have a path iterator, but I have no idea how to use it.
推荐答案
您可能会看到诸如 形状图编辑器 .
You might look at a library such as the one described in A Shape Diagram Editor.
如果您想尝试, GraphPanel
是一个简单的对象绘制程序具有通过边缘连接的可移动,可调整大小的彩色节点.如果节点小一点,它们将是Shape
上的可移动点,可以按此处所示进行迭代用于Polygon
.
If you want to experiment, GraphPanel
is a simple object drawing program that features moveable, resizable, colored nodes connected by edges. If the nodes were a little smaller, they'd be moveable points on a Shape
that can be iterated as shown here for Polygon
.
附录:我希望每个对象之间的距离大致均匀.
class Node
公开了许多对List<Node>
进行操作的静态方法,例如selected
.现有的实现例如用于翻译或调整多个选择作为一个单元的大小. Align
和Distribute
的功能可以类似地实现.我将以LayoutManger
作为后者的示例.
The class Node
exposes a number of static methods that operate on a List<Node>
such as selected
. Existing implementations serve, for example, to translate or resize multiple selections as a unit. Functions for Align
and Distribute
could be implemented similarly. I'd look at LayoutManger
as an example for the latter.
这篇关于Java-绘制动态形状轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!