Paintable Canvas

Here’s a window that has the paintable canvas components with bound properties. You can easily play with properties. Remember, they are entirely created with the Java2D code under the action for the repaint Event of the objects - you can tweak the code to behave however you’d like. Also, the sizing is relative, so you can resize the images - they even work with different aspect ratios.
paintedComponents.fwin (65.6 KB)


If anyone’s feeling peppy, give this one a shot. I think it could be done with Java2D easily enough on a Paintable Canvas. I created this from shape components.
button.fwin (52.1 KB)


Pretty cool stuff Nathan. I had played around with the Affine Transform before when I was trying to replicate my pump instances, but couldn’t get it to work, so I used translate instead. Your matrix example makes more sense.

I have another question about replicating many objects. I have been experimenting with “buffered images” (so far all I could copy was solid black boxes though), and wanted to know if that approach would make sense on a screen where there are many instances of a single object. For instance, it looks like a BufferedImage can be created with the createGraphics method, and drawn over and over (I presume as a raw byte for byte copy, rather than drawing each individual vector again). Then, only the dynamic part of an object (such as the object name or fill level) would need to be overlayed. Or, the buffered image could also be pulled in from a graphics file and displayed.

Would this be a good approach? I have one particular screen that will have 100 identical objects on it with the exception of the fill level, and thought this would be worth a try.

I’ve also attached the global script and another version of the pump window that includes zoom in and zoom out buttons as well as cleaned up code. I put the geometry in a global script as you suggested, and will do the same for the pump next. I swear, this stuff is addictive.
Pumps_8.fwin (97.9 KB)
Geometry.py (511 Bytes)

Sounds like you’re having fun. Using buffered images to create a “rubber stamp” image that you then paint many times is a very high-performance graphics technique. I have used it to make Java2D-based applications have fluid animation. It is probably overkill for what you’re doing, but it isn’t too hard, so go for it.

The easiest way to do it is to get an instance of BufferedImage using its 3-argument constructor, painting to it via bufferedImage.createGraphics(), an then use it multiple times as you paint the 100 objects.

One tip though - It looks like you’re searching out performance improvements for fun. While your time is your own, you might be going overboard. Don’t prematurely optimize.

Thanks Carl, I’ll give that a try again.

This definitely isn’t for fun. Part of it is because I’m picky (why would I draw something a hundred times when I could draw it once and copy it?), but actually I have good reasons for doing this based on what other vendor’s screens look like, and I want to take my screens to the next level. Plus, I like to understand all of the tools in the toolbox, and use the right ones. Like the old saying goes, when all you have is a hammer, everything looks like a nail.

Fair enough! There are a number of books on Java2D that you might want to look at so you understand what you’re dealing with re: shapes, paints, graphics, and transforms.

Also, I just want to put a disclaimer up here for any casual readers of this forum: This isn’t a typical way to use FactoryPMI. You don’t need to know anything about what we’re talking about here to create a great SCADA system with our software. This stuff is a very advanced feature meant for enterprising customers (Like Step7) who like to really get their hands dirty doing very technical customizations to the base system.

Someone has a new link for this example?