?? dc.java
字號:
package SWF2SVG;
import java.awt.Font;
import java.awt.Polygon;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
public class dc{
public int inch;
public float d_x;
public float d_y;
public WMFToolkit cvtTool = new WMFToolkit();
Polygon poly = new Polygon();
short x;
short y;
short x2;
short y2;
short numChars;
short wOptions;
int selColor;
short w;
short h;
short lbhatch;
short lbstyle;
short numPoints;
String polyName;
String shapeName;
String tempBuffer;
String colorBuffer;
String currentFont;
byte[] textBuffer;
float fontHeight = 10;
short fontHeightShort = 10;
String this_one;
MetaRecord record;
String svgGraphic;
int fontWeight ;
boolean fontItalic;
int fontStyle ;
boolean fromSelect=false;
WMFHandleTable ht;
int recordIndex ;
DataInputStream parmStream;
public short logExtX;
public short logExtY;
public short logOrgX = 0;
public short logOrgY = 0;
public short devExtX;
public short devExtY;
boolean styleSet=false;
boolean drawFilled=false;
private int[] ncount;
short oldy;
short oldx;
Vector MetaRecordVector ;
Enumeration MetaRecordInfo;
String svg="";
public int penRed =0;
public int penGreen =0;
public int penBlue =0;
public int textRed =0;
public int textGreen =0;
public int textBlue =0;
String textColor = "000000";
String penColor = "000000";
String brushColor="000000";
List ls;
int i=0;
int j=0;
int k=0;
dc(List ls){
this.x=0;
this.y=0;
this.x2=0;
this.y2=0;
this.numChars=0;
this.wOptions=0;
this.ls=ls;
this.w=0;
this.h=0;
this.lbhatch=0;
this.lbstyle=0;
this.polyName="";
this.shapeName="";
this.colorBuffer="";
this.tempBuffer="";
this.currentFont= "Dialog";
this.svgGraphic="";
this.fontWeight=0;
drawFilled = false;
}
public void setstream( byte[] d){
ByteArrayInputStream b_in;
b_in = new ByteArrayInputStream(d);
parmStream = new DataInputStream(b_in);
}
public void addlist(Vector v){
this.MetaRecordVector=v;
}
public boolean getstyset(){
return styleSet;
}
public void setsvgGraphic(){
svgGraphic="";
}
public String change(){
MetaRecordInfo = MetaRecordVector.elements();
while(MetaRecordInfo.hasMoreElements()){
record = (MetaRecord) MetaRecordInfo.nextElement();
readrecord(record, false);
//處理每個記錄.同時對生成的svg圖片做出處理.
}
return svgGraphic;
}
public void readrecord( MetaRecord record,boolean fromSelect){
this.record=record;
// this.inch=1000;
setstream(record.getParm());
switch(record.getFunction()){
case 0x2fa: // create pen indirect
if (!fromSelect){
// System.out.println(" add pen indirect");
// ht.addObject(recordIndex,record );
// ls1.add(i, record);
// i++;
} else {
// System.out.println(" create pen indirect");
lbstyle = readInt(parmStream); //if 5 outline is off
x = readInt(parmStream);
y = readInt(parmStream);
selColor = readLong(parmStream);
cvtTool.setColors(selColor);
colorBuffer = cvtTool.getRGBColor( selColor);
penColor = colorBuffer;
/* if (styleSet){
svgGraphic = svgGraphic +" \n";
} else{
styleSet = true;
}*/
svgGraphic = svgGraphic + "stroke: #" + penColor + "stroke-width:#"+2+"\" > \n";
}
break;
case 0x2fc: //createBrushIndirect0x02FC
// System.out.println("createBrushIndirect");
if (!fromSelect){ // if not seleceting it, just add it to table
// ht.addObject(recordIndex,record );
// ls2.add(j, record);
// j++;
}
else{
lbstyle = readInt(parmStream);
selColor = readLong(parmStream);
lbhatch = readInt(parmStream);
cvtTool.setColors(selColor);
colorBuffer = cvtTool.getRGBColor( selColor);
// System.out.println("colorBuffer"+colorBuffer);
// System.out.print("color is"+colorBuffer);
brushColor=colorBuffer;
if (styleSet){
svgGraphic = svgGraphic +"</g> \n";
} else{
styleSet = true;
}
if (lbstyle > 0 ){
drawFilled = false;
svgGraphic = svgGraphic + "<g style = \"stroke: #" + brushColor + "\" > \n";
}
else{
drawFilled = true;
System.out.print("color is"+colorBuffer);
svgGraphic = svgGraphic + "<g style = \"fill: #" + brushColor + "\" > \n";
}
}
break;
case 0x2fb: //createFontIndirect
// System.out.println(" 創建字體");
if (!fromSelect){ // if not selecting it, just add it to table
// ht.addObject(recordIndex,record );
//ls3.add(k, record);
//k++;
} else{
fontHeightShort = readInt(parmStream);
fontHeight = fontHeightShort;
fontHeightShort = (short)fontHeight;
if (fontHeightShort < 0) {
fontHeightShort *= -1;
fontHeightShort = mapY(fontHeightShort);
}
else{
fontHeight = (fontHeight/inch);
fontHeight = (fontHeight*72);
fontHeightShort = (short)fontHeight;
if (fontHeightShort < 5){
fontHeightShort = 9;
}
}
x2 = readInt(parmStream); // width
y2 = readInt(parmStream); //esc
y2 = readInt(parmStream); // orientation
y2 = readInt(parmStream); //weight
fontWeight = y2;
textBuffer = new byte[1];
try{
parmStream.read(textBuffer);
}
catch(IOException e){ System.err.println(e);}
x = (short)textBuffer[0]; // italic
fontItalic = false;
if (x < 0){
fontItalic = true;
}
textBuffer = new byte[7];
try{
parmStream.read(textBuffer);
}
catch(IOException e){ System.err.println(e);}
tempBuffer = new String(textBuffer,0);
textBuffer = new byte[32]; // name of font
try{
parmStream.read(textBuffer);
}
catch(IOException e){ System.err.println(e);}
String str = new String( textBuffer );
tempBuffer = str ;
currentFont = "Dialog";
if (tempBuffer.startsWith("Courier")){
currentFont = "Courier";
//System.out.println("Courier");
}
else if (tempBuffer.startsWith("MS Sans Serif")) {
currentFont = "Dialog";
//System.out.println("Dialog");
}
else if (tempBuffer.startsWith("Arial")) {
currentFont = "Helvetica";
// System.out.println("Helvetica");//使用了
}
else if (tempBuffer.startsWith("Arial Narrow")) {
currentFont = "Helvetica";
}
else if (tempBuffer.startsWith("Arial Black")) {
currentFont = "Helvetica";
fontWeight = 700;
}
else if (tempBuffer.startsWith("Times New Roman")) {
currentFont = "TimesRoman";
// System.out.println("TimesRoman");//沒有使用
}
else if (tempBuffer.startsWith("Wingdings")) {
currentFont = "ZapfDingbats";
// System.out.println("ZapfDingbats");//沒有使用
}
if (fontItalic) {
fontStyle = Font.ITALIC;
if (fontWeight >= 700){ // bold + italic
fontStyle = 3;
}
}
else{
fontStyle = Font.PLAIN; // plain
if (fontWeight >= 700){ // bold
fontStyle = Font.BOLD;
}
}
// g.setFont(new Font (currentFont, fontStyle, fontHeightShort));
svgGraphic = svgGraphic + " <g>\n <desc> Java Font definition:" + currentFont + " " + fontWeight + "</desc> \n </g>\n";
}
break;
case 0x12d: //select object
// System.out.println("select object");
int windowInt = readInt(parmStream);
if (( windowInt & 0x80000000 ) != 0 ) // Stock Object
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -