public class IlvScalableFontManager extends Object implements Serializable
Component
.
An IlvScalableFontManager
instance defines an internal scale
transform used to compute the new font of components associated with this
font manager. This scale transform is computed as the ratio of the current
size of a reference component and the reference size. Both the reference
component and the reference size must be specified at construction time.
Once an IlvScalableFontManager
instance has been initialized
(that is the scale transform has been defined), you can associate any
component with this instance to add support for scalable font to a component.
This association is performed by means of the setFontManager(java.awt.Component, ilog.views.chart.IlvScalableFontManager, java.awt.Font)
method.
By default, an IlvScalableFontManager
instance is installed on
an IlvChart
and can be accessed by means of the IlvChart.getFontManager()
method. The scaling font mode of a chart is disabled by default. You can
activate it by means of its IlvChart.setScalingFont(boolean)
method.
An IlvScalableFontManager
instance can also be used indirectly
to get a font derived from a specified font to which the font manager scale
transform has been applied (getDeriveFont(java.awt.Font)
).
Constructor and Description |
---|
IlvScalableFontManager(Component comp,
Dimension refSize)
Creates a new
IlvScalableFontManager object
associated with the specified component with the specified
transform parameters and no min/max bounds ratio. |
IlvScalableFontManager(Component comp,
Dimension refSize,
float minRatio,
float maxRatio)
Creates a new
IlvScalableFontManager object
associated with the specified component with the specified
transform parameters. |
Modifier and Type | Method and Description |
---|---|
protected float[] |
computeScaleRatios()
Returns the scale ratio as an array of float, the x-ratio being the
first element of this array, the y-ratio being the second element of this
array.
|
void |
dispose()
Disposes this scalable font manager.
|
Component |
getComponent()
Returns the reference component.
|
Font |
getDeriveFont(Font font)
Returns a derived font from the specified font according to the
current scale transform parameters.
|
static IlvScalableFontManager |
getFontManager(Component comp)
Returns the font manager instance that handles the specified component or
null if none is found. |
float |
getMaxRatio()
Returns the maximum value of the scale ratio.
|
float |
getMinRatio()
Returns the minimum value of the scale ratio.
|
Dimension |
getRefSize()
Returns the reference size.
|
boolean |
isEnabled()
Returns whether the scalable mode is enabled.
|
void |
setEnabled(boolean enabled)
Sets whether the scalable mode is enabled.
|
static void |
setFontManager(Component comp,
IlvScalableFontManager manager,
Font refFont)
Associates the specified component with the specified font manager.
|
void |
setRefSize(Dimension refSize)
Sets the reference size parameter.
|
void |
setScaleTransform(Dimension refSize,
float minRatio,
float maxRatio)
Sets the transform parameters.
|
public IlvScalableFontManager(Component comp, Dimension refSize)
IlvScalableFontManager
object
associated with the specified component with the specified
transform parameters and no min/max bounds ratio.comp
- The component to handle.refSize
- The reference size used to compute the scale ratio. If
null
, the reference size is equal to the component size when it
is shown the first time.public IlvScalableFontManager(Component comp, Dimension refSize, float minRatio, float maxRatio)
IlvScalableFontManager
object
associated with the specified component with the specified
transform parameters.comp
- The component to handle.refSize
- The reference size used to compute the scale ratio. If
null
, the reference size is equal to the component size when it
is shown the first time.minRatio
- The minimum scale ratio. If not 0
, the scale
ratio is bounded to this minimum value.maxRatio
- The maximum scale ratio. If not 0
, the scale
ratio is bounded to this maximum value.public void setScaleTransform(Dimension refSize, float minRatio, float maxRatio)
refSize
- The reference size used to compute the scale ratio. If
null
, the reference size is equal to the component size when it
is shown the first time.minRatio
- The minimum scale ratio. If not 0
, the scale
ratio is bounded to this minimum value.maxRatio
- The maximum scale ratio. If not 0
, the scale
ratio is bounded to this maximum value.public void setRefSize(Dimension refSize)
public Dimension getRefSize()
public final Component getComponent()
public final float getMinRatio()
0
, the
scale ratio is bounded to this minimum value.public final float getMaxRatio()
0
, the
scale ratio is bounded to this maximum value.public void setEnabled(boolean enabled)
public final boolean isEnabled()
public Font getDeriveFont(Font font)
font
- The derived font. This font is the same as the one specified
as parameter if the enabled
is false
, or if
the derived font cannot be computed.protected float[] computeScaleRatios()
public static IlvScalableFontManager getFontManager(Component comp)
null
if none is found.public static void setFontManager(Component comp, IlvScalableFontManager manager, Font refFont) throws IllegalArgumentException
dispose()
method instead.comp
- The component to handle.manager
- The font manager that will handle this component. A
null
value remove this component from its font manager.refFont
- The reference font for this component. May be
null
if parent font should be used.IllegalArgumentException
- If the component is already bound to a
font manager, or if it is the reference component of the specified
font manager.public final void dispose()
dispose
method has been called should no longer be used.© Copyright 2024 Rogue Wave Software, Inc., a Perforce company.. All Rights Reserved.