{"id":590,"date":"2016-12-13T13:44:21","date_gmt":"2016-12-13T18:44:21","guid":{"rendered":"http:\/\/jsevy.com\/wordpress\/?page_id=590"},"modified":"2017-09-02T15:14:45","modified_gmt":"2017-09-02T19:14:45","slug":"android-adxf-library","status":"publish","type":"page","link":"https:\/\/jsevy.com\/wordpress\/index.php\/java-and-android\/android-apps-and-libraries\/android-adxf-library\/","title":{"rendered":"Android ADXF Library"},"content":{"rendered":"<p><a href=\"http:\/\/jsevy.com\/wordpress\/wp-content\/uploads\/2016\/12\/ADXF_Screenshot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-664 size-full\" src=\"http:\/\/jsevy.com\/wordpress\/wp-content\/uploads\/2016\/12\/ADXF_Screenshot.png\" alt=\"adxf_screenshot\" width=\"1920\" height=\"1080\" srcset=\"https:\/\/jsevy.com\/wordpress\/wp-content\/uploads\/2016\/12\/ADXF_Screenshot.png 1920w, https:\/\/jsevy.com\/wordpress\/wp-content\/uploads\/2016\/12\/ADXF_Screenshot-300x169.png 300w, https:\/\/jsevy.com\/wordpress\/wp-content\/uploads\/2016\/12\/ADXF_Screenshot-768x432.png 768w, https:\/\/jsevy.com\/wordpress\/wp-content\/uploads\/2016\/12\/ADXF_Screenshot-1024x576.png 1024w\" sizes=\"auto, (max-width: 1920px) 100vw, 1920px\" \/><\/a><\/p>\n<p>The Android ADXF library provides support for generation of DXF files for use with CAD programs using standard Android &#8220;draw&#8221; commands. The library provides a special Canvas subclass, DXFCanvas, that is associated with a DXF document and that renders draw commands into DXF syntax. A sequence of Android Canvas drawing method calls will thus create a structured DXF document that, when opened with a standard CAD program, will display the Canvas image as a CAD design that can be modified within the CAD program.<\/p>\n<p>This library is released under the <a href=\"http:\/\/choosealicense.com\/licenses\/mit\/\">MIT License.<br \/>\n<\/a><\/p>\n<h2>Basic Workflow<\/h2>\n<p>The class DXFCanvas implements the graphics operations defined by the standard Android Canvas class. To create a DXF drawing, you use the standard Android Canvas drawing calls (including drawing, transformations, etc.) on an instance of DXFCanvas. The DXFCanvas will encode these Android drawing commands as DXF objects in an associated DXFDocument, which can then be saved as a DXF file.<\/p>\n<p>A DXFCanvas is associated with a DXFDocument. The basic workflow is:<\/p>\n<p>\/* Create a DXF document and get its associated DXFCanvas *\/<br \/>\nDXFDocument dxfDocument = new DXFDocument(&#8220;Example&#8221;);<br \/>\nDXFCanvas dxfCanvas = dxfDocument.getCanvas();<\/p>\n<p>\/* Do drawing commands as on any other Canvas *\/<br \/>\nPaint paint = new Paint();<br \/>\npaint.setColor(Color.RED);<br \/>\npaint.setTypeface(Typeface.SERIF);<br \/>\npaint.setTextSize(38);<br \/>\npaint.setStyle(Style.STROKE);<br \/>\ndxfCanvas.drawLine(0, 0,100, 100, paint);<br \/>\ndxfCanvas.drawRect(120, 180, 400, 400, paint);<br \/>\ndxfCanvas.drawText(&#8220;Some text&#8221;, 200, 600, paint);<br \/>\npaint.setStyle(Style.FILL);<br \/>\ndxfCanvas.skew(0.1f, 0.2f);<br \/>\ndxfCanvas.rotate(-35);<br \/>\ndxfCanvas.drawCircle(300, 300, 100, paint);<\/p>\n<p>\/* Write the DXF representation in the document to a file; DXF is just text, so the document generates a String as output *\/<br \/>\nString dxfText = dxfDocument.toDXFString();<br \/>\nString filePath = &#8220;path\/to\/file.dxf&#8221;;<br \/>\nFileWriter fileWriter = new FileWriter(filePath);<br \/>\nfileWriter.write(dxfText);<br \/>\nfileWriter.flush();<br \/>\nfileWriter.close();<\/p>\n<h2>Features<\/h2>\n<p>The ADXF library provides most of the drawing operations available in the standard Canvas class. However, certain methods are unimplemented at present (some due to lack of support in DXF). These unimplemented operations will be ignored or throw an UnsupportedOperationException if used, as indicated below. Some additional features currently have no or limited support, as indicated below.<\/p>\n<h3>Supported operations<\/h3>\n<ul>\n<li>Drawing operations, including\n<ul>\n<li>drawLine, drawLines<\/li>\n<li>drawArc<\/li>\n<li>drawCircle<\/li>\n<li>drawOval<\/li>\n<li>drawRect<\/li>\n<li>drawRoundRect<\/li>\n<li>drawPoints<\/li>\n<\/ul>\n<\/li>\n<li>Text operations\n<ul>\n<li>drawText<\/li>\n<li>drawPosText<\/li>\n<li>drawTextOnPath<\/li>\n<\/ul>\n<\/li>\n<li>Paint properties\n<ul>\n<li>Color<\/li>\n<li>Line width<\/li>\n<li>Font properties: serif\/sans-serif, size, bold, italic<\/li>\n<\/ul>\n<\/li>\n<li>Matrix transformation operations\n<ul>\n<li>scale<\/li>\n<li>skew<\/li>\n<li>translate<\/li>\n<li>rotate<\/li>\n<li>concat<\/li>\n<\/ul>\n<\/li>\n<li>State save and restore\n<ul>\n<li>Saves and restores the transformation state of the graphics canvas<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Extensions<\/h3>\n<p>The library provides methods for creating and drawing B-splines on the standard Java canvas, as well as generating DXF code for splines.<\/p>\n<h3>Not supported<\/h3>\n<ul>\n<li>Dotted lines &#8211; represented as solid lines<\/li>\n<li>Underlined and strikethrough text &#8211; text drawn without underline\/strikethrough<\/li>\n<li>Image drawing through drawBitmap &#8211; currently ignored<\/li>\n<li>Grid and 3D drawing through drawBitmapMesh and drawVertices &#8211; currently ignored<\/li>\n<li>Paint xfermodes &#8211; Ignored<\/li>\n<li>drawPaint, drawColor, drawRGB &#8211; currently ignored<\/li>\n<li>State-save flags and layer information are ignored &#8211; save(flags), saveLayer, and saveLayerAlpha all behave the same as plain save()<\/li>\n<li>quickReject() methods &#8211; always return false<\/li>\n<li>drawTextRun method &#8211; throws UnsupportedOperationException<\/li>\n<li>Clipping, including clipRect, clipRegion, clipPath, etc. &#8211; throws UnsupportedOperationException<\/li>\n<li>drawPath method &#8211; throws UnsupportedOperationException<\/li>\n<li>drawPicture method &#8211; throws UnsupportedOperationException<\/li>\n<li>drawPatch method &#8211; throws UnsupportedOperationException<\/li>\n<\/ul>\n<h2>Example DXF Files<\/h2>\n<p>Some example files generated with ADXF are at the links below. The Java source code used to generate these through the ADXF Library is available in the Example Code section.<\/p>\n<ul>\n<li><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/a_test_dxf_file_generation_graphics.dxf\">Example of basic graphics operations<\/a><\/li>\n<li><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/a_test_dxf_file_generation_text.dxf\">Example of basic text operations<\/a><\/li>\n<li><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/a_test_dxf_file_generation_transformations_graphics.dxf\">Example of matrix transformation operations on graphics<\/a><\/li>\n<li><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/a_test_dxf_file_generation_transformations_text.dxf\">Example of matrix transformation operators on text<\/a><\/li>\n<\/ul>\n<h2>Example Code<\/h2>\n<p>A test project is available that illustrates how to use the library and that can also be used to test its functionality.<\/p>\n<ul>\n<li>ADXFTest.java<\/li>\n<li>ADXFTestView.java<\/li>\n<\/ul>\n<p><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/adxf_tst_src_v1.0.tar.gz\">Download example source<\/a><\/p>\n<h2><\/h2>\n<h2>Documentation<\/h2>\n<ul>\n<li><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/doc\/index.html\">Browse Javadoc documentation<\/a><\/li>\n<li><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/adxf_doc.tar.gz\">Download documentation tarball<\/a><\/li>\n<\/ul>\n<h2><\/h2>\n<h2>Downloads<\/h2>\n<p>The downloads are supplied as gzipped tar archives; the library archive contains the compiled gnuapdf.jar file for inclusion in a project, while the source archive contains the Java source files that can be used to rebuild the .jar file or included as source files in a referencing project. The test app source contains source for a simple test app that uses the classes in the ADXF library.<\/p>\n<table style=\"width: 457px;\" border=\"1\">\n<tbody>\n<tr>\n<td style=\"width: 55px;\"><strong>Version<br \/>\n<\/strong><\/td>\n<td style=\"width: 128px;\"><strong>Library (.jar)<br \/>\n<\/strong><\/td>\n<td style=\"width: 131px;\"><strong>Source<br \/>\n<\/strong><\/td>\n<td style=\"width: 156px;\"><strong>Test App Source<\/strong><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 55px;\">\u00a01.0<\/td>\n<td style=\"width: 128px;\"><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/adxf_lib_v1.0.tar.gz\">adxf_lib_v1.0.tar.gz<\/a><\/td>\n<td style=\"width: 131px;\"><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/adxf_src_v1.0.tar.gz\">adxf_src_v1.0.tar.gz<\/a><\/td>\n<td style=\"width: 156px;\"><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/adxf_tst_src_v1.0.tar.gz\">adxf_tst_src_v1.0.tar.gz<\/a><\/td>\n<\/tr>\n<tr>\n<td style=\"width: 55px;\">1.1<\/td>\n<td style=\"width: 128px;\"><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/adxf_lib_v1.1.1.tar.gz\">adxf_lib_v1.1.1.tar.gz<\/a><\/td>\n<td style=\"width: 131px;\"><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/adxf_src_v1.1.1.tar.gz\">adxf_src_v1.1.1.tar.gz<\/a><\/td>\n<td style=\"width: 156px;\"><a href=\"http:\/\/jsevy.com\/android\/apps\/adxf\/adxf_tst_src_v1.1.tar.gz\">adxf_tst_src_v1.1.tar.gz<\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><\/h3>\n<h3>Revision History<\/h3>\n<table style=\"height: 49px; width: 480px;\" border=\"1\">\n<tbody>\n<tr style=\"height: 14px;\">\n<td style=\"height: 14px; width: 95px; text-align: center;\"><strong>Version<br \/>\n<\/strong><\/td>\n<td style=\"height: 14px; width: 132.317px; text-align: center;\"><strong>Date<\/strong><\/td>\n<td style=\"height: 14px; width: 441.683px;\"><strong>Changes<br \/>\n<\/strong><\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 95px; height: 24px; text-align: center;\">1.0<\/td>\n<td style=\"width: 132.317px; height: 24px; text-align: center;\">2016-12-13<\/td>\n<td style=\"width: 441.683px; height: 24px;\">Initial release<\/td>\n<\/tr>\n<tr style=\"height: 24px;\">\n<td style=\"width: 95px; height: 24px; text-align: center;\">1.1<\/td>\n<td style=\"width: 132.317px; height: 24px; text-align: center;\">2017-08-31<\/td>\n<td style=\"width: 441.683px; height: 24px;\">Add AutoCAD support<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h3>Notes<\/h3>\n<p>Version 1.1 adds DXF elements that are not strictly required by the standard, but are required in order to open the files in AutoCAD.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Android ADXF library provides support for generation of DXF files for use with CAD programs using standard Android &#8220;draw&#8221; commands. The library provides a special Canvas subclass, DXFCanvas, that is associated with a DXF document and that renders draw commands into DXF syntax. A sequence of Android Canvas drawing method calls will thus create &hellip; <a href=\"https:\/\/jsevy.com\/wordpress\/index.php\/java-and-android\/android-apps-and-libraries\/android-adxf-library\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Android ADXF Library<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"parent":116,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-590","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/jsevy.com\/wordpress\/index.php\/wp-json\/wp\/v2\/pages\/590","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jsevy.com\/wordpress\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/jsevy.com\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/jsevy.com\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jsevy.com\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=590"}],"version-history":[{"count":27,"href":"https:\/\/jsevy.com\/wordpress\/index.php\/wp-json\/wp\/v2\/pages\/590\/revisions"}],"predecessor-version":[{"id":979,"href":"https:\/\/jsevy.com\/wordpress\/index.php\/wp-json\/wp\/v2\/pages\/590\/revisions\/979"}],"up":[{"embeddable":true,"href":"https:\/\/jsevy.com\/wordpress\/index.php\/wp-json\/wp\/v2\/pages\/116"}],"wp:attachment":[{"href":"https:\/\/jsevy.com\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=590"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}