public class ChainedFontFactory extends Object implements LoggingFontFactory
FontFactory
instances which it delegates calls to, one after the other.
The first result will become the chain's result. No further delegates will be asked. If all
delegates return null
, this will also be the ChainedFontFactory
's result.
A typical place to use FontFactory
instances is in FontFactoryReaderSettings
. The
FontFactory
registered there must never return null
. A simple way to fulfil
this requirement is to register a ChainedFontFactory
which, as its last delegate, has a
FontFactory
that always returns a Font
. One such example is the
BasicFontFactory
.
Constructor and Description |
---|
ChainedFontFactory(FontFactory... factoryChain) |
Modifier and Type | Method and Description |
---|---|
Font |
create(FontAttributeSet fontAttributeSet,
Map<String,Object> scope)
Supply a
Font which fits well for the requested parameters. |
Font |
createAndLog(FontAttributeSet fontAttributeSet,
Map<String,Object> scope,
Log log)
Perform the
FontFactory 's usual duties, but also create log output. |
public ChainedFontFactory(FontFactory... factoryChain)
public Font create(FontAttributeSet fontAttributeSet, Map<String,Object> scope)
FontFactory
Font
which fits well for the requested parameters. Care should be taken to
provide a fast implementation. This method might be called frequently and from various Threads at
the same time. Blocking should be avoided.create
in interface FontFactory
fontAttributeSet
- The Attribute
s the requested font should have. Characteristics
like its name or styles.scope
- Information about this request's scope. This could encompass things like its intent,
target, purpose or source.Font
deemed appropriate, or null
if no such Font
is
available. Some implementations might be able to return a Font
which fits all
requested characteristics. Others might have several to choose from or none at all. The
Font
which is returned doesn't have to fit all of the requested characteristics,
or even any at all. It must only be appropriate in the given situation.Scopes
public Font createAndLog(FontAttributeSet fontAttributeSet, Map<String,Object> scope, Log log)
LoggingFontFactory
FontFactory
's usual duties, but also create log output. Typically this method
would delegate to FontFactory.create(FontAttributeSet, Map)
.createAndLog
in interface LoggingFontFactory
fontAttributeSet
- see FontFactory.create(FontAttributeSet, Map)
scope
- see FontFactory.create(FontAttributeSet, Map)
log
- Receives the log output created during this invocationFontFactory.create(FontAttributeSet, Map)
Copyright © 2024 levigo holding gmbh. All rights reserved.