SlideShare a Scribd company logo
1 of 42
Download to read offline
HOW TO MAKE YOUR ECLIPSE
APPLICATION HI-DPI READY!
Lakshmi P Shanmugam
Eclipse Platform Committer & Co-lead
IBM India
AGENDA
• Introduction to HiDPI
• Autoscaling
• Steps to make the application Hi-DPI ready
• Using high resolution images
• Using new Image constructors
• Using HiDPI APIs
• Missing pieces
WHAT IS HI-DPI?
• DPI - Dots Per Inch / PPI - Pixels Per Inch
• Measure of pixel density
• Default DPI - Windows & Linux-GTK - 96, Mac - 72
• HiDPI Display - Display with higher pixel density
HAVE HIGH PIXEL DENSITY
HI-DPI DISPLAYS
INCREASES LEGIBILITY/CLARITY/SHARPNESS OF UI ELEMENTS
WHY HI-DPI DISPLAYS?
EXISTING CODE AND APPLICATIONS ARE NOT DPI AWARE.
CURRENT PROBLEM
• Increasing DPI makes UI elements appear smaller on Windows &
Linux/GTK
100% zoom 200% zoom
on Hi-DPI monitoron non-Hi-DPI monitor
• On Mac, increasing DPI scales the UI elements and make them
appear blur
on non-Retina on Retina
DPI AWARE APPLICATION
WHAT IS A HI-DPI READY APPLICATION?
• UI is resolution independent
• UI elements appear the same size and are sharp on both standard and
high resolution
• Hi-DPI support provided by SWT is platform independent
• SWT APIs now use point geometry - Display, Graphics API, events use
points - clients need to work only with points and don't have to deal
with pixels
• SWT internally uses pixels for OS calls
LEVERAGE THE SUPPORT PROVIDED BY ECLIPSE
HOW TO MAKE THE APPLICATION HI-DPI
READY?
AUTOMATIC SCALING OF IMAGES & LAYOUT
AUTOSCALING
• Required when high resolution images are not available
• Mac provides native autoscaling of Images on Retina displays
• Text is scaled automatically by the OS on all platforms
• SWT provides automatic scaling of Images & layout on Windows &
Linux based on the OS zoom factor
• Available in Eclipse since Neon (4.6)
AUTOSCALING IN ACTION
TWEAKING SWT’S AUTOSCALING
• On Windows and GTK, SWT's auto-scaling can be configured using
the swt.autoScale Java property.
• swt.autoscale options: default is integer200
• false: scale factor is set to 100% (no scaling)
• integer200: scale factor depends on the current display
resolution, but only uses integer multiples of 100%. The detected
native zoom is generally rounded down (e.g. at 150%, will use
100%), unless close to the next integer multiple (currently at
175%, will use 200%). Maximal zoom level is 200%.
• experimental options - integer, quarter, exact, <value>
USE HI-RESOLUTION IMAGES
STEP 1:
USING HIGH RESOLUTION IMAGES IN YOUR
APPLICATION
• Out of the box support for icon images created using
org.eclipse.jface.resource.ImageDescriptor.createFromURL(URL)
• Append "@2x" to the file name and place into the same folder as
the original icon
• For OSGi bundles, you can also put the icons into a fragment that
contains the same folder structure
2x images in org.eclipse.jface
plugin
Example code
GENERATING HIGH RESOLUTION ICONS
• Create an SVG Image (Scalable Vector Graphics (SVG) is an XML-
based vector image format)
• Generate 1x and 2x png images
• eclipse.platform.images repo
• org.eclipse.images has platform images - svg, 1x, 2x png, gif
• org.eclipse.images.renderer has the generator
• Generator can be used to generate png images of different sizes
from SVG images
CREATE HI-DPI AWARE IMAGES
STEP 2:
USING NEW IMAGE CONSTRUCTORS
CREATE DPI AWARE IMAGES
• SWT provides two new Image constructors that accept image-
provider callbacks that allow clients to supply resolution-
dependent versions of images
• Depending on the user's monitor configuration, SWT will request
images with the corresponding zoom level.
• Available since Eclipse Mars (4.5)
REPLACE WITH NEW IMAGE CONSTRUCTOR FOR IMAGE DATA
• ImageDataProvider provides a callback mechanism to get
ImageData at the required zoom level to be rendered.
• ImageDataProvider.getImageData() will be called by SWT during
the image rendering. Returns the ImageData for the given zoom
level.
Example Code for ImageDataProvider
REPLACE WITH NEW IMAGE CONSTRUCTOR FOR FILE NAME
• ImageFileNameProvider provides a callback mechanism to get
image file path for the required zoom level.
• ImageFileNameProvider.getImagePath() will be called by SWT
during the image rendering. Returns the image filePath for the
given zoom level.
Example Code for ImageFileNameProvider
USE HI-DPI AWARE APIS TO
WORK WITH IMAGES
STEP 3:
GETTING THE IMAGE DATA
It is deprecated as it doesn’t make sense in an environment having
multiple monitors with different DPIs
• It returns an ImageData for the given zoom level
• It is mainly intended to be used by custom implementations of
ImageDataProvider that draw a composite image at the requested
zoom level based on other images.
It returns the ImageData at 100% zoom level
CODE TO DRAW ARROW IN BREADCRUMB VIEW
Replace Image.getImageData() with Image.getImageData(zoom)
USING ImageDescriptor
• ImageDescriptor and CompositeImageDescriptor classes in
org.eclipse.jface.resource are fully ready for HiDPI images.
• An ImageDescriptor is an object that knows how to create an
SWT image.
• Using ImageDescriptor abstract class involves defining a concrete
subclass and re-implementing the getImageData(int) method.
• Legacy subclasses that are not HiDPI-aware used to override the
deprecated getImageData() method.
• Subclasses must re-implement exactly one of the getImageData
methods and they should not re-implement both.
CREATES HI-DPI AWARE IMAGES
Using ImageDescriptor Class
subclasses must
implement
deprecated
USING CompositeImageDescriptor
• An Abstract base class for ImageDescriptor that synthesize
an image from other images in order to simulate the effect of
custom drawing.
• Subclasses must implement getSize() and
drawCompositeImage(int, int).
• Subclasses of CompositeImageDescriptor will have to update
their implementation of drawCompositeImage(int, int) to
use the new drawImage(ImageDataProvider, int, int)
method to draw the elements of the composite image.
CREATES HI-DPI AWARE COMPOSITE IMAGES
Using CompositeImageDescriptor Class
subclasses must
implement
deprecated
use
protected void drawCompositeImage(int width, int height) {
// draw overlay in top-right corner:
ImageData imageData = myImageDescriptor.getImageData();
drawImage(imageData, width - imageData.width, 0);
}
protected void drawCompositeImage(int width, int height) {
// draw overlay in top-right corner:
CachedImageDataProvider provider =
createCachedImageDataProvider(myImageDescriptor);
drawImage(provider, width - provider.getWidth(), 0);
}
Old Code:
New Code:
DecorationOverlayIcon
• A DecorationOverlayIcon is an ImageDescriptor that can be used
to overlay decoration images on to the 4 corner quadrants of a
base image.
• Clients that use DecorationOverlayIcon will get HiDPI support for
free.
MISSING PIECES!!
DYNAMIC RESOLUTION SWITCHING
• Moving the application from one monitor to another of different
DPI
• Works well on Mac due to native support
• Not supported by Eclipse on Windows & GTK
• Windows 7 & GTK - support same DPI on all monitors
• Windows 10 & Wayland - support different DPI on connected
monitors.
SCALING PROBLEM OF IMAGES DRAWN USING
GC ON MAC
PROPOSED APIs
• API to getDPI for each display/Monitor
• API to support DPI aware Image drawing in GC
DEMO
THANK YOU!
swt.autoscale arguments:
• false: scale factor is set to 100% (no scaling)
• integer: scale factor depends on the current display resolution, but only uses
integer multiples of 100%. The detected native zoom is generally rounded
down (e.g. at 150%, will use 100%), unless close to the next integer multiple
(currently at 175%, will use 200%).
• quarter: scale factor depends on the current display resolution, but only uses
integer multiples of 25%. The detected native zoom is rounded to the closest
permissible value. (This used to be the default in the last two pre-release
milestones.)
• exact: scale factor is set to the native zoom (with 1% as minimal step)
• <value>: scale factor uses the given integer value in percent as zoom level
default: integer
nearest
smooth
• The scaling method can be configured by setting the
swt.autoScale.method system property to:
• Default: nearest, except on GTK when the deviceZoom is not an integer
multiple of 100%.
• The smooth strategy currently doesn't work on Windows and Mac OS X.
nearest: nearest-
neighbor interpolation,
may look jagged
smooth: smooth edges,
may look blurry

