RobotTask:样条曲线模型的添加

2015.5.3

1.model

  1 import java.io.*;
  2 import java.util.List;
  3 import java.io.BufferedReader;
  4 import java.io.File;
  5 import java.io.FileReader;
  6 import java.io.FileWriter;
  7 import java.io.IOException;
  8
  9 import org.dom4j.Element;
 10 import org.eclipse.draw2d.geometry.Dimension;
 11 import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
 12 import org.eclipse.ui.views.properties.IPropertyDescriptor;
 13 import org.eclipse.ui.views.properties.PropertyDescriptor;
 14 import org.eclipse.ui.views.properties.TextPropertyDescriptor;
 15
 16 import com.example.helper.ConstantResourceFactory;
 17 import com.example.helper.ModelStringConstant;
 18 import com.example.helper.CustomErrorInfo;
 19 import com.example.model.ModelType;
 20 import com.example.model.NonContainerModel;
 21 import com.example.propertyDiscriptor.EditDialogPropertyDescriptor;
 22 import com.example.propertyDiscriptor.FileDialogPropertyDescriptor;
 23
 24 public class SampleModel extends NonContainerModel {
 25     public String edit;
 26     public static final String SELECT_LABEL = "label";
 27     public static final String SELECT_NAME = "name";
 28     public static final String SELECT_EDIT = "edit";
 29     //******************************************结构体部分********************************
 30     public SampleModel() {
 31         super(ConstantResourceFactory.LABEL_SAMPLE_MODEL,
 32                 ConstantResourceFactory.ID_SAMPLE_MODEL,
 33                 ConstantResourceFactory.SIZE_SAMPLE_ELEMENT);
 34         setName("样条曲线");
 35         setEdit("编辑属性");
 36         //setModel("空");这里的setModel是setModelString,string里放的是文件的内容
 37     }
 38     //******************************************结构体部分********************************
 39
 40
 41
 42     //******************************************属性编辑部分********************************
 43     public IPropertyDescriptor[] descriptors = new IPropertyDescriptor[] {
 44             new PropertyDescriptor(SELECT_LABEL, "模型名字"),
 45             new TextPropertyDescriptor(SELECT_NAME, "名字"),
 46             new EditDialogPropertyDescriptor(SELECT_EDIT,"编辑"),
 47     };
 48
 49     public IPropertyDescriptor[] getPropertyDescriptors() {
 50         return descriptors;
 51     }
 52
 53     public Object getPropertyValue(Object id) {
 54         super.getPropertyValue(id);
 55         if (id.equals(SELECT_LABEL)){
 56             return getModelName();
 57         }
 58         else if (id.equals(SELECT_NAME)){
 59             return getName();
 60         }
 61         else if (id.equals(SELECT_EDIT)){
 62             return getEdit();
 63         }
 64         return null;
 65      }
 66
 67      public boolean isPropertySet(Object id) {
 68             return true;
 69      }
 70
 71      public void resetPropertyValue(Object id) {
 72      }
 73
 74      public void setPropertyValue(Object id, Object value) {
 75             super.setPropertyValue(id, value);
 76             if(id.equals(SELECT_NAME)){
 77                 setName((String)value);
 78             }
 79
 80             else if(id.equals(SELECT_EDIT)){
 81                 setEdit((String)value);
 82             }
 83     }
 84     //******************************************属性编辑部分********************************
 85
 86
 87
 88     //******************************************XML部分********************************
 89     public void doSaveXML(){
 90            super.doSaveXML();
 91 //           this.addXMLElementAttribute(ModelType.ATR_MODELSTRING, (String) getModel());
 92            //文件内容读取并保存部分
 93 //           this.doSaveModel();
 94
 95     }
 96
 97
 98     @Override
 99     public void rebuildFromXml(Element e,List<Object> err) {
100             // TODO Auto-generated method stub
101         super.rebuildFromXml(e,err);
102     }
103     //******************************************XML部分********************************
104
105
106
107
108
109     /*
110     //******************************************复制部分********************************
111     @Override
112     public Object copy() {
113         // TODO Auto-generated method stub
114         LinearMotionModel model=new LinearMotionModel();
115         initCopyModel(model);
116         return model;
117     }
118
119     protected void initCopyModel(LinearMotionModel model) {
120         // TODO Auto-generated method stub
121         super.initCopyModel(model);
122         model.setCoorType(coorType);
123         model.setDisplacement(displacement);
124         model.setVelocity(velocity);
125     }
126     //******************************************复制部分********************************
127     */
128
129
130     //******************************************get/set部分********************************
131     public String getEdit() {
132         return edit;
133     }
134
135     public  void setEdit(String edit) {
136         this.edit = edit;
137         firePropertyChange(ConstantResourceFactory.P_EDIT,null,edit);
138     }
139     //******************************************get/set部分********************************
140 }

