NttCAD
EntityCAD
Version R_2012_08_15

Developers

Application Development

Development of NttCAD applications is possible using the java platform.

The NttCAD API can be used to develop customized commands (or macros).

See also Javadoc
and Sample Application.

Currently, the IDE used for NttCAD development is NetBeans.

Viewer

The free CAD viewer, included with the NttCAD API, is a panel for java applications and applets that displays a read-only view of drawings in the formats supported by NttCAD: dxf, svg and ntt.

With the viewer, it is possible to create plug-ins like the same used in the drawings page. The Java source file of the applet used to display the drawings is Viewer.java.

Viewer.java

An application could create an Applet class to download and display drawing files from a server. Sample code might look like this:

Viewer.java

package nttcad.viewer;

import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import nttcad.formats.DwgReader;
import nttcad.formats.DxfReader;
import nttcad.formats.ObjReader;
import nttcad.formats.SVGReader;
import nttcad.nttcad.gui.E_FileChooser;
import nttcad.nttcad.gui.E_Viewer;



public class Viewer
	extends JApplet {

@Override
public void init()
{
	try {
		String s = UIManager.getSystemLookAndFeelClassName();
		//String s = UIManager.getCrossPlatformLookAndFeelClassName();
		//String s = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
		UIManager.setLookAndFeel(s);
	}
	catch (Exception e) {
	}

	E_Viewer viewer = new E_Viewer();
	E_FileChooser fileChooser = viewer.getFileChooser();
	fileChooser.addFormat("svg", SVGReader.class);
	fileChooser.addFormat("dxf", DxfReader.class);
	fileChooser.addFormat("dwg", DwgReader.class);
	fileChooser.addFormat("obj", ObjReader.class);

	String name = getParameter("name");
	JPanel jPanel = viewer.createJPanel(this, false,
		Viewer.class,
		"/nttcad/viewer/folder/"+name);

	add(jPanel);

	validate();
	repaint();
}



public static void main(String[] args)
{
	JFrame jFrame = new JFrame();
	jFrame.add(new E_Viewer().createJPanel(
		jFrame, true, Viewer.class, "/nttcad/viewer/folder/dinasaur.ntt"));

	jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	jFrame.setSize(600, 400);
	jFrame.setLocationRelativeTo(null);
	jFrame.setVisible(true);
}



}


The JAR files that must be included in the classpath can be found in the free library nttcad.zip.

applet tag

The drawings must be retrieved from the JAR file specified in the applet tag. Storing drawings in JAR files is recommended, since they will be cached on the local machine by Java Plug-in.

Sample HTML code might look like this:



<script src="http://www.java.com/js/deployJava.js"></script>
<script>

	var attributes = {
		code: "nttcad.viewer.Viewer",
		archive: "dist/viewer/gnome-logo.jar",
		width: "100%",
		height: "100%"
	};
	var parameters = {
		name: "gnome-logo.svg"
	};
	deployJava.runApplet(attributes, parameters, null);

</script>
<noscript>

<applet
	code="nttcad.viewer.Viewer"
	archive="dist/viewer/gnome-logo.jar"
	width="100%"
	height="100%">

<param name="name" value="gnome-logo.svg"/>

<br/>
<br/>Is javascript disabled? Enable javascript on your browser or go to
<a href="http://www.java.com" target="_blank">java.com</a>.

</applet>

</noscript>