资源简介
基于java开发的一个关于voronoi图和delaunay triangulation(三角网)的实现,并可以在gui页面显示具体的效果
代码片段和文件信息
/*
* Copyright (c) 2005 by L. Paul Chew.
*
* Permission is hereby granted without written agreement and without
* license or royalty fees to use copy modify and distribute this
* software and its documentation for any purpose subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND EXPRESS
* OR IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER
* LIABILITY WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING
* FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import javax.swing.*;
import java.util.Set;
/**
* The Delauany applet.
* Creates and displays a Delaunay Triangulation (DT) or a Voronoi Diagram (VoD).
* Has a main program so it is an application as well as an applet.
*
* @author Paul Chew
*
* Created July 2005. Derived from an earlier messier version.
*/
public class DelaunayAp extends javax.swing.Japplet implements Runnable {
/**
* Initialize the applet.
* As recommended the actual use of Swing components takes place in the
* event-dispatching thread.
*/
public void init () {
try {SwingUtilities.invokeAndWait(this);}
catch (Exception e) {System.err.println(“Initialization failure“);}
}
/**
* Set up the applet‘s GUI.
* As recommended the init method executes this in the event-dispatching
* thread.
*/
public void run () {
setLayout(new BorderLayout());
// Build the button controls
JRadioButton voronoiButton = new JRadioButton(“Voronoi Diagram“);
voronoiButton.setActionCommand(“voronoi“);
JRadioButton delaunayButton = new JRadioButton(“Delaunay Triangulation“);
delaunayButton.setActionCommand(“delaunay“);
JButton clearButton = new JButton(“Clear“);
clearButton.setActionCommand(“clear“);
ButtonGroup group = new ButtonGroup();
group.add(voronoiButton);
group.add(delaunayButton);
JPanel buttonPanel = new JPanel();
buttonPanel.add(voronoiButton);
buttonPanel.add(delaunayButton);
buttonPanel.add(clearButton);
this.add(buttonPanel “North“);
// Build the mouse-entry switches
JLabel circleLabel = new JLabel(“Show Empty Circles“);
circleLabel.setName(“circles“);
JLabel delaunayLabel = new JLabel(“Show Delaunay Edges“);
delaunayLabel.setName(“delaunay“);
JLabel voronoiLabel = new JLabel(“S
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2011-01-14 14:51 voronoi\
文件 386 2011-01-17 11:57 voronoi\.classpath
文件 383 2011-01-14 14:51 voronoi\.project
目录 0 2011-01-14 14:51 voronoi\.settings\
文件 629 2011-01-14 14:51 voronoi\.settings\org.eclipse.jdt.core.prefs
目录 0 2011-01-14 14:51 voronoi\bin\
文件 3130 2011-01-17 16:12 voronoi\bin\DelaunayAp.class
文件 6709 2011-01-17 16:12 voronoi\bin\DelaunayPanel.class
文件 4356 2011-01-17 16:04 voronoi\bin\DelaunayTriangulation.class
文件 673 2011-01-17 11:57 voronoi\bin\log4j.properties
文件 8772 2011-01-17 16:12 voronoi\bin\Pnt.class
文件 4182 2011-01-17 16:04 voronoi\bin\Simplex.class
文件 5002 2011-01-17 16:04 voronoi\bin\Triangulation.class
目录 0 2011-01-14 14:51 voronoi\src\
文件 12644 2011-01-17 16:12 voronoi\src\DelaunayAp.java
文件 6080 2011-01-17 15:56 voronoi\src\DelaunayTriangulation.java
文件 673 2011-01-17 11:57 voronoi\src\log4j.properties
文件 17820 2011-01-17 16:12 voronoi\src\Pnt.java
文件 5367 2011-01-14 14:51 voronoi\src\Simplex.java
文件 6146 2011-01-17 15:57 voronoi\src\Triangulation.java
- 上一篇:java写的雷电(代码+论文+幻灯片+效果图)
- 下一篇:足球游戏Java
评论
共有 条评论