I am trying to figure out a way to show a template based on its distance value.
I have a rectangle with a range of 0 to 200. This range is a variable read in from a tag.
I want to be able to show a template, for simplicity just a green square within that rectangle, at a certain spot within that rectangle.
For example say the overall rectangle distance is 200. There are three templates I want to show on this rectangle. Template 1 has a distance value of 50, template 2 has a distance value of 75, and template 3 has a distance value of 150. The left side of the rectangle would be 0 and the right side would 200.
In this instance I would see template 1 at 50, followed by template 2 at 75, and template 3 t 150. Using the distance associated with each template I want to position each template where it is centered at the associated distance within the rectangle.
Is there a way to use the template distance associated with it to dynamically place the template within the rectangle, which also has a variable overall distance?
Using vision, anything similar?
Some examples:
The overall length of the rectangle, the number of templates, and the template position for each template are all variables.
I also have to show the same thing for negative template positions, only the left hand side of the rectangle is say -200, and the right side of the rectangle would be 0
maybe use something like a template canvas? Played around with it a little bit. Can't figure out how to set the distance between the template instances but seems like there could be some way to read in tag values, like the number of templates, the overall distance, the template positions, and then update the dataset of the canvas?
Are the actual things you want to display as simple as in your mockup there?
If so, then I'd use a Paintable Canvas:
@justinedwards.jle might make a mockup for you just because he heard "paintable canvas"
The paintable canvas gives you direct access to the underlying graphical "primitives" Java swing exposes, so you can literally directly draw the rectangles and text you want. It's a little bit of a 'weird' API, but once you're over the learning curve quite powerful.
If that was just a mockup, and you actually want the full power of expressive templates, then the template canvas is absolutely the way to go. I'd probably use a standard rectangle for the background component, and only try to position the "foreground" rectangles via the template canvas, which supports Miglayout instructions, which include (among many capabilities) absolute positions if nothing else works.
2 Likes
touché
Although, I imagine simply searching the forum for canvas @justinedwards.jle would reveal plenty of examples for implementing both Vision canvases.
1 Like
Michael, you used the term "view" in your question title. This term is used in Perspective. The term for Vision is "window". Can you edit your original question to clarify and add the appropriate tag from the dropdown below the title editor on the right.
No, the template would include the band number, the band position, and a possible red square below the green square. All of these again would be variables within the template
That would be the x column of the template parameters dataset
1 Like
Thanks for the help. I did look at your other post about dynamically setting the dataset parameters based on a dropdown. In my case I am populating a tag dataset and updating it based on a gateway tag change script. Sort of similar.