ccsaver/ 0000755 0001750 0000144 00000000000 10062411261 013503 5 ustar nyergler users 0000000 0000000 ccsaver/.project 0000644 0001750 0000144 00000000556 10061614545 015171 0 ustar nyergler users 0000000 0000000
ccsaver
org.eclipse.jdt.core.javabuilder
org.eclipse.jdt.core.javanature
ccsaver/src/ 0000755 0001750 0000144 00000000000 10062402145 014273 5 ustar nyergler users 0000000 0000000 ccsaver/src/java/ 0000755 0001750 0000144 00000000000 10062411212 015207 5 ustar nyergler users 0000000 0000000 ccsaver/src/java/CcSaver.java 0000644 0001750 0000144 00000007100 10062405765 017416 0 ustar nyergler users 0000000 0000000 /*
* ccsaver
* copyright 2004, Nathan R. Yergler
* http://yergler.net/projects/ccsaver
* licensed under the GNU GPL
*
* Sample JDIC SaverBeans screen saver which displays random, Creative Commons
* licensed images.
*/
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.concurrent.ArrayBlockingQueue;
import javax.imageio.ImageIO;
import org.jdesktop.jdic.screensaver.ScreensaverSettings;
import org.jdesktop.jdic.screensaver.SimpleScreensaver;
/**
* @author Nathan R. Yergler
*/
public class CcSaver extends SimpleScreensaver {
private UrlTaskFactory taskFactory;
private ArrayBlockingQueue urlQueue;
public void init() {
// set up the timer for switching images
ScreensaverSettings settings = getContext().getSettings();
long interval = 30 * 1000;
try {
interval = Long.getLong(settings.getProperty("interval")).longValue() * 1000;
} catch (Exception e){
}
// instantiate the URL queue and retrieval timers
this.urlQueue = new ArrayBlockingQueue(10);
this.taskFactory = new UrlTaskFactory(interval, this.urlQueue);
// show the CC logo while we load up the first image
this.urlQueue.offer(this.loadImage("/cc.jpg"));
// create the first task
this.taskFactory.newTask(UrlTaskFactory.NOW);
} // init
public Image loadImage(String path) {
Image imageData = null;
try {
InputStream in = getClass().getResourceAsStream(path);
imageData = ImageIO.read(in);
in.close();
imageData.flush();
}
catch (IOException e) {
e.printStackTrace();
}
return imageData;
}
public Image loadImage(URL imageUrl) {
// Open composite image (can be created with Skinner)
Image compositeImage = null;
try {
InputStream in = imageUrl.openStream();
compositeImage = ImageIO.read( in );
in.close();
compositeImage.flush();
}
catch( IOException e ) {
e.printStackTrace();
}
return compositeImage;
} // loadImage
public void paint(Graphics g) {
Image currImage = null;
// see if there is a URL in the queue
if (this.urlQueue.isEmpty()) {
// no items exist, bail out
return;
}
Object qObj = this.urlQueue.remove();
if (qObj instanceof URL) {
// load the image to draw
currImage = loadImage((URL)qObj);
}
else
if (qObj instanceof Image) {
currImage = (Image)qObj;
}
else {
// not an Image or URL
return;
}
this.paintImage(g, currImage);
// schedule the next URL retrieval
this.taskFactory.newTask();
} // paint
public void paintImage(Graphics g, Image paintImage) {
Graphics2D g2 = (Graphics2D) g;
Component c = getContext().getComponent();
Dimension d = c.getSize();
// Clears the previously drawn image.
g2.setColor(Color.white);
g2.fillRect(0, 0, d.width, d.height);
// Creates the buffered image.
int w = d.width;
int h = d.height;
BufferedImage buffImg = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
Graphics2D gbi = buffImg.createGraphics();
gbi.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
// calculate the position of the image (currently centered)
int img_x = (w - paintImage.getWidth(null)) / 2;
int img_y = (h - paintImage.getHeight(null)) / 2;
((Graphics)gbi).drawImage(paintImage, img_x, img_y, null);
// Draws the buffered image.
g2.drawImage(buffImg, null, 0, 0);
} // paintImage
}
ccsaver/src/java/UrlSource.java 0000644 0001750 0000144 00000001230 10062332567 020010 0 ustar nyergler users 0000000 0000000 /*
* ccsaver
* copyright 2004, Nathan R. Yergler
* http://yergler.net/projects/ccsaver
* licensed under the GNU GPL
*
* UrlSource.java
* $Id:$
*/
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Random;
public abstract class UrlSource {
protected int MAX_ID=23044;
protected Random randNums = new Random();
public UrlSource() {
// stub constructor
super();
}
// nextUrlString: sub-classes must implement
protected abstract String nextUrlString();
public URL nextUrl() {
try {
return new URL(this.nextUrlString());
} catch (MalformedURLException e) {
return null;
}
} // nextUrl
} // UrlSource
ccsaver/src/java/UrlTimerTask.java 0000644 0001750 0000144 00000001534 10062332170 020450 0 ustar nyergler users 0000000 0000000 /*
* ccsaver
* copyright 2004, Nathan R. Yergler
* http://yergler.net/projects/ccsaver
* licensed under the GNU GPL
*
* UrlTimerTask.java
* $Id:$
* Implements a java.util.TimerTask sub-class which retrieves an image URL from a random
* source when called.
*/
import java.net.URL;
import java.util.Queue;
import java.util.Random;
import java.util.TimerTask;
public class UrlTimerTask extends TimerTask {
private Queue queue = null;
private UrlTaskFactory factory = null;
private Random randNums = new Random();
public UrlTimerTask(Queue queue, UrlTaskFactory factory) {
super();
this.queue = queue;
this.factory = factory;
}
public void run() {
URL imageURL;
imageURL = this.factory.sources[this.randNums.nextInt(this.factory.sources.length)].nextUrl();
// add the URL to the queue
this.queue.offer(imageURL);
}
}
ccsaver/src/java/UrlTaskFactory.java 0000644 0001750 0000144 00000003560 10062332461 021003 0 ustar nyergler users 0000000 0000000 /*
* ccsaver
* copyright 2004, Nathan R. Yergler
* http://yergler.net/projects/ccsaver
* licensed under the GNU GPL
*
* UrlTaskFactory.java
* $Id:$
* Factory class for UrlTimerTasks; manages a list of possible image sources, as well as
* references to the screen-savers URL queue.
*/
import java.util.Queue;
import java.util.Timer;
public class UrlTaskFactory {
public static final long NOW = 0;
public UrlSource[] sources;
private long interval = 1000;
private Timer timer = null;
private Queue urlQueue = null;
public UrlTaskFactory(long interval, Queue urlQueue) {
// store the constructor parameters
this.interval = interval;
this.urlQueue = urlQueue;
// create the timer
this.timer = new Timer();
// initialize the source list
// XXX we do this statically now, but is there a way to use introspection to instantiate all available sources?
this.sources = new UrlSource[1];
this.sources[0] = new OpenPhotoUrlSource();
}
// getInterval: return the current interval, in milliseconds
public long getInterval() {
return this.interval;
} // getInterval
// setInterval_msec: sets the interval to a new value, specified in milliseconds
public void setInterval_msec(long interval) {
this.interval = interval;
}
// setInterval_sec: sets the interval to a new value, specified in seconds
public void setInterval_sec(long interval) {
this.interval = interval * 1000;
}
// newTask: creates and schedules a task object, using the default interval
public void newTask() {
// defer to the more generalized newTask method (pass in default interval)
this.newTask(this.interval);
} // newTask
// newTask: creates and schedules a task object, using the specified interval
public void newTask(long scheduleInterval) {
this.timer.schedule(new UrlTimerTask(this.urlQueue, this), scheduleInterval);
} // newTask
} // UrlTaskFactory
ccsaver/src/java/OpenPhotoUrlSource.java 0000644 0001750 0000144 00000001122 10062332671 021640 0 ustar nyergler users 0000000 0000000 /*
* ccsaver
* copyright 2004, Nathan R. Yergler
* http://yergler.net/projects/ccsaver
* licensed under the GNU GPL
*
* OpenPhotoUrlSource.java
* $Id:$
* Generates image URLs from the OpenPhoto.net website.
*/
public class OpenPhotoUrlSource extends UrlSource {
// MAX_ID stores the number of images in OpenPhoto; this should probably be detected somehow
protected int MAX_ID=23044;
public String nextUrlString() {
return "http://legacy.openphoto.net/cgi-bin/image?image_id=" + String.valueOf(this.randNums.nextInt(this.MAX_ID)) + "&geometry=800x600&filters=&rotate=";
}
}
ccsaver/src/java/FreeMediaUrlSource.java 0000644 0001750 0000144 00000001107 10062333034 021543 0 ustar nyergler users 0000000 0000000 /*
* ccsaver
* copyright 2004, Nathan R. Yergler
* http://yergler.net/projects/ccsaver
* licensed under the GNU GPL
*
* FreeMediaUrlSource.java
* $Id:$
* Generates image URLs from the FreeMedia website; currently broken.
*/
public class FreeMediaUrlSource extends UrlSource {
protected int MAX_ID=23044;
protected String nextUrlString() {
// TODO: Implement FreeMedia specific retrieval
return "";
// return "http://legacy.openphoto.net/cgi-bin/image?image_id=" + String.valueOf(this.randNums.nextInt(this.MAX_ID)) + "&geometry=800x600&filters=&rotate=";
}
}
ccsaver/src/doc/ 0000755 0001750 0000144 00000000000 10061616363 015050 5 ustar nyergler users 0000000 0000000 ccsaver/src/doc/unix/ 0000755 0001750 0000144 00000000000 10061616363 016033 5 ustar nyergler users 0000000 0000000 ccsaver/src/doc/unix/README.txt 0000644 0001750 0000144 00000012453 10061616363 017536 0 ustar nyergler users 0000000 0000000 -------------------------------------------------------------------------------
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is
subject to license terms.
This program is free software; you can redistribute it and/or modify
it under the terms of the Lesser GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
-------------------------------------------------------------------------------
SaverBeans Screensaver Pack Unix README
---------------------------------------
Requirements:
* Administrator access
* lesstif (provides /usr/X11R6/lib/libXm.so)
Any version will do - you may need an older version if you don't
have glibc2.3; such is the case with Java Desktop System for example.
* xscreensaver (any version should do, 4-14 and greater is known to work)
* Java VM 1.5 Beta or higher (Get at http://java.sun.com/).
To Install:
* Edit Makefile and jdkhome and xscreensaverhome to valid directories
* Run 'make' to build the screensaver binaries for your platform
* In the future, there will be a 'make install' task (contributions welcome).
For now this has to be done manually:
* Copy files to the right directories.
Java Desktop System:
SCREENSAVER_BIN=/usr/lib/xscreensaver
SCREENSAVER_CONF=/usr/lib/xscreensaver/config
Solaris:
SCREENSAVER_BIN=/usr/openwin/lib/xscreensaver
SCREENSAVER_CONF=/usr/openwin/share/control-center-2.0/screensavers
Red Hat 9:
SCREENSAVER_BIN=/usr/X11R6/bin
SCREENSAVER_CONF=/usr/share/control-center/screensavers
Other platforms:
SCREENSAVER_BIN=(search for an xscreensaver, like apollonian)
SCREENSAVER_CONF=(search for a config file, like apollonian.xml)
Please check where your other screensavers are installed. You will
need root access to do this (RPM will be provided later)
1. Copy or symbolically link *.jar to SCREENSAVER_BIN
2. Copy *.xml to SCREENSAVER_CONF
3. For each screensaver, you will see two files, e.g.
bouncingline and bouncingline-bin. Copy or symbolically
link bouncingline and bouncingline-bin to SCREENSAVER_BIN
* Edit ~/.xscreensaver and add an entry for the screensaver. For
example, for BouncingLine, add the following to the programs section:
"Bouncing Line (Java)" /full/path/to/bouncingline -root \n\
(the bouncingline.bin, saverbeans-examples.jar saverbeans-api.jar files
must appear in the same directory)
NOTE: If you don't have a .xscreensaver file, go to your screensaver
preferences and adjust the settings of a screensaver. The file will
be created for you automatically.
* Make sure the Java Virtual Machine can be located by each screensaver
from the shell launched by the xscreensaver process.
The following sources will be checked for your Java Virtual Machine
(in order). See the screensaver wrapper script for more details.
At worst, you can always edit these scripts directly, but usually
editing ~/.xscreensaver and adding -jdkhome will suffice.
- -jdkhome parameter, if present (this parameter is also set by the
screensaver "Java Home" option in the control panel)
- $JAVA_HOME environment variable, if set
- `rpm -ql j2sdk`, if available
- `which java`, if found
- otherwise error
* Run xscreensaver-demo to test and select. Look for
"Bouncing Line (Java)". If it works, you should see a bouncing line
in the preview window. If not, look for an error message in stderr.
To Run:
* Go to screensaver settings - the new screensavers will appear there.
For a basic example, look for BouncingLine.
Release Notes:
* JDK 1.4 support is upcoming in a future release.
* If it does not work but you get no error, try running bouncingline
directly from the commandline and observe the output.
* If you get an error containing:
libjvm.so: cannot open shared object file: No such file or directory
Then the screensaver cannot find the JDK. Pass -jdkhome as
a parameter, pointing to a valid installation of J2SDK 1.5.0 or
greater.
* If you get the error:
Could not find class sun/awt/X11/XEmbeddedFrame
Exception in thread "main" java.lang.NoClassDefFoundError:
sun/awt/X11/XEmbeddedFrame
Then you're not using JDK 1.5. JDK 1.5 is currently required on
Linux/Solaris. See above for how to fix this (most likely with
-jdkhome)
* If you get the error:
java.lang.UnsupportedClassVersionError ...
(unsupported major.minor version)
Then you're not using JDK 1.5. JDK 1.5 is currently required on
Linux/Solaris. See above for how to fix this (most likely with
-jdkhome)
* If "Bouncing Line" does not appear, try restarting xscreensaver
(or log out and log back in):
pkill xscreensaver
xscreensaver -nosplash &
ccsaver/src/doc/win32/ 0000755 0001750 0000144 00000000000 10061616363 016012 5 ustar nyergler users 0000000 0000000 ccsaver/src/doc/win32/README.txt 0000644 0001750 0000144 00000003002 10061616363 017503 0 ustar nyergler users 0000000 0000000 -------------------------------------------------------------------------------
Copyright 2004 Sun Microsystems, Inc. All rights reserved. Use is
subject to license terms.
This program is free software; you can redistribute it and/or modify
it under the terms of the Lesser GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
-------------------------------------------------------------------------------
SaverBeans Screensaver Pack Windows README
------------------------------------------
Requirements:
* Administrator access, to copy screensaver to Windows system directory
* Windows ME or XP (may work on other versions of Windows as well)
* Java VM 1.4 or higher (Get at http://java.com/)
To Install:
* Copy all files in this directory (except for this README) to
your Windows system directory (e.g. c:\windows\system32).
To Run:
* Go to screensaver settings - the new screensavers will appear there.
For a basic example, look for BouncingLine.
ccsaver/src/conf/ 0000755 0001750 0000144 00000000000 10061615657 015235 5 ustar nyergler users 0000000 0000000 ccsaver/src/conf/ccsaver.xml 0000644 0001750 0000144 00000002631 10062065602 017375 0 ustar nyergler users 0000000 0000000
<_description>
Sample screensaver written as an exercise of long-rusty Java skills. Loads random Creative Commons
licensed images from the internet for your slide show viewing pleasure.
ccsaver/src/res/ 0000755 0001750 0000144 00000000000 10062402216 015063 5 ustar nyergler users 0000000 0000000 ccsaver/src/res/cc.jpg 0000644 0001750 0000144 00000021037 10062402216 016155 0 ustar nyergler users 0000000 0000000 JFIF ,, Created with The GIMP C !"$"$ C " L
!1AQa"2q #BRbr3$Ccs&4DSTU ? p T5O4
EpNSOiv[#YS/Oh&r;BR}Xщ%U˂K d~"
jKKⰦx,4|I[S)KZ*RI=Giޑt%wq
0;Nhl}I:tꖈȄJ-
nH'ēllF~OSPL[[%ڃl{ Sj4Jΰy9.\IeFLL6zfJa>˲qI:ZBY*9,U&gp[kR&ܭl=NYT1^+YZVRϔIo6!W`cso