实用标准文档
文案大全
import java.util.*;
import java.awt.*;
public class MyEdge {
public static int count=0;
public int id;
private int begin;
private int end;
private int useCount;
public MyEdge(int begin,int end)
{
this.id=++count;
this.begin=begin;
this.end=end;
this.useCount=0;
}
public MyEdge(MyPoint begin,MyPoint end)
{
this.id=++count;
this.begin=begin.id;
this.end=end.id;
this.useCount=0;
}
public int getUseCount()
{
return this.useCount;
}
public void addUseCount()
{
this.useCount++;
}
/*
* 下面这两个方法是得到边的来个顶点
* 若集合中没有指定的对象则返回空值
*/
public MyPoint getBeginPoint(Map pointSet)
{
MyPoint temp=pointSet.get(this.begin);
return temp;
}
public MyPoint getEndPoint(Map pointSet)
{
MyPoint temp=pointSet.get(this.end);
return temp;
}
/*
* 下面是根据两个点的ID,在边集中找寻两点组成的边
* 返回的是边对象
* 若没找到,则返回空
*/
public static MyEdge getEdge(int begin,int end,Map edgeSet)
{
MyEdge temp=null;
for(int i=1;i<=edgeSet.size();i++)
{
temp=edgeSet.get(i);
if(temp.begin==begin&&temp.end==end)
break;
}
return temp;
}
/*
* 下面是根据两个点对象,在边集中找寻两点组成的边
* 返回的是边对象
* 若没找到,则返回空
*/
public static MyEdge getEdge(MyPoint begin,MyPoint end,Map edgeSet)
{
MyEdge temp=null;
for(int i=1;i<=edgeSet.size();i++)
{
temp=edgeSet.get(i);
if(temp.begin==begin.id&&temp.end==end.id)
break;
}
return temp;
}
public void draw(Graphics g,Map pointSet)
{
MyPoint begin=pointSet.get(this.begin);
MyPoint end=pointSet.get(this.end);
Color c=g.getColor();
g.setColor(Color.blue);
g.drawLine(begin.x, begin.y, end.x,end.y );
g.setColor(c);
}
/*
* 下面这个方法是用来判断点在当前直线的左边还是右边
* 当然当前直线是有方向的
* 若点在直线的右边,则返回false
* 否则返回true
*/
public boolean isOnLeft(MyPoint p,Map pointSet)
{
boolean flag=false;
MyPoint begin=pointSet.get(this.begin);
MyPoint end=pointSet.get(this.end);
int Line=(beg