Creating Usable Toolbar for High Resolution Screen - java

High resolution screens are old news, but for some reason we (and the Eclipse guys) ignored them until now. Well, we can't any longer.
What we want to do is create Eclipse applications that work for "normal" displays, but for high resolution ones, too. Right now the icons are way to small to see or click.
This bug links to this (rather sparse) documentation states we only need to use a new constructor for Image. Okay, so we need to create our own implementation of ImageDataProvider.
While that might work for the images we created ourselves, it does not work for the main tool bar icons.
So let's say we'll start a completely new application from scratch: how would we set up everything to make the toolbar work with the new API and so with all kinds of screens?
(There is a similar question, but it's from the perspective of an Eclipse user, while this question is from the perspective of a developer of an Eclipse application.)

When HiDPI mode scaling is in use anything using ImageDescriptor.createFromURL to load images will look for a image with #2x or #1.5x appended to the name depending on the current scaling (so, for example, remove.png and remove#2x.png). This is used to create an ImageDataProvider.
Eclipse will use this for the tool bar images and many other things.

Related

CodenameOne - Importing set of images in the theme

My CodenameOne app is mainly intended to be the iOS counterpart of an existing Android app. It is for older devices, in fact, as soon as possible, or in the future, a Swift app is going to replace it for OS 14>.
I need some customised icons and I have the svg code for it.
Initially I had to use the Flamingo tool, that converts svg files in Java classes.
I used it like
ScaleImageButton appButton=new ScaleImageButton(new AppIcon().scaled(doubleButtonSize,doubleButtonSize).toImage());
It is cumbersome but it does not even work on iOS.
So now I resorted to create png images for every icon in every dpi level, as it can also be done on Android.
I renamed the files so they follow the standard I think it is proposed in CodenameOne.
The possible names are:
verylow.png
low.png
medium.png
high.png
veryhigh.png
560.png
hd.png
2hd.png
4k.png
In the end it has to be used like
Image icon = theme.getImage("icon.png");
It seems that the images can be imported in the project in more than one way.
I was said to include them in the theme.
According to the CN1 developer guide I have to set the size for each.
If I import them as a whole (selecting the folder or selecting all images and hitting the "Open" button) in the theme editor a dialog appears with all wrong sizes (but they resemble a particular set of choice, although very unlikely).
They are not always the same sizes but neither they are defaulted according to the provided set of images.
I provide images as 24px, 36px, 48px, 72px, 96px, 144px, 192px, 288px, 384px for normal size icons, and also I provide double sized images for double size icons in my app (the values are not doubled as expected).
I also have to check "Square image" and "Preserve aspect ratio" options (my images are already square).
Then the strangest part is that there is a percentage, I see it is 20 for example.
The caption reads "will affect all entries". I understood that it is to scale images, that is what a developer just do not want, unless the developer has wrong sizes, but still proportioned among themselves, that cannot be the case I think.
However I do not need any scaling, the images are right as they are. I created them on purpose.
The developer guide is not enough clear to me.
So I am asking
is it right to tweak the wrong size to match the right ones, and what about the percentage?
This specific UI is a bit out of date by now and wasn't used much even when it was added. Most users opted to do desktop scaling for multi images.
The scale option is designed to scale down from a high resolution image on the desktop. You don't want/need that.
You don't need to edit the file. Just make sure to turn on the XML team mode and make sure your images use the right file names. Then once you save the images will appear in the resource file.
I suggest adding a multi-image using the standard method of add in the menu. Then replacing all the generated images with your copies and reopening the file, then saving again (the last save is important as it will override the res file).

Why my font in design viewer is blurry in Android Studio?

Why my text inside the android design viewer appears blurry. I tried changing the resolution DPI setting as well. But it didn't work for me.
Please look at my second picture, to let you know which one is I am talking about.
Try changing the scaling to 100% instead to 125%. Normally in Windows 10 default scale in 125% recommended. But using 100% will fix this.
To Find Scaling Setting:
Right Click on the desktop
Navigate to Display Setting
Dont Forget to go advanced scaling setting
And
Turn on the Fixed Scaling for the apps
Just incase sometimes
Before:
After:
How about changing device settings?
It just change the resolution of example device and it would make more clear sight from design view. It doesn't change the layout codes.
It would help the development with clear visual, but you have to test various resolutions of devices if you needed to.
Go to 'Help' tab and click on 'Edit Custom Properties'. It might ask you to generate a file if it doesn't already exist. Once this properties file was made, I wrote 'hidpi=false' (no quotations) on a new line, saved it, and restarted Android Studio.

Running a Sikuli script in multiple computers

I have a Sikuli script written in java to click the windows start button and then click "All Programs" as appear. The script works absolutely fine on my computer but when I transfer the same script to another computer, it doesn't work.
Code:
Screen screen = new Screen();
screen.type(Key.WIN);
screen.click(IMAGE_DIR + "program.PNG");
I used concepts like Wait, Pattern and similar but not able to solve this issue. Not sure if this is a limitation of sikuli.
Like was already mentioned in the comments, differences in screens resolutions will definitely ruin your existing scripts as Sikuli is super sensitive to them. In such case, the only solution is to recapture the patterns and use a different set of them on each machine.
However, if you have such issue but screens resolutions seem to be identical, there are few more things that should be checked.
Clear Type, which is Microsoft's implementation of subpixel rendering that is supposed to improve the fonts visual appearance. If you have this feature switch on on one machine and switched off on another, that might be an issue.
Smooth Edges of screen fonts setting that can be found in the "Visual Effects" settings window in "Performance Options". It does exactly what it says, smooths windows fonts to improve the looks. As in the case of ClearType, this feature should be switched off or on on both machines you run your scripts on. The general recommendation to have the always off to avoid this kind of issues.
For those still using Sikuli and experiencing inconsistency when running across different machines, it's helpful to debug on the boxes that are showing the issue.
Some things like issues around various AppData temp files not being managed correctly can show up in some PCs but not others. It's a pain to install your IDE into different places but it sometimes is the only way to really see what's going wrong - and be able to fix it.

How to make Java Swing application developed in NetBeans not have hideous buttons?

I developed a Java application in Netbeans, and I'm going to release it soon so I'm working on making it less ugly. Since I'm developing on a Mac, the GUI builder uses the Mac Look & Feel, which looks decent, but many of my users won't be using Macs. The default L&F is Nimbus, which looks fine except for the buttons, which have annoying borders that are not overridden by the manually setting the borders (you can see how the manual borders look in the image). With the manually set borders, the Nimbus L&F adds its own odd border inside the border I made, which just looks idiotic. Without the manually set borders, Nimbus's borders overlap in visually unappealing ways, and in order to avoid overlap I have to space the buttons really far apart, which I also don't like.
I tried using the other L&Fs available in Netbeans (Metal and something else), but they're just too ugly to stand.
Basically, I would like some advice on how to customize the way buttons look in this application. I don't want to write a button drawing function from scratch or design my own images. I just want a way to change the settings so things don't look stupid. I read in various places that the Substance L&F is good, but I can't find where to download it anywhere. If someone could link me to a download page for Substance or recommend another popular, simple and not stupid-looking L&F, I would greatly appreciate it.
Yeah pretty much all the L&Fs you'll find in Netbeans are worse than the default. The program will use the default Look & Feel of the operating system - so if it's being run on Windows it will have the "Windows-esce" buttons and fonts and on Mac will have the Mac style.
It all depends on what you're looking for. If you're application is meant to be professional and you don't mind it having different styles depending on the OS of the user then I'd leave it as default. It lends familiarity to your program which can truly make the user feel much more comfortable.
If you're after an indetical look for all users then, as you know, you just need to include the L&F with your program. I couldn't find a download for Substance but there are a few L&F's here - both commercial and free.
http://www.java2s.com/Product/Java/Swing/Look-And-Feel-LaF.htm

Cross platform UI spacing/padding

I have written a Java UI using the SWT UI library and the MigLayout layout library.
This page shows screenshots of the UI on Windows, Linux and OSX: http://mchr3k.github.com/org.intrace/screenshots.html
On Linux and OSX my UI has a lot more padding and spacing which I feel wastes a lot of screen space. Is this normal for these platforms? If not, what is the best way to work around this?
EDIT: the linked screenshots have now been updated and no longer show an extra gap on OSX as I have explicitly set the margins on some of my UI elements to 0. The OSX UI is still quite spaced out but I assume that this is correct for the platform.
This is Mikael Grev, the creator of MigLayout.
As someone else mentioned this is a feature of MigLayout. Instead of using x number of pixels (you can of course use that too) by default it is using gaps like related, unrelated and paragraph. These correspond to different sizes in different UI toolkits. For instance on OS X the recommended white space between components is larger than on Windows.
So, yes, this is how it's supposed to look and it will look correct for a native OS X user.
You do seem to have too much white space at the bottom of the Output pane though, in both OS X and Windows.
You can use the PlatformDefaults class in MigLayout to either force a platform or to change the default gaps. Check the source code if you want to know what's happening behind the scenes.
And remember, this is a feature so that every developer won't have to keep track of how to spacing should look like on different platforms, which is kind of hard.
Cheers,
Mikael
That's actually a feature of MigLayout, if I recall correctly. If you don't want this I am sure you could so configure MigLayout. Otherwise, you could use a different layout manager (but I still highly recommend a table-based one) which uses constant spacing for all platforms (such as my MatrixLayout).

Categories

Resources