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

📄 mxdistancecostfunction.java

📁 经典的java图像处理程序源码
💻 JAVA
字号:
/** * $Id: mxDistanceCostFunction.java,v 1.1 2008/09/26 14:47:40 gaudenz Exp $ * Copyright (c) 2007, Gaudenz Alder */package com.mxgraph.algebra;import com.mxgraph.util.mxPoint;import com.mxgraph.view.mxCellState;/** * Implements a cost function for the euclidian length of an edge. */public class mxDistanceCostFunction implements mxICostFunction{	/**	 * Returns the euclidion length of the edge defined by the absolute	 * points in the given state or 0 if no points are defined.	 */	public double getCost(mxCellState state)	{		double cost = 0;		int pointCount = state.getAbsolutePointCount();		if (pointCount > 0)		{			mxPoint last = state.getAbsolutePoint(0);			for (int i = 1; i < pointCount; i++)			{				mxPoint point = state.getAbsolutePoint(i);				cost += point.getPoint().distance(last.getPoint());				last = point;			}		}		return cost;	}}

⌨️ 快捷键说明

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