//***************************************************************************** // 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.net.MalformedURLException; import java.net.URL; import figue.*; import figue.box.*; import figue.path.*; import figue.resource.*; public final class Tutorial_33 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_33.java,v $ $revision$ $Date: 1998/11/04 15:57:19 $ 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; _portableFont = null; _yellow = null; _blue = null; _red = null; super.destroy(); } private final void initResources() { try { _portableFont = _facade.doGetPortableFont(null,"laurass12",600,1.5); _red = _facade.doGetColor("red",BasicColor.RED); _yellow = _facade.doGetColor("yellow",BasicColor.YELLOW); _blue = _facade.doGetColor(null,0,0,255); _facade.doGetStyle("flashy",null,_red,null); } catch ( WrongResourceException anException ) { ; } initStandardResources(_facade); } private final void buildBox() { final GlyphInterface theContext = new ChangeGraphicalContextAnonymous(null,_blue,_yellow); final GlyphInterface theLine = new Paragraph(10,0,10); theContext.addChild(theLine); final StringBuffer theBuffer = new StringBuffer(); for ( int theRank = 255; theRank > 0 ; theRank-- ) { theBuffer.setLength(0); theBuffer.append(theRank).append(':'); theLine.addChild(Atom.newAtom(theBuffer.toString(),"flashy")); theBuffer.setLength(0); theBuffer.append((char)theRank); theLine.addChild(new Symbol(theBuffer.toString(),_portableFont)); } PathInterface thePath = new Path(); thePath.addOperation(new InsertGlyph(theContext,0)); _facade.buildInit(thePath); _facade.buildComplete(); } private final FacadeInitializer getParameters() { FacadeInitializer theParameters = new FacadeInitializer(); setAppletParameters(theParameters); try { final URL theCodeBaseUrl = getCodeBase(); theParameters.setPortableFontLibrary(new URL(theCodeBaseUrl,theCodeBaseUrl + "")); } catch ( MalformedURLException anException ) { anException.printStackTrace(); } return theParameters; } private AWTFacade _facade; private PortableFontInterface _portableFont; private ColorInterface _yellow; private ColorInterface _blue; private ColorInterface _red; }