//***************************************************************************** // Copyright (c) 1998 INRIA. // http://www.inria.fr/croap/aioli/modules/figue/web/credits.html#COPYRIGHT //***************************************************************************** package figue.tutorial; import java.awt.BorderLayout; import java.awt.TextArea; import java.io.StringWriter; import java.io.IOException; import figue.*; import figue.box.*; import figue.path.*; import figue.resource.*; public final class Tutorial_34 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_34.java,v $ $revision$ $Date: 1998/11/02 15:55:58 $ Copyright 1998 INRIA."; protected final void initTutorial() { final int theColumnNumber = 60; FacadeInitializer theParameters = getParameters(); theParameters.setFormattingWidth(theColumnNumber); _facade = new AWTFacade(theParameters); internalInit(); initResources(_facade); buildBox(_facade); final StringWriter theOutputStream = new StringWriter(); _facade.executeWhenInactive(new CommandInterface() { public final boolean execute() { try { _facade.writeAsXML(theOutputStream); final String theOutput = theOutputStream.toString(); final int theLength = theOutput.length(); int theRank = 0; int theEnd; boolean theExitFlag = false; while ( ! theExitFlag ) { theEnd = theRank + theColumnNumber; if ( theEnd >= theLength ) { theExitFlag = true; theEnd = theLength; } _textArea.append(theOutput.substring(theRank,theEnd)); _textArea.append("\n"); theRank += theColumnNumber; } } catch ( IOException anException ) { ; } return true; } public final String getName() { return "Done"; } }); } public final void destroy() { _facade.disposeWhenInactive(); _facade = null; super.destroy(); } private final void buildBox(FacadeInterface aFacade) { final GlyphInterface theLine = new Horizontal(10); pushWords(theLine); PathInterface thePath = new Path(); thePath.addOperation(new InsertGlyph(theLine,0)); aFacade.buildInit(thePath); aFacade.buildComplete(); } private final void pushWords(GlyphInterface aGlyph) { aGlyph.addChild(Atom.newAtom("It's")); aGlyph.addChild(Atom.newAtom("a")); aGlyph.addChild(Atom.newAtom("wonderful","style hot")); aGlyph.addChild(Atom.newAtom("life")); aGlyph.addChild(Atom.newAtom("!!")); } private final void initResources(FacadeInterface aFacade) { try { aFacade.doGetFont(Constants.DEFAULT_FONT,FontFamily.TIMES_ROMAN,FontStyle.PLAIN,15,false); aFacade.doGetColor(Constants.DEFAULT_COLOR,BasicColor.BLUE); aFacade.doGetColor(Constants.DEFAULT_BACKGROUND,BasicColor.WHITE); aFacade.doGetFont("big font",FontFamily.COURIER,FontStyle.BOLD,33,false); aFacade.doGetColor("yellow",BasicColor.YELLOW); aFacade.doGetColor("red",BasicColor.RED); aFacade.doGetStyle("style hot", aFacade.getFont("big font"), aFacade.getColor("red"), aFacade.getColor("yellow")); } catch ( WrongResourceException anException ) { ; } initStandardResources(aFacade); } private final FacadeInitializer getParameters() { FacadeInitializer theParameters = new FacadeInitializer(); setAppletParameters(theParameters); return theParameters; } private final void internalInit() { setLayout(new BorderLayout()); add(BorderLayout.NORTH,_facade.getAwtComponent()); setDefaultKeyListener(_facade); _textArea = new TextArea("",13,51,TextArea.SCROLLBARS_BOTH); _textArea.setFont(new java.awt.Font("Monospaced",java.awt.Font.PLAIN,13)); _textArea.setBackground(java.awt.Color.white); _textArea.setColumns(55); _textArea.setEditable(false); add(BorderLayout.CENTER,_textArea); validate(); } private AWTFacade _facade; private TextArea _textArea; }