Java-绘制动态形状轮廓 [英] Java - Drawing a dynamic shape outline

查看:148
本文介绍了Java-绘制动态形状轮廓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望通过将对象(带有绘制功能)添加到屏幕上沿形状周边的适当位置来为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.现有的实现例如用于翻译或调整多个选择作为一个单元的大小. AlignDistribute的功能可以类似地实现.我将以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-绘制动态形状轮廓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