shape.setEdgeBounds(bounds);
FillStyleArray fillStyles = new FillStyleArray();
LineStyleArray lineStyles = new LineStyleArray();
Styles styles = new Styles(fillStyles, lineStyles);
ShapeWithStyle shapeWithStyle = new ShapeWithStyle(styles);
shape.setShapes(shapeWithStyle);
// translate into source bitmap
Matrix tsm = new Matrix();
// unity in twips
tsm.setScale(ISWFConstants.TWIPS_PER_PIXEL, ISWFConstants.TWIPS_PER_PIXEL);
// 9 identical fillstyles to fool things
// not sure why this is needed, and why we're indexing into
// the into, as the values are identical. Was ported over from hero.
for (int i = 0; i < 9; ++i)
{
FillStyle fs = new FillStyle();
fs.setBitmapCharacter(image);
fs.setBitmapMatrix(tsm);
fs.setFillStyleType(FillStyle.NON_SMOOTHED_REPEATING_BITMAP);
fillStyles.add(fs);
}
int slt = r.xMin();
int srt = r.xMax();
int stt = r.yMin();
int sbt = r.yMax();
int dxa = slt;
int dxb = srt - slt;
int dxc = width - srt;
int dya = stt;
int dyb = sbt - stt;
int dyc = height - sbt;
StyleChangeRecord startStyle = new StyleChangeRecord();
startStyle.setMove(0, dya);
shapeWithStyle.addShapeRecord(startStyle);
// border
addEdgesWithFill(styles, shapeWithStyle, new int[][] { {0, -dya}, {dxa, 0}}, 0, 1);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{dxb, 0}}, 0, 2);
addEdgesWithFill(styles, shapeWithStyle, new int[][] { {dxc, 0}, {0, dya}}, 0, 3);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{0, dyb}}, 0, 6);
addEdgesWithFill(styles, shapeWithStyle, new int[][] { {0, dyc}, {-dxc, 0}}, 0, 9);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{-dxb, 0}}, 0, 8);
addEdgesWithFill(styles, shapeWithStyle, new int[][] { {-dxa, 0}, {0, -dyc}}, 0, 7);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{0, -dyb}}, 0, 4);
// down 1
StyleChangeRecord down1Style = new StyleChangeRecord();
down1Style.setMove(dxa, 0);
shapeWithStyle.addShapeRecord(down1Style);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{0, dya}}, 2, 1);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{0, dyb}}, 5, 4);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{0, dyc}}, 8, 7);
// down 2
StyleChangeRecord down2Style = new StyleChangeRecord();
down2Style.setMove(dxa + dxb, 0);
shapeWithStyle.addShapeRecord(down2Style);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{0, dya}}, 3, 2);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{0, dyb}}, 6, 5);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{0, dyc}}, 9, 8);
// right 1
StyleChangeRecord right1Style = new StyleChangeRecord();
right1Style.setMove(0, dya);
shapeWithStyle.addShapeRecord(right1Style);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{dxa, 0}}, 1, 4);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{dxb, 0}}, 2, 5);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{dxc, 0}}, 3, 6);
// right 2
StyleChangeRecord right2Style = new StyleChangeRecord();
right2Style.setMove(0, dya + dyb);
shapeWithStyle.addShapeRecord(right2Style);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{dxa, 0}}, 4, 7);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{dxb, 0}}, 5, 8);
addEdgesWithFill(styles, shapeWithStyle, new int[][] {{dxc, 0}}, 6, 9);
return shape;