?? buildsmillabel.java
字號:
package com.talkweb.micp.icsp.parse;
import org.kxml.kdom.Element;
import org.kxml.Attribute;
import java.util.Vector;
import com.talkweb.micp.twsmil.*;
/**
* BuildSmilLabel.java
* <p>標題: 建立SMIL標簽對象</p>
* <p>描述: 根據SMIL標簽元素建立標簽對象并設置其相關的屬性值</p>
* <p>版權: Copyright (c) 2006</p>
* <p>公司: 湖南拓維信息系統股份有限公司</p>
* 作者: 郭勇華
* 版本: 1.0
*/
public class BuildSmilLabel {
/**
* 得到其相關的SMIL標簽對象
* @param smilElement Element SMIL文檔元素
* @return Object smil標簽對象
*/
public static Object getSmilLabel(Element smilElement){
String smilLabel = smilElement.getName();
if (smilLabel.equals("img")){
return setImgLabel(smilElement) ;
}
else if(smilLabel.equals("audio")){
return setAudioLabel(smilElement);
}
else if(smilLabel.equals("meta")){
//return setRootLayoutLabel(smilElement);
}
else if(smilLabel.equals("root-layout")){
return setRootLayoutLabel(smilElement);
}
else if(smilLabel.equals("region")){
return setRegionLabel(smilElement);
}
return null ;
}
/**
* 設置IMG標簽的屬性值并放回其對象
* @param smilElement Element SMIL文檔元素
* @return ImgLabel 返回IMG標簽對象
*/
private static ImgLabel setImgLabel(Element smilElement){
ImgLabel label = new ImgLabel();
label.setId(smilElement.hashCode());
Vector vecAttr = smilElement.getAttributes() ; // 得到屬性的集合
for (int j=0 ; j<vecAttr.size(); j++){
Attribute aEle = (Attribute) vecAttr.elementAt(j) ;
if (aEle.getName().equals("name")){
label.setName(aEle.getValue());
}
else if (aEle.getName().equals("src")){
label.setSrc(aEle.getValue());
}
else if (aEle.getName().equals("end")){
label.setEnd(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("begin")){
label.setBegin(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("region")){
label.setRegion(aEle.getValue());
}
else if (aEle.getName().equals("dur")){
label.setDur(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("repeatcount")){
label.setRepeatCount(Short.parseShort(aEle.getValue()));
}
else if (aEle.getName().equals("repeatdur")){
label.setRepeatDur(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("fill")){
label.setFill(aEle.getValue());
}
}
return label ;
}
/**
* 設置AUDIO標簽的屬性值并放回其對象
* @param smilElement Element SMIL文檔元素
* @return AudioLabel 返回AUDIO標簽對象
*/
private static AudioLabel setAudioLabel(Element smilElement){
AudioLabel label = new AudioLabel();
label.setId(smilElement.hashCode());
Vector vecAttr = smilElement.getAttributes() ; // 得到屬性的集合
for (int j=0 ; j<vecAttr.size(); j++){
Attribute aEle = (Attribute) vecAttr.elementAt(j) ;
if (aEle.getName().equals("name")){
label.setName(aEle.getValue());
}
else if (aEle.getName().equals("src")){
label.setSrc(aEle.getValue());
}
else if (aEle.getName().equals("end")){
label.setEnd(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("begin")){
label.setBegin(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("region")){
label.setRegion(aEle.getValue());
}
else if (aEle.getName().equals("dur")){
label.setDur(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("repeatcount")){
label.setRepeatCount(Short.parseShort(aEle.getValue()));
}
else if (aEle.getName().equals("repeatdur")){
label.setRepeatDur(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("fill")){
label.setFill(aEle.getValue());
}
}
return label ;
}
/**
* 設置Region標簽的屬性值并放回其對象
* @param smilElement Element SMIL文檔元素
* @return RegionLabel 返回Region標簽對象
*/
private static RegionLabel setRegionLabel(Element smilElement){
RegionLabel label = new RegionLabel();
label.setId(smilElement.hashCode());
Vector vecAttr = smilElement.getAttributes() ; // 得到屬性的集合
for (int j=0 ; j<vecAttr.size(); j++){
Attribute aEle = (Attribute) vecAttr.elementAt(j) ;
if (aEle.getName().equals("id")){
label.setLabelId(aEle.getValue());
}
else if (aEle.getName().equals("z-index")){
label.setZIndex(Short.parseShort(aEle.getValue()));
}
else if (aEle.getName().equals("left")){
label.setLeft(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("height")){
label.setHeight(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("title")){
label.setTitle(aEle.getValue());
}
else if (aEle.getName().equals("top")){
label.setTop(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("width")){
label.setWidth(Short.parseShort(aEle.getValue()));
}
else if (aEle.getName().equals("backgroundColor")){
label.setBackgroundColor(aEle.getValue());
}
}
return label ;
}
/**
* 設置RootLayout標簽的屬性值并放回其對象
* @param smilElement Element SMIL文檔元素
* @return RootLayoutLabel 返回RootLayout標簽對象
*/
private static RootLayoutLabel setRootLayoutLabel(Element smilElement){
RootLayoutLabel label = new RootLayoutLabel();
label.setId(smilElement.hashCode());
Vector vecAttr = smilElement.getAttributes() ; // 得到屬性的集合
for (int j=0 ; j<vecAttr.size(); j++){
Attribute aEle = (Attribute) vecAttr.elementAt(j) ;
if (aEle.getName().equals("backgroundColor")){
label.setBackgroundColor(aEle.getValue());
}
else if (aEle.getName().equals("height")){
label.setHeight(Integer.parseInt(aEle.getValue()));
}
else if (aEle.getName().equals("width")){
label.setWidth(Short.parseShort(aEle.getValue()));
}
}
return label;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -