⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connectionendpointeditpolicyex.java

📁 对eclipse gef进行封装,可以生成图形化编辑器
💻 JAVA
字号:
/*******************************************************************************
 * $Header: /cvsroot/EOS6/work_dir/niegy/com.primeton.studio.gef.ui/src/com/primeton/studio/gef/ui/ui/policy/ConnectionEndpointEditPolicyEx.java,v 1.1 2006/12/05 05:18:59 niegy Exp $
 * $Revision: 1.1 $
 * $Date: 2006/12/05 05:18:59 $
 *
 *==============================================================================
 *
 * Copyright (c) 2001-2006 Primeton Technologies, Ltd.
 * All rights reserved.
 * 
 * Created on 2006-11-29
 *******************************************************************************/


package com.primeton.studio.gef.ui.ui.policy;

import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;

/**
 * 选中连线时设置连线的式样
 *
 * @author niegy (mailto:niegy@primeton.com)
 */
/*
 * 修改历史
 * $Log: ConnectionEndpointEditPolicyEx.java,v $
 * Revision 1.1  2006/12/05 05:18:59  niegy
 * 修改模型,增加连线的扩展点
 * 
 */
public class ConnectionEndpointEditPolicyEx extends
		ConnectionEndpointEditPolicy {
	private static Font BOLD_FONT;

	protected void addSelectionHandles(){
		super.addSelectionHandles();
		getConnectionFigure().setLineWidth(2);
	}

	protected PolylineConnection getConnectionFigure(){
		return (PolylineConnection)getHostFigure();
	}

	/**
	 * 未被选中时的动作
	 */
	protected void hideSelection() {
		super.hideSelection();
		getHostFigure().setFont(null);
		getHostFigure().invalidateTree();
	}

	protected void removeSelectionHandles(){
		super.removeSelectionHandles();
		getConnectionFigure().setLineWidth(0);
	}

	/**
	 * 选中连线
	 */
	protected void showSelection() {
		super.showSelection();
		if (BOLD_FONT == null) {
			FontData[] data = getConnectionFigure().getFont().getFontData();
			for (int i = 0; i < data.length; i++)
				if ((data[i].getStyle() & SWT.BOLD) == 0)
					data[i].setStyle(data[i].getStyle() | SWT.BOLD);
			BOLD_FONT = new Font(null, data);
		}
		getHostFigure().setFont(BOLD_FONT);
		getHostFigure().invalidateTree();
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -