今日SESノードのファイルを考える突然JDXF Javaパッケージを見つけましたが、2018年5月に初版が出版された、私は次の読み取りを感じ、どのようにJavaグラフィックスの輸出CADファイルへの質問です。:次のアドレスのオリジナルhttps://jsevy.com/wordpress/
著者は非常に興味深い老人があるウェブサイトの多様からの記事は、あらゆる種類のものは、非常に興味深い得ます。
身近に、JavaのJDXFは、JavaのAWTグラフィカルのJava Development Kitを使用してDXFファイルを生成するためのサポートを提供することであるのGraphics2Dの特殊なサブクラスを提供し、DXFGraphicsは、そのDXFファイルに関連付けられ、描画コマンドに提示(実際には、テキスト形式です) DXFの構文。したがって、DXFGraphicsインスタンスで呼び出されるメソッドをレンダリングするの標準的なJavaグラフィックスのシリーズは、構造化DXFファイルを作成します。
Javaの開発キットは、MITライセンスの下でライセンスが発行されます。
基本的なプロセス:
DXFGraphicsのクラスは、標準のJavaのGraphics2Dクラス定義のグラフィックス処理を実装しています。(図面、変換などを含む)の呼び出しをレンダリングDXFGraphicsグラフィック上で、標準のJavaインスタンスを使用するには、まず必要DXFグラフィックスファイルを作成します。これらのJava DXFGraphicsは、DXFは、オブジェクトDXFDocumentに関連付けられた描画コマンドとしてコード化され、そしてそれはDXFファイルにテキスト文字列として取得し、保存することができます。
DXFGraphics DXFDocumentでは、関連付けられています。次のように基本的なワークフローは次のとおりです。
/* Create a DXF document and get its associated DXFGraphics instance */
DXFDocument dxfDocument = new
DXFDocument("Example");
DXFGraphics dxfGraphics =
dxfDocument.getGraphics();
/* Do drawing commands as on any other Graphics. If you have a paint(Graphics) method, you can just use it with the DXFGraphics instance since it's a subclass of Graphics. */
paint(dxfGraphics);
/* Get the DXF output as a string - it's just text - and save in a file for use with a CAD package */
String stringOutput = dxfDocument.toDXFString();
String filePath = “path/to/file.dxf”;
FileWriter fileWriter = new FileWriter(filePath);
fileWriter.write(dxfText);
fileWriter.flush();
fileWriter.close();
/* For drawing, just use standard Java
drawing operations */
public void paint(Graphics graphics)
{
// set pen characteristics
graphics.setColor(Color.RED);
graphics.setStroke(new BasicStroke(3));
// draw stuff - line, rectangles, ovals, ...
graphics.drawLine(0, 0, 1000, 500);
graphics.drawRect(1000, 500, 150, 150);
graphics.drawRoundRect(20, 200, 130, 100, 20,
10);
graphics.drawOval(200, 800, 200, 400);
graphics.drawArc(100, 1900, 400, 200, 60, 150);
// can draw filled shapes, which get
// implemented as DXF hatches
graphics.setColor(Color.BLUE);
graphics.fillRect(100, 100, 100, 50);
int[] xPoints = {200, 300, 250};
int[] yPoints = {200, 250, 300};
graphics.fillPolygon(xPoints, yPoints,
xPoints.length);
// text too
graphics.setFont(new Font(Font.MONOSPACED,
Font.PLAIN, 38));
graphics.drawString("Some 38-point monospaced
blue text at position 480, 400", 480, 400);
// and even transformations
graphics.shear(0.1f, 0.2f);
graphics.drawRect(100, 100, 200, 200);
}
プロパティ
JDXFパッケージには、描画操作と利用可能な標準的なJavaクラスのGraphics2Dグラフィックスのほとんどを提供します。しかし、(同様の操作が不足しているDXFいくつかのために)を達成するいかなる特定の方法がありません。下記に示すように、これらの未実現は、にUnsupportedOperationExceptionでの使用を無視し、またはスローされます。以下に示すように、いくつかの追加機能は、現在、または限定的にサポートされません。
ヒント:
JDXFライブラリは、DXF標準的なパラメータを追加して重要ではないが、AutoCADでファイルを開くために、これらの要素が必要とされています。