More Related Content

What's hot

Hadoop installation and Running KMeans Clustering with MapReduce Program on H...
Hadoop installation and Running KMeans Clustering with MapReduce Program on H...Hadoop installation and Running KMeans Clustering with MapReduce Program on H...
Hadoop installation and Running KMeans Clustering with MapReduce Program on H...Titus Damaiyanti
 
Developing SAP Integration services in IBM BPM Advanced
Developing SAP Integration services in IBM BPM Advanced Developing SAP Integration services in IBM BPM Advanced
Developing SAP Integration services in IBM BPM Advanced Logan Vadivelu
 
Terminal Commands (Linux - ubuntu) (part-1)
Terminal Commands  (Linux - ubuntu) (part-1)Terminal Commands  (Linux - ubuntu) (part-1)
Terminal Commands (Linux - ubuntu) (part-1)raj upadhyay
 
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...Simplilearn
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기raccoony
 
[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOSAkihiro Suda
 
05 윈도우 프로그램 유형
05 윈도우 프로그램 유형05 윈도우 프로그램 유형
05 윈도우 프로그램 유형jaypi Ko
 
왕초보를 위한 도커 사용법
왕초보를 위한 도커 사용법왕초보를 위한 도커 사용법
왕초보를 위한 도커 사용법GeunCheolYeom
 
Decoupling your application using Symfony Messenger and events
Decoupling your application using Symfony Messenger and eventsDecoupling your application using Symfony Messenger and events
Decoupling your application using Symfony Messenger and eventshmmonteiro
 
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Simplilearn
 
CSS Styling for Eclipse RCP 3.x and 4.x
CSS Styling for Eclipse RCP 3.x and 4.xCSS Styling for Eclipse RCP 3.x and 4.x
CSS Styling for Eclipse RCP 3.x and 4.xKai Tödter
 
Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)Novell
 
