Friday, July 29, 2016

Java and High DPI Displays

Are you running into issues with your Ignition Designer (or runtime) being extremely small on a high DPI display?

Your not alone. A lot of our customers are running into this issue. Ignition's Designer and runtime are Java Swing applications. The problem is that Java Swing claims that they are DPI aware, but they're not, so Windows doesn't scale it.

Unfortunately, this is not something that Oracle will fix, however, there is a way around it by modifying the EXE manifests for java.exe and javaw.exe and javaws.exe. 

This fix requires a resource editor and is for Java 8 or higher. I used Resource Hacker to modify the EXE manifests.

Follow these instructions:
  1. Install Resource Hacker
  2. Run Resource Hacker with administrative privileges
  3. Open java.exe from the installed Java 8 JRE (or JDK) path. Example:

    C:\Program Files\Java\jre1.8.0_51\bin\java.exe

    Note: If you have multiple versions of Java 8 installed you will have follow these steps for each one.
  4. Expand folder 24
  5. Expand folder 1
  6. Click on node 0 and you will see XML on the right
  7. Locate the dpiAware setting under application:

    <dpiAware>true</dpiAware>

    and change true to false:

    <dpiAware>false</dpiAware>



  8. Press the Compile Script button at the top
  9. Save your changes through File > Save
  10. Follow the same instructions for javaw.exe and javaws.exe. Make sure to do this for all Java versions (JRE and JDK) you have.
  11. Make sure to use the Native Client Launcher for Ignition. 
That's it. Now you can set your scaling to 150% or 200% in Windows and the Ignition Designer will look much better. You may have to restart your computer for the settings to take affect. 

Note: If you are using the 64-bit JRE make sure you are applying these changes to java.exe in Program Files not Program Files (x86) and vice-versa. 

Also, if you update your JRE to a newer version you must follow these steps for the new java.exe and javaw.exe.

Thursday, July 21, 2016

Template Layout and Resizing

First of all, I want to say sorry for neglecting the blog for a couple of years. Starting this week, I want to post a new blog entry once a week. I have realized that there are a lot of little things that I know that can really make a difference when developing in Ignition. Stay tuned and follow me for new and exciting tips and tricks on Ignition.

This week I want to touch on template's layout and resizing. I find that a lot of people get tripped up with how the layout works and what happens when you resize the template. For this post, I want to explain exactly how it works.

By default, when you drag a template onto the window from the Project Browser, the size of the instance is exactly the same size as the master template (template definition). You can make the size of the template instance on the window larger or smaller but it only changes the size of that instance. Usually people want to make the template instance larger that what was defined.

However, if you modify the size of the master template it will NOT automatically resize the template instance on the window. For that, you must locate the template instance (everywhere it is being used), right click and select "Revert to Master Size."


That will change the size of the template instance on the window to the size of the master template.

Putting a template on the window is the same idea as putting a Vision component on the window. It is very important to note that you are now dealing with 2 different layouts: the layout of the template on the window AND the layout of the components inside of the template. By default, the layout of the template instance on the window will be "Relative - Maintain Aspect Ratio" and the layout of the components inside of the template is "Relative - Stretch."

The layout of the template instance dictates the layout of the components inside of the template. In other words, if the template instance does not resize than the components inside of the template will not resize as well. Also, the template instance can have a different layout than the components inside of the template. For example, you may want the template instance to fill out the entire window using anchored layout but you want the components inside of the template to maintain their aspect ratio.

So here comes the issue that everybody runs into: you set the layout of the components inside of the template to anchored or to maintain the aspect ratio but when you resize the template on the window it ignores that layout and stretches the components.

That happens because a template acts the same way as a "Component Group" by default. That means the layout is stuck to "Relative - Stretch." If you want the template instances to respect your layout settings, you need to set the "Enable Layout" property to true in the template definition.


That little checkbox will allow you to control the layout inside of the template. With that you can now control both layouts: on the window and in the template.

If you have any questions please feel free to email me at travis@inductiveautomation.com. Please stay tuned for more tips and tricks.