//***************************************************************************** // 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.Button; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.Component; import java.awt.FlowLayout; import java.awt.Panel; import java.awt.Label; import figue.*; import figue.path.*; import figue.box.*; import figue.resource.*; public final class Tutorial_22 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_22.java,v $ $revision$ $Date: 1998/11/02 15:55:53 $ Copyright 1998 INRIA."; protected final void initTutorial() { setLayout(new BorderLayout()); Panel thePanel = new Panel(); thePanel.setLayout(new FlowLayout(FlowLayout.CENTER,10,5)); add(BorderLayout.NORTH,thePanel); _buttonStart = new Button("Start"); thePanel.add(_buttonStart); _buttonStart.setEnabled(true); _buttonStart.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { _buttonStart.setEnabled(false); final GlyphInterface theBox = buildBox(); PathInterface thePath = new Path(); thePath.addOperation(new InsertGlyph(theBox,0)); _facade.buildInit(thePath); _facade.buildComplete(); } }); add(BorderLayout.NORTH,thePanel); _facade = new AWTFacade(getParameters()); _component = _facade.getAwtComponent(); validate(); setDefaultKeyListener(_facade); add(BorderLayout.CENTER,_component); initResources(); } public final void destroy() { _facade.disposeWhenInactive(); _facade = null; super.destroy(); } private final GlyphInterface buildBox() { final double theTime = System.currentTimeMillis(); final GlyphInterface theGlyph = new Vertical(0,50); final GlyphInterface theContext = new ChangeGraphicalContextAnonymous("italic","blue",null); theContext.addChild(theGlyph); for ( int j = 0; j < 165; j++ ) { final GlyphInterface theLine = new Paragraph(10,0,10); theGlyph.addChild(theLine); for ( int i = 0; i < 50; i++ ) { theLine.addChild(Atom.newAtom("<" + j + "|" + i + ">")); theLine.addChild(Atom.newAtom("It's")); theLine.addChild(Atom.newAtom('a')); theLine.addChild(Atom.newAtom("wonderful","style hot")); theLine.addChild(Atom.newAtom("life","style hot")); theLine.addChild(Atom.newAtom("!!")); } } add(BorderLayout.SOUTH, new Label("Box construction time : " + (System.currentTimeMillis() - theTime) + " ms")); validate(); return theContext; } private final void initResources() { try { _facade.doGetFont("italic",FontFamily.TIMES_ROMAN,FontStyle.BOLD_ITALIC,12,false); _facade.doGetFont("big font",FontFamily.COURIER,FontStyle.BOLD,20,false); _facade.doGetColor("red",BasicColor.RED); _facade.doGetColor("yellow",BasicColor.YELLOW); _facade.doGetColor("blue",BasicColor.BLUE); _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(450); setAppletParameters(theParameters); return theParameters; } private AWTFacade _facade; private Component _component; private Button _buttonStart; }