{"id":1255,"date":"2023-03-22T11:20:44","date_gmt":"2023-03-22T15:20:44","guid":{"rendered":"https:\/\/jausoft.com\/blog\/?p=1255"},"modified":"2023-03-22T11:23:54","modified_gmt":"2023-03-22T15:23:54","slug":"graphui-easy-to-use-for-your-desktop-embedded-systems","status":"publish","type":"post","link":"https:\/\/jausoft.com\/blog\/2023\/03\/22\/graphui-easy-to-use-for-your-desktop-embedded-systems\/","title":{"rendered":"GraphUI &#8211; Easy to Use for your Desktop &#038; Embedded Systems"},"content":{"rendered":"<p>Part of the <a href=\"https:\/\/jausoft.com\/blog\/tag\/graph_type_rendering\/\">Graph Type Rendering and UI<\/a> Saga. After a few reviews &amp; iterations cleaning up technical issues like bugs &amp; performance, I couldn&#8217;t stop w\/o simplifying the API itself. So here I will just describe the most simple <a href=\"https:\/\/jogamp.org\/cgit\/jogl.git\/tree\/src\/demos\/com\/jogamp\/opengl\/demos\/graph\/ui\/UISceneDemo00.java#n50\">UISeneDemo00<\/a> and will details others in upcoming blog entries including a rebuild API doc using Doxygen.<!--more--><\/p>\n<p>This demo and most of the other, is simply coded using the main function for simplicity. Only <a href=\"https:\/\/jausoft.com\/blog\/2023\/03\/22\/graphui-enhanced-scene-and-shape-interactions-mediabutton\/\">UISceneDemo20 as mentioned earlier<\/a> uses a GLEventListener and is still heavily coded due to layouting the Shapes on the screen. However, this will be overcome soon as well using a layout container.<\/p>\n<p>So we start creating a Font instance to be used for like Button and Label Shape&#8217;s and a Scene, which contains the Shapes and handles their representation (draw) as well as user interaction. For the latter, it transforms mouse screen coordinates to Shape coordinates and forwards such events while also handling drag-move and drag-resize.<\/p>\n<p>Below I <a href=\"https:\/\/jogamp.org\/cgit\/jogl.git\/tree\/src\/demos\/com\/jogamp\/opengl\/demos\/graph\/ui\/UISceneDemo00.java#n50\">extracted the bare minimum<\/a> to see something on the screen, i.e. a Button Shape.<\/p>\n<pre>final Font font = FontFactory.get(FontFactory.UBUNTU).get(FontSet.FAMILY_LIGHT, \r\n                                                          FontSet.STYLE_SERIF);\r\n\r\n\/\/ Assuming normalized Scene plane size, i.e. 1.0\r\nShape shape = new Button(renderModes, font, \"+\", 0.10f, 0.10f\/2.5f);\r\n\r\n\/\/ The scene shall act as the GLEventListener, hence ass glClear*() params.\r\nfinal Scene scene = new Scene();\r\nscene.setClearParams(new float[] { 1f, 1f, 1f, 1f}, GL.GL_COLOR_BUFFER_BIT | \r\n                                                    GL.GL_DEPTH_BUFFER_BIT);\r\nscene.addShape(shape);\r\n\r\n\/\/ The GLWindow ...\r\nfinal GLCapabilities caps = new GLCapabilities(glp);\r\ncaps.setAlphaBits(4);\r\nfinal GLWindow window = GLWindow.create(caps);\r\nwindow.setSize(surface_width, surface_height);\r\nwindow.setVisible(true);\r\nwindow.addGLEventListener(scene); \/\/ here the Scene becomes displayed.\r\n\r\nscene.attachInputListenerTo(window);\r\n\r\n\/\/ Just for automated repaint final Animator animator = new Animator(); \r\nanimator.add(window);\r\nanimator.start(); \/\/ Go! ;-)\r\n\r\n\/\/ Wait until first display of the Scene occurred, incl. init() and reshape()\r\n\/\/ This b\/c our little demo just runs from main() w\/o its own GLEventListener.\r\nscene.waitUntilDisplayed();<\/pre>\n<p>.. and that&#8217;s it already \ud83d\ude09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Part of the Graph Type Rendering and UI Saga. After a few reviews &amp; iterations cleaning up technical issues like bugs &amp; performance, I couldn&#8217;t stop w\/o simplifying the API itself. So here I will just describe the most simple UISeneDemo00 and will details others in upcoming blog entries including a rebuild API doc using&hellip; <a class=\"more-link\" href=\"https:\/\/jausoft.com\/blog\/2023\/03\/22\/graphui-easy-to-use-for-your-desktop-embedded-systems\/\">Continue reading <span class=\"screen-reader-text\">GraphUI &#8211; Easy to Use for your Desktop &#038; Embedded Systems<\/span> <span class=\"meta-nav\" aria-hidden=\"true\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[7,3,8],"tags":[9,13,71,16,44,31,17,68],"class_list":["post-1255","post","type-post","status-publish","format-standard","hentry","category-3d-opengl","category-computer-stuff","category-jogamp","tag-3d","tag-embedded-device","tag-graph_type_rendering","tag-java","tag-jogamp","tag-mobile","tag-opengl","tag-type-rendering"],"_links":{"self":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/1255","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/comments?post=1255"}],"version-history":[{"count":2,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/1255\/revisions"}],"predecessor-version":[{"id":1257,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/posts\/1255\/revisions\/1257"}],"wp:attachment":[{"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/media?parent=1255"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/categories?post=1255"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jausoft.com\/blog\/wp-json\/wp\/v2\/tags?post=1255"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}