public class UserScaleContext
extends java.lang.Object
ScaleType.USR_SCALE
and ScaleType.OBJ_SCALE
).
The context can be associated with a UI object (see ScaleContextAware
) to define its HiDPI behaviour.
Unlike ScaleContext
, UserScaleContext is device scale independent and is thus used for vector-based painting.ScaleContextAware
,
ScaleContext
Modifier and Type | Class and Description |
---|---|
static class |
UserScaleContext.Cache<D,S extends UserScaleContext>
A cache for the last usage of a data object matching a scale context.
|
static interface |
UserScaleContext.UpdateListener
A context update listener.
|
Modifier and Type | Field and Description |
---|---|
protected Scale |
objScale |
protected double |
pixScale |
protected Scale |
usrScale |
Modifier | Constructor and Description |
---|---|
protected |
UserScaleContext() |
Modifier and Type | Method and Description |
---|---|
void |
addUpdateListener(UserScaleContext.UpdateListener l) |
double |
apply(double value,
DerivedScaleType type)
Applies the scale of the provided type to
value and returns the result. |
double |
apply(double value,
ScaleType type)
Applies the scale of the provided type to
value and returns the result. |
<T extends UserScaleContext> |
copy() |
static UserScaleContext |
create()
Creates a default context with the current user scale
|
static UserScaleContext |
create(Scale... scales)
Creates a context with the provided scale factors (system scale is ignored)
|
static UserScaleContext |
create(UserScaleContext ctx)
Creates a context from the provided
ctx . |
static UserScaleContext |
createIdentity()
Creates a context with all scale factors set to 1.
|
protected double |
derivePixScale() |
void |
dispose()
Clears the links.
|
boolean |
equals(java.lang.Object obj) |
double |
getScale(DerivedScaleType type) |
double |
getScale(ScaleType type) |
int |
hashCode() |
protected boolean |
isScaleOverridden(Scale scale) |
protected void |
notifyUpdateListeners() |
protected boolean |
onUpdated(boolean updated) |
boolean |
overrideScale(Scale scale)
Permanently overrides the provided scale (the scale won't be changed on subsequent
update() ). |
void |
removeUpdateListener(UserScaleContext.UpdateListener l) |
boolean |
setScale(Scale scale)
Sets the new scale (system scale is ignored).
|
java.lang.String |
toString() |
boolean |
update()
Updates the user scale with the current global user scale if necessary.
|
boolean |
update(UserScaleContext ctx)
Updates the context with the state of the provided one.
|
protected <T extends UserScaleContext> |
updateAll(T ctx) |
protected Scale usrScale
protected Scale objScale
protected double pixScale
public static UserScaleContext createIdentity()
public static UserScaleContext create(Scale... scales)
public static UserScaleContext create()
public static UserScaleContext create(UserScaleContext ctx)
ctx
.protected double derivePixScale()
public boolean overrideScale(Scale scale)
update()
).
Can be used to make a UI object user scale independent:
((ScaleContextAware)uiObject).getScaleContext().overrideScale(USR_SCALE.of(1.0));
scale
- the new scale to overrideScaleType.of(double)
protected boolean isScaleOverridden(Scale scale)
public boolean setScale(Scale scale)
ScaleType.of(double)
to provide the new scale.
Note, the new scale value can be change on subsequent update()
. Use overrideScale(Scale)
to set a scale permanently.scale
- the new scale to setScaleType.of(double)
public double getScale(ScaleType type)
public double getScale(DerivedScaleType type)
public double apply(double value, DerivedScaleType type)
value
and returns the result.public double apply(double value, ScaleType type)
value
and returns the result.protected boolean onUpdated(boolean updated)
public boolean update()
public boolean update(UserScaleContext ctx)
ctx
- the new contextprotected <T extends UserScaleContext> boolean updateAll(T ctx)
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void dispose()
public void addUpdateListener(UserScaleContext.UpdateListener l)
public void removeUpdateListener(UserScaleContext.UpdateListener l)
protected void notifyUpdateListeners()
public <T extends UserScaleContext> T copy()
public java.lang.String toString()
toString
in class java.lang.Object