[richfaces-svn-commits] JBoss Rich Faces SVN: r13991 - in trunk/samples/richfaces-demo/src/main: flash and 6 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Sun May 3 08:36:41 EDT 2009


Author: nbelaevski
Date: 2009-05-03 08:36:41 -0400 (Sun, 03 May 2009)
New Revision: 13991

Added:
   trunk/samples/richfaces-demo/src/main/flash/
   trunk/samples/richfaces-demo/src/main/flash/text.sc
   trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/mediaoutput/
   trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/mediaoutput/text.swf
   trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/examples/flashSampleDynamic.xhtml
Modified:
   trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaBean.java
   trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/common/components.properties
   trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/examples/jpegSample.xhtml
   trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/usage.xhtml
Log:
SWF Example

Added: trunk/samples/richfaces-demo/src/main/flash/text.sc
===================================================================
--- trunk/samples/richfaces-demo/src/main/flash/text.sc	                        (rev 0)
+++ trunk/samples/richfaces-demo/src/main/flash/text.sc	2009-05-03 12:36:41 UTC (rev 13991)
@@ -0,0 +1,14 @@
+#compile using http://www.swftools.org/
+
+.flash filename="text.swf"
+.font times "Times.swf"
+.text richfaces text="RichFaces" font=times size=200% color=blue
+.text mediaoutput text="mediaOutput" font=times size=100% color=red
+
+.frame 1
+        .put richfaces pin=center x=50 y=50 
+        .put mediaoutput pin=center x=50 y=50 alpha=25%
+.frame 200
+     .change richfaces rotate+=360 pin=center alpha=25% 
+     .change mediaoutput rotate-=360 pin=center alpha=100% 
+.end
\ No newline at end of file

Modified: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaBean.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaBean.java	2009-05-03 11:51:44 UTC (rev 13990)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaBean.java	2009-05-03 12:36:41 UTC (rev 13991)
@@ -3,26 +3,54 @@
 import java.awt.Graphics2D;
 import java.awt.image.BufferedImage;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.OutputStream;
+
 import javax.imageio.ImageIO;
 
 public class MediaBean {
 
 	public void paint(OutputStream out, Object data) throws IOException{
 		if (data instanceof MediaData) {
-			
-		MediaData paintData = (MediaData) data;
-		BufferedImage img = new BufferedImage(paintData.getWidth(),paintData.getHeight(),BufferedImage.TYPE_INT_RGB);
-		Graphics2D graphics2D = img.createGraphics();
-		graphics2D.setBackground(paintData.getBackground());
-		graphics2D.setColor(paintData.getDrawColor());
-		graphics2D.clearRect(0,0,paintData.getWidth(),paintData.getHeight());
-		graphics2D.drawLine(5,5,paintData.getWidth()-5,paintData.getHeight()-5);
-		graphics2D.drawChars(new String("RichFaces").toCharArray(),0,9,40,15);
-		graphics2D.drawChars(new String("mediaOutput").toCharArray(),0,11,5,45);
+
+			MediaData paintData = (MediaData) data;
+			BufferedImage img = new BufferedImage(paintData.getWidth(),paintData.getHeight(),BufferedImage.TYPE_INT_RGB);
+			Graphics2D graphics2D = img.createGraphics();
+			graphics2D.setBackground(paintData.getBackground());
+			graphics2D.setColor(paintData.getDrawColor());
+			graphics2D.clearRect(0,0,paintData.getWidth(),paintData.getHeight());
+			graphics2D.drawLine(5,5,paintData.getWidth()-5,paintData.getHeight()-5);
+			graphics2D.drawChars(new String("RichFaces").toCharArray(),0,9,40,15);
+			graphics2D.drawChars(new String("mediaOutput").toCharArray(),0,11,5,45);
+
+			ImageIO.write(img,"jpeg",out);
+
+		}
+	}
+
+	private void copy(InputStream in, OutputStream out) throws IOException {
+		byte[] buffer = new byte[2048];
+		int read;
 		
-		ImageIO.write(img,"jpeg",out);
+		while ((read = in.read(buffer)) != -1) {
+			out.write(buffer, 0, read);
+		}
+	}
+	
+	public void paintFlash(OutputStream out, Object data) throws IOException {
+		ClassLoader loader = Thread.currentThread().getContextClassLoader();
+		if (loader == null) {
+			loader = getClass().getClassLoader();
+		}
 		
+		InputStream stream = loader.getResourceAsStream("org/richfaces/demo/mediaoutput/text.swf");
+		if (stream != null) {
+			try {
+				copy(stream, out);
+				out.flush();
+			} finally {
+				stream.close();
+			}
 		}
 	}
 }