EMC Documentum - xCP 2.x Installation and Deployment
EMC Documentum - xCP 2.x Installation and DeploymentEMC Documentum - xCP 2.x Installation and Deployment
EMC Documentum - xCP 2.x Installation and DeploymentHaytham Ghandour
 
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...Amazon Appstore Developers
 

What's hot (20)

Ansible 101
Ansible 101Ansible 101
Ansible 101
 
Hadoop installation and Running KMeans Clustering with MapReduce Program on H...
Hadoop installation and Running KMeans Clustering with MapReduce Program on H...Hadoop installation and Running KMeans Clustering with MapReduce Program on H...
Hadoop installation and Running KMeans Clustering with MapReduce Program on H...
 
Developing SAP Integration services in IBM BPM Advanced
Developing SAP Integration services in IBM BPM Advanced Developing SAP Integration services in IBM BPM Advanced
Developing SAP Integration services in IBM BPM Advanced
 
Ansible get started
Ansible get startedAnsible get started
Ansible get started
 
Terminal Commands (Linux - ubuntu) (part-1)
Terminal Commands  (Linux - ubuntu) (part-1)Terminal Commands  (Linux - ubuntu) (part-1)
Terminal Commands (Linux - ubuntu) (part-1)
 
Terraform
TerraformTerraform
Terraform
 
Docker, LinuX Container
Docker, LinuX ContainerDocker, LinuX Container
Docker, LinuX Container
 
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
What Is Docker? | What Is Docker And How It Works? | Docker Tutorial For Begi...
 
Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기Docker (Compose) 활용 - 개발 환경 구성하기
Docker (Compose) 활용 - 개발 환경 구성하기
 
Android studio installation
Android studio installationAndroid studio installation
Android studio installation
 
[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS[KubeCon EU 2022] Running containerd and k3s on macOS
[KubeCon EU 2022] Running containerd and k3s on macOS
 
05 윈도우 프로그램 유형
05 윈도우 프로그램 유형05 윈도우 프로그램 유형
05 윈도우 프로그램 유형
 
왕초보를 위한 도커 사용법
왕초보를 위한 도커 사용법왕초보를 위한 도커 사용법
왕초보를 위한 도커 사용법
 
Decoupling your application using Symfony Messenger and events
Decoupling your application using Symfony Messenger and eventsDecoupling your application using Symfony Messenger and events
Decoupling your application using Symfony Messenger and events
 
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
Docker Tutorial For Beginners | What Is Docker And How It Works? | Docker Tut...
 
systemd
systemdsystemd
systemd
 
CSS Styling for Eclipse RCP 3.x and 4.x
CSS Styling for Eclipse RCP 3.x and 4.xCSS Styling for Eclipse RCP 3.x and 4.x
CSS Styling for Eclipse RCP 3.x and 4.x
 
Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)Virtualization with KVM (Kernel-based Virtual Machine)
Virtualization with KVM (Kernel-based Virtual Machine)
 
EMC Documentum - xCP 2.x Installation and Deployment
EMC Documentum - xCP 2.x Installation and DeploymentEMC Documentum - xCP 2.x Installation and Deployment
EMC Documentum - xCP 2.x Installation and Deployment
 
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
IMPLEMENTING VOICE CONTROL WITH THE ANDROID MEDIA SESSION API ON AMAZON FIRE ...
 

Similar to How to make your Eclipse application HiDPI ready!

Scaling Eclipse on HiDPI Monitors - Niraj Modi
Scaling Eclipse on HiDPI Monitors - Niraj ModiScaling Eclipse on HiDPI Monitors - Niraj Modi
Scaling Eclipse on HiDPI Monitors - Niraj ModiEclipse Day India
 
Synapse india reviews on i phone and android os
Synapse india reviews on i phone and android osSynapse india reviews on i phone and android os
Synapse india reviews on i phone and android ossaritasingh19866
 
How to deal with Fragmentation on Android
How to deal with Fragmentation on AndroidHow to deal with Fragmentation on Android
How to deal with Fragmentation on AndroidSittiphol Phanvilai
 
FITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesFITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesRami Sayar
 
GIMP Designer Certification
GIMP Designer CertificationGIMP Designer Certification
GIMP Designer CertificationVskills
 
Getting Intimate with Images on Android with James Halpern
Getting Intimate with Images on Android with James HalpernGetting Intimate with Images on Android with James Halpern
Getting Intimate with Images on Android with James HalpernFITC
 
Android programming
Android programmingAndroid programming
Android programmingvijay_uttam
 
Better DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen WorldBetter DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen WorldJoe Pairman
 
Graphics on the Go
Graphics on the GoGraphics on the Go
Graphics on the GoGil Irizarry
 
Working with camera and imaging on Nokia Asha software platform 1.0
Working with camera and imaging on Nokia Asha software platform 1.0Working with camera and imaging on Nokia Asha software platform 1.0
Working with camera and imaging on Nokia Asha software platform 1.0Microsoft Mobile Developer
 
Building Applications with the Microsoft Kinect SDK
Building Applications with the Microsoft Kinect SDKBuilding Applications with the Microsoft Kinect SDK
Building Applications with the Microsoft Kinect SDKDataLeader.io
 
Wids datathon slides_vanim
Wids datathon slides_vanimWids datathon slides_vanim
Wids datathon slides_vanimVani Mandava
 
Images blast off at the speed of Jamstack! - Alba Silvente Fuentes
Images blast off at the speed of Jamstack! - Alba Silvente FuentesImages blast off at the speed of Jamstack! - Alba Silvente Fuentes
Images blast off at the speed of Jamstack! - Alba Silvente FuentesWey Wey Web
 
Wids datathon slides_vanim (updated)
Wids datathon slides_vanim (updated)Wids datathon slides_vanim (updated)
Wids datathon slides_vanim (updated)Vani Mandava
 
