The public methods mentioned in
By methods of IlvBaseTextDirectionInterface and some additional ones used for
handling base text direction are available in the class
IlvGraphic. To control base text direction in a custom graphic
object, you can extend this class to use the bidi functionality already
implemented in it. The easiest way to do so is by taking as base class
IlvBidiGraphic, which contains the full implementations of all
methods of
IlvBaseTextDirectionInterface.
Subclasses of IlvBidiGraphic should implement:
public boolean isBaseTextDirectionSensitive() to return true when the resolved base text direction has any effect
on the bounding box of the graphic object.
public boolean usesBidiMarkers() should return true if the in-place editing implementation uses bidi
markers; the implementation from IlvBidiGraphic always returns false.
public void baseTextDirectionChanged(int,
int) to react whenever the resolved base text direction
changes. For example, if internal drawing caches are affected by the
resolved base text direction, they should be cleaned inside this method.
If the current class is an
IlvGraphicBag, the implementation does not need to call
baseTextDirectionChanged(int,
int) recursively on all contained subobjects, because
the implementation of
IlvBidiGraphic does this automatically.
public void draw(Graphics,
IlvTransformer) to draw the text by taking the resolved
base text direction into account.
public IlvRect boundingBox(IlvTransformer) to take the resolved base text direction into account.
Implementations of other methods, such
as contains, intersects, inside, might also need to take
the resolved base text direction into account.
If you cannot use IlvBidiGraphic as base class, then you can subclass IlvGraphic directly.
You must implement more methods, because IlvGraphic contains only empty or partial implementations:
Define baseTextDirection as a bean property.
Implement setBaseTextDirection and getBaseTextDirection.
int _baseTextDirection;
public void setBaseTextDirection(int baseTextDirection)
{
if (baseTextDirection == _baseTextDirection)
return;
int oldBTDir = getResolvedBaseTextDirection();
_baseTextDirection = baseTextDirection;
int newBTDir = getResolvedBaseTextDirection();
if (oldBTDir != newBTDir)
baseTextDirectionChanged(oldBTDir, newBTDir);
}
public int getBaseTextDirection()
{
return _baseTextDirection;
}
If the class is an
IlvGraphicSet, you must use a different variant
that notifies all contained objects if the resolved base text direction
changes:
int _baseTextDirection;
public void setBaseTextDirection(int baseTextDirection)
{
if (baseTextDirection == _baseTextDirection)
return;
IlvGraphicVector v = IlvGraphicUtil.startBidiChange(this);
try {
_baseTextDirection = baseTextDirection;
} finally {
// this calls applyToObject on all contained objects
// and calls baseTextDirectionChanged on this and all
// contained objects when needed.
IlvGraphicUtil.stopBidiChange(this, v, false);
}
}
public int getBaseTextDirection()
{
return _baseTextDirection;
}
Override setBaseTextDirectionDuringConstruction to change the data member without any notification:
protected void setBaseTextDirectionDuringConstruction(int baseTextDirection)
{
_baseTextDirection = baseTextDirection;
}
Override the other methods already mentioned for
IlvBidiGraphic. (See the methods listed under
[no title] for details.