private int parseRegionLength(String length, boolean horizontal) { if (length.endsWith("px")) { length = length.substring(0, length.indexOf("px")); return Integer.parseInt(length); } else if (length.endsWith("%")) { double value = 0.01*Integer.parseInt(length.substring(0, length.length() - 1)); if (horizontal) { value *= ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getWidth(); } else { value *= ((SMILDocument) getOwnerDocument()).getLayout().getRootLayout().getHeight(); } return (int) Math.round(value); } else { return Integer.parseInt(length); } }
private static SMILRegionElement getRegion(SMILDocument document, PduPart part) { if (PartParser.isAudio(part)) return null; SMILRegionElement region = (SMILRegionElement) document.createElement("region"); if (PartParser.isText(part)) { region.setId("Text"); region.setTop(SmilUtil.ROOT_HEIGHT); region.setHeight(50); } else { region.setId("Image"); region.setTop(0); region.setHeight(SmilUtil.ROOT_HEIGHT); } region.setLeft(0); region.setWidth(SmilUtil.ROOT_WIDTH); region.setFit("meet"); return region; }
private static SMILMediaElement getMediaElement(SMILDocument document, PduPart part) { final String tag; if (PartParser.isImage(part)) { tag = "img"; } else if (PartParser.isAudio(part)) { tag = "audio"; } else if (PartParser.isVideo(part)) { tag = "video"; } else if (PartParser.isText(part)) { tag = "text"; } else { tag = "ref"; } return createMediaElement(tag, document, new String(part.getName() == null ? new byte[]{} : part.getName())); }
public static SMILDocument getDocument(PduBody pb) { // Find SMIL part in the message. PduPart smilPart = findSmilPart(pb); SMILDocument document = null; // Try to load SMIL document from existing part. if (smilPart != null) { document = getSmilDocument(smilPart); } if (document == null) { // Create a new SMIL document. document = createSmilDocument(pb); } return document; }
private static SMILDocument createSmilDocument(PduBody body) { Log.w(TAG, "Creating SMIL document from PduBody."); SMILDocument document = new SmilDocumentImpl(); SMILElement smilElement = (SMILElement) document.createElement("smil"); document.appendChild(smilElement); SMILElement headElement = (SMILElement) document.createElement("head"); smilElement.appendChild(headElement); SMILLayoutElement layoutElement = (SMILLayoutElement) document.createElement("layout"); headElement.appendChild(layoutElement); SMILRootLayoutElement rootLayoutElement = (SMILRootLayoutElement) document.createElement("root-layout"); rootLayoutElement.setWidth(ROOT_WIDTH); rootLayoutElement.setHeight(ROOT_HEIGHT); layoutElement.appendChild(rootLayoutElement); SMILElement bodyElement = (SMILElement) document.createElement("body"); smilElement.appendChild(bodyElement); SMILParElement par = (SMILParElement) document.createElement("par"); bodyElement.appendChild(par); for (int i=0; i<body.getPartsNum(); i++) { PduPart part = body.getPart(i); SMILRegionElement regionElement = getRegion(document, part); SMILMediaElement mediaElement = getMediaElement(document, part); if (regionElement != null) { ((SMILRegionMediaElement)mediaElement).setRegion(regionElement); layoutElement.appendChild(regionElement); } par.appendChild(mediaElement); } return document; }
@Override public SMILRegionElement getSmilRegion(SMILDocument document) { SMILRegionElement region = (SMILRegionElement) document.createElement("region"); region.setId("Image"); region.setLeft(0); region.setTop(0); region.setWidth(SmilUtil.ROOT_WIDTH); region.setHeight(SmilUtil.ROOT_HEIGHT); region.setFit("meet"); return region; }
@Override public SMILRegionElement getSmilRegion(SMILDocument document) { SMILRegionElement region = (SMILRegionElement) document.createElement("region"); region.setId("Text"); region.setLeft(0); region.setTop(SmilUtil.ROOT_HEIGHT); region.setWidth(SmilUtil.ROOT_WIDTH); region.setHeight(50); region.setFit("meet"); return region; }
public static SMILDocument createSmilDocument(SlideDeck deck) { Log.w(TAG, "Creating SMIL document from SlideDeck."); SMILDocument document = new SmilDocumentImpl(); SMILElement smilElement = (SMILElement) document.createElement("smil"); document.appendChild(smilElement); SMILElement headElement = (SMILElement) document.createElement("head"); smilElement.appendChild(headElement); SMILLayoutElement layoutElement = (SMILLayoutElement) document.createElement("layout"); headElement.appendChild(layoutElement); SMILRootLayoutElement rootLayoutElement = (SMILRootLayoutElement) document.createElement("root-layout"); rootLayoutElement.setWidth(ROOT_WIDTH); rootLayoutElement.setHeight(ROOT_HEIGHT); layoutElement.appendChild(rootLayoutElement); SMILElement bodyElement = (SMILElement) document.createElement("body"); smilElement.appendChild(bodyElement); SMILParElement par = (SMILParElement) document.createElement("par"); bodyElement.appendChild(par); for (Slide slide : deck.getSlides()) { SMILRegionElement regionElement = slide.getSmilRegion(document); SMILMediaElement mediaElement = slide.getMediaElement(document); if (regionElement != null) { ((SMILRegionMediaElement)mediaElement).setRegion(regionElement); layoutElement.appendChild(regionElement); } par.appendChild(mediaElement); } return document; }
private void validateDocument(SMILDocument doc) { /* * Calling getBody() will create "smil", "head", and "body" elements if they * are not present. It will also initialize the SequentialTimeElementContainer * member of SMILDocument, which could not be set on creation of the document. * @see com.android.mms.dom.smil.SmilDocumentImpl#getBody() */ doc.getBody(); /* * Calling getLayout() will create "layout" element if it is not present. * @see com.android.mms.dom.smil.SmilDocumentImpl#getLayout() */ doc.getLayout(); }
public static SMILParElement addPar(SMILDocument document) { SMILParElement par = (SMILParElement) document.createElement("par"); // Set duration to eight seconds by default. par.setDur(8.0f); document.getBody().appendChild(par); return par; }
public static SMILMediaElement createMediaElement( String tag, SMILDocument document, String src) { SMILMediaElement mediaElement = (SMILMediaElement) document.createElement(tag); mediaElement.setSrc(escapeXML(src)); return mediaElement; }
private SlideshowModel ( LayoutModel layouts, ArrayList<SlideModel> slides, SMILDocument documentCache, PduBody pbCache, Context context) { mLayout = layouts; mSlides = slides; mContext = context; mDocumentCache = documentCache; mPduBodyCache = pbCache; for (SlideModel slide : mSlides) { increaseMessageSize(slide.getSlideSize()); slide.setParent(this); } }
private static SMILMediaElement createMediaElement(String tag, SMILDocument document, String src) { SMILMediaElement mediaElement = (SMILMediaElement) document.createElement(tag); mediaElement.setSrc(escapeXML(src)); return mediaElement; }
@Override public SMILMediaElement getMediaElement(SMILDocument document) { return SmilUtil.createMediaElement("video", document, new String(getPart().getName())); }
@Override public SMILRegionElement getSmilRegion(SMILDocument document) { return null; }