📄 referenceconnectioneditpart.java
字号:
/*******************************************************************************
* $Header: /cvsroot/EOS6/work_dir/niegy/com.primeton.studio.gef.ui/src/com/primeton/studio/gef/ui/parts/ReferenceConnectionEditPart.java,v 1.2 2006/12/16 09:04:42 niegy Exp $
* $Revision: 1.2 $
* $Date: 2006/12/16 09:04:42 $
*
*==============================================================================
*
* Copyright (c) 2001-2006 Primeton Technologies, Ltd.
* All rights reserved.
*
* Created on 2006-11-29
*******************************************************************************/
package com.primeton.studio.gef.ui.parts;
import org.eclipse.draw2d.ConnectionEndpointLocator;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PolygonDecoration;
import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.PolylineDecoration;
import org.eclipse.draw2d.RotatableDecoration;
import org.eclipse.draw2d.geometry.PointList;
import com.primeton.studio.gef.ui.editor.AbstractGraphicalEditor;
/**
* Referenc连线
*
* @author niegy (mailto:niegy@primeton.com)
*/
/*
* 修改历史
* $Log: ReferenceConnectionEditPart.java,v $
* Revision 1.2 2006/12/16 09:04:42 niegy
* 重构代码
*
* Revision 1.1 2006/12/05 05:18:59 niegy
* 修改模型,增加连线的扩展点
*
*/
public class ReferenceConnectionEditPart extends ConnectionEditPart {
/**
* @param editor
*/
public ReferenceConnectionEditPart(AbstractGraphicalEditor editor) {
super(editor);
}
private Label srcCount, srcName, targetCount, targetName;
private ConnectionEndpointLocator srcCountLocator, srcNameLocator,
targetCountLocator, targetNameLocator;
private RotatableDecoration srcDecor, targetDecor;
private PolygonDecoration createPolygonDecoration() {
PolygonDecoration decoration = new PolygonDecoration();
PointList decorationPointList = new PointList();
decorationPointList.addPoint(0,0);
decorationPointList.addPoint(-1,1);
decorationPointList.addPoint(-2,0);
decorationPointList.addPoint(-1,-1);
decoration.setTemplate(decorationPointList);
return decoration;
}
private PolylineDecoration createPolylineDecoration () {
PolylineDecoration decoration = new PolylineDecoration();
decoration.setScale(10, 5);
return decoration;
}
/* (non-Javadoc)
* @see com.primeton.studio.gef.ui.parts.ConnectionEditPart#createFigure()
*/
protected IFigure createFigure() {
// TODO Auto-generated method stub
PolylineConnection conn = new PolylineConnection();
// Create the endpoint locators
srcCountLocator = new ConnectionEndpointLocator(conn, false);
srcNameLocator = new ConnectionEndpointLocator(conn, false);
srcNameLocator.setVDistance(-4);
targetCountLocator = new ConnectionEndpointLocator(conn, true);
targetNameLocator = new ConnectionEndpointLocator(conn, true);
targetCountLocator.setVDistance(-4);
//updateSourceDecoration
srcDecor = createPolygonDecoration();
conn.setSourceDecoration(srcDecor);
//updateTargetDecoration
targetDecor = createPolylineDecoration();
conn.setTargetDecoration(targetDecor);
//updateSourceCount
srcCount = new Label("1..n");
srcCount.setOpaque(true);
conn.add(srcCount, srcCountLocator);
//updateSourceName
srcName = new Label("src");
srcName.setOpaque(true);
conn.add(srcName, srcNameLocator);
//updateTargetCount
targetCount = new Label("1..n");
targetCount.setOpaque(true);
conn.add(targetCount, targetCountLocator);
//updateTargetName
targetName = new Label("target");
targetName.setOpaque(true);
conn.add(targetName, targetNameLocator);
return conn;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -