|
|
|
|
Working with Resources : Font, Color and Background
|
|
Step by Step
Import the usual figue packages.
|
import figue.*;
import figue.box.*;
import figue.path.*; |
Import the resource package.
Keep a reference to a font.
|
private FontInterface _bigFont; |
Keep a reference to a color.
|
private ColorInterface _red; |
Create and keep a reference to an anonymous font.
|
_italicFont = _facade.doGetFont(null,
FontFamily.TIMES_ROMAN,
FontStyle.BOLD_ITALIC,
24,
false); |
Define a named font.
|
_facade.doGetFont("big font",
FontFamily.COURIER,
FontStyle.BOLD,
46,
false); |
Do the same for colors.
|
_facade.doGetColor("red",BasicColor.RED);
_yellow = _facade.doGetColor("yellow",BasicColor.YELLOW);
_blue = _facade.doGetColor(null,0,0,255);; |
Modify the inherited graphical context.
|
final GlyphInterface theFirstContext
= new ChangeGraphicalContextAnonymous(
_italicFont,
_blue,
null);
final GlyphInterface theLine = new Horizontal(10);
theFirstContext.addChild(theLine); |
Modify the inherited graphical context another time.
|
theLine.addChild(Atom.newAtom("It's"));
theLine.addChild(Atom.newAtom('a'));
final GlyphInterface theSecondContext
= new ChangeGraphicalContextAnonymous(
_facade.getFont("big font"),
_facade.getColor("red"),
_yellow);
theLine.addChild(theSecondContext);
theSecondContext.addChild(Atom.newAtom("wonderful"));
theLine.addChild(Atom.newAtom("world")); |
Deal with wrong resource allocation.
|
catch ( WrongResourceException anException ) { |
|
|
Example
- Accelerators :
- home, end, page up, page down, left arrow,right arrow, up arrow, down arrow.
- Autoscrolling :
- drag the mouse inside the
text area, approach a border or a corner, and wait.
|
|
|
Related Classes
and Methods
|
|
|
What Next ?
Now you can :
|
|
|
|
|
|
|
|
|