Package org.vanted.scaling
Class ScalerLoader
java.lang.Object
org.vanted.scaling.ScalerLoader
public final class ScalerLoader extends Object
A 'static' Loader for scaling effects to take place. Use this to
perform/confirm the scaling operations. Although, the implemented slider
interface uses live update, it is needed to perform the scaling explicitly on
some occasions, such as - on start-up or on foreign components, not part of
the main container. The most convenient way is simply calling
init(Container, Class)
. As of the current
implementation, this relies on a static getInstance
method in
your main container. This should be implemented accordingly there. For
alternatives - read below.
Additional usage:
Important: Call
in your main frame, after it has been initialized, to allow live startup
scaling of its components. Then you could use the synchronized initial
scaling ScalerLoader#doSyncInitialScaling()
.
- Author:
- D. Garkov
-
Method Summary
Modifier and Type Method Description static void
await()
static Container
awaitMainContainer(Class<? extends Container> clazz)
An utility method for waiting on the main container visibility.static void
doInitialScaling(Container c)
Scale any loading banner to reflect the DPI factor.static void
doScaling(boolean components, Container... parent)
It does exactly what its name suggests - it ventures preferences and scales according to the value.static void
doSyncExternalScaling(Container c)
This waits for the application's main frame to have been initialized, in order to scale its user-set components.static void
doSyncInitialScaling(Container c)
This waits for the application's main frame to have been initialized, in order to scale its components on initial basis.static void
init(Container main, Class<? extends Container> clazz)
Globalinit
for LAF and External (Component) scaling operations.static void
signal()
Signal that the main frame has loaded to scale its components.
-
Method Details
-
init
Globalinit
for LAF and External (Component) scaling operations.- Parameters:
main
- the application's main container, frame, etc. Could be still uninitialized, but has to be in the process of being, or right before doing so! Its resizable components will then be resized.clazz
- the Class of this main Container, use:Classname.class
.
-
doScaling
It does exactly what its name suggests - it ventures preferences and scales according to the value. Particularly on start up.- Parameters:
components
- false: scale LAF Defaults only,parent
- (one or none): component to start from
-
doInitialScaling
Scale any loading banner to reflect the DPI factor. As a side effect, it might fix an issue with Metal L&F. Metal does not call updatePreferences on startup and therefore does not scale properly. -
doSyncInitialScaling
This waits for the application's main frame to have been initialized, in order to scale its components on initial basis. Should be signaled.Synchronized with Main Frame/Container.
-
doSyncExternalScaling
This waits for the application's main frame to have been initialized, in order to scale its user-set components.Synchronized with Main Frame.
-
signal
public static void signal()Signal that the main frame has loaded to scale its components. -
await
- Throws:
InterruptedException
-
awaitMainContainer
An utility method for waiting on the main container visibility.- Parameters:
the
- class to use Type Introspection on.
-