Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
jvx:reference [2018/05/08 07:56] admin |
jvx:reference [2020/06/10 11:15] cduncan [The basics] |
||
---|---|---|---|
Line 2: | Line 2: | ||
~~Title: JVx Concepts and Reference~~ | ~~Title: JVx Concepts and Reference~~ | ||
- | Version: 1.0 / 2018-04-17 | + | Version: 1.0 / 2019-07-01 |
====== Introduction ====== | ====== Introduction ====== | ||
- | This collection of various tutorials is aimed to provide you with a broad overview over the concepts and mechanics of the [[https://sourceforge.net/projects/jvx/|JVx]] application framework. | + | This collection of various tutorials is aimed at providing you with a broad overview over the concepts and mechanics of the [[https://sourceforge.net/projects/jvx/|JVx]] application framework. |
====== Of Technologies and Factories ====== | ====== Of Technologies and Factories ====== | ||
- | Let’s talk about the UI layer, the implementations and the factory that powers it all. | + | Let’s talk about the UI layer, the implementations, and the factory that powers it all. |
- | ===== The basics ===== | + | ===== The Basics ===== |
- | For everyone who does not know, [[https://sourceforge.net/projects/jvx/|JVx]] allows you to write code once and run it on different GUI frameworks, without changing your code. This is achieved by hiding the concrete GUI implementations behind our own classes, the UI classes, and providing “bindings” for different GUI frameworks behind the scenes. Such a “[[https://en.wikipedia.org/wiki/Single_source_publishing|single sourcing]]” approach has many advantages, and just one of them is that migrating to a new GUI framework requires only the change of a single line, the one which controls which factory is used. | + | For everyone who does not know, [[https://sourceforge.net/projects/jvx/|JVx]] allows you to write code once and run it on different GUI frameworks without changing your code. This is achieved by hiding the concrete GUI implementations behind our own classes, the UI classes, and providing “bindings” for different GUI frameworks behind the scenes. Such a “[[https://en.wikipedia.org/wiki/Single-source_publishing|single sourcing]]” approach has many advantages, and just one of them is that migrating to a new GUI framework requires only the change of a single line, the one which controls which factory is used. |
===== The patterns ===== | ===== The patterns ===== | ||
- | [[https://en.wikipedia.org/wiki/Factory_%28object_oriented_programming%29|The factory pattern]] is an important pattern in [[https://en.wikipedia.org/wiki/Object_oriented_programming|Object-oriented programming]], it empowers us to delegate the creation of objects to another object which must not be known at design and/or compile time. That allows us to use objects which have not been created by us but merely “provided” to us by an, for us unknown, source. | + | [[https://en.wikipedia.org/wiki/Factory_%28object-oriented_programming%29|The factory pattern]] is an important pattern in [[https://en.wikipedia.org/wiki/Object-oriented_programming|Object-oriented programming]], it empowers us to delegate the creation of objects to another object which must not be known at design and/or compile time. That allows us to use objects which have not been created by us but merely “provided” to us by an, for us unknown, source. |
[[https://en.wikipedia.org/wiki/Bridge_pattern|The bridge pattern]] on the other hand describes a technique which wraps implementations in another implementation and forwards all/most functionality to that wrapped implementation. This allows us to mix and match functionality without the need to have it in all implementations at once. | [[https://en.wikipedia.org/wiki/Bridge_pattern|The bridge pattern]] on the other hand describes a technique which wraps implementations in another implementation and forwards all/most functionality to that wrapped implementation. This allows us to mix and match functionality without the need to have it in all implementations at once. | ||
Line 716: | Line 716: | ||
* Binary Data | * Binary Data | ||
- | Text and Binary Data are both objects (arrays of primitives are Objects after all) and Numbers are either primitives or Objects. Most of the time if we deal with numbers inside a database we want them to be of arbitrary precision, which means we must represent them as ''%%BigDecimal%%''. Supporting ''%%double%%'' or ''%%float%%'' in these cases would be dangerously, because one might write a ''%%float%%'' into the database [[https://en.wikipedia.org/wiki/Floating_point_arithmetic|which might or might not end up with the correct value]] in the database. To completely eliminate such problems, we do only support Objects, which means that one is “limited” to the usage of Number extensions like ''%%BigLong%%'' and ''%%BigDecimal%%'', which do not suffer from such problems. | + | Text and Binary Data are both objects (arrays of primitives are Objects after all) and Numbers are either primitives or Objects. Most of the time if we deal with numbers inside a database we want them to be of arbitrary precision, which means we must represent them as ''%%BigDecimal%%''. Supporting ''%%double%%'' or ''%%float%%'' in these cases would be dangerously, because one might write a ''%%float%%'' into the database [[https://en.wikipedia.org/wiki/Floating-point_arithmetic|which might or might not end up with the correct value]] in the database. To completely eliminate such problems, we do only support Objects, which means that one is “limited” to the usage of Number extensions like ''%%BigLong%%'' and ''%%BigDecimal%%'', which do not suffer from such problems. |
==== Where are the DataPages? ==== | ==== Where are the DataPages? ==== | ||
Line 800: | Line 800: | ||
But first, we will start without anything. The most simple application you can create with [[https://sourceforge.net/projects/jvx/|JVx]] is an application which does open a single window and only works with in memory data (if at all). This can be easily achieved by “just starting” the application. | But first, we will start without anything. The most simple application you can create with [[https://sourceforge.net/projects/jvx/|JVx]] is an application which does open a single window and only works with in memory data (if at all). This can be easily achieved by “just starting” the application. | ||
- | [[https://blog.sibvisions.com/2016/12/07/jvx_reference_of_technologies_and_factories/|The JVx GUI is a simple layer on top of the Technology]] which implements the actual functionality. So if we want to have a GUI we’ll need to initialize the factory before doing anything else: | + | [[https://blog.sibvisions.com/2016/12/07/jvx-reference-of-technologies-and-factories/|The JVx GUI is a simple layer on top of the Technology]] which implements the actual functionality. So if we want to have a GUI we’ll need to initialize the factory before doing anything else: |
<code java> | <code java> | ||
Line 982: | Line 982: | ||
===== Interactive Demo ===== | ===== Interactive Demo ===== | ||
- | [[https://blog.sibvisions.com/wp_content/uploads/2017/04/lifecycle_objects_demo.html|There is an interactive demo on our blog]] which allows you to explore the connections between the client and server side. The complement classes are always highlighted and you can click on the names of the objects to receive additional information about them. | + | [[https://blog.sibvisions.com/wp-content/uploads/2017/04/lifecycle-objects-demo.html|There is an interactive demo on our blog]] which allows you to explore the connections between the client and server side. The complement classes are always highlighted and you can click on the names of the objects to receive additional information about them. |
===== The JVx application: Manual example ===== | ===== The JVx application: Manual example ===== | ||
Line 1632: | Line 1632: | ||
===== Interactive demo ===== | ===== Interactive demo ===== | ||
- | Sometimes, however, it might not be obvious what anchors are created and how they are used. For this we have created a simple interactive demonstration application which allows to inspect the created anchors of a layout, the [[https://github.com/sibvisions/jvx.formlayout_visualization|JVx FormLayout Visualization]]. | + | Sometimes, however, it might not be obvious what anchors are created and how they are used. For this we have created a simple interactive demonstration application which allows to inspect the created anchors of a layout, the [[https://github.com/sibvisions/jvx.formlayout-visualization|JVx FormLayout Visualization]]. |
{{:jvx:reference:formlayout-visualization.png?nolink|FormLayout Visualization Demo}} | {{:jvx:reference:formlayout-visualization.png?nolink|FormLayout Visualization Demo}} | ||
- | On the left is the possibility to show and hide anchors together with the information about the currently highlighted anchor. On the right is a Lua scripting area which allows you to quickly and easily rebuild and test layouts. It utilizes the [[https://blog.sibvisions.com/2017/09/25/jvx_lua_proof_of_concept/|JVx-Lua bridge from a previous blog post]] and so any changes to the code are directly applied. | + | On the left is the possibility to show and hide anchors together with the information about the currently highlighted anchor. On the right is a Lua scripting area which allows you to quickly and easily rebuild and test layouts. It utilizes the [[https://blog.sibvisions.com/2017/09/25/jvx-lua-proof-of-concept/|JVx-Lua bridge from a previous blog post]] and so any changes to the code are directly applied. |
===== The most simple usage: Flow-like ===== | ===== The most simple usage: Flow-like ===== | ||
Line 1758: | Line 1758: | ||
===== What are events… ===== | ===== What are events… ===== | ||
- | Events are an [[https://en.wikipedia.org/wiki/Event_driven_programming|important mechanism no matter to what programming language or framework you turn to]]. It allows us to react on certain actions and “defer” actions until something triggered them. Such triggers can be anything, like a certain condition is hit in another thread, the user clicked a button or another action has finally finished. Long story short, you get notified that something happened, and that you can now do something. | + | Events are an [[https://en.wikipedia.org/wiki/Event-driven_programming|important mechanism no matter to what programming language or framework you turn to]]. It allows us to react on certain actions and “defer” actions until something triggered them. Such triggers can be anything, like a certain condition is hit in another thread, the user clicked a button or another action has finally finished. Long story short, you get notified that something happened, and that you can now do something. |
===== …and why do I need to handle them? ===== | ===== …and why do I need to handle them? ===== | ||
Line 1977: | Line 1977: | ||
Now every time the event is dispatched, the ''%%somethingOtherHappened%%'' method will be invoked. Anyway, don’t use this. The upside of having a “simple” listener interface with just one method is that it allows to use lambdas with it. A listener interface with multiple methods won’t allow this. | Now every time the event is dispatched, the ''%%somethingOtherHappened%%'' method will be invoked. Anyway, don’t use this. The upside of having a “simple” listener interface with just one method is that it allows to use lambdas with it. A listener interface with multiple methods won’t allow this. | ||
- | In [[https://sourceforge.net/projects/jvx/|JVx]] [[http://blog.sibvisions.com/2015/01/28/jvx_and_java_8_events_and_lambdas/|we reduced our listener interfaces to just one method (in a backward compatible way)]] to make sure all events can be used with lambdas. | + | In [[https://sourceforge.net/projects/jvx/|JVx]] [[http://blog.sibvisions.com/2015/01/28/jvx-and-java-8-events-and-lambdas/|we reduced our listener interfaces to just one method (in a backward compatible way)]] to make sure all events can be used with lambdas. |
===== Fire away! ===== | ===== Fire away! ===== |