Algorithm-VSM
view release on metacpan or search on metacpan
examples/corpus/SlideShowApplet.java view on Meta::CPAN
//SlideShowApplet.java
import javax.swing.*;
import java.awt.*; //for Graphics, Color, Dimension, etc.
import java.awt.event.*;
import java.net.*; //for URL needed for image loading
public class SlideShowApplet extends JApplet { //(B)
int frameIndex = 0; //current frame number
String dir; //directory relative to the codebase
Timer timer; //timer for sequencing through images
int pause; //time interval between images
int numImages; //number of images to display
int width; //width of the applet
int height; //height of the applet
int displayWidth;
int displayHeight;
JComponent contentPane; //the applet's content pane
ImageIcon images[]; //the images
boolean finishedLoading = false;
JLabel statusLabel;
examples/corpus/SlideShowApplet.java view on Meta::CPAN
newFrameAvailable = false;
}
};
contentPane.setBackground(Color.white); //(F)
setContentPane(contentPane);
statusLabel = new JLabel("Loading Images...", JLabel.CENTER);
statusLabel.setForeground( Color.red );
contentPane.add(statusLabel);
timer = new Timer( pause, new ActionListener() { //(G)
public void actionPerformed( ActionEvent evt ) {
frameIndex++; //(H)
if ( frameIndex == numImages )
frameIndex = 1;
newFrameAvailable = true;
contentPane.repaint();
}
});
timer.setInitialDelay( 0 );
timer.setCoalesce(false);
images = new ImageIcon[numImages]; //(I)
new Thread() { //(J)
public void run() {
loadImages();
}
}.start();
}
public void start() { //(K)
if ( finishedLoading )
timer.restart();
}
public void loadImages() { //(L)
String prefix = dir + "/flower";
for ( int i = 0; i < numImages; i++ ) {
statusLabel.setText( "loading image " + ( i + 1 ) );
try {
images[i] = //(M)
new ImageIcon( new URL( getCodeBase() +
prefix + (i+1) + ".jpg" ) );
} catch( MalformedURLException m ) {
System.out.println(
"Couldn't create image: badly formed URL" );
}
}
finishedLoading = true;
statusLabel.setText( null );
timer.start();
}
public void stop() { //(N)
timer.stop();
}
public String getAppletInfo() { //(O)
return "Title: A SlideShow Applet\n";
}
public String[][] getParameterInfo() { //(P)
String[][] info = {
{"dir",
"String",
examples/corpus_with_java_and_cpp/SlideShowApplet.java view on Meta::CPAN
//SlideShowApplet.java
import javax.swing.*;
import java.awt.*; //for Graphics, Color, Dimension, etc.
import java.awt.event.*;
import java.net.*; //for URL needed for image loading
public class SlideShowApplet extends JApplet { //(B)
int frameIndex = 0; //current frame number
String dir; //directory relative to the codebase
Timer timer; //timer for sequencing through images
int pause; //time interval between images
int numImages; //number of images to display
int width; //width of the applet
int height; //height of the applet
int displayWidth;
int displayHeight;
JComponent contentPane; //the applet's content pane
ImageIcon images[]; //the images
boolean finishedLoading = false;
JLabel statusLabel;
examples/corpus_with_java_and_cpp/SlideShowApplet.java view on Meta::CPAN
newFrameAvailable = false;
}
};
contentPane.setBackground(Color.white); //(F)
setContentPane(contentPane);
statusLabel = new JLabel("Loading Images...", JLabel.CENTER);
statusLabel.setForeground( Color.red );
contentPane.add(statusLabel);
timer = new Timer( pause, new ActionListener() { //(G)
public void actionPerformed( ActionEvent evt ) {
frameIndex++; //(H)
if ( frameIndex == numImages )
frameIndex = 1;
newFrameAvailable = true;
contentPane.repaint();
}
});
timer.setInitialDelay( 0 );
timer.setCoalesce(false);
images = new ImageIcon[numImages]; //(I)
new Thread() { //(J)
public void run() {
loadImages();
}
}.start();
}
public void start() { //(K)
if ( finishedLoading )
timer.restart();
}
public void loadImages() { //(L)
String prefix = dir + "/flower";
for ( int i = 0; i < numImages; i++ ) {
statusLabel.setText( "loading image " + ( i + 1 ) );
try {
images[i] = //(M)
new ImageIcon( new URL( getCodeBase() +
prefix + (i+1) + ".jpg" ) );
} catch( MalformedURLException m ) {
System.out.println(
"Couldn't create image: badly formed URL" );
}
}
finishedLoading = true;
statusLabel.setText( null );
timer.start();
}
public void stop() { //(N)
timer.stop();
}
public String getAppletInfo() { //(O)
return "Title: A SlideShow Applet\n";
}
public String[][] getParameterInfo() { //(P)
String[][] info = {
{"dir",
"String",
( run in 1.026 second using v1.01-cache-2.11-cpan-49f99fa48dc )