\ No newline at end of file

Modified: trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/common/components.properties
===================================================================
--- trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/common/components.properties	2009-05-03 11:51:44 UTC (rev 13990)
+++ trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/common/components.properties	2009-05-03 12:36:41 UTC (rev 13991)
@@ -60,7 +60,7 @@
 loadStyle=          ajaxResources,        Style,                /images/ico_common.gif,                 /images/cn_Style.gif,                    loadStyle.html,                                          jbossajax4jsf/freezone/docs/tlddoc/a4j/loadStyle.html,            jbossajax4jsf/freezone/docs/apidoc/org/ajax4jsf/taglib/ajax/LoadStyleTag.html,                          /richfaces/style.jsf
 keepAlive=          ajaxResources,        Keep Alive,           /images/ico_common.gif,                 /images/cn_KeepAlive.gif,                keepAlive.html,                                          jbossajax4jsf/freezone/docs/tlddoc/a4j/keepAlive.html,            jbossajax4jsf/freezone/docs/apidoc/org/ajax4jsf/taglib/html/jsp/KeepAliveTag.html,             /richfaces/keepAlive.jsf
 include=            ajaxOutput,           Include,              /images/ico_common.gif,                 /images/cn_include2.gif,                 include.html,                                            jbossajax4jsf/freezone/docs/tlddoc/a4j/include.html,              jbossajax4jsf/freezone/docs/apidoc/org/ajax4jsf/ajax/UIInclude.html,                           /richfaces/include.jsf
-mediaOutput=        ajaxOutput,           Media Output,         /images/ico_common.gif,                 /images/cn_MediaOutput.gif,              mediaOutput.html,                                        jbossajax4jsf/freezone/docs/tlddoc/a4j/mediaOutput.html,          jbossajax4jsf/freezone/docs/apidoc/org/ajax4jsf/ajax/resource/UIMediaOutput.html,              /richfaces/mediaOutput.jsf
+mediaOutput=        ajaxOutput,           Media Output,         /images/ico_common.gif,                 /images/cn_MediaOutput.gif,              mediaOutput.html,                                        jbossajax4jsf/freezone/docs/tlddoc/a4j/mediaOutput.html,          jbossajax4jsf/freezone/docs/apidoc/org/ajax4jsf/ajax/resource/UIMediaOutput.html,              /richfaces/mediaOutput.jsf, new
 outputPanel=        ajaxOutput,           Output Panel,         /images/ico_common.gif,                 /images/cn_OutputPanel.gif,              outputPanel.html,                                        jbossajax4jsf/freezone/docs/tlddoc/a4j/outputPanel.html,          jbossajax4jsf/freezone/docs/apidoc/org/ajax4jsf/ajax/UIAjaxOutputPanel.html,                   /richfaces/outputPanel.jsf
 repeat=             richDataIterators,    Repeat,               /images/ico_Repeat.gif,                 /images/cn_Repeat.gif,                   repeat.html,                                             jbossajax4jsf/freezone/docs/tlddoc/a4j/repeat.html,               jbossajax4jsf/freezone/docs/apidoc/org/ajax4jsf/ajax/repeat/UIRepeat.html,                     /richfaces/repeat.jsf
 htmlCommandLink=    ajaxMisc,             Html Command Link,    /images/ico_common.gif,                 /images/cn_HtmlCommandLink.gif,          htmlCommandLink.html,                                    jbossajax4jsf/freezone/docs/tlddoc/a4j/htmlCommandLink.html,      jbossajax4jsf/freezone/docs/apidoc/org/ajax4jsf/taglib/ajax/HtmlCommandLinkTag.html,   /richfaces/htmlCommandLink.jsf

