package VN2;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import javax.swing.JPanel;
public class DDTPanel extends JPanel
{
private final int m_r = 1400;//设置窗口的大小
public int getWidth()
{
return this.m_r;
}
public DDTPanel()
{
}
public void paintComponent(Graphics g)//在组件里面绘制
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
for(int i=0;i<m_r; i++)
{
for(int j=0;j<m_r;j++)
{
if(m_test.getJNode(i,j).isBorderJNode())
{
//g2.setPaint(Color.RED);
//画切割线
g2.setPaint(Color.GREEN);
//
g2.draw(new Line2D.Double((m_test.getJNode(i,j).getPoint().getY()),
(m_test.getJNode(i,j).getPoint().getX()),
(m_test.getJNode(i,j).getPoint().getY()),
(m_test.getJNode(i,j).getPoint().getX())));
//
continue;
}
else if(m_test.getJNode(i,j).isCenter())
{
g2.setPaint(Color.BLACK);
//画小圆点
Ellipse2D.Double circle=new Ellipse2D.Double((m_test.getJNode(i,j).getYValue()), (m_test.getJNode(i,j).getXValue()), 9, 9);
// g2.draw(new Ellipse2D.Double( (m_test.getJNode(i,j).getYValue()),
// (m_test.getJNode(i,j).getXValue()),
// 5, 5));//小圆圈的大小
g2.fill(circle);
continue;
}
else if(m_test.getJNode(i,j).isBorderE())
{
g2.setPaint(Color.RED);
g2.draw(new Line2D.Double((m_test.getJNode(i,j).getPoint().getY()),
(m_test.getJNode(i,j).getPoint().getX()),
(m_test.getJNode(i,j).getPoint().getY()),
(m_test.getJNode(i,j).getPoint().getX())));
}
else
{
if(m_test.getJNode(i,j).getDilationValue()%3 != 0)
{
continue;
}
}
}
}
}
private DilationContainer m_test;
public void Compu()
{
m_test = new DilationContainer(m_r);
m_test.generateSeed(100);//记得看函数作用,图形密集程度
m_test.dilationOper();//画切割线
m_test.ensureBoundaryNodes();//与画图无关
m_test.dispMaxSubtration();//与画图无关
}
}