{"id":10413,"date":"2015-08-28T07:07:10","date_gmt":"2015-08-28T11:07:10","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/?p=10413"},"modified":"2015-08-24T10:02:51","modified_gmt":"2015-08-24T14:02:51","slug":"linestyles-java-provides-examples-of-the-available-styles-for-joining-line-segments","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=10413","title":{"rendered":"LineStyles.java Provides examples of the available styles for joining line segments"},"content":{"rendered":"<pre>import javax.swing.*;\r\nimport java.awt.*;\r\nimport java.awt.geom.*;\r\n\r\n\/** A demonstration of different controls when joining two line\r\n\u00a0*\u00a0 segments. The style of the line end point is controlled\r\n\u00a0*\u00a0 through the capStyle parameter.\r\n\u00a0*\r\n\u00a0************************************\r\n\r\npublic class LineStyles extends JPanel {\r\n\u00a0 private GeneralPath path;\r\n\u00a0 private static int x = 30, deltaX = 150, y = 300,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 deltaY = 250, thickness = 40;\r\n\u00a0 private Circle p1Large, p1Small, p2Large, p2Small,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 p3Large, p3Small;\r\n\u00a0 private int compositeType = AlphaComposite.SRC_OVER;\r\n\u00a0 private AlphaComposite transparentComposite =\r\n\u00a0\u00a0\u00a0 AlphaComposite.getInstance(compositeType, 0.4F);\r\n\u00a0 private int[] caps =\r\n\u00a0\u00a0\u00a0 { BasicStroke.CAP_SQUARE, BasicStroke.CAP_BUTT,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 BasicStroke.CAP_ROUND };\r\n\u00a0 private String[] capNames =\r\n\u00a0\u00a0\u00a0 { \"CAP_SQUARE\", \"CAP_BUTT\", \"CAP_ROUND\" };\r\n\u00a0 private int[] joins =\r\n\u00a0\u00a0\u00a0 { BasicStroke.JOIN_MITER, BasicStroke.JOIN_BEVEL,\r\n\u00a0\u00a0\u00a0\u00a0\u00a0 BasicStroke.JOIN_ROUND };\r\n\u00a0 private String[] joinNames =\r\n\u00a0\u00a0\u00a0 { \"JOIN_MITER\", \"JOIN_BEVEL\", \"JOIN_ROUND\" };\r\n\r\n\u00a0 public LineStyles() {\r\n\u00a0\u00a0\u00a0 path = new GeneralPath();\r\n\u00a0\u00a0\u00a0 path.moveTo(x, y);\r\n\u00a0\u00a0\u00a0 p1Large = new Circle(x, y, thickness\/2);\r\n\u00a0\u00a0\u00a0 p1Small = new Circle(x, y, 2);\r\n\u00a0\u00a0\u00a0 path.lineTo(x + deltaX, y - deltaY);\r\n\u00a0\u00a0\u00a0 p2Large = new Circle(x + deltaX, y - deltaY, thickness\/2);\r\n\u00a0\u00a0\u00a0 p2Small = new Circle(x + deltaX, y - deltaY, 2);\r\n\u00a0\u00a0\u00a0 path.lineTo(x + 2*deltaX, y);\r\n\u00a0\u00a0\u00a0 p3Large = new Circle(x + 2*deltaX, y, thickness\/2);\r\n\u00a0\u00a0\u00a0 p3Small = new Circle(x + 2*deltaX, y, 2);\r\n\u00a0\u00a0\u00a0 setFont(new Font(\"SansSerif\", Font.BOLD, 20));\r\n\u00a0 }\r\n\r\n\u00a0 public void paintComponent(Graphics g) {\r\n\u00a0\u00a0\u00a0 super.paintComponent(g);\r\n\u00a0\u00a0\u00a0 Graphics2D g2d = (Graphics2D)g;\r\n\u00a0\u00a0\u00a0 g2d.setColor(Color.lightGray);\r\n\u00a0\u00a0\u00a0 for(int i=0; i<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>import javax.swing.*; import java.awt.*; import java.awt.geom.*; \/** A demonstration of different controls when joining two line \u00a0*\u00a0 segments. The style of the line end point is controlled \u00a0*\u00a0 through the capStyle parameter. \u00a0* \u00a0************************************ public class LineStyles extends JPanel { \u00a0 private GeneralPath path; \u00a0 private static int x = 30, deltaX = 150, y &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=10413\">Continue reading<\/a><\/p>\n","protected":false},"author":130,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1417,1424],"tags":[706,308,285],"class_list":["post-10413","post","type-post","status-publish","format-standard","hentry","category-code-programming-samples--","category-javaj2eej2me","tag-code","tag-java","tag-285","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":26890,"url":"http:\/\/bangla.sitestree.com\/?p=26890","url_meta":{"origin":10413,"position":0},"title":"LineStyles.java Provides examples of the available styles for joining line segments #Programming Code Examples #Java\/J2EE\/J2ME #Drawing","author":"Author-Check- Article-or-Video","date":"May 4, 2021","format":false,"excerpt":"import javax.swing.*; import java.awt.*; import java.awt.geom.*; \/** A demonstration of different controls when joining two line * segments. The style of the line end point is controlled * through the capStyle parameter. * ************************************ public class LineStyles extends JPanel { private GeneralPath path; private static int x = 30, deltaX\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":10395,"url":"http:\/\/bangla.sitestree.com\/?p=10395","url_meta":{"origin":10413,"position":1},"title":"An applet that permits freehand drawing","author":"","date":"August 28, 2015","format":false,"excerpt":"import java.applet.Applet; import java.awt.*; import java.awt.event.*; \/** An applet that lets you perform freehand drawing. \u00a0* \u00a0 \u00a0**************** public class SimpleWhiteboard extends Applet { \u00a0 protected int lastX=0, lastY=0; \u00a0 public void init() { \u00a0\u00a0\u00a0 setBackground(Color.white); \u00a0\u00a0\u00a0 setForeground(Color.blue); \u00a0\u00a0\u00a0 addMouseListener(new PositionRecorder()); \u00a0\u00a0\u00a0 addMouseMotionListener(new LineDrawer()); \u00a0 } \u00a0 protected void record(int\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":26777,"url":"http:\/\/bangla.sitestree.com\/?p=26777","url_meta":{"origin":10413,"position":2},"title":"An applet that permits freehand drawing #Programming Code Examples #Java\/J2EE\/J2ME #Mouse and Keyboard Events","author":"Author-Check- Article-or-Video","date":"May 1, 2021","format":false,"excerpt":"import java.applet.Applet; import java.awt.*; import java.awt.event.*; \/** An applet that lets you perform freehand drawing. * **************** public class SimpleWhiteboard extends Applet { protected int lastX=0, lastY=0; public void init() { setBackground(Color.white); setForeground(Color.blue); addMouseListener(new PositionRecorder()); addMouseMotionListener(new LineDrawer()); } protected void record(int x, int y) { lastX = x; lastY =\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":27192,"url":"http:\/\/bangla.sitestree.com\/?p=27192","url_meta":{"origin":10413,"position":3},"title":"JTable Examples #Programming Code Examples #Java\/J2EE\/J2ME #Advanced Swing","author":"Author-Check- Article-or-Video","date":"May 13, 2021","format":false,"excerpt":"# JTableSimpleExample.java Simple table that takes column names and data from arrays of Strings. import java.awt.*; import javax.swing.*; \/** Simple JTable example that uses a String array for the * table header and table data. * *\/ public class JTableSimpleExample extends JFrame { public static void main(String[] args) { new\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":65938,"url":"http:\/\/bangla.sitestree.com\/?p=65938","url_meta":{"origin":10413,"position":4},"title":"EJB 3: Entity Bean Basic #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 18, 2021","format":false,"excerpt":"Plain Java objects with persistence storage. They are not remotable and must be accessed through the new javax.persistence.EntityManager service. An entity bean implementation is provided in the following three files\/classesBeansOrder.javaLineItem.javaEntity ManagerShoppingCartBean.java\/\/Order.javaimport javax.persistence.CascadeType;import javax.persistence.Entity;import javax.persistence.FetchType;import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;import javax.persistence.Id;import javax.persistence.OneToMany;import javax.persistence.Table;import javax.persistence.Id;import javax.persistence.CascadeType;import javax.persistence.FetchType;import java.util.ArrayList;import java.util.Collection;@Entity@Table(name = \"PURCHASE_ORDER\")public class Order implements\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":10279,"url":"http:\/\/bangla.sitestree.com\/?p=10279","url_meta":{"origin":10413,"position":5},"title":"BetterCircleTest.java","author":"","date":"August 26, 2015","format":false,"excerpt":"********************** BetterCircleTest.java ********************** import java.awt.*; import java.applet.Applet; \/** Position circles down the diagonal so that their borders \u00a0*\u00a0 just touch. Illustrates that Java 1.1 lightweight \u00a0*\u00a0 components can be partially transparent. \u00a0* \u00a0 *\/ public class BetterCircleTest extends Applet { \u00a0 public void init() { \u00a0\u00a0\u00a0 setBackground(Color.lightGray); \u00a0\u00a0\u00a0 setLayout(null); \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":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10413","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\/130"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10413"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10413\/revisions"}],"predecessor-version":[{"id":10414,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/10413\/revisions\/10414"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10413"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10413"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10413"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}