{"id":26892,"date":"2021-05-04T23:10:05","date_gmt":"2021-05-05T03:10:05","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/rotationexample-java-an-example-of-translating-and-rotating-the-coordinate-system-prior-to-drawing-programming-code-examples-java-j2ee-j2me-drawing\/"},"modified":"2021-05-04T23:10:05","modified_gmt":"2021-05-05T03:10:05","slug":"rotationexample-java-an-example-of-translating-and-rotating-the-coordinate-system-prior-to-drawing-programming-code-examples-java-j2ee-j2me-drawing","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=26892","title":{"rendered":"RotationExample.java An example of translating and rotating the coordinate system prior to drawing #Programming Code Examples #Java\/J2EE\/J2ME #Drawing"},"content":{"rendered":"<pre>import java.awt.*;\n\n\/** An example of translating and rotating the coordinate\n *  system before each drawing.\n *\n *******************************\n\npublic class RotationExample extends StrokeThicknessExample {\n  private Color[] colors = { Color.white, Color.black };\n\n  public void paintComponent(Graphics g) {\n    clear(g);\n    Graphics2D g2d = (Graphics2D)g;\n    drawGradientCircle(g2d);\n    drawThickCircleOutline(g2d);\n    \/\/ Move the origin to the center of the circle.\n    g2d.translate(185.0, 185.0);\n    for (int i=0; i&lt;16; i++) {\n      \/\/ Rotate the coordinate system around current\n      \/\/ origin, which is at the center of the circle.\n      g2d.rotate(Math.PI\/8.0);\n      g2d.setPaint(colors[i%2]);\n      g2d.drawString(&quot;Java&quot;, 0, 0);\n    }\n  }\n\npublic static void main(String[] args) {\n    WindowUtilities.openInJFrame(new RotationExample(),\n                                 380, 400);\n  }\n}\n<\/pre>\n<p>Note: Brought from our old site: http:\/\/www.salearningschool.com\/example_codes\/ on Jan 2nd, 2017 From: http:\/\/sitestree.com\/?p=10380<br \/> Categories:Programming Code Examples, Java\/J2EE\/J2ME, Drawing<br \/>Tags:Java\/J2EE\/J2MEDrawing<br \/> Post Data:2017-01-02 16:04:39<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>import java.awt.*; \/** An example of translating and rotating the coordinate * system before each drawing. * ******************************* public class RotationExample extends StrokeThicknessExample { private Color[] colors = { Color.white, Color.black }; public void paintComponent(Graphics g) { clear(g); Graphics2D g2d = (Graphics2D)g; drawGradientCircle(g2d); drawThickCircleOutline(g2d); \/\/ Move the origin to the center of the circle. g2d.translate(185.0, &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=26892\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-26892","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":10415,"url":"http:\/\/bangla.sitestree.com\/?p=10415","url_meta":{"origin":26892,"position":0},"title":"RotationExample.java An example of translating and rotating the coordinate system prior to drawing","author":"","date":"August 28, 2015","format":false,"excerpt":"import java.awt.*; \/** An example of translating and rotating the coordinate \u00a0*\u00a0 system before each drawing. \u00a0* \u00a0******************************* public class RotationExample extends StrokeThicknessExample { \u00a0 private Color[] colors = { Color.white, Color.black }; \u00a0 public void paintComponent(Graphics g) { \u00a0\u00a0\u00a0 clear(g); \u00a0\u00a0\u00a0 Graphics2D g2d = (Graphics2D)g; \u00a0\u00a0\u00a0 drawGradientCircle(g2d); \u00a0\u00a0\u00a0 drawThickCircleOutline(g2d);\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10301,"url":"http:\/\/bangla.sitestree.com\/?p=10301","url_meta":{"origin":26892,"position":1},"title":"DashedStrokeExample.java Draws a circle with a dashed line segment (border). Inherits from FontExample.java.","author":"","date":"August 26, 2015","format":false,"excerpt":">>>>>>>>>>>>>>>>> import java.awt.*; \/** An example of creating a custom dashed line for drawing. \u00a0* \u00a0********************* public class DashedStrokeExample extends FontExample { \u00a0 public void paintComponent(Graphics g) { \u00a0\u00a0\u00a0 clear(g); \u00a0\u00a0\u00a0 Graphics2D g2d = (Graphics2D)g; \u00a0\u00a0\u00a0 drawGradientCircle(g2d); \u00a0\u00a0\u00a0 drawBigString(g2d); \u00a0\u00a0\u00a0 drawDashedCircleOutline(g2d); \u00a0 } \u00a0 protected void drawDashedCircleOutline(Graphics2D g2d) { \u00a0\u00a0\u00a0\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10411,"url":"http:\/\/bangla.sitestree.com\/?p=10411","url_meta":{"origin":26892,"position":2},"title":"Demonstrates setting the pen width (in pixels) using a BasicStroke prior to drawing. Inherits from FontExample.java.","author":"","date":"August 28, 2015","format":false,"excerpt":"StrokeThicknessExample.java >>>>>>>>>>>>>>>>>>>>>>>>>>> import java.awt.*; \/** An example of controlling the Stroke (pen) widths when \u00a0*\u00a0 drawing. \u00a0* \u00a0****************** \u00a0*\/ public class StrokeThicknessExample extends FontExample { \u00a0 public void paintComponent(Graphics g) { \u00a0\u00a0\u00a0 clear(g); \u00a0\u00a0\u00a0 Graphics2D g2d = (Graphics2D)g; \u00a0\u00a0\u00a0 drawGradientCircle(g2d); \u00a0\u00a0\u00a0 drawBigString(g2d); \u00a0\u00a0\u00a0 drawThickCircleOutline(g2d); \u00a0 } \u00a0 protected void drawThickCircleOutline(Graphics2D\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10408,"url":"http:\/\/bangla.sitestree.com\/?p=10408","url_meta":{"origin":26892,"position":3},"title":"Illustrates using a local font (Goudy Handtooled BT) to perform drawing in Java 2D","author":"","date":"August 28, 2015","format":false,"excerpt":"import java.awt.*; \/** An example of using local fonts to perform drawing in \u00a0*\u00a0 Java 2D. \u00a0* \u00a0********************** public class FontExample extends GradientPaintExample { \u00a0 public FontExample() { \u00a0\u00a0\u00a0 GraphicsEnvironment env = \u00a0\u00a0\u00a0\u00a0\u00a0 GraphicsEnvironment.getLocalGraphicsEnvironment(); \u00a0\u00a0\u00a0 env.getAvailableFontFamilyNames(); \u00a0\u00a0\u00a0 setFont(new Font(\"Goudy Handtooled BT\", Font.PLAIN, 100)); \u00a0 } \u00a0 protected void drawBigString(Graphics2D g2d)\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27243,"url":"http:\/\/bangla.sitestree.com\/?p=27243","url_meta":{"origin":26892,"position":4},"title":"DashedStrokeExample.java Draws a circle with a dashed line segment (border). Inherits from FontExample.java. #Programming Code Examples #Java\/J2EE\/J2ME #Advanced Swing","author":"Author-Check- Article-or-Video","date":"May 15, 2021","format":false,"excerpt":">>>>>>>>>>>>>>>>> import java.awt.*; \/** An example of creating a custom dashed line for drawing. * ********************* public class DashedStrokeExample extends FontExample { public void paintComponent(Graphics g) { clear(g); Graphics2D g2d = (Graphics2D)g; drawGradientCircle(g2d); drawBigString(g2d); drawDashedCircleOutline(g2d); } protected void drawDashedCircleOutline(Graphics2D g2d) { g2d.setPaint(Color.blue); \/\/ 30-pixel line, 10-pixel gap, 10-pixel line, 10-pixel\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26878,"url":"http:\/\/bangla.sitestree.com\/?p=26878","url_meta":{"origin":26892,"position":5},"title":"Draws a circle with a gradient fill #Programming Code Examples #Java\/J2EE\/J2ME #Drawing","author":"Author-Check- Article-or-Video","date":"May 4, 2021","format":false,"excerpt":"GradientPaintExample.java Draws a circle with a gradient fill. Inherits from ShapeExample.java. ************************************** import java.awt.*; \/** An example of applying a gradient fill to a circle. The * color definition starts with red at (0,0), gradually * changing to yellow at (175,175). * ********************************** public class GradientPaintExample extends ShapeExample { private\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26892","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=26892"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/26892\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=26892"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=26892"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=26892"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}