2.editPart,直接复制的callPart,里面没什么代码,父类都实现了。

3.partFactory

4.figure,复制的callFigure,没动。

 1 import org.eclipse.draw2d.ColorConstants;
 2 import org.eclipse.draw2d.Ellipse;
 3 import org.eclipse.draw2d.Graphics;
 4 import org.eclipse.draw2d.geometry.Dimension;
 5 import org.eclipse.draw2d.geometry.Point;
 6 import org.eclipse.draw2d.geometry.Rectangle;
 7 import org.eclipse.swt.graphics.Color;
 8
 9
10
11 public class SampleFigure extends PortElementFigure {
12
13     public SampleFigure(){
14         super();
15     }
16
17     public Dimension getPreferredSize(int wHint, int hHint) {
18         return FigureDimensionConstant.SIZE_PORT_ELEMENT;
19     }
20
21     protected void paintFigure(Graphics g) {
22         super.paintFigure(g);
23
24         int x = getMainRect().x;
25         int y = getMainRect().y;
26         int w = getMainRect().width;
27         int h = getMainRect().height;
28
29         g.drawLine(x+w/6,y+5*h/6,x+w/3, y+h/3);
30         g.drawLine(x+3*w/6,y+2*h/3,x+w/3, y+h/3);
31         g.drawLine(x+5*w/6,y+h/6,x+3*w/6,y+2*h/3);
32
33         if(isShow()){
34             drawLabelFrame(g,getNameFigure().getBounds(),true);
35             //drawLabelFrame(g,getTypeFigure().getBounds(),true);
36         }
37
38     }
39
40 }

5.figureFactory

6.paletteFactory

7.customModelFactory

8.ModelType

9.plugin.xml

运行没有问题。

还需要解决的问题:

(1)如何获取数据一开始就导入到属性栏中?(2)保存数据部分的程序还没有写。

时间: 2024-08-03 15:54:18

RobotTask:样条曲线模型的添加的相关文章

[Asp.net MVC]Asp.net MVC5系列——在模型中添加验证规则

目录 概述 在模型中添加验证规则 自定义验证规则 伙伴类的使用 总结 系列文章 [Asp.net MVC]Asp.net MVC5系列——第一个项目 [Asp.net MVC]Asp.net MVC5系列——添加视图 [Asp.net MVC]Asp.net MVC5系列——添加模型 [Asp.net MVC]Asp.net MVC5系列——从控制器访问模型中的数据 [Asp.net MVC]Asp.net MVC5系列——添加数据 概述 上篇文章中介绍了添加数据,在提交表单的数据的时候,我们需

Asp.net MVC]Asp.net MVC5系列——在模型中添加

目录 概述 在模型中添加验证规则 自定义验证规则 伙伴类的使用 总结 系列文章 [Asp.net MVC]Asp.net MVC5系列--第一个项目 [Asp.net MVC]Asp.net MVC5系列--添加视图 [Asp.net MVC]Asp.net MVC5系列--添加模型 [Asp.net MVC]Asp.net MVC5系列--从控制器访问模型中的数据 [Asp.net MVC]Asp.net MVC5系列--添加数据 概述 上篇文章中介绍了添加数据,在提交表单的数据的时候,我们需

