设计通用工具管理器

发布于 2024-11-29 15:28:17 字数 524 浏览 1 评论 0原文

我想处理 UI 组件(按钮、文本字段、swfs、自定义对象等)上的多个操作,

例如缩放、倾斜、颜色、旋转等,并保存它们。早些时候,这些操作是

使用单个工具和单个 mxml 文件完成的,但现在该工具被分成不同的工具。

想知道如何设计/使用 Toolmanager 类之类的东西来处理操作等?

另外,棘手的部分是某些对象可以为它们定义更多操作。 就像“object1”有 3 个可以对其执行的操作,“object2”有 5 个对其定义的操作。

我们使用 MVC 设计模式,但没有这样的框架。

可使用哪些不同的设计模式来实现此目的?

编辑:
更准确地说,我想以 AS3 OO 方式实现它。 该应用程序类似于绘图应用程序,支持添加各种图像、文本、音频、swfs等。添加的一个用户可以对对象执行各种操作..比如 添加颜色、缩放、倾斜、旋转等以及自定义效果,然后将绘图导出为 PNG。同样,一些适用于文本的效果不适用于图像 反之亦然。有些影响可能是常见的。

有什么想法吗?

I want to handle multiple operations on a UI Component (button ,textfield, swfs,custom objects etc)

in like scaling,skewing ,color,rotations etc etc and save them too. Earlier the actions were done

using a single tool and single mxml file but now the tool is separated into different tools.

Was wondering how i can design / use something like Toolmanager class to handle actions etc?

Also the tricky part is that some objects can have more operations defined for them .
Like 'object1' has 3 operations that can be performed on it and 'object2' has 5 operations defined on it.

We are using MVC design pattern but no frameworks as such.

What are the different design patterns that can be used to do this?

Edit:
To be more precise i want implement this in AS3 OO way.
The application is similar to drawing application which supports addition of various images,text,audio,swfs etc. One added user can perform various operations of the objects..like
adding color,scaling skewing,rotation etc etc and custom effects and after that export the drawing as PNG.Likewise some effects that are applicable to text are not applicable to images
and vice versa. and some effects can be common.

Any ideas?

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

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

发布评论

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

评论(2

深居我梦 2024-12-06 15:28:17

也许您可以有一个工具栏、工具(从公共基础继承)和某种属性面板,这些对象可以从管理器类访问,该管理器类将它们包装在一起并使所有类都可以访问一些变量。
也许您需要管理器类中的选择数组或向量以及选择工具来操作此集合

(例如(在管理器中))

protected var _selection:Vector.<EditableBase> = new Vector.<EditableBase>();
public function get selection() { return _selection;}

以及有关编辑库扩展及其可用工具的集合。
每次选择工具更新选择集合(可能从选择工具的 onMouseUp 方法调用管理器上的方法)时,您可以更新工具栏以显示当前选择

(在管理器中)

protected var _ToolsByType:Object (or Dictionary) = {"EditableAudio": ["toolA", "toolB", etc]};
protected var _defaultSet:Array = ["toolA", "toolB"];

的适当工具,并且在选择已被操作之后(在经理也)

public function onSelectionChangedCallback():void
{
  var toolsToDisplay:Array = _defaultSet;
  if(_selection.length == 1)
  {
   //not actual syntax
   var type:String = getQualifiedClassName(_selection[0]);
   if(type in _ToolsByType) toolsToDisplay = _ToolsByType[type];
  }

  myToolBar.showSet(toolsToDisplay);
}

工具的祖先应该看起来像这样:

public class ToolBase
{
  protected var _manager:ToolManager;
  function ToolBase(manager:ToolManager)//and probably a bunch of other params as well
  {
     _manager = manager;
  }
  function onSelect()
  {
    //you can manipulate the properties panel here
  }
  function onDeSelect()...
  function onMouseDown(mouseData:event/whateverWrapperYouHaveCreated)...
  function onMouseMove...
  function onMouseUp...
}

等等:)
有点直截了当。
检查 Photoshop 插件教程,或谷歌搜索“扩展{这里的任何 adobe 东西,例如 flash 或其他东西}
那是 javascript,但这个概念也可以应用在这里

Probably you could have a toolbar, tools(inheriting from a common base), and some kind of property panel, these objects are accessible from a manager class which wrappes them together and makes some variables accessible for all classes.
Probably you want a selection array or vector in the manager class and a select tool to manipulate this collection

like (in the manager)

protected var _selection:Vector.<EditableBase> = new Vector.<EditableBase>();
public function get selection() { return _selection;}

and a collection about the editbase extensions and the tools avaiable for them.
every time the selection tool updates the selection collection (probably calling a method on manager from the select tool's onMouseUp method) you can update the toolbar to display the apropriate tools for the current selection

(in manager)

protected var _ToolsByType:Object (or Dictionary) = {"EditableAudio": ["toolA", "toolB", etc]};
protected var _defaultSet:Array = ["toolA", "toolB"];

and after the selection has benn manipulated (in manager also)

public function onSelectionChangedCallback():void
{
  var toolsToDisplay:Array = _defaultSet;
  if(_selection.length == 1)
  {
   //not actual syntax
   var type:String = getQualifiedClassName(_selection[0]);
   if(type in _ToolsByType) toolsToDisplay = _ToolsByType[type];
  }

  myToolBar.showSet(toolsToDisplay);
}

the ancestor for the tools should look something like this:

public class ToolBase
{
  protected var _manager:ToolManager;
  function ToolBase(manager:ToolManager)//and probably a bunch of other params as well
  {
     _manager = manager;
  }
  function onSelect()
  {
    //you can manipulate the properties panel here
  }
  function onDeSelect()...
  function onMouseDown(mouseData:event/whateverWrapperYouHaveCreated)...
  function onMouseMove...
  function onMouseUp...
}

and so and so on :)
kinda straight forward.
check photoshop plugin tutorials, or google around "extending {any adobe stuff here, like flash or something}
thats javascript but the concept can be applied here as well

空宴 2024-12-06 15:28:17

也许您可以通过在 MVC 实现中创建一些额外的类来使用策略设计模式

http://en.wikipedia。 org/wiki/Strategy_pattern

算法,检查此工具中的图像:

再见! :)

maybe you could use the Strategy Design Pattern by creating some extra classes in your MVC implementation

http://en.wikipedia.org/wiki/Strategy_pattern

algo, check this tool for images:
http://www.senocular.com/demo/TransformToolAS3/TransformTool.html

bye! :)

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