Qt World Summit 2015 Talk by V-Play: How to Develop with Qt for Multiple Scre...
Qt World Summit 2015 Talk by V-Play: How to Develop with Qt for Multiple Scre...Qt World Summit 2015 Talk by V-Play: How to Develop with Qt for Multiple Scre...
Qt World Summit 2015 Talk by V-Play: How to Develop with Qt for Multiple Scre...FELGO SDK
 
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksDeep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksAmazon Web Services
 
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksDeep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksAmazon Web Services
 

Similar to How to make your Eclipse application HiDPI ready! (20)

Scaling Eclipse on HiDPI Monitors - Niraj Modi
Scaling Eclipse on HiDPI Monitors - Niraj ModiScaling Eclipse on HiDPI Monitors - Niraj Modi
Scaling Eclipse on HiDPI Monitors - Niraj Modi
 
Android - Graphics Animation in Android
Android - Graphics Animation in AndroidAndroid - Graphics Animation in Android
Android - Graphics Animation in Android
 
Synapse india reviews on i phone and android os
Synapse india reviews on i phone and android osSynapse india reviews on i phone and android os
Synapse india reviews on i phone and android os
 
Synapse india mobile apps update
Synapse india mobile apps updateSynapse india mobile apps update
Synapse india mobile apps update
 
How to deal with Fragmentation on Android
How to deal with Fragmentation on AndroidHow to deal with Fragmentation on Android
How to deal with Fragmentation on Android
 
FITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive ImagesFITC - Exploring Art-Directed Responsive Images
FITC - Exploring Art-Directed Responsive Images
 
GIMP Designer Certification
GIMP Designer CertificationGIMP Designer Certification
GIMP Designer Certification
 
Getting Intimate with Images on Android with James Halpern
Getting Intimate with Images on Android with James HalpernGetting Intimate with Images on Android with James Halpern
Getting Intimate with Images on Android with James Halpern
 
Android programming
Android programmingAndroid programming
Android programming
 
Better DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen WorldBetter DITA Graphics for a Multi-Screen World
Better DITA Graphics for a Multi-Screen World
 
Graphics on the Go
Graphics on the GoGraphics on the Go
Graphics on the Go
 
Working with camera and imaging on Nokia Asha software platform 1.0
Working with camera and imaging on Nokia Asha software platform 1.0Working with camera and imaging on Nokia Asha software platform 1.0
Working with camera and imaging on Nokia Asha software platform 1.0
 
Building Applications with the Microsoft Kinect SDK
Building Applications with the Microsoft Kinect SDKBuilding Applications with the Microsoft Kinect SDK
Building Applications with the Microsoft Kinect SDK
 
Wids datathon slides_vanim
Wids datathon slides_vanimWids datathon slides_vanim
Wids datathon slides_vanim
 
Intro to auto_desk_maya2015
Intro to auto_desk_maya2015Intro to auto_desk_maya2015
Intro to auto_desk_maya2015
 
Images blast off at the speed of Jamstack! - Alba Silvente Fuentes
Images blast off at the speed of Jamstack! - Alba Silvente FuentesImages blast off at the speed of Jamstack! - Alba Silvente Fuentes
Images blast off at the speed of Jamstack! - Alba Silvente Fuentes
 
Wids datathon slides_vanim (updated)
Wids datathon slides_vanim (updated)Wids datathon slides_vanim (updated)
Wids datathon slides_vanim (updated)
 
Qt World Summit 2015 Talk by V-Play: How to Develop with Qt for Multiple Scre...
Qt World Summit 2015 Talk by V-Play: How to Develop with Qt for Multiple Scre...Qt World Summit 2015 Talk by V-Play: How to Develop with Qt for Multiple Scre...
Qt World Summit 2015 Talk by V-Play: How to Develop with Qt for Multiple Scre...
 
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksDeep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive: Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
 
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech TalksDeep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
Deep Dive on Amazon EC2 Elastic GPUs - May 2017 AWS Online Tech Talks
 

More from Lakshmi Priya

