//***************************************************************************** // Copyright (c) 1998 INRIA. // http://www.inria.fr/croap/aioli/modules/figue/web/credits.html#COPYRIGHT //***************************************************************************** package figue.tutorial; import java.awt.GridLayout; import java.util.StringTokenizer; import figue.*; import figue.box.*; import figue.resource.*; import figue.path.*; public final class Tutorial_8 extends TutorialApplet { /** * For code identification with unix what command. * @level internal */ public final static String VERSION_ID = "@(#) $Source: /net/croap/CVSROOT/figue/java/tutorial/Tutorial_8.java,v $ $revision$ $Date: 1998/11/02 15:56:00 $ Copyright 1998 INRIA."; protected final void initTutorial() { setLayout(new GridLayout(1,1)); _facade = new AWTFacade(getParameters()); add(_facade.getAwtComponent()); setDefaultKeyListener(_facade); initResources(); buildBox(); } public final void destroy() { _facade.disposeWhenInactive(); _facade = null; super.destroy(); } private final void buildBox() { final GlyphInterface theParagraph = new Paragraph(10,50,10); String theText = "It's a Wonderful Life !!"; String theCurrentToken; for ( int theRank = 0; theRank < 25; theRank++ ) { StringTokenizer theIterator = new StringTokenizer(theText); while ( theIterator.hasMoreTokens() ) { theCurrentToken = theIterator.nextToken(); if ( theCurrentToken.equals("Wonderful") ) { theParagraph.addChild(Atom.newAtom(theCurrentToken,"style hot")); } else { theParagraph.addChild(Atom.newAtom(theCurrentToken)); } } } PathInterface thePath = new Path(); thePath.addOperation(new InsertGlyph(theParagraph,0)); _facade.buildInit(thePath); _facade.buildComplete(); } private final void initResources() { try { _facade.doGetFont(Constants.DEFAULT_FONT,FontFamily.TIMES_ROMAN,FontStyle.PLAIN,15,false); _facade.doGetColor(Constants.DEFAULT_COLOR,BasicColor.BLUE); _facade.doGetColor(Constants.DEFAULT_BACKGROUND,BasicColor.WHITE); _facade.doGetFont("big font",FontFamily.COURIER,FontStyle.BOLD,20,false); _facade.doGetColor("yellow",BasicColor.YELLOW); _facade.doGetColor("red",BasicColor.RED); _facade.doGetStyle("style hot", _facade.getFont("big font"), _facade.getColor("red"), _facade.getColor("yellow")); } catch ( WrongResourceException anException ) { ; } initStandardResources(_facade); } private final FacadeInitializer getParameters() { FacadeInitializer theParameters = new FacadeInitializer(); theParameters.setFormattingWidth(475); setAppletParameters(theParameters); return theParameters; } private AWTFacade _facade; }