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

📄 nulledge.java

📁 ALGAE是一个快速创建算法演示的框架。目前支持的算法实现语言包括java和c
💻 JAVA
字号:
package edu.odu.cs.zeil.AlgAE.Client.DataViewer.DataGraph;import edu.odu.cs.zeil.AlgAE.Direction;import edu.odu.cs.zeil.AlgAE.Client.DataViewer.DataGraph.Edge;import edu.odu.cs.zeil.AlgAE.Client.DataViewer.DataGraph.Edgeable;import edu.odu.cs.zeil.AlgAE.Client.GraphicsInfo;import java.awt.Color;import java.awt.Point;import java.awt.FontMetrics;import java.awt.Graphics;  /** *  A NullEdge is an edge with a source but no destination. *  This may not make mush sense in classical graph theory, but in *  AlgAE a NullEdge is used to represent null pointers. */public class NullEdge extends Edge{  NullEdge(Edgeable src, int direction, Color colour, String edgeLabel)  {    super (src, null, direction, colour, edgeLabel);  }    Point entryPoint()  {    return source.exitPoint(Direction.SW);  // For lack of anything better  }      void draw(GraphicsInfo gi)  {    Graphics g = gi.g;    g.setColor (color);    // Draw a small circle at the exit point.    Point sourcePt = exitPoint();    drawExitPoint (gi, sourcePt);    if (label != null && label.length() != 0)      {	FontMetrics fm = gi.g.getFontMetrics();	int labelwidth = fm.stringWidth(label);	int labelheight = fm.getAscent();	switch (dir) {	case Direction.NW:	  g.drawString (label,			sourcePt.x - (1 + gi.getTextOffset().width)/2 - labelwidth,			sourcePt.y);	  break;	case Direction.NNW:	case Direction.N:	case Direction.NNE:	  g.drawString (label,			sourcePt.x - labelwidth / 2,			sourcePt.y - (gi.getTextOffset().height+1)/2);	  break;	  	case Direction.NE:	  g.drawString (label,			sourcePt.x + (1 + gi.getTextOffset().width)/2,			sourcePt.y - (gi.getTextOffset().height+1)/2);	  break;	  	case Direction.ENE:	case Direction.E:	case Direction.ESE:	  g.drawString (label,			sourcePt.x + (1 + gi.getTextOffset().width)/2,			sourcePt.y);	  break;	  	case Direction.SE:	  g.drawString (label,			sourcePt.x + (1 + gi.getTextOffset().width)/2,			sourcePt.y + labelheight);	  break;	  	case Direction.SSE:	case Direction.S:	case Direction.SSW:	  g.drawString (label,			sourcePt.x - labelwidth / 2,			sourcePt.y + labelheight			  + (1 + gi.getTextOffset().height)/2);	  break;	  	case Direction.SW:	  g.drawString (label,			sourcePt.x - labelwidth - (1 + gi.getTextOffset().width)/2,			sourcePt.y + labelheight			  + (1 + gi.getTextOffset().height)/2);	  break;	  	case Direction.WSW:	case Direction.W:	case Direction.WNW:	  g.drawString (label,			sourcePt.x - labelwidth,			sourcePt.y);	  break;	  	  	}      }  }  double length()  {    return 0.0;  }    double positionScore(double targetLength)  {    return 0.0;  }}

⌨️ 快捷键说明

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