Ece2020 tips&amp;tricks-with-shortcuts
Ece2020 tips&amp;tricks-with-shortcutsEce2020 tips&amp;tricks-with-shortcuts
Ece2020 tips&amp;tricks-with-shortcutsLakshmi Priya
 
EGit Essentials, Tips & Tricks
EGit Essentials, Tips & TricksEGit Essentials, Tips & Tricks
EGit Essentials, Tips & TricksLakshmi Priya
 
Eclipse Tips and Tricks
Eclipse Tips and TricksEclipse Tips and Tricks
Eclipse Tips and TricksLakshmi Priya
 
Eclipse Tips and Tricks
Eclipse Tips and TricksEclipse Tips and Tricks
Eclipse Tips and TricksLakshmi Priya
 
Whats new in Eclipse Oxygen!
Whats new in Eclipse Oxygen!Whats new in Eclipse Oxygen!
Whats new in Eclipse Oxygen!Lakshmi Priya
 
Whats new in Eclipse Oxygen!
Whats new in Eclipse Oxygen!Whats new in Eclipse Oxygen!
Whats new in Eclipse Oxygen!Lakshmi Priya
 
Whats new in Eclipse Photon!
Whats new in Eclipse Photon!Whats new in Eclipse Photon!
Whats new in Eclipse Photon!Lakshmi Priya
 
What's new in Eclipse Mars
What's new in Eclipse MarsWhat's new in Eclipse Mars
What's new in Eclipse MarsLakshmi Priya
 
Eclipse tips & tricks
Eclipse tips & tricksEclipse tips & tricks
Eclipse tips & tricksLakshmi Priya
 
Top 3 SWT Exceptions
Top 3 SWT ExceptionsTop 3 SWT Exceptions
Top 3 SWT ExceptionsLakshmi Priya
 

More from Lakshmi Priya (10)

Ece2020 tips&amp;tricks-with-shortcuts
Ece2020 tips&amp;tricks-with-shortcutsEce2020 tips&amp;tricks-with-shortcuts
Ece2020 tips&amp;tricks-with-shortcuts
 
EGit Essentials, Tips & Tricks
EGit Essentials, Tips & TricksEGit Essentials, Tips & Tricks
EGit Essentials, Tips & Tricks
 
Eclipse Tips and Tricks
Eclipse Tips and TricksEclipse Tips and Tricks
Eclipse Tips and Tricks
 
Eclipse Tips and Tricks
Eclipse Tips and TricksEclipse Tips and Tricks
Eclipse Tips and Tricks
 
Whats new in Eclipse Oxygen!
Whats new in Eclipse Oxygen!Whats new in Eclipse Oxygen!
Whats new in Eclipse Oxygen!
 
Whats new in Eclipse Oxygen!
Whats new in Eclipse Oxygen!Whats new in Eclipse Oxygen!
Whats new in Eclipse Oxygen!
 
Whats new in Eclipse Photon!
Whats new in Eclipse Photon!Whats new in Eclipse Photon!
Whats new in Eclipse Photon!
 
What's new in Eclipse Mars
What's new in Eclipse MarsWhat's new in Eclipse Mars
What's new in Eclipse Mars
 
Eclipse tips & tricks
Eclipse tips & tricksEclipse tips & tricks
Eclipse tips & tricks
 
Top 3 SWT Exceptions
Top 3 SWT ExceptionsTop 3 SWT Exceptions
Top 3 SWT Exceptions
 

Recently uploaded

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentationphoebematthew05
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 

Recently uploaded (20)

AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
costume and set research powerpoint presentation
costume and set research powerpoint presentationcostume and set research powerpoint presentation
costume and set research powerpoint presentation
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 

