public class ScaleContext extends JBUI.BaseScaleContext
UserScaleContext with the system scale, and is thus used for raster-based painting.
The context is created via a context provider. If the provider is Component, the context's
system scale can be updated via a call to update(), reflecting the current component's
system scale (which may change as the component moves b/w devices).ScaleContextAware| Modifier and Type | Class and Description |
|---|---|
static class |
ScaleContext.Cache<D> |
UserScaleContext.UpdateListener| Modifier and Type | Field and Description |
|---|---|
protected java.lang.ref.WeakReference<java.awt.Component> |
compRef |
protected Scale |
sysScale |
objScale, pixScale, usrScale| Modifier | Constructor and Description |
|---|---|
protected |
ScaleContext() |
protected |
ScaleContext(Scale scale) |
| Modifier and Type | Method and Description |
|---|---|
<T extends UserScaleContext> |
copy() |
static ScaleContext |
create()
Creates a default context with the default screen scale and the current user scale
|
static ScaleContext |
create(java.awt.Component comp)
Creates a context based on the comp's system scale and sticks to it via the
update() method. |
static ScaleContext |
create(java.awt.Graphics2D g)
Creates a context based on the g's system scale
|
static ScaleContext |
create(java.awt.GraphicsConfiguration gc)
Creates a context based on the gc's system scale
|
static ScaleContext |
create(Scale... scales)
Creates a context with the provided scale factors
|
static ScaleContext |
create(Scale scale)
Creates a context with the provided scale
|
static ScaleContext |
create(UserScaleContext ctx)
Creates a context from the provided
ctx. |
static ScaleContext |
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() |
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.
|
protected <T extends UserScaleContext> |
updateAll(T ctx) |
getScale, update, updateaddUpdateListener, apply, apply, isScaleOverridden, notifyUpdateListeners, onUpdated, overrideScale, removeUpdateListener, updateprotected Scale sysScale
protected java.lang.ref.WeakReference<java.awt.Component> compRef
protected ScaleContext()
protected ScaleContext(Scale scale)
public static ScaleContext createIdentity()
public static ScaleContext create(UserScaleContext ctx)
ctx.public static ScaleContext create(java.awt.Component comp)
update() method.public static ScaleContext create(java.awt.GraphicsConfiguration gc)
public static ScaleContext create(java.awt.Graphics2D g)
public static ScaleContext create(Scale scale)
public static ScaleContext create(Scale... scales)
public static ScaleContext create()
protected double derivePixScale()
derivePixScale in class UserScaleContextpublic double getScale(ScaleType type)
getScale in class UserScaleContextpublic double getScale(DerivedScaleType type)
getScale in class UserScaleContextpublic boolean update()
update in class UserScaleContextpublic boolean setScale(Scale scale)
ScaleType.of(double) to provide the new scale.
Note, the new scale value can be change on subsequent UserScaleContext.update(). Use UserScaleContext.overrideScale(Scale)
to set a scale permanently.
Also includes the system scale.setScale in class UserScaleContextscale - the new scale to setScaleType.of(double)protected <T extends UserScaleContext> boolean updateAll(T ctx)
updateAll in class UserScaleContextpublic boolean equals(java.lang.Object obj)
equals in class UserScaleContextpublic int hashCode()
hashCode in class UserScaleContextpublic void dispose()
UserScaleContextdispose in class UserScaleContextpublic <T extends UserScaleContext> T copy()
copy in class UserScaleContextpublic java.lang.String toString()
toString in class UserScaleContext