Revision: 4156 http://vexi.svn.sourceforge.net/vexi/?rev=4156&view=rev Author: clrg Date: 2011-06-22 00:45:49 +0000 (Wed, 22 Jun 2011)
Log Message: ----------- Make border, bar, and text colors customizable Modified Paths: -------------- trunk/org.vexi-launcher/meta/module.xml trunk/org.vexi-launcher/src/main/java/org/vexi/launcher/Launcher.java trunk/org.vexi-launcher/src/main/java/org/vexi/launcher/Splash.java trunk/org.vexi-launcher/src/test/java/org/vexi/launcher/TestLauncher.java trunk/org.vexi-launcher.vexi_org/src/main/java/org/vexi/launcher/VexiLauncher.java trunk/org.vexi-launcher.vexi_org/src/main/java/org/vexi/launcher/vexi_splash.png trunk/org.vexi-launcher.vexi_org/src/poke/java/poke/launcher/PokeSplash.java Modified: trunk/org.vexi-launcher/meta/module.xml =================================================================== --- trunk/org.vexi-launcher/meta/module.xml 2011-06-08 09:24:13 UTC (rev 4155) +++ trunk/org.vexi-launcher/meta/module.xml 2011-06-22 00:45:49 UTC (rev 4156) @@ -2,6 +2,8 @@ <artifact name="java_classes.jar" /> <dependencies> <system name="java.jre" tag="1.4"/> - <dependency source="local" name="library.crypto" /> + <dependency source="local" name="library.crypto" /> + <!-- Test Dependencies --> + <dependency source="local" name="library.testing" scope="test"/> </dependencies> </ebuild-module> Modified: trunk/org.vexi-launcher/src/main/java/org/vexi/launcher/Launcher.java =================================================================== --- trunk/org.vexi-launcher/src/main/java/org/vexi/launcher/Launcher.java 2011-06-08 09:24:13 UTC (rev 4155) +++ trunk/org.vexi-launcher/src/main/java/org/vexi/launcher/Launcher.java 2011-06-22 00:45:49 UTC (rev 4156) @@ -26,7 +26,8 @@ * @author m...@webenableit.co.uk * @contributor char...@webenableit.co.uk * - * <p>The launcher is responsible for downloading the vexi core + * <p>The launcher is responsible for downloading the Vexi Core + * and the principle application components (.vexi files) * and launching it as a separate process so that it can * exist and survive outside of the restrictive environment * that is imposed upon applets.</p> @@ -39,6 +40,9 @@ // the event that it is compromised we can update the copy on these // domains. In this way the fetching of the applet acts as the security // check. + abstract public Color getTextColor(); + abstract public Color getBorderColor(); + abstract public Color getBarColor(); abstract public URL getSplashImageResource(); abstract public String[] getPermittedDomains(); abstract public Map getCerts(); @@ -180,7 +184,7 @@ /** applet entry point - this is where it all begins */ public final void init() { - Splash.init(getVersion(),getSplashImageResource()); + Splash.init(getVersion(),getSplashImageResource(), getTextColor(), getBorderColor(), getBarColor()); initDotVexi(); // the rest is initialized outside of the restrictive applet sandbox @@ -201,14 +205,14 @@ } - private InputStream progressInputStream(InputStream is, final String displayname, final int contentLength ){ + private InputStream progressInputStream(InputStream is, final String displayname, final int contentLength ) { final String left = "Downloading: "+displayname; - final String right = fetchIndex+"/"+fetchCount; + final String right = fetchIndex+"/"+fetchCount; return new FilterInputStream(new BufferedInputStream(is)) { int total = 0; int percent = 0; - private void display(){ + private void display() { double loaded = ((double)total) / ((double)contentLength); int newpercent = ((int)Math.ceil(loaded * 100)); if (newpercent!=percent) { @@ -276,7 +280,6 @@ return r; } - /** fetches a file from the distribution site, writing it to the appropriate place */ public File fetch(String url) throws IOException { File localfile = dotvexi.getLocalFile(url); @@ -285,6 +288,7 @@ return localfile; } + /** attempts to create a local file for logging vexi output to */ protected File createLog(String logfile) throws IOException { File dir = dotvexi.findSubDir("logs"); dir.mkdirs(); @@ -455,7 +459,7 @@ BufferedReader br = new BufferedReader(isr); String line=null; while ((line = br.readLine()) != null) { - if(listenDisplay && line.contains("**display launched**")){ + if (listenDisplay && line.contains("**display launched**")) { Splash.close(); } log(type + ">" + line); @@ -473,7 +477,7 @@ final Font font = new Font("Sans-serif", Font.BOLD, 12); final private Object statusLock = new Object(); private String statusText; - private Color statusColor; + private Color statusColor; private Image backbuffer = null; /** controls the visual display of the applet @@ -488,7 +492,7 @@ protected void updateError(String statusText) { System.err.println("Error: "+statusText); updateStatus(statusText, Color.red); - } + } private void updateStatus(String statusText, Color statusColor) { synchronized (statusLock) { this.statusText = statusText; Modified: trunk/org.vexi-launcher/src/main/java/org/vexi/launcher/Splash.java =================================================================== --- trunk/org.vexi-launcher/src/main/java/org/vexi/launcher/Splash.java 2011-06-08 09:24:13 UTC (rev 4155) +++ trunk/org.vexi-launcher/src/main/java/org/vexi/launcher/Splash.java 2011-06-22 00:45:49 UTC (rev 4156) @@ -12,40 +12,51 @@ import java.awt.Toolkit; import java.awt.Window; import java.awt.image.BufferedImage; +import java.io.IOException; import java.net.URL; +/** + * + * @author Mike Goodwin + * + */ public class Splash { - static String version; - static SplashWindow instance; - static URL splashImage; - static private SplashWindow initFallback(){ + private static String version; + private static SplashWindow instance; + private static Color textcolor; + private static Color bordercolor; + private static Color barcolor; + static private SplashWindow initFallback() { return new Fallback(); } - static private SplashWindow initFast(){ + static private SplashWindow initFast() { SplashScreen splash = SplashScreen.getSplashScreen(); - if(splash==null){ + if (splash==null) { System.err.println("[warning] could not find fast splash screen, using old style"); return initFallback(); - }else{ + } else { return new Fast(splash); } } - - static public SplashWindow init(String version, URL splashImage){ + + static public SplashWindow init(String version, URL splashImage, Color textcolor, Color bordercolor, Color barcolor) { Splash.version = version; - Splash.splashImage = splashImage; - try{ + Splash.textcolor = textcolor; + Splash.bordercolor = bordercolor; + Splash.barcolor = barcolor; + try { Splash.class.getClassLoader().loadClass("java.awt.SplashScreen"); instance = initFast(); - }catch(ClassNotFoundException e){ + } catch (ClassNotFoundException e) { instance = initFallback(); } + instance.setImageURL(splashImage); return instance; } static final int MARGIN = 5; static final Font FONT = new Font("Sans-serif", Font.BOLD, 9); - static public void update(String statusLeft, String statusRight, double percent){ + static public void update(String statusLeft, String statusRight, double percent) { instance.update(statusLeft, statusRight, percent); } @@ -56,27 +67,28 @@ // c = c.darker(); // } // } - static void drawVersion(Graphics2D g){ + static void drawVersion(Graphics2D g) { // right justify int rightOffset = (int)FONT.getStringBounds(version, g.getFontRenderContext()).getWidth(); g.setFont(FONT); - g.setColor(Color.DARK_GRAY); + g.setColor(textcolor); g.drawString(version, 600-rightOffset-MARGIN, 240-MARGIN); } - static void draw(Graphics2D g, String statusLeft, String statusRight, double percent){ + static void draw(Graphics2D g, String statusLeft, String statusRight, double percent) { // drawVersion(g); // active area - g.setColor(Color.WHITE); - g.fillRect(45, 165, 510, 40); + //g.drawImage(background, 0, 0, Color.white, null); + //g.setColor(Color.white); + //g.fillRect(45, 165, 510, 40); // progress bar int w = (int)((double)5 * percent); - g.setColor(Color.green); + g.setColor(barcolor); g.fillRect(50, 188, w, 14); - g.setColor(Color.darkGray); + g.setColor(bordercolor); g.drawRect(49, 187, 501, 15); // right justify @@ -84,47 +96,65 @@ // status text g.setFont(FONT); - g.setColor(Color.DARK_GRAY); + g.setColor(textcolor); g.drawString(statusLeft, 50, 183); g.drawString(statusRight, 550-rightOffset, 183); } - static public void close(){ instance.close(); } + static public void close() { instance.close(); } static interface SplashWindow { + public void setImageURL(URL imageURL); public void update(String statusLeft, String statusRight, double percent); public void close(); } - static class Fast implements SplashWindow{ + /** + * <p>A splash screen that uses Java 1.6's default + * splash implementation.</p> + */ + static class Fast implements SplashWindow { final Graphics2D graphics; final SplashScreen splash; - public Fast(SplashScreen splash){ + public Fast(SplashScreen splash) { this.splash = splash; this.graphics = splash.createGraphics(); drawVersion(graphics); } - public void update(String statusLeft, String statusRight, double percent){ + public void setImageURL(URL imageURL) { + try { + splash.setImageURL(imageURL); + } catch (IOException e) { }; + } + public void update(String statusLeft, String statusRight, double percent) { + splash.update(); draw(graphics, statusLeft, statusRight, percent); - splash.update(); } - public void close(){ SplashScreen.getSplashScreen().close(); } + public void close() { SplashScreen.getSplashScreen().close(); } } - static class Fallback extends Window implements SplashWindow{ + /** + * <p>A splash screen implemented using AWT for + * Java 1.5 or earlier.</p> + */ + static class Fallback extends Window implements SplashWindow { private Image buffer; + private Image background; private int imgWidth, imgHeight; private static final int BORDERSIZE = 0; public Fallback() { super(new Frame()); - buffer = loadSplashImage(); + } + + public void setImageURL(URL splashImage) { + buffer = loadSplashImage(splashImage); showSplashScreen(); } - private Image loadSplashImage() { + private Image loadSplashImage(URL splashImage) { MediaTracker tracker = new MediaTracker(this); - Image background = Toolkit.getDefaultToolkit().getImage(splashImage); + background = Toolkit.getDefaultToolkit().getImage(splashImage); try { tracker.addImage(background, 0); tracker.waitForAll(); @@ -132,14 +162,12 @@ imgWidth = background.getWidth(this); imgHeight = background.getHeight(this); - -// Image buffer = createImage(imgWidth, imgHeight); Image buffer = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB); - Graphics2D graphics = (Graphics2D)buffer.getGraphics(); - graphics.drawImage(background, 0, 0, Color.white, null); - drawVersion(graphics); + Graphics2D g = (Graphics2D)buffer.getGraphics(); + g.drawImage(background, 0, 0, Color.white, null); + drawVersion(g); return buffer; - }catch (Exception e) { + } catch (Exception e) { throw new Error(e); } } @@ -156,15 +184,17 @@ } public void paint(Graphics g) { - synchronized(buffer){ + synchronized (buffer) { g.drawImage(buffer, BORDERSIZE, BORDERSIZE, imgWidth, imgHeight, this); - } + } } public void update(String statusLeft, String statusRight, double percent) { - synchronized(buffer){ + synchronized (buffer) { Graphics2D g = (Graphics2D)buffer.getGraphics(); + g.drawImage(background, 0, 0, Color.white, null); + drawVersion(g); draw(g, statusLeft, statusRight, percent); } repaint(); Modified: trunk/org.vexi-launcher/src/test/java/org/vexi/launcher/TestLauncher.java =================================================================== --- trunk/org.vexi-launcher/src/test/java/org/vexi/launcher/TestLauncher.java 2011-06-08 09:24:13 UTC (rev 4155) +++ trunk/org.vexi-launcher/src/test/java/org/vexi/launcher/TestLauncher.java 2011-06-22 00:45:49 UTC (rev 4156) @@ -1,5 +1,6 @@ package org.vexi.launcher; +import java.awt.Color; import java.net.URL; import java.util.Map; @@ -10,6 +11,9 @@ public void testCheckUrls(){ Launcher l = new Launcher(){ + public Color getTextColor() { return null; } + public Color getBorderColor() { return null; } + public Color getBarColor() { return null; } public URL getSplashImageResource() { return null; } public String[] getPermittedDomains() { return new String[]{"localhost"}; } public Map getCerts() { return null; } @@ -21,6 +25,9 @@ public void testCheckUrlsSubdomain(){ Launcher l = new Launcher(){ + public Color getTextColor() { return null; } + public Color getBorderColor() { return null; } + public Color getBarColor() { return null; } public URL getSplashImageResource() { return null; } public String[] getPermittedDomains() { return new String[]{"emanate5.com"}; } public Map getCerts() { return null; } Modified: trunk/org.vexi-launcher.vexi_org/src/main/java/org/vexi/launcher/VexiLauncher.java =================================================================== --- trunk/org.vexi-launcher.vexi_org/src/main/java/org/vexi/launcher/VexiLauncher.java 2011-06-08 09:24:13 UTC (rev 4155) +++ trunk/org.vexi-launcher.vexi_org/src/main/java/org/vexi/launcher/VexiLauncher.java 2011-06-22 00:45:49 UTC (rev 4156) @@ -1,5 +1,6 @@ package org.vexi.launcher; +import java.awt.Color; import java.io.InputStream; import java.net.URL; import java.util.HashMap; @@ -9,7 +10,11 @@ import org.vexi.security.CryptoUtil; public class VexiLauncher extends Launcher { - public URL getSplashImageResource(){ + public Color getTextColor() { return Color.black; } + public Color getBorderColor() { return Color.black; } + public Color getBarColor() { return Color.green; } + + public URL getSplashImageResource() { return getClass().getResource("vexi_splash.png"); } @@ -18,7 +23,7 @@ } public String[] getPermittedDomains() { - return new String[]{"localhost", "127.0.0.1", "vexi.org", "vexi.sourceforge.net", "emanate-project.org"}; + return new String[] { "localhost", "127.0.0.1", "vexi.org", "vexi.sourceforge.net", "emanate-project.org" }; } public Map getCerts() { Modified: trunk/org.vexi-launcher.vexi_org/src/main/java/org/vexi/launcher/vexi_splash.png =================================================================== (Binary files differ) Modified: trunk/org.vexi-launcher.vexi_org/src/poke/java/poke/launcher/PokeSplash.java =================================================================== --- trunk/org.vexi-launcher.vexi_org/src/poke/java/poke/launcher/PokeSplash.java 2011-06-08 09:24:13 UTC (rev 4155) +++ trunk/org.vexi-launcher.vexi_org/src/poke/java/poke/launcher/PokeSplash.java 2011-06-22 00:45:49 UTC (rev 4156) @@ -7,7 +7,7 @@ static public void main(String[] args) throws InterruptedException { VexiLauncher vl = new VexiLauncher(); - Splash.init(vl.getVersion(),vl.getSplashImageResource()); + Splash.init(vl.getVersion(),vl.getSplashImageResource(),vl.getTextColor(),vl.getBorderColor(),vl.getBarColor()); for(int i=0; i<=5; i++){ Thread.sleep(1000); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Simplify data backup and recovery for your virtual environment with vRanger. Installation's a snap, and flexible recovery options mean your data is safe, secure and there when you need it. Data protection magic? Nope - It's vRanger. Get your free trial download today. http://p.sf.net/sfu/quest-sfdev2dev _______________________________________________ Vexi-svn mailing list Vexi-svn@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/vexi-svn