📄 import.java
字号:
/*
* DisplayList.java
* Examples
*
* Created by Stuart MacKay on Tue May 13 2003.
* Copyright (c) 2001-2006 Flagstone Software Ltd. All rights reserved.
*
* This code is distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND Flagstone HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING
* WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
*/
package com.flagstone.transform.examples;
import com.flagstone.transform.*;
import java.util.*;
/*
* The DisplayList class illustrates how to use the classes that update and change
* the Flash Player's display list.
*
* To run this example, type the following on a command line:
*
* java DisplayList [--resultDir path]
*
* where
*
* resultDir is the directory where the Flash file generated by the example is
* written to.
*
*/
public class Import extends Example
{
public static void main(String[] args)
{
new Import(args);
}
public Import(String[] args)
{
super(args);
createMovie();
writeFile("Import.swf");
}
public void createMovie()
{
int fontSize = 240;
int leading = 80;
ArrayList characters = new ArrayList();
ArrayList lines = new ArrayList();
characters.add(new FSCharacter(1, 120)); // 'a'
characters.add(new FSCharacter(0, 120)); // ' '
characters.add(new FSCharacter(19, 120)); // 's'
characters.add(new FSCharacter(20, 120)); // 't'
characters.add(new FSCharacter(18, 120)); // 'r'
characters.add(new FSCharacter(9, 120)); // 'i'
characters.add(new FSCharacter(14, 120)); // 'n'
characters.add(new FSCharacter(7, 120)); // 'g'
// Create the string setting the height to be 12-point (240 twips) and displaying the characters in black.
// the text is not indented or offset.
lines.add(new FSText(1, FSColorTable.black(), 0, 0, 240, characters));
// Calculate the bounding rectangle that encloses the text.
// The width of the text by summing all the advances.
int textWidth = 0;
int textHeight = fontSize + leading;
for (Iterator i = characters.iterator(); i.hasNext();)
textWidth += ((FSCharacter)i.next()).getAdvance();
FSBounds bounds = new FSBounds(0, 0, textWidth, textHeight);
// Define the text with no coordinate transformation (use the default unity transform which leaves
// the text unchanged.
FSDefineText text = new FSDefineText(2, bounds, new FSCoordTransform(), lines);
movie.setFrameRate(2.0f);
movie.setFrameSize(new FSBounds(0, 0, 5000, 3600));
movie.add(new FSSetBackgroundColor(FSColorTable.lightblue()));
movie.add(new FSImport("hybridfont.swf", 1, "VerdanaExport"));
movie.add(text);
movie.add(new FSPlaceObject2(text.getIdentifier(), 1, 1000 , 1000));
movie.add(new FSShowFrame());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -