Top Description Fields Constructors Methods
jogamp.nativewindow

public Class SurfaceScaleUtils

extends Object
Class Inheritance
Imports
com.jogamp.nativewindow.ScalableSurface

Basic ScalableSurface utility to validate and compute pixel-scale values.

Field Summary

Modifier and TypeField and Description
private static final float

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static float

Returns:

the constrained pixel-scale
clampPixelScale
(final float
pixel-scale to be constrained
pixelScale
,
final float
minimum pixel-scale
minPixelScale
,
final float
maximum pixel-scale
maxPixelScale
)

Method constrains the given pixel-scale within ]0..

public static float[]

Returns:

the constrained result for chaining
clampPixelScale
(final float[]
float[2] storage for result, maybe same as s for in-place
result
,
final float[]
float[2] pixelScale to be constrained
pixelScale
,
final float[]
float[2] minimum pixel-scale
minPixelScale
,
final float[]
float[2] maximum pixel-scale
maxPixelScale
)

Method constrains the given float[2] pixel-scale within ]0..

private static boolean
isZero(final float a)

public static int

Returns:

the integer rounded product
scale
(final int
the int value
a
,
final float
the float scale factor
pixelScale
)

Returns integer rounded product, i.e. (int) ( a * pixelScale + 0.5f )

public static int[]

Returns:

the result for chaining
scale
(final int[]
the int[2] result, may be a for in-place operation
result
,
final int[]
the int[2] values
a
,
final float[]
the float[2] scale factors
pixelScale
)

Returns integer rounded product, i.e. (int) ( a * pixelScale + 0.5f )

public static int

Returns:

the integer rounded product
scaleInv
(final int
the int value
a
,
final float
the float scale factor
pixelScale
)

Returns integer rounded product, i.e. (int) ( a / pixelScale + 0.5f )

public static int[]

Returns:

the result for chaining
scaleInv
(final int[]
the int[2] result, may be a for in-place operation
result
,
final int[]
the int[2] values
a
,
final float[]
the float[2] scale factors
pixelScale
)

Returns integer rounded product, i.e. (int) ( a / pixelScale + 0.5f )

public static boolean

Returns:

true if pixel-scale has changed, otherwise false.
setNewPixelScale
(final float[]
int[2] storage for result, maybe same as prePixelScale for in-place
result
,
final float[]
float[2] previous pixel-scale
prePixelScale
,
final float[]
float[2] requested pixel-scale, validated via validateReqPixelScale(float[], float[], String).
reqPixelScale
,
final float[]
float[2] minimum pixel-scale
minPixelScale
,
final float[]
float[2] maximum pixel-scale
maxPixelScale
,
final String
if set, dumps debug info on stderr using this prefix
DEBUG_PREFIX
)

Method writes the given float[2] requested pixel-scale reqPixelScale into result within its constraints ]0..

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EPSILONback to summary
private static final float EPSILON

Constructor Detail

SurfaceScaleUtilsback to summary
public SurfaceScaleUtils()

Method Detail

clampPixelScaleback to summary
public static float clampPixelScale(final float pixelScale, final float minPixelScale, final float maxPixelScale)

Method constrains the given pixel-scale within ]0..maxPixelScale], as described below.

Method returns IDENTITY_PIXELSCALE if:

Method returns maxPixelScale if

Method returns minPixelScale if

  • pixelScale < minPixelScale
  • pixelScale ~= minPixelScale

Otherwise method returns the given pixelScale.

~= denominates a delta ≤ FloatUtil#EPSILON.

Parameters
pixelScale:float

pixel-scale to be constrained

minPixelScale:float

minimum pixel-scale

maxPixelScale:float

maximum pixel-scale

Returns:float

the constrained pixel-scale

clampPixelScaleback to summary
public static float[] clampPixelScale(final float[] result, final float[] pixelScale, final float[] minPixelScale, final float[] maxPixelScale)

Method constrains the given float[2] pixel-scale within ]0..maxPixelScale], as described in clampPixelScale(float, float, float).

Parameters
result:float[]

float[2] storage for result, maybe same as s for in-place

pixelScale:float[]

float[2] pixelScale to be constrained

minPixelScale:float[]

float[2] minimum pixel-scale

maxPixelScale:float[]

float[2] maximum pixel-scale

Returns:float[]

the constrained result for chaining

isZeroback to summary
private static boolean isZero(final float a)
scaleback to summary
public static int scale(final int a, final float pixelScale)

Returns integer rounded product, i.e. (int) ( a * pixelScale + 0.5f )

Parameters
a:int

the int value

pixelScale:float

the float scale factor

Returns:int

the integer rounded product

scaleback to summary
public static int[] scale(final int[] result, final int[] a, final float[] pixelScale)

Returns integer rounded product, i.e. (int) ( a * pixelScale + 0.5f )

Parameters
result:int[]

the int[2] result, may be a for in-place operation

a:int[]

the int[2] values

pixelScale:float[]

the float[2] scale factors

Returns:int[]

the result for chaining

scaleInvback to summary
public static int scaleInv(final int a, final float pixelScale)

Returns integer rounded product, i.e. (int) ( a / pixelScale + 0.5f )

Parameters
a:int

the int value

pixelScale:float

the float scale factor

Returns:int

the integer rounded product

scaleInvback to summary
public static int[] scaleInv(final int[] result, final int[] a, final float[] pixelScale)

Returns integer rounded product, i.e. (int) ( a / pixelScale + 0.5f )

Parameters
result:int[]

the int[2] result, may be a for in-place operation

a:int[]

the int[2] values

pixelScale:float[]

the float[2] scale factors

Returns:int[]

the result for chaining

setNewPixelScaleback to summary
public static boolean setNewPixelScale(final float[] result, final float[] prePixelScale, final float[] reqPixelScale, final float[] minPixelScale, final float[] maxPixelScale, final String DEBUG_PREFIX)

Method writes the given float[2] requested pixel-scale reqPixelScale into result within its constraints ]0..maxPixelScale], as described in clampPixelScale(float, float, float).

Method only differs from clampPixelScale(float[], float[], float[], float[]) by returning the whether the value has changed, i.e. different from the given prePixelScale.

Parameters
result:float[]

int[2] storage for result, maybe same as prePixelScale for in-place

prePixelScale:float[]

float[2] previous pixel-scale

reqPixelScale:float[]

float[2] requested pixel-scale, validated via validateReqPixelScale(float[], float[], String).

minPixelScale:float[]

float[2] minimum pixel-scale

maxPixelScale:float[]

float[2] maximum pixel-scale

DEBUG_PREFIX:String

if set, dumps debug info on stderr using this prefix

Returns:boolean

true if pixel-scale has changed, otherwise false.