【phpcms-v9】phpcms-v9视频模型的添加

1.  下载化蝶自由飞插件http://www.phpcms.cn/show-90-8-1.html 下载回去后解压,覆盖 phpcms/ 和 statics/ 目录即可. 2.  执行一个sql语句-- v9_player.sql ,以增加播放器代码;注意sql语句里的表前缀需要替换为你的v9数据库前缀,使用文本编辑工具如editplus打开替换 v9_ 为你的数据库前缀; 3.  字段安装方法为: \phpcms\modules\content\fields\fields.inc.php 在

【从零开始学习YOLOv3】7. 教你在YOLOv3模型中添加Attention机制

前言:[从零开始学习YOLOv3]系列越写越多,本来安排的内容比较少,但是在阅读代码的过程中慢慢发掘了一些新的亮点,所以不断加入到这个系列中.之前都在读YOLOv3中的代码,已经学习了cfg文件.模型构建等内容.本文在之前的基础上,对模型的代码进行修改,将之前Attention系列中的SE模块和CBAM模块集成到YOLOv3中. 1. 规定格式 正如[convolutional],[maxpool],[net],[route]等层在cfg中的定义一样,我们再添加全新的模块的时候,要规定一下cfg

iOS 模型之中添加非空的方法

- (id)initWithDict:(NSDictionary *)dict { self = [super init]; if (self) { [self setValuesForKeysWithDictionary:dict]; self.max = [NSString stringWithFormat:@"%@", dict[@"max"]]; self.average = [NSString stringWithFormat:@"%@"

【转】、Asp.Net MVC4.0 官方教程 入门指南之八--为Movie模型和库表添加字段

在本节中,您将使用实体框架代码先行迁移功能对模型类进行修改,并使修改应用到数据库中. 默认情况下,当您使用实体框架代码先行自动创建一个数据库,像你在本教程前面做的那样,代码首先添加一张表到数据库中,以帮助跟踪数据库架构是否是同步的模型类是产生的.如果它们不同步,实体框架抛出一个错误.这使得它更容易在早期开发时跟踪发现问题,否则,你可能在运行时发现隐晦错误. 为模型修改建立代码先行迁移如果您使用的是Visual Studio 2012,在“解决方案资源管理器”中双击Movies.mdf的文件,打开

织梦如何添加新的内容模型及字段?

修改方法如下: 1.进织梦DedeCms后台后打开 核心 -> 频道模型 -> 内容模型管理. 这样就会看到织梦DedeCms集成的几个内容模板,比如商品.图片集.文章和软件之类的,然后点击你需要修改的频道模型名称.比如我现在需要在普通文章模型里面添加上价格这个字段,我就点击它.就会出现更改内容模型的页面,点击字段管理,点击添加新字段. 新加字段的调用方法: 内容页:{dede:field.***** /} 列表页:[field:***** /] {dede:list addfields=’m

SpringMVC:学习笔记(4)——处理模型数据

SpringMVC-处理模型数据 说明 SpringMVC 提供了以下几种途径输出模型数据: – ModelAndView: 处理方法返回值类型为 ModelAndView时, 方法体即可通过该对象添加模型数据 – Map及Model:入参为org.springframework.ui.Model.org.springframework.ui.ModelMap 或 Java.uti.Map 时,处理方法返回时,Map中的数据会自动添加到模型中. – @SessionAttributes: 将模型

django1.8读书笔记模型高级进阶

一.访问外键和多对多值 例如:模型类定义如下 from django.db import models class Publisher(models.Model): name = models.CharField(max_length=30) address = models.CharField(max_length=50) city = models.CharField(max_length=60) state_province = models.CharField(max_length=30