⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fsshapeconstructortest.java

📁 利用opensource的开源jar实现生成flash文件
💻 JAVA
字号:
package com.flagstone.transform.test;

import java.io.*;

import com.flagstone.transform.*;
import com.flagstone.transform.util.*;

public class FSShapeConstructorTest
{
    private File destDir = null;
    
    public FSShapeConstructorTest()
    {
    }
    /**
     * @testng.configuration beforeTest = "true" alwaysRun = "true" 
     * @testng.parameters value = "dstDir"
     */
    public void configure(String dstDir)
    {
        destDir = new File(dstDir);
    }
	/**
     * @testng.test
	 */
    public void basicShapes()
    {
        try 
        {
            File dstFile = new File(destDir, "BasicShapes.swf");
            
            if (destDir.exists() == false)
                assert destDir.mkdirs() : "Count not create directory: "+destDir;

            FSShapeConstructor path = new FSShapeConstructor();
            FSMovie movie = new FSMovie();
            
            path.COORDINATES_ARE_PIXELS = true;
            
            int width = 150;
            int height = 100;
            int cornerRadius = 10;
            
            int identifier = 0;
            
            path.add(new FSSolidLine(20, FSColorTable.black()));
            path.add(new FSSolidFill(FSColorTable.red()));
            
            movie.setFrameRate(1.0f);
            movie.setFrameSize(new FSBounds(-4000, -4000, 4000, 4000));
            movie.add(new FSSetBackgroundColor(FSColorTable.lightblue()));
            
            identifier = movie.newIdentifier();
            
            path.selectStyle(0, 0);
            path.rect(width/2, -height/2, width, height);
            movie.add(path.defineShape(identifier));
            movie.add(new FSPlaceObject2(identifier, 1, 0, 0));
            movie.add(new FSShowFrame());
            
            /*
             * Draw a rectangle with rounded corners
             */
            identifier = movie.newIdentifier();

            path.newPath();
            path.selectStyle(0, 0);
            path.rect(width/2, height/2, width, height, cornerRadius);
            movie.add(path.defineShape(identifier));
            movie.add(new FSPlaceObject2(identifier, 1));
            movie.add(new FSShowFrame());

            /*
             * Draw a circle
             */
            identifier = movie.newIdentifier();

            path.newPath();
            path.selectStyle(0, 0);
            path.circle(-width/2, height/2, height/2);
            movie.add(path.defineShape(identifier));
            movie.add(new FSPlaceObject2(identifier, 1));
            movie.add(new FSShowFrame());
            
            /*
             * Draw a elipse
             */
            identifier = movie.newIdentifier();

            path.newPath();
            path.selectStyle(0, 0);
            path.ellipse(-width/2, -height/2, width/2, height/2);
            movie.add(path.defineShape(identifier));
            movie.add(new FSPlaceObject2(identifier, 1));
            movie.add(new FSShowFrame());
            
            /*
             * Draw a polyline
             */
            identifier = movie.newIdentifier();

            int[] points = new int[] { 
                0, -100, 
                10, 0, 
                0, 90, 
                90, 0, 
                0, 20,
                -90, 0,
                0, 90,
                -20, 0,
                0, -90,
                -90, 0,
                0, -20,
                90, 0,
                0, -90,
                10, 0
            };

            path.newPath();
            path.selectStyle(0, 0);
            path.polygon(points);
            movie.add(path.defineShape(identifier));
            movie.add(new FSPlaceObject2(identifier, 1));
            movie.add(new FSShowFrame());
            
            /*
             * Draw a cubic bezier curve
             */
            identifier = movie.newIdentifier();

            path.newPath();
            path.selectStyle(0, 0);
            path.curve(0, -100, 150, -100, 150, 0);
            path.closePath();
            movie.add(path.defineShape(identifier));
            movie.add(new FSPlaceObject2(identifier, 1));
            movie.add(new FSShowFrame());
    
            movie.encodeToFile(dstFile.getPath());
        }
        catch (Exception e)
        {
            assert false;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -