• 大小: 17.04 KB
    文件类型: .rar
    金币: 1
    下载: 1 次
    发布日期: 2024-10-01
  • 语言: Java
  • 标签: voronoi  

资源简介

是用Java编写的一个voronoi图。采用膨胀的方法生成三角网,然后再生成Voronoi图。

资源截图

代码片段和文件信息

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;

/*
 * Created on 2005-9-26GOUXIRONG
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code style - Code Templates
 */

/**
 * @author Administrator
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code style - Code Templates
 */
public class DDTPanel extends JPanel 
{
public DDTPanel()
{
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;

for(int i=0;i {
for(int j=0;j {
if(m_test.getJNode(ij).isBorderJNode())
{
g2.setPaint(Color.BLACK);
g2.draw(new Line2D.Double( (m_test.getJNode(ij).getPoint().getY())
                            (m_test.getJNode(ij).getPoint().getX())
                            (m_test.getJNode(ij).getPoint().getY())
                            (m_test.getJNode(ij).getPoint().getX())));
continue;
}
else if(m_test.getJNode(ij).isCenter())
{
g2.setPaint(Color.BLACK);
g2.draw(new Ellipse2D.Double( (m_test.getJNode(ij).getYValue())
                            (m_test.getJNode(ij).getXValue())
                            5
                            5));
continue;
}
else if(m_test.getJNode(ij).isBorderE())
{
g2.setPaint(Color.RED);
g2.draw(new Line2D.Double( (m_test.getJNode(ij).getPoint().getY())
                            (m_test.getJNode(ij).getPoint().getX())
                            (m_test.getJNode(ij).getPoint().getY())
                            (m_test.getJNode(ij).getPoint().getX())));
}
else
{
    if(m_test.getJNode(ij).getDilationValue()%3 != 0)
        {
        continue;
        }
    else
    {
//         if(m_test.getJNode(ij).isHorizontal())
//         {
//             g2.setPaint(Color.BLACK);
// g2.draw(new Ellipse2D.Double(
//                             (m_test.getJNode(ij).getOYValue() - m_test.getJNode(ij).getHorzontalLen())
//                             (m_test.getJNode(ij).getOXValue() - m_test.getJNode(ij).getHorzontalLen())
//                             m_test.getJNode(ij).getHorzontalLen()*2
//                             m_test.getJNode(ij).getHorzontalLen()*2));
//         }
    }
    g2.setPaint(Color.BLACK);
g2.draw(new Line2D.Double( (m_test.getJNode(ij).getPoint().getY())
                            (m_test.getJNode(ij).getPoint().getX())
                            (m_test.getJNode(ij).getPoint().getY())
                            (m_test.getJNode(ij).getPoint().getX())));
}
}
}
}

public void Compu()
{
m_test = new DilationContainer(m_r);
m_test.genera

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件        232  2009-04-17 13:26  voronoi\.classpath

     文件        382  2009-04-17 13:26  voronoi\.project

     文件       2187  2009-04-23 10:41  voronoi\bin\DDTPanel.class

     文件       7203  2009-04-18 16:52  voronoi\bin\DilationContainer$JSeed.class

     文件       5878  2009-04-18 16:52  voronoi\bin\DilationContainer.class

     文件       1181  2009-04-17 13:42  voronoi\bin\GUIDDT.class

     文件       5562  2009-04-17 13:41  voronoi\bin\JNode.class

     文件       3264  2009-05-17 09:19  voronoi\src\DDTPanel.java

     文件      20315  2009-05-17 09:19  voronoi\src\DilationContainer.java

     文件       1027  2009-05-17 09:20  voronoi\src\GUIDDT.java

     文件       6434  2009-05-17 09:20  voronoi\src\JNode.java

     目录          0  2009-05-10 13:34  voronoi\bin

     目录          0  2009-05-10 13:34  voronoi\src

     目录          0  2009-05-10 13:34  voronoi

----------- ---------  ---------- -----  ----

                53665                    14


评论

共有 条评论