Added: trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/mediaoutput/text.swf
===================================================================
(Binary files differ)


Property changes on: trunk/samples/richfaces-demo/src/main/resources/org/richfaces/demo/mediaoutput/text.swf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/examples/flashSampleDynamic.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/examples/flashSampleDynamic.xhtml	                        (rev 0)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/examples/flashSampleDynamic.xhtml	2009-05-03 12:36:41 UTC (rev 13991)
@@ -0,0 +1,36 @@
+<ui:composition xmlns="http://www.w3.org/1999/xhtml"
+	xmlns:ui="http://java.sun.com/jsf/facelets"
+	xmlns:h="http://java.sun.com/jsf/html"
+	xmlns:f="http://java.sun.com/jsf/core"
+	xmlns:a4j="http://richfaces.org/a4j"
+	xmlns:rich="http://richfaces.org/rich">
+
+
+	<p>SWF Movie:</p>
+
+	<a4j:loadScript src="resource:///org/richfaces/renderkit/html/js/swfobject.js" />
+
+	<a4j:outputPanel id="flashPanelDynamic">
+		
+		<a4j:mediaOutput element="a" id="swfLink" style="display: none;" cacheable="false" session="true"
+			createContent="#{mediaBean.paintFlash}" value="#{mediaData}" />
+
+		<a4j:outputPanel layout="block" id="myFlashContent" style="width: 200px; height: 200px">
+			<a href="http://www.adobe.com/go/getflashplayer">
+				<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
+			</a>
+		</a4j:outputPanel>
+
+		<script type="text/javascript">
+		var flashvars = {};
+		var params = {};
+		var attributes = {};
+		swfobject.embedSWF(#{rich:element('swfLink')}.href, "#{rich:clientId('myFlashContent')}", "200", "200", "9.0.0", false, flashvars, params, attributes);	
+		</script>
+
+	</a4j:outputPanel>
+
+	<br />
+	<br />
+
+</ui:composition>
\ No newline at end of file

Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/examples/jpegSample.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/examples/jpegSample.xhtml	2009-05-03 11:51:44 UTC (rev 13990)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/examples/jpegSample.xhtml	2009-05-03 12:36:41 UTC (rev 13991)
@@ -6,7 +6,8 @@
       xmlns:rich="http://richfaces.org/rich">
 			
 
-	<br/>
+	<p>Dynamically generated JPEG file:</p>
+
 	<a4j:mediaOutput element="img" cacheable="false" session="true"
 		createContent="#{mediaBean.paint}" value="#{mediaData}" mimeType="image/jpeg" />
 	<br/><br/>

Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/usage.xhtml	2009-05-03 11:51:44 UTC (rev 13990)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/mediaOutput/usage.xhtml	2009-05-03 12:36:41 UTC (rev 13991)
@@ -35,12 +35,20 @@
 				<div class="sample-container">
 
 					<ui:include src="/richfaces/mediaOutput/examples/jpegSample.xhtml"/>
+
+					<ui:include src="/richfaces/mediaOutput/examples/flashSampleDynamic.xhtml"/>
+
 					<ui:include src="/templates/include/sourceview.xhtml">
 						<ui:param name="sourcepath" value="/richfaces/mediaOutput/examples/jpegSample.xhtml"/>
-						<ui:param name="openlabel" value="View Source" />
+						<ui:param name="openlabel" value="View JPEG Example Source" />
 					</ui:include>
 				
 					<ui:include src="/templates/include/sourceview.xhtml">
+						<ui:param name="sourcepath" value="/richfaces/mediaOutput/examples/flashSampleDynamic.xhtml"/>
+						<ui:param name="openlabel" value="View SWF Example Source" />
+					</ui:include>
+
+					<ui:include src="/templates/include/sourceview.xhtml">
 						<ui:param name="sourcepath" value="/WEB-INF/src/org/richfaces/demo/media/MediaBean.java"/>
 						<ui:param name="openlabel" value="View MediaBean.java Source" />
 						<ui:param name="sourcetype" value="java" />




More information about the richfaces-svn-commits mailing list