How to make your Eclipse application HiDPI ready!

  • 1. HOW TO MAKE YOUR ECLIPSE APPLICATION HI-DPI READY! Lakshmi P Shanmugam Eclipse Platform Committer & Co-lead IBM India
  • 2. AGENDA • Introduction to HiDPI • Autoscaling • Steps to make the application Hi-DPI ready • Using high resolution images • Using new Image constructors • Using HiDPI APIs • Missing pieces
  • 3. WHAT IS HI-DPI? • DPI - Dots Per Inch / PPI - Pixels Per Inch • Measure of pixel density • Default DPI - Windows & Linux-GTK - 96, Mac - 72 • HiDPI Display - Display with higher pixel density
  • 4. HAVE HIGH PIXEL DENSITY HI-DPI DISPLAYS
  • 5. INCREASES LEGIBILITY/CLARITY/SHARPNESS OF UI ELEMENTS WHY HI-DPI DISPLAYS?
  • 6. EXISTING CODE AND APPLICATIONS ARE NOT DPI AWARE. CURRENT PROBLEM • Increasing DPI makes UI elements appear smaller on Windows & Linux/GTK 100% zoom 200% zoom
  • 7. on Hi-DPI monitoron non-Hi-DPI monitor
  • 8. • On Mac, increasing DPI scales the UI elements and make them appear blur
  • 10. DPI AWARE APPLICATION WHAT IS A HI-DPI READY APPLICATION? • UI is resolution independent • UI elements appear the same size and are sharp on both standard and high resolution • Hi-DPI support provided by SWT is platform independent • SWT APIs now use point geometry - Display, Graphics API, events use points - clients need to work only with points and don't have to deal with pixels • SWT internally uses pixels for OS calls
  • 11. LEVERAGE THE SUPPORT PROVIDED BY ECLIPSE HOW TO MAKE THE APPLICATION HI-DPI READY?
  • 12. AUTOMATIC SCALING OF IMAGES & LAYOUT AUTOSCALING • Required when high resolution images are not available • Mac provides native autoscaling of Images on Retina displays • Text is scaled automatically by the OS on all platforms • SWT provides automatic scaling of Images & layout on Windows & Linux based on the OS zoom factor • Available in Eclipse since Neon (4.6)
  • 14. TWEAKING SWT’S AUTOSCALING • On Windows and GTK, SWT's auto-scaling can be configured using the swt.autoScale Java property. • swt.autoscale options: default is integer200 • false: scale factor is set to 100% (no scaling) • integer200: scale factor depends on the current display resolution, but only uses integer multiples of 100%. The detected native zoom is generally rounded down (e.g. at 150%, will use 100%), unless close to the next integer multiple (currently at 175%, will use 200%). Maximal zoom level is 200%. • experimental options - integer, quarter, exact, <value>
  • 16. USING HIGH RESOLUTION IMAGES IN YOUR APPLICATION • Out of the box support for icon images created using org.eclipse.jface.resource.ImageDescriptor.createFromURL(URL) • Append "@2x" to the file name and place into the same folder as the original icon • For OSGi bundles, you can also put the icons into a fragment that contains the same folder structure
  • 17. 2x images in org.eclipse.jface plugin Example code
  • 18. GENERATING HIGH RESOLUTION ICONS • Create an SVG Image (Scalable Vector Graphics (SVG) is an XML- based vector image format) • Generate 1x and 2x png images • eclipse.platform.images repo • org.eclipse.images has platform images - svg, 1x, 2x png, gif • org.eclipse.images.renderer has the generator • Generator can be used to generate png images of different sizes from SVG images
  • 19. CREATE HI-DPI AWARE IMAGES STEP 2:
  • 20. USING NEW IMAGE CONSTRUCTORS CREATE DPI AWARE IMAGES • SWT provides two new Image constructors that accept image- provider callbacks that allow clients to supply resolution- dependent versions of images • Depending on the user's monitor configuration, SWT will request images with the corresponding zoom level. • Available since Eclipse Mars (4.5)
  • 21. REPLACE WITH NEW IMAGE CONSTRUCTOR FOR IMAGE DATA • ImageDataProvider provides a callback mechanism to get ImageData at the required zoom level to be rendered. • ImageDataProvider.getImageData() will be called by SWT during the image rendering. Returns the ImageData for the given zoom level.
  • 22. Example Code for ImageDataProvider
  • 23. REPLACE WITH NEW IMAGE CONSTRUCTOR FOR FILE NAME • ImageFileNameProvider provides a callback mechanism to get image file path for the required zoom level. • ImageFileNameProvider.getImagePath() will be called by SWT during the image rendering. Returns the image filePath for the given zoom level.
  • 24. Example Code for ImageFileNameProvider
  • 25. USE HI-DPI AWARE APIS TO WORK WITH IMAGES STEP 3:
  • 26. GETTING THE IMAGE DATA It is deprecated as it doesn’t make sense in an environment having multiple monitors with different DPIs • It returns an ImageData for the given zoom level • It is mainly intended to be used by custom implementations of ImageDataProvider that draw a composite image at the requested zoom level based on other images. It returns the ImageData at 100% zoom level
  • 27. CODE TO DRAW ARROW IN BREADCRUMB VIEW Replace Image.getImageData() with Image.getImageData(zoom)
  • 28. USING ImageDescriptor • ImageDescriptor and CompositeImageDescriptor classes in org.eclipse.jface.resource are fully ready for HiDPI images. • An ImageDescriptor is an object that knows how to create an SWT image. • Using ImageDescriptor abstract class involves defining a concrete subclass and re-implementing the getImageData(int) method. • Legacy subclasses that are not HiDPI-aware used to override the deprecated getImageData() method. • Subclasses must re-implement exactly one of the getImageData methods and they should not re-implement both.
  • 29. CREATES HI-DPI AWARE IMAGES Using ImageDescriptor Class subclasses must implement deprecated
  • 30. USING CompositeImageDescriptor • An Abstract base class for ImageDescriptor that synthesize an image from other images in order to simulate the effect of custom drawing. • Subclasses must implement getSize() and drawCompositeImage(int, int). • Subclasses of CompositeImageDescriptor will have to update their implementation of drawCompositeImage(int, int) to use the new drawImage(ImageDataProvider, int, int) method to draw the elements of the composite image.
  • 31. CREATES HI-DPI AWARE COMPOSITE IMAGES Using CompositeImageDescriptor Class subclasses must implement deprecated use
  • 32. protected void drawCompositeImage(int width, int height) { // draw overlay in top-right corner: ImageData imageData = myImageDescriptor.getImageData(); drawImage(imageData, width - imageData.width, 0); } protected void drawCompositeImage(int width, int height) { // draw overlay in top-right corner: CachedImageDataProvider provider = createCachedImageDataProvider(myImageDescriptor); drawImage(provider, width - provider.getWidth(), 0); } Old Code: New Code:
  • 33. DecorationOverlayIcon • A DecorationOverlayIcon is an ImageDescriptor that can be used to overlay decoration images on to the 4 corner quadrants of a base image. • Clients that use DecorationOverlayIcon will get HiDPI support for free.
  • 35. DYNAMIC RESOLUTION SWITCHING • Moving the application from one monitor to another of different DPI • Works well on Mac due to native support • Not supported by Eclipse on Windows & GTK • Windows 7 & GTK - support same DPI on all monitors • Windows 10 & Wayland - support different DPI on connected monitors.
  • 36. SCALING PROBLEM OF IMAGES DRAWN USING GC ON MAC
  • 37. PROPOSED APIs • API to getDPI for each display/Monitor • API to support DPI aware Image drawing in GC
  • 38. DEMO
  • 39.
  • 41. swt.autoscale arguments: • false: scale factor is set to 100% (no scaling) • integer: scale factor depends on the current display resolution, but only uses integer multiples of 100%. The detected native zoom is generally rounded down (e.g. at 150%, will use 100%), unless close to the next integer multiple (currently at 175%, will use 200%). • quarter: scale factor depends on the current display resolution, but only uses integer multiples of 25%. The detected native zoom is rounded to the closest permissible value. (This used to be the default in the last two pre-release milestones.) • exact: scale factor is set to the native zoom (with 1% as minimal step) • <value>: scale factor uses the given integer value in percent as zoom level default: integer
  • 42. nearest smooth • The scaling method can be configured by setting the swt.autoScale.method system property to: • Default: nearest, except on GTK when the deviceZoom is not an integer multiple of 100%. • The smooth strategy currently doesn't work on Windows and Mac OS X. nearest: nearest- neighbor interpolation, may look jagged smooth: smooth edges, may look blurry