?? tagwriter.java
字號:
if( hasFillStyle1 )
{
out.writeUBits( fillBits, fill1Index );
}
if( hasLineStyle )
{
out.writeUBits( lineBits, lineIndex );
}
moveXY = null;
fill0Index = -1;
fill1Index = -1;
lineIndex = -1;
}
}
protected void writeMoveXY( int moveX, int moveY ) throws IOException
{
int moveBits = OutStream.determineSignedBitSize( moveX );
int moveYBits = OutStream.determineSignedBitSize( moveY );
if( moveYBits > moveBits ) moveBits = moveYBits;
out.writeUBits( 5, moveBits );
out.writeSBits( moveBits, moveX );
out.writeSBits( moveBits, moveY );
}
protected void writeStyles( Vector styles ) throws IOException
{
int numStyles = (styles != null) ? styles.size() : 0;
if( numStyles < 0xff )
{
out.writeUI8( numStyles );
}
else
{
out.writeUI8( 0xff );
out.writeUI16( numStyles );
}
if( styles != null )
{
for( Enumeration enum = styles.elements();
enum.hasMoreElements(); )
{
Style style = (Style)enum.nextElement();
style.write( out, hasAlpha );
}
styles.removeAllElements();
}
}
}
protected static class MorphShapeImpl extends TagWriter.SWFShapeImpl
{
protected int edgeOffsetBase;
protected int edgeOffsetTarget;
protected int shapeCount;
protected int fillBitSize;
protected int lineBitSize;
protected int shapeStart;
public MorphShapeImpl( TagWriter writer ) throws IOException
{
super( writer, true, false );
fill0Index = -1;
fill1Index = -1;
lineIndex = -1;
shapeCount = 2;
this.out = writer.getOutStream();
edgeOffsetBase = (int)this.out.getCount();
this.out.writeUI32( 0 ); //edge offset - to be filled in later
}
public void done() throws IOException
{
if( ! initialStyles )
{
writeInitialStyles();
initialStyles = true;
}
this.out.writeUBits( 6, 0 ); //end record
this.out.flushBits();
if( shapeCount == 2 )
{
edgeOffsetTarget = (int)this.out.getCount();
fill0Index = -1;
fill1Index = -1;
lineIndex = -1;
moveXY = null;
outstandingChanges = true;
initialStyles = false;
shapeCount--;
return;
}
this.out.flush();
byte[] bytes = writer.bytes.toByteArray();
int edgeOffset = edgeOffsetTarget - edgeOffsetBase - 4;
byte[] offsetBytes = OutStream.uintTo4Bytes( edgeOffset );
bytes[ edgeOffsetBase ] = offsetBytes[0];
bytes[ edgeOffsetBase + 1 ] = offsetBytes[1];
bytes[ edgeOffsetBase + 2 ] = offsetBytes[2];
bytes[ edgeOffsetBase + 3 ] = offsetBytes[3];
writer.out = null;
writer.bytes = null;
writer.mTags.tag( writer.tagType, writer.longTag, bytes );
}
protected void writeInitialStyles() throws IOException
{
this.out.flushBits();
int fillCount = fillStyles.size()/2;
int lineCount = lineStyles.size()/2;
fillBitSize = OutStream.determineUnsignedBitSize( fillCount );
lineBitSize = OutStream.determineUnsignedBitSize( lineCount );
//--Write style definitions
if( shapeCount == 2 )
{
if( fillCount < 255 )
{
this.out.writeUI8( fillCount );
}
else
{
this.out.writeUI8( 255 );
this.out.writeUI16( fillCount );
}
for( Enumeration enum = fillStyles.elements(); enum.hasMoreElements(); )
{
FillStyle startStyle = (FillStyle)enum.nextElement();
FillStyle endStyle = (FillStyle)enum.nextElement();
FillStyle.writeMorphFillStyle( this.out, startStyle, endStyle );
}
if( lineCount < 255 )
{
this.out.writeUI8( lineCount );
}
else
{
this.out.writeUI8( 255 );
this.out.writeUI16( lineCount );
}
for( Enumeration enum = lineStyles.elements(); enum.hasMoreElements(); )
{
LineStyle startStyle = (LineStyle)enum.nextElement();
LineStyle endStyle = (LineStyle)enum.nextElement();
LineStyle.writeMorphLineStyle( this.out, startStyle, endStyle );
}
}
if( shapeStart == 0 ) shapeStart = (int)this.out.getCount();
this.out.writeUBits( 4, fillBitSize );
this.out.writeUBits( 4, lineBitSize );
}
protected void writeChangeRecord() throws IOException
{
boolean hasMoveTo = ( moveXY != null );
boolean hasFillStyle0 = fill0Index >= 0;
boolean hasFillStyle1 = fill1Index >= 0;
boolean hasLineStyle = lineIndex >= 0;
if( hasFillStyle0 || hasFillStyle1 || hasLineStyle || hasMoveTo )
{
this.out.writeUBits( 1, 0 ); //non-edge record
this.out.writeUBits( 1, 0 );
this.out.writeUBits( 1, hasLineStyle ? 1 : 0 );
this.out.writeUBits( 1, hasFillStyle1 ? 1 : 0 );
this.out.writeUBits( 1, hasFillStyle0 ? 1 : 0 );
this.out.writeUBits( 1, hasMoveTo ? 1 : 0 );
if( hasMoveTo )
{
int moveX = moveXY[0];
int moveY = moveXY[1];
int moveBits = OutStream.determineSignedBitSize( moveX );
int moveYBits = OutStream.determineSignedBitSize( moveY );
if( moveYBits > moveBits ) moveBits = moveYBits;
this.out.writeUBits( 5, moveBits );
this.out.writeSBits( moveBits, moveX );
this.out.writeSBits( moveBits, moveY );
}
if( hasFillStyle0 )
{
this.out.writeUBits( fillBitSize, fill0Index );
}
if( hasFillStyle1 )
{
this.out.writeUBits( fillBitSize, fill1Index );
}
if( hasLineStyle )
{
this.out.writeUBits( lineBitSize, lineIndex );
}
moveXY = null;
fill0Index = -1;
fill1Index = -1;
lineIndex = -1;
}
}
}
protected static class Font2ShapeImpl extends TagWriter.SWFShapeImpl
{
protected int flags;
protected int ascent;
protected int descent;
protected int leading;
protected int[] codes;
protected int[] advances;
protected Rect[] bounds;
protected int[] kernCodes1;
protected int[] kernCodes2;
protected int[] kernAdjustments;
public Font2ShapeImpl( TagWriter writer, int flags, int glyphCount,
int ascent, int descent, int leading,
int[] codes, int[] advances, Rect[] bounds,
int[] kernCodes1, int[] kernCodes2,
int[] kernAdjustments )
{
super( writer, glyphCount );
this.flags = flags;
this.ascent = ascent;
this.descent = descent;
this.leading = leading;
this.codes = codes;
this.advances = advances;
this.bounds = bounds;
this.kernCodes1 = kernCodes1;
this.kernCodes2 = kernCodes2;
this.kernAdjustments = kernAdjustments;
}
protected void finishFont() throws IOException
{
this.out = writer.getOutStream();
int glyphCount = glyphByteArrays.size();
boolean is32 = ( flags & FONT2_32OFFSETS ) != 0;
int offset = is32 ? (( glyphCount + 1 ) * 4) : (( glyphCount + 1 ) * 2);
for( int i = 0; i <= glyphCount; i++ )
{
if( is32 )
{
this.out.writeUI32( offset );
}
else
{
this.out.writeUI16( offset );
}
if( i < glyphCount )
{
offset += ((byte[])glyphByteArrays.elementAt( i )).length;
}
}
for( int i = 0; i < glyphCount; i++ )
{
this.out.write( (byte[])glyphByteArrays.elementAt( i ) );
}
boolean isWide = ( flags & FONT2_WIDECHARS ) != 0 || glyphCount > 256 ;
for( int i = 0; i < glyphCount; i++ )
{
if( isWide ) this.out.writeUI16( codes[i] );
else this.out.writeUI8( codes[i] );
}
if( ( flags & FONT2_HAS_LAYOUT ) != 0 )
{
this.out.writeSI16( (short)ascent );
this.out.writeSI16( (short)descent );
this.out.writeSI16( (short)leading );
for( int i = 0; i < glyphCount; i++ )
{
this.out.writeSI16( (short)advances[i] );
}
for( int i = 0; i < glyphCount; i++ )
{
bounds[i].write( this.out );
}
int kerningCount = (kernCodes1 != null ) ? kernCodes1.length : 0;
this.out.writeUI16( kerningCount );
for( int i = 0; i < kerningCount; i++ )
{
if( isWide )
{
this.out.writeUI16( kernCodes1[i] );
this.out.writeUI16( kernCodes2[i] );
this.out.writeSI16( (short)kernAdjustments[i] );
}
else
{
this.out.writeUI8 ( kernCodes1[i] );
this.out.writeUI8 ( kernCodes2[i] );
this.out.writeSI16( (short)kernAdjustments[i] );
}
}
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -