Images looping
Ok I am having major problems running this program.
I need the user to enter in the command line argument;
java ImageDiplay dog jpg 3meaning that the program will select dog1.jpg, dog2.jpg
and dog3.jpg put them in the images array and loop these pictures by showing each one at a time.
My problem is how do I assign each argument to the constructor to build the images name put them in the array. and then use the array to show the pics in an applet.
import java.awt.Toolkit;
import java.awt.Image;
import javax.swing.JFrame;
import java.awt.Graphics;
* This class loads a set of images and flips through them
public class ImageDisplay extends JFrame implements Runnable
protected Image[] images;
protected int current_image = 0;
* Read the basename and num_images parameters.
* Then read in the images, using the specified base name.
* For example, if basename is images/anim, read images/anim0,
* images/anim1, images/anim2, etc.
public ImageDisplay(String baseName, String fileType, int numPics)
super("ImageDisplay");
//add code here to load the pictures
//create a JFrame
//get basename
//get numPics
//add number to each imagename
Toolkit tKit = super.getToolkit();
= tKit.createImage(baseName);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(300,300);
this.setVisible(true);
* This is the body of the thread, the method that does the animation.
public void run()
Thread workThread = null;
for (int i=0;i<images.length;++i)
// tracker.waitForID(i);
lastLoaded = i;
repaint();
while (workThread != null)
repaint();
try
Thread.sleep(100);
catch (InterruptedException e)
}//end of method
* This method paints the current image to the screen.
* This method is complete.
* @param g the graphics object that actually does the drawing
public void paint(Graphics g)
System.out.println("Painting");
g.clearRect(0, 0, 300, 300);
g.drawImage(images[current_image], 30, 30, this);
* The main method parses the command line arguments. Then
* it creates a new ImageDisplay object and passes it,
* as a target, to a thread.
public static void main (String[] args)
if (args.length == 3)
ImageDisplay myDisplay = new ImageDisplay(args[0],args[1], Integer.parseInt(args[2]) );
Runnable runner = new ImageDisplay(args[0],args[1],Integer.parseInt(args[2]) );
Thread t1 = new Thread(runner);
t1.start();
}
here you go again
all questions answered together
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.*;
import javax.swing.*;
import java.util.*;
import java.awt.image.*;
public class ShowPic extends JFrame implements Runnable{
Image[] images;
int current_image=0;
int maxNumber;
Toolkit tKit = Toolkit.getDefaultToolkit();
Thread th;
Graphics g;
JPanel panel;
public ShowPic(String image, String type, int num) {
panel=new JPanel();
panel.setSize(getWidth(),getHeight());
maxNumber=num;
images = new Image[maxNumber];
for (int i=0;i<maxNumber;i++) {
images=tKit.getImage(image+String.valueOf(i)+"."+type);
System.out.println(image+String.valueOf(i)+"."+type+" added");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(500,500);
this.setContentPane(panel);
this.setVisible(true);
th = new Thread (this);
th.start ();
public static void main(String[] args) {
try {
System.out.println(args[0]+" "+args[1]+" "+(Integer.parseInt(args[2])));
ShowPic showPic = new ShowPic(args[0],args[1], Integer.parseInt(args[2]));
} catch (NullPointerException e) {
System.out.println("Something is wrong!");
public void run() {
while (true) {
System.out.println("Thread is true - animate");
animate(g);
try {
Thread.sleep(100);
}catch (InterruptedException e) {
System.out.println(e);
}//end of method
public void animate(Graphics g){
if ( current_image == maxNumber-1){
current_image=0;
}else{
current_image++;
paint(g);
public void paint(Graphics g) {
if(g == null){
g=panel.getGraphics();
g.setColor(Color.WHITE);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(Color.BLACK);
g.drawString(""+current_image,10,10);
g.drawImage(images[current_image],10,10, this);
Similar Messages
-
We have a Zenworks problem which has just arisen and I wonder if you can shed any light.
We were running Zenworks 7SP1 IR4. Last week we loaded Zenworks 7SP1 SR4.
Now, whenever we image a PC, the imaging process appears to finish, but we get an error: "Zenworks Imaging failed with Error:52"
The system then reboots and starts the process again. If you look at the workstation properties, the Zenworks Image tickbox has not cleared, and hence the restart of the imaging.
I found that Zenworks error 52 is: "52 - No partition type given when asked to create a part". I don't know why it would be saying that. (It is also possible that this message has always been there, but we have never noticed it, as the process has always worked).
I rolled back to IR4, but no change.
We are now in an infinite loop, as when the system is PXE booted, the machine is imaged each time.
Do you have any thoughts?
Thanks
Leo & Anthonyanthonywhill,
It appears that in the past few days you have not received a response to your
posting. That concerns us, and has triggered this automated reply.
Has your problem been resolved? If not, you might try one of the following options:
- Visit http://support.novell.com and search the knowledgebase and/or check all
the other self support options and support programs available.
- You could also try posting your message again. Make sure it is posted in the
correct newsgroup. (http://forums.novell.com)
Be sure to read the forum FAQ about what to expect in the way of responses:
http://forums.novell.com/faq.php
If this is a reply to a duplicate posting, please ignore and accept our apologies
and rest assured we will issue a stern reprimand to our posting bot.
Good luck!
Your Novell Product Support Forums Team
http://support.novell.com/forums/ -
Sorry for posting again, but here is some more information, as well as some extra things we have tried.
Hi,
The screen results with this exit code after the workstation has been imaged, prior to booting back into PXE and then re-imaging, along with completion and the same message.
================================================== ==================
Novell ZENworks Imaging Engine v10.2.0.0
Copyright 1999-2009, Novell, Inc.
All rights reserved.
Imaging operation(s) assigned by 10.0.0.21
Elapsed time: 12:48
No more jobs to be done in policy
ZENworks imaging failed with error: 52.
Novell ZENworks SID changer for linux
Version 10.2.0.0 Copyright 2007 - 2009
Exiting: Computer has not been recently imaged
================================================== ==================
The above message occurs (and this happens to other Laptops & PCs) after the machine has been imaged, but we are still having the computer re-imaging itself, it is in a constant loop.
We were running Zenworks 7SP1 IR4. Last week we loaded Zenworks 7SP1 SR4.
My manager has rolled back to IR4, but no change, as we have computers constantly re-imaging over and over in a loop.
I have tried deleting the workstation object (name) from within ConsoleOne, and still the problem occurs. I have also made sure there are no add-on images attached to the imaging.
Notes:
Now, whenever we image a PC, the imaging process appears to finish, but we get an error: "Zenworks Imaging failed with Error:52"
The system then reboots and starts the process again. If you look at the workstation properties, the Zenworks Image tickbox has not cleared, and hence the restart of the imaging.
I found that Zenworks error 52 is: "52 - No partition type given when asked to create a part". I don't know why it would be saying that. (It is also possible that this message has always been there, but we have never noticed it, as the process has always worked).
I came across an article that suggests the "ZENworks agent on the workstation has to be the same version as the ZENworks snap-ins in ConsoleOne".
We are using:
ConsoleOne Version 1.3.6h
ZENworks Desktop Management 7.0.1 = snap-ins for configuring policy settings
ZENworks Desktop Management 7.0.1 = snap-ins for administering and managing software distributions
If you have any ideas could you please let us know?
Cheers and thanks,anthonywhill,
It appears that in the past few days you have not received a response to your
posting. That concerns us, and has triggered this automated reply.
Has your problem been resolved? If not, you might try one of the following options:
- Visit http://support.novell.com and search the knowledgebase and/or check all
the other self support options and support programs available.
- You could also try posting your message again. Make sure it is posted in the
correct newsgroup. (http://forums.novell.com)
Be sure to read the forum FAQ about what to expect in the way of responses:
http://forums.novell.com/faq.php
If this is a reply to a duplicate posting, please ignore and accept our apologies
and rest assured we will issue a stern reprimand to our posting bot.
Good luck!
Your Novell Product Support Forums Team
http://support.novell.com/forums/ -
hai to all
i am in a problem that is, i did a backgorund image changer
for 10 secs for my project. the code below works fine. all well but
what i need is after compeleting all the images in the xml file it
stops.
i want it to loop or repeat the process again can any say how
plzzz
this is my code:-
xmlData = new XML ();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load ("images.xml");
function loadXML (loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image
= xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
//trace (image
firstImage ();
else {
trace ("file not loaded!");
p = 0;
filesize = picture.getBytesTotal ();
loaded = picture.getBytesLoaded ();
function firstImage () {
if (loaded == filesize) {
picture.loadMovie (image[0], 1);
picture._alpha = 100;
alpha (picture);
effect (picture);
timer ();
function nextImage () {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture.loadMovie (image[p], 1);
picture._alpha = 100;
alpha (picture);
//removeMovieClip("effect1");
effect (picture);
timer ();
/*function prevImage () {
if (p>(total-1)) {
p--;
picture.loadMovie (image[p], 1);
picture._alpha = 100;
timer ();
function timer () {
var secs = 10;
var id = setInterval (function () {
clearInterval (id);
nextImage ();
}, secs*1000);
var alpha_interval = setInterval (alpha, 100, picture);
function alpha (picture) {
picture._alpha += 10;
if (picture._alpha<100) {
trace ("alpha");
clearInterval (alpha_interval);
function effect (picture) {
this.attachMovie ("effect", "effect1", 10);go to google and type: as3 slideshow tutorial.
-
Tips for a better Looping image display?
I have a rather simple and large (file size) image display
here for a website in sacramento:
www.norcaldesigns.com/cLandscapes
the image loop is just one image that moves on the timeline
and returns to frame one at the end. I would love some advice or
links to examples of better ideas for looping image display.
Thanks!
-JesseAssuming that this is a valid concept (sorry, as a user I
find it quite annoying and dizzying after awhile), one of the
approaches to speed it up in the beginning - split the image into
several ones and load them one by one or in groups so that first
few to show load, naturally, first. Then you will need to append
them to the strip.
It would be much more scalable to keep the reference to the
images in an XML so that should you remove or add images -
everything is done in the XML and you don't have to recompile every
time.
Also, I would set a higher frame rate (around 30fps) -
animation looks a bit jerky.
If the presentation of many images is important - perhaps
another type of transition should be considered (not scrolling but,
say, blending via alphas or something). In addition to the movement
being dizzying, there is very little time to appreciate the
images. -
Help needed in rendering images...ThAnkS
I have 2 classes for rendering images. When i run the application, the images kept flashing, may i know how could i actually have 1 image appearing instead of many images flashing? In other words, i would like in a way similar to mosaic rendering process...Thanks alot
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
* TumbleItem.java requires these files:
* SwingWorker.java
* all the images in the images/tumble directory
* (or, if specified in the applet tag, another directory [dir]
* with images named T1.gif ... Tx.gif, where x is the total
* number of images [nimgs])
* the appropriate code to specify that the applet be executed,
* such as the HTML code in TumbleItem.html or TumbleItem.atag,
* or the JNLP code in TumbleItem.jnlp
public class TumbleItem extends JApplet
implements ActionListener {
int loopslot = -1; //the current frame number
String dir; //the directory relative to the codebase
//from which the images are loaded
javax.swing.Timer timer;
//the timer animating the images
int pause; //the length of the pause between revs
int offset; //how much to offset between loops
int off; //the current offset
int speed; //animation speed
int nimgs; //number of images to animate
int width; //width of the applet's content pane
Animator animator; //the applet's content pane
ImageIcon imgs[]; //the images
int maxWidth; //width of widest image
boolean finishedLoading = false;
JLabel statusLabel;
static Color[] labelColor = { Color.black, Color.black,
Color.black, Color.black,
Color.black, Color.black,
Color.white, Color.white,
Color.white, Color.white };
//Called by init.
protected void loadAppletParameters() {
//Get the applet parameters.
String at = getParameter("img");
dir = (at != null) ? at : "images/tumble";
at = getParameter("pause");
pause = (at != null) ? Integer.valueOf(at).intValue() : 1900;
at = getParameter("offset");
offset = (at != null) ? Integer.valueOf(at).intValue() : 0;
at = getParameter("speed");
speed = (at != null) ? (1000 / Integer.valueOf(at).intValue()) : 100;
at = getParameter("nimgs");
nimgs = (at != null) ? Integer.valueOf(at).intValue() : 16;
at = getParameter("maxwidth");
maxWidth = (at != null) ? Integer.valueOf(at).intValue() : 0;
* Create the GUI. For thread safety, this method should
* be invoked from the event-dispatching thread.
private void createGUI() {
//Animate from right to left if offset is negative.
width = getSize().width;
if (offset < 0) {
off = width - maxWidth;
//Custom component to draw the current image
//at a particular offset.
animator = new Animator();
animator.setOpaque(true);
animator.setBackground(Color.white);
setContentPane(animator);
//Put a "Loading Images..." label in the middle of
//the content pane. To center the label's text in
//the applet, put it in the center part of a
//BorderLayout-controlled container, and center-align
//the label's text.
statusLabel = new JLabel("Loading Images...",
JLabel.CENTER);
statusLabel.setForeground(labelColor[0]);
animator.add(statusLabel, BorderLayout.CENTER);
//Called when this applet is loaded into the browser.
public void init() {
loadAppletParameters();
//Execute a job on the event-dispatching thread:
//creating this applet's GUI.
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGUI();
} catch (Exception e) {
System.err.println("createGUI didn't successfully complete");
//Set up the timer that will perform the animation.
timer = new javax.swing.Timer(speed, this);
timer.setInitialDelay(pause);
timer.setCoalesce(false);
timer.start(); //Start the animation.
//Loading the images can take quite a while, so to
//avoid staying in init() (and thus not being able
//to show the "Loading Images..." label) we'll
//load the images in a SwingWorker thread.
imgs = new ImageIcon[nimgs];
final SwingWorker worker = new SwingWorker() {
public Object construct() {
//Images are numbered 1 to nimgs,
//but fill array from 0 to nimgs-1.
for (int i = 0; i < nimgs; i++) {
imgs[i] = loadImage(i+1);
finishedLoading = true;
return imgs;
//Executes in the event-dispatching thread.
public void finished() {
//Remove the "Loading images" label.
animator.removeAll();
loopslot = -1;
worker.start();
//The component that actually presents the GUI.
public class Animator extends JPanel {
public Animator() {
super(new BorderLayout());
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (finishedLoading &&
(loopslot > -1) && (loopslot < nimgs)) {
if (imgs != null && imgs[loopslot] != null) {
imgs[loopslot].paintIcon(this, g, off, 0);
//Update the the loopslot (frame number) and the offset.
//If it's the last frame, restart the timer to get a long
//pause between loops.
public void actionPerformed(ActionEvent e) {
loopslot++;
if (!finishedLoading) {
int colorIndex = loopslot % labelColor.length;
try {
statusLabel.setForeground(labelColor[colorIndex]);
} catch (NullPointerException exc) {}
return;
if (loopslot >= nimgs) {
loopslot = 0;
off += offset;
if (off < 0) {
off = width - maxWidth;
} else if (off + maxWidth > width) {
off = 0;
animator.repaint();
if (loopslot == nimgs - 1) {
timer.restart();
//Called to start the applet's execution.
public void start() {
if (finishedLoading && (nimgs > 1)) {
timer.restart();
//Called to stop (temporarily or permanently) the applet's execution.
public void stop() {
timer.stop();
protected ImageIcon loadImage(int imageNum) {
String path = dir + "/Image" + imageNum + ".jpg";
int MAX_IMAGE_SIZE = 2400; //Change this to the size of
//your biggest image, in bytes.
int count = 0;
BufferedInputStream imgStream = new BufferedInputStream(
this.getClass().getResourceAsStream(path));
if (imgStream != null) {
byte buf[] = new byte[MAX_IMAGE_SIZE];
try {
count = imgStream.read(buf);
imgStream.close();
} catch (java.io.IOException ioe) {
System.err.println("Couldn't read stream from file: " + path);
return null;
if (count <= 0) {
System.err.println("Empty file: " + path);
return null;
return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buf));
} else {
System.err.println("Couldn't find file: " + path);
return null;
public String getAppletInfo() {
return "Title: TumbleItem v1.2, 23 Jul 1997\n"
+ "Author: Interactive Mosaic\n"
+ "A simple Item class to play an image loop.";
public String[][] getParameterInfo() {
String[][] info = {
{"img", "string", "the directory containing the images to loop"},
{"pause", "int", "pause between complete loops; default is 3900"},
{"offset", "int", "offset of each image to simulate left (-) or "
+ "right (+) motion; default is 0 (no motion)"},
{"speed", "int", "the speed at which the frames are looped; "
+ "default is 100"},
{"nimgs", "int", "the number of images to be looped; default is 16"},
{"maxwidth", "int", "the maximum width of any image in the loop; "
+ "default is 0"}
return info;
import javax.swing.SwingUtilities;
public abstract class SwingWorker {
private Object value; // see getValue(), setValue()
* Class to maintain reference to current worker thread
* under separate synchronization control.
private static class ThreadVar {
private Thread thread;
ThreadVar(Thread t) { thread = t; }
synchronized Thread get() { return thread; }
synchronized void clear() { thread = null; }
private ThreadVar threadVar;
* Get the value produced by the worker thread, or null if it
* hasn't been constructed yet.
protected synchronized Object getValue() {
return value;
* Set the value produced by worker thread
private synchronized void setValue(Object x) {
value = x;
* Compute the value to be returned by the <code>get</code> method.
public abstract Object construct();
* Called on the event dispatching thread (not on the worker thread)
* after the <code>construct</code> method has returned.
public void finished() {
* A new method that interrupts the worker thread. Call this method
* to force the worker to stop what it's doing.
public void interrupt() {
Thread t = threadVar.get();
if (t != null) {
t.interrupt();
threadVar.clear();
* Return the value created by the <code>construct</code> method.
* Returns null if either the constructing thread or the current
* thread was interrupted before a value was produced.
* @return the value created by the <code>construct</code> method
public Object get() {
while (true) {
Thread t = threadVar.get();
if (t == null) {
return getValue();
try {
t.join();
catch (InterruptedException e) {
Thread.currentThread().interrupt(); // propagate
return null;
* Start a thread that will call the <code>construct</code> method
* and then exit.
public SwingWorker() {
final Runnable doFinished = new Runnable() {
public void run() { finished(); }
Runnable doConstruct = new Runnable() {
public void run() {
try {
setValue(construct());
finally {
threadVar.clear();
SwingUtilities.invokeLater(doFinished);
Thread t = new Thread(doConstruct);
threadVar = new ThreadVar(t);
* Start the worker thread.
public void start() {
Thread t = threadVar.get();
if (t != null) {
t.start();
}I have 2 classes for rendering images. When i run the application, the images kept flashing, may i know how could i actually have 1 image appearing instead of many images flashing? In other words, i would like in a way similar to mosaic rendering process...Thanks alot
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
* TumbleItem.java requires these files:
* SwingWorker.java
* all the images in the images/tumble directory
* (or, if specified in the applet tag, another directory [dir]
* with images named T1.gif ... Tx.gif, where x is the total
* number of images [nimgs])
* the appropriate code to specify that the applet be executed,
* such as the HTML code in TumbleItem.html or TumbleItem.atag,
* or the JNLP code in TumbleItem.jnlp
public class TumbleItem extends JApplet
implements ActionListener {
int loopslot = -1; //the current frame number
String dir; //the directory relative to the codebase
//from which the images are loaded
javax.swing.Timer timer;
//the timer animating the images
int pause; //the length of the pause between revs
int offset; //how much to offset between loops
int off; //the current offset
int speed; //animation speed
int nimgs; //number of images to animate
int width; //width of the applet's content pane
Animator animator; //the applet's content pane
ImageIcon imgs[]; //the images
int maxWidth; //width of widest image
boolean finishedLoading = false;
JLabel statusLabel;
static Color[] labelColor = { Color.black, Color.black,
Color.black, Color.black,
Color.black, Color.black,
Color.white, Color.white,
Color.white, Color.white };
//Called by init.
protected void loadAppletParameters() {
//Get the applet parameters.
String at = getParameter("img");
dir = (at != null) ? at : "images/tumble";
at = getParameter("pause");
pause = (at != null) ? Integer.valueOf(at).intValue() : 1900;
at = getParameter("offset");
offset = (at != null) ? Integer.valueOf(at).intValue() : 0;
at = getParameter("speed");
speed = (at != null) ? (1000 / Integer.valueOf(at).intValue()) : 100;
at = getParameter("nimgs");
nimgs = (at != null) ? Integer.valueOf(at).intValue() : 16;
at = getParameter("maxwidth");
maxWidth = (at != null) ? Integer.valueOf(at).intValue() : 0;
* Create the GUI. For thread safety, this method should
* be invoked from the event-dispatching thread.
private void createGUI() {
//Animate from right to left if offset is negative.
width = getSize().width;
if (offset < 0) {
off = width - maxWidth;
//Custom component to draw the current image
//at a particular offset.
animator = new Animator();
animator.setOpaque(true);
animator.setBackground(Color.white);
setContentPane(animator);
//Put a "Loading Images..." label in the middle of
//the content pane. To center the label's text in
//the applet, put it in the center part of a
//BorderLayout-controlled container, and center-align
//the label's text.
statusLabel = new JLabel("Loading Images...",
JLabel.CENTER);
statusLabel.setForeground(labelColor[0]);
animator.add(statusLabel, BorderLayout.CENTER);
//Called when this applet is loaded into the browser.
public void init() {
loadAppletParameters();
//Execute a job on the event-dispatching thread:
//creating this applet's GUI.
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGUI();
} catch (Exception e) {
System.err.println("createGUI didn't successfully complete");
//Set up the timer that will perform the animation.
timer = new javax.swing.Timer(speed, this);
timer.setInitialDelay(pause);
timer.setCoalesce(false);
timer.start(); //Start the animation.
//Loading the images can take quite a while, so to
//avoid staying in init() (and thus not being able
//to show the "Loading Images..." label) we'll
//load the images in a SwingWorker thread.
imgs = new ImageIcon[nimgs];
final SwingWorker worker = new SwingWorker() {
public Object construct() {
//Images are numbered 1 to nimgs,
//but fill array from 0 to nimgs-1.
for (int i = 0; i < nimgs; i++) {
imgs[i] = loadImage(i+1);
finishedLoading = true;
return imgs;
//Executes in the event-dispatching thread.
public void finished() {
//Remove the "Loading images" label.
animator.removeAll();
loopslot = -1;
worker.start();
//The component that actually presents the GUI.
public class Animator extends JPanel {
public Animator() {
super(new BorderLayout());
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (finishedLoading &&
(loopslot > -1) && (loopslot < nimgs)) {
if (imgs != null && imgs[loopslot] != null) {
imgs[loopslot].paintIcon(this, g, off, 0);
//Update the the loopslot (frame number) and the offset.
//If it's the last frame, restart the timer to get a long
//pause between loops.
public void actionPerformed(ActionEvent e) {
loopslot++;
if (!finishedLoading) {
int colorIndex = loopslot % labelColor.length;
try {
statusLabel.setForeground(labelColor[colorIndex]);
} catch (NullPointerException exc) {}
return;
if (loopslot >= nimgs) {
loopslot = 0;
off += offset;
if (off < 0) {
off = width - maxWidth;
} else if (off + maxWidth > width) {
off = 0;
animator.repaint();
if (loopslot == nimgs - 1) {
timer.restart();
//Called to start the applet's execution.
public void start() {
if (finishedLoading && (nimgs > 1)) {
timer.restart();
//Called to stop (temporarily or permanently) the applet's execution.
public void stop() {
timer.stop();
protected ImageIcon loadImage(int imageNum) {
String path = dir + "/Image" + imageNum + ".jpg";
int MAX_IMAGE_SIZE = 2400; //Change this to the size of
//your biggest image, in bytes.
int count = 0;
BufferedInputStream imgStream = new BufferedInputStream(
this.getClass().getResourceAsStream(path));
if (imgStream != null) {
byte buf[] = new byte[MAX_IMAGE_SIZE];
try {
count = imgStream.read(buf);
imgStream.close();
} catch (java.io.IOException ioe) {
System.err.println("Couldn't read stream from file: " + path);
return null;
if (count <= 0) {
System.err.println("Empty file: " + path);
return null;
return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buf));
} else {
System.err.println("Couldn't find file: " + path);
return null;
public String getAppletInfo() {
return "Title: TumbleItem v1.2, 23 Jul 1997\n"
+ "Author: Interactive Mosaic\n"
+ "A simple Item class to play an image loop.";
public String[][] getParameterInfo() {
String[][] info = {
{"img", "string", "the directory containing the images to loop"},
{"pause", "int", "pause between complete loops; default is 3900"},
{"offset", "int", "offset of each image to simulate left (-) or "
+ "right (+) motion; default is 0 (no motion)"},
{"speed", "int", "the speed at which the frames are looped; "
+ "default is 100"},
{"nimgs", "int", "the number of images to be looped; default is 16"},
{"maxwidth", "int", "the maximum width of any image in the loop; "
+ "default is 0"}
return info;
import javax.swing.SwingUtilities;
public abstract class SwingWorker {
private Object value; // see getValue(), setValue()
* Class to maintain reference to current worker thread
* under separate synchronization control.
private static class ThreadVar {
private Thread thread;
ThreadVar(Thread t) { thread = t; }
synchronized Thread get() { return thread; }
synchronized void clear() { thread = null; }
private ThreadVar threadVar;
* Get the value produced by the worker thread, or null if it
* hasn't been constructed yet.
protected synchronized Object getValue() {
return value;
* Set the value produced by worker thread
private synchronized void setValue(Object x) {
value = x;
* Compute the value to be returned by the <code>get</code> method.
public abstract Object construct();
* Called on the event dispatching thread (not on the worker thread)
* after the <code>construct</code> method has returned.
public void finished() {
* A new method that interrupts the worker thread. Call this method
* to force the worker to stop what it's doing.
public void interrupt() {
Thread t = threadVar.get();
if (t != null) {
t.interrupt();
threadVar.clear();
* Return the value created by the <code>construct</code> method.
* Returns null if either the constructing thread or the current
* thread was interrupted before a value was produced.
* @return the value created by the <code>construct</code> method
public Object get() {
while (true) {
Thread t = threadVar.get();
if (t == null) {
return getValue();
try {
t.join();
catch (InterruptedException e) {
Thread.currentThread().interrupt(); // propagate
return null;
* Start a thread that will call the <code>construct</code> method
* and then exit.
public SwingWorker() {
final Runnable doFinished = new Runnable() {
public void run() { finished(); }
Runnable doConstruct = new Runnable() {
public void run() {
try {
setValue(construct());
finally {
threadVar.clear();
SwingUtilities.invokeLater(doFinished);
Thread t = new Thread(doConstruct);
threadVar = new ThreadVar(t);
* Start the worker thread.
public void start() {
Thread t = threadVar.get();
if (t != null) {
t.start();
} -
BLOB image not shows in JSP page!!
Hi Dear all,
I had tried to configure how to show BLOB image to jsp page . The code are works fine and servlet works ok but image can not show only. can you help me that what need to be added. Please help me.
Can any experts help me? BLOB image not shows in JSP page. I am using ADF11g/DB 10gR2.
My as Code follows:
_1. Servlet Config_
<servlet>
<servlet-name>images</servlet-name>
<servlet-class>his.model.ClsImage</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>images</servlet-name>
<url-pattern>/render_images</url-pattern>
</servlet-mapping>
3. class code
package his.model;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import oracle.jbo.ApplicationModule;
import oracle.jbo.Row;
import oracle.jbo.ViewObject;
import oracle.jbo.client.Configuration;
import oracle.jbo.domain.BlobDomain;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class ClsImage extends HttpServlet
//private static final Log LOG = LogFactory.getLog(ImageServlet.class);
private static final Log LOG = LogFactory.getLog(ClsImage.class);
public void init(ServletConfig config)
throws ServletException
super.init(config);
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException
System.out.println("GET---From servlet============= !!!");
String appModuleName = "his.model.ModuleAssetMgt";//this.getServletConfig().getInitParameter("ApplicationModuleName");
String appModuleConfig = "TempModuleAssetMgt";//this.getServletConfig().getInitParameter("ApplicationModuleConfig");
String voQuery ="select ITEM_IMAGE from MM_ITEMIMAGE where IMAGE_NO = 'P1000000000006'" ;// 'P1000000000006' this.getServletConfig().getInitParameter("ImageViewObjectQuery");
String mimeType = "jpg";//this.getServletConfig().getInitParameter("gif");
//?IMAGE_NO='P1000000000006'
//TODO: throw exception if mandatory parameter not set
ApplicationModule am =
Configuration.createRootApplicationModule(appModuleName, appModuleConfig);
ViewObject vo = am.createViewObjectFromQueryStmt("TempView2", voQuery);
Map paramMap = request.getParameterMap();
Iterator paramValues = paramMap.values().iterator();
int i=0;
while (paramValues.hasNext())
// Only one value for a parameter is expected.
// TODO: If more then 1 parameter is supplied make sure the value is bound to the right bind
// variable in the query! Maybe use named variables instead.
String[] paramValue = (String[])paramValues.next();
vo.setWhereClauseParam(i, paramValue[0]);
i++;
System.out.println("before run============= !!!");
// Run the query
vo.executeQuery();
// Get the result (only the first row is taken into account
System.out.println("after run============= !!!");
Row product = vo.first();
//System.out.println("============"+(BlobDomain)product.getAttribute(0));
BlobDomain image = null;
// Check if a row has been found
if (product != null)
System.out.println("onside product============= !!!");
// We assume the Blob to be the first a field
image = (BlobDomain) product.getAttribute(0);
//System.out.println("onside run product============= !!!"+image.toString() +"======="+image );
// Check if there are more fields returned. If so, the second one
// is considered to hold the mime type
if ( product.getAttributeCount()> 1 )
mimeType = (String)product.getAttribute(1);
else
//LOG.warn("No row found to get image from !!!");
LOG.warn("No row found to get image from !!!");
return;
System.out.println("Set Image============= !!!");
// Set the content-type. Only images are taken into account
response.setContentType("image/"+ mimeType+ "; charset=windows-1252");
OutputStream os = response.getOutputStream();
InputStream is = image.getInputStream();
// copy blob to output
byte[] buffer = new byte[4096];
int nread;
while ((nread = is.read(buffer)) != -1)
os.write(buffer, 0, nread);
//System.out.println("Set Image============= loop!!!"+(is.read(buffer)));
os.close();
// Remove the temporary viewobject
vo.remove();
// Release the appModule
Configuration.releaseRootApplicationModule(am, false);
} 3 . Jsp Tag
<af:image source="/render_images" shortDesc="Item"/> Thanks.
zakir
====
Edited by: Zakir Hossain on Apr 23, 2009 11:19 AMHi here is solution,
later I will put a project for this solution, right now I am really busy with ADF implementation.
core changes is to solve my problem:
byte[] buffer = new byte[image.getBufferSize()];
int nread;
vo.remove();
while ((nread = is.read(buffer)) != -1) {
os.write(buffer);
}All code as below:
Servlet Code*
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
String appModuleName =
"his.model.ModuleAssetMgt";
String appModuleConfig =
"TempModuleAssetMgt";
String imgno = request.getParameter("imgno");
if (imgno == null || imgno.equals(""))
return;
String voQuery =
"select ITEM_IMAGE from MM_ITEMIMAGE where IMAGE_NO = '" + imgno + "'";
String mimeType = "gif";
ApplicationModule am =
Configuration.createRootApplicationModule(appModuleName,
appModuleConfig);
am.clearVOCaches("TempView2", true);
ViewObject vo = null;
String s;
vo = am.createViewObjectFromQueryStmt("TempView2", voQuery);
// Run the query
vo.executeQuery();
// Get the result (only the first row is taken into account
Row product = vo.first();
BlobDomain image = null;
// Check if a row has been found
if (product != null) {
// We assume the Blob to be the first a field
image = (BlobDomain)product.getAttribute(0);
// Check if there are more fields returned. If so, the second one
// is considered to hold the mime type
if (product.getAttributeCount() > 1) {
mimeType = (String)product.getAttribute(1);
} else {
LOG.warn("No row found to get image from !!!");
return;
// Set the content-type. Only images are taken into account
response.setContentType("image/" + mimeType);
OutputStream os = response.getOutputStream();
InputStream is = image.getInputStream();
// copy blob to output
byte[] buffer = new byte[image.getBufferSize()];
int nread;
vo.remove();
while ((nread = is.read(buffer)) != -1) {
os.write(buffer);
is.close();
os.close();
// Release the appModule
Configuration.releaseRootApplicationModule(am, true);
}Jsp Tag
<h:graphicImage url="/render_images?imgno=#{bindings.ImageNo.inputValue}"
height="168" width="224"/> -
How do you acquire multiple image buffers and save to disk later?
Good morning everyone,
I am working with the LabVIEW code posted below. I am taking images through a CCD camera at a high frequency. Therefore, I need this code to be able to keep up with the trigger. I take anywhere from 30 to a few 100 images and acquire them through buffers. The code I have now (which I got from someone else in my lab; I did not write it) saves the images in the for loop in which each is required. This slows down the code considerably. Timing is important to my application. Does anyone know if there is a way to set each buffer aside after they are acquired and then save them to disk AFTER all the images are acquired. I think this will allow the code to keep up with the trigger.
As a side question, I would like to have the code trigger my camera on both the rising and falling edge of the trigger pulse. As you can see from the code, I tried to set this up, but the method I tried doesn't work; each time a new trigger is setup it wipes out the old one. Is there a way to set up 2 triggers?
Thank you very much,
Matt
Attachments:
Save_Image_Matt_Trig.vi 46 KBLeft from the loop there's an "Array Subset" vi because I didn't use the first two pictures of the ring.
So you can forget about it and wire the ring directly to the "For Loop".
You can see the Ring as an array of images, so basically you don't need any VI to retrieve an image from the ring, just an "Index array" will do.
Wire the output of the "Index array" to an image control.
This is of course if you first fill the ring and then process it.
If you want live images, then you can use the vi you're using to extract an image from the buffer but I understood that you want to acquire images as fast as possible and process them afterwards.
Correct? Yes, then you don't need the "IMAQ Extract Buffer" vi.
And yes, you can remove everything from the loop, just check if the number of frames is reached.
When all frames are acquired, quit the loop and process the ring buffer.
I checked your code again, and observed that you do nothing with the ring buffer
You build it up in the first For loop and delete it at the end of the code but never used it in the loop
I attach a larger view of the acquisition loop, so that you can have a better idea of the whole ring stuff.
I have a shift register for the ring so that all states can access it.
The state "Save all images" loops through the array, to save the images one by one.
I'm sorry I can't post the complete vi, it's way too large and contains lots of sub vi's to analyse the images and handle the I/O toward the process line.
Attachments:
SNAG-003.jpg 217 KB -
Version 11.1.1.1.0
After run the .jspx page don't show any error but don't show blob image in page.
Servlet Code is
public class ClsServlet extends HttpServlet{
public ClsServlet() {
super();
public void init(ServletConfig config) throws ServletException {
super.init(config);
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
String appModuleName = "image.model.AppModule";
String appModuleConfig = "TempAppModule";
String imgno = request.getParameter("imgno");
String tblName = request.getParameter("tblnm");
String clmName = request.getParameter("clnm");
String pkclmName = request.getParameter("pkclnm");
String mType ;//= request.getParameter("mtype");
mType = "jpg";
String voQuery =
"select " + clmName + " from " + tblName + " where " + pkclmName +
" = '" + imgno + "'";
String mimeType =
mType; //"gif";//this.getServletConfig().getInitParameter("gif");
ApplicationModule am =
Configuration.createRootApplicationModule(appModuleName,
appModuleConfig);
am.clearVOCaches("TempView", true);
ViewObject vo = null;
//String s;
System.out.println("voQuery="+voQuery);
try {
vo = am.createViewObjectFromQueryStmt("TempView", voQuery);
} catch (Exception e) {
System.out.println( e.toString()+" err:VO Exists...");
System.out.println("before run============= !!!");
// Run the query
try {
vo.executeQuery();
} catch (Exception e) {
System.out.println(e.toString());
// Get the result (only the first row is taken into account
System.out.println("after run============= !!!");
Row product = vo.first();
BlobDomain image = null;
// Check if a row has been found
if (product != null) {
System.out.println("onside product============= !!!");
// We assume the Blob to be the first a field
image = (BlobDomain)product.getAttribute(0);
if (product.getAttributeCount() > 1) {
mimeType = (String)product.getAttribute(1);
} else {
//LOG.warn("No row found to get image from !!!");
//LOG.warn("No row found to get image from !!!");
System.out.println("No row found to get image from !!!");
vo.remove();
//vo.clearCache();
return;
System.out.println("Set Image============= !!!");
// Set the content-type. Only images are taken into account
response.setContentType("image/" + mimeType);
OutputStream os = response.getOutputStream();
InputStream is = image.getInputStream();
System.out.println(image.getBufferSize() + "image.getBufferSize()");
// copy blob to output
byte[] buffer = new byte[image.getBufferSize()];
int nread;
vo.remove();
//while ((nread = is.read(buffer)) != -1) {
while ((nread = is.read(buffer)) != -1) {
// try {
os.write(buffer);
System.out.println(buffer.length + "Set Image============= loop!!! " +
nread);
System.out.println("==out strim===" + os.toString());
is.close();
os.close();
os.flush();
// Remove the temporary viewobject
vo.remove();
//vo.clearCache();
// Release the appModule
Configuration.releaseRootApplicationModule(am, true);
how can i show this imageHard to tell from your code and the information given.
Do you get the image from the DB?
Can you shoe the code to show the image on the page?
Timo -
DOCU WINDOW
This is the window on the top right side
1.Document no (hard coded)
2.Then display the document number for the first document for the current row. Maybe you should check prior to printing if the current row was posted error free
and invoke printing only if this is the case. Then get the first(!!!) document number from the error/message log for this row. ZGF_ICO_RECHR_L-DOCFR
3. Document date (hard coded) it is P_BLDAT on the selection screen, already correct in the form
4. VAT No (hard coded)
5. Then display the EU VAT reg.no of that company. This is in table KNA1, where KUNNR = L_ROW-CUSTFR. The field is KNA1-STCEG, if it is empty, try to populate
KNA1-STCD1.
6. Order number(Hard coded)
7. Just concatenate L_ROW-REF + the last number for that reference from the log table ZGF_ICO_RECHR_L (notice this table has not yet been created!!! and also
the part is missing where we populate that table when posting both documents for a particular row) ZGF_ICO_RECHR_L-REF+NUMBER
report ZG00F_.
Top Include for the data declarations
class LCL_REF definition deferred.
include ZG00F_INT_POST_INVOICE_TOP.
data: G_ALV_TREE type ref to CL_GUI_ALV_TREE,
G_CUSTOM_CONTAINER type ref to CL_GUI_CUSTOM_CONTAINER,
G_TEXT_CONTAINER type ref to CL_GUI_CUSTOM_CONTAINER,
G_LOGGER type ref to CL_GUI_TEXTEDIT,
G_TOOLBAR type ref to CL_GUI_TOOLBAR.
data: " gt_zgf_ico_rechr type zgf_ico_rechr occurs 0,
"Output-Table
OKCODE like SY-UCOMM.
CLASS LCL_REF DEFINITION
class LCL_REF definition.
public section.
data : VALID type BOOLEAN,
CAN type BOOLEAN.
methods : CONSTRUCTOR
importing IM_REF type ZGF_ICO_RECHR,
CAN_POST
returning VALUE(CAN) type BOOLEAN,
IS_VALID
returning VALUE(IS_VALID) type BOOLEAN,
GET_DIVA returning VALUE(DIVA) type LVC_S_LAYN,
GET_DIVAC returning VALUE(DIVAC) type LVC_S_LACN,
FILL_BAPI_TABLES,
GET_REF returning VALUE(R_REF) type ZGF_ICO_RECHR-REF,
POST_INVOICE,
PRINT_INVOICE,
GET_ERRORS returning
VALUE(R_ERROR_TAB) type ABAPTXT255_TAB,
GET_PRDATA returning
VALUE(PR_REF) type ZGF_ICO_RECHR.
private section.
data: LINE type ABAPTXT255,
ERROR_TAB type ABAPTXT255_TAB,
FIELD like LINE.
methods : CHECK_VALIDITY.
endclass. "lcl_ref DEFINITION
CLASS lcl_ref IMPLEMENTATION
class LCL_REF implementation.
method GET_ERRORS.
R_ERROR_TAB = ME->ERROR_TAB.
endmethod. "get_errors
method IS_VALID.
IS_VALID = ME->VALID.
endmethod. "is_valid
method GET_PRDATA.
PR_REF = L_REF.
endmethod. "is_valid
method PRINT_INVOICE.
data: L_KUNNR type KNA1-KUNNR.
data: L_ROW type ZGF_ICO_RECHR.
call function 'OPEN_FORM'
exporting
APPLICATION = 'TX'
ARCHIVE_INDEX =
ARCHIVE_PARAMS =
DEVICE = 'PRINTER'
DIALOG = 'X'
FORM = 'ZGF_INVOICE'
LANGUAGE = SY-LANGU
OPTIONS = is_options
exceptions
CANCELED = 1
DEVICE = 2
others = 12.
if SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'START_FORM'
exporting
ARCHIVE_INDEX =
FORM = 'ZGF_INVOICE'
LANGUAGE = SY-LANGU
exceptions
FORM = 1
others = 8.
if SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
IF L_REF-TOTAL >= 0.
IV_INVOICE = 'INVOICE (COMCoE Recharge)'.
ELSE.
IV_INVOICE = 'Credit Memo (COMCoE Recharge)'.
ENDIF.
call method ME->GET_PRDATA
receiving
PR_REF = L_ROW.
L_KUNNR = L_ROW-CUSTFR.
select single RCOMP ADRNR LAND1 ORT01
into (IV_RCOMP, IV_ADRNR, IV_COMPLAND1, IV_COMPORT01)
from T001 where BUKRS = L_ROW-CCFR.
call function 'WRITE_FORM'
exporting
WINDOW = 'INVOICE'
ELEMENT = 'T3'
exceptions
WINDOW = 1
ELEMENT = 2.
IV_DOCDATE = P_BLDAT.
IV_ORDNU = L_ROW-REF.
call function 'WRITE_FORM'
exporting
WINDOW = 'DOCU'
ELEMENT = 'T2'
exceptions
WINDOW = 1
ELEMENT = 2.
select single KUNNR STRAS NAME1 LAND1 ORT01 STCEG
into
(IV_CUSTNO, IV_CUSTADD, IV_CUSTNAME1, IV_CUSTLAND1, IV_CUSTCITY,
IV_DOCVAT)
from KNA1
where KUNNR = L_KUNNR.
call function 'WRITE_FORM'
exporting
WINDOW = 'CUST'
ELEMENT = 'T6'
exceptions
WINDOW = 1
ELEMENT = 2.
IV_CUSTNO = L_KUNNR.
IV_CURR = L_ROW-CURR.
call function 'WRITE_FORM'
exporting
WINDOW = 'CUSTNO'
ELEMENT = 'T4'
exceptions
WINDOW = 1
ELEMENT = 2.
data: L_VAR(21).
concatenate P_DATEFR0(4) '/' P_DATEFR4(2) '/' P_DATEFR+6(2)
'-' P_DATETO0(4) '/' P_DATETO4(2) '/' P_DATETO+6(2)
into L_VAR.
IV_PERDAT = L_VAR.
call function 'WRITE_FORM'
exporting
WINDOW = 'MAIN'
ELEMENT = 'T1'
exceptions
WINDOW = 1
ELEMENT = 2.
call function 'WRITE_FORM'
exporting
WINDOW = 'FOOTER'
ELEMENT = 'T5'
exceptions
WINDOW = 1
ELEMENT = 2.
*CALL FUNCTION 'END_FORM'
IMPORTING
RESULT =
EXCEPTIONS
UNOPENED = 1
BAD_PAGEFORMAT_FOR_PRINT = 2
SPOOL_ERROR = 3
CODEPAGE = 4
OTHERS = 5.
call function 'END_FORM'
exceptions
UNOPENED = 1.
if SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
call function 'CLOSE_FORM'
exceptions
others = 6.
if SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endmethod. "is_valid
method GET_REF.
R_REF = REF.
endmethod. "get_ref
method CONSTRUCTOR.
L_REF = IM_REF.
REF = IM_REF-REF.
call method ME->CHECK_VALIDITY.
endmethod. "constructor
method GET_DIVA.
DIVA-ISFOLDER = ''.
if VALID <> 'X'.
DIVA-N_IMAGE = ICON_NEGATIVE.
else.
DIVA-N_IMAGE = ICON_POSITIVE.
endif.
endmethod. "get_diva
method GET_DIVAC.
if V_ERROR1 = 'Y' or V_ERROR2 = 'Y'.
DIVAC-N_IMAGE = ICON_RED_LIGHT.
elseif V_ERROR1 = 'N' and V_ERROR2 = 'N'.
DIVAC-N_IMAGE = ICON_GREEN_LIGHT.
endif.
DIVAC-U_N_IMAGE = 'X'.
endmethod. "get_divac
method CAN_POST.
CAN = 'X'.
call method ME->FILL_BAPI_TABLES.
endmethod. "can_post
method CHECK_VALIDITY.
*Reference field must begin with M, Q, Y or J. Otherwise display an
*error msg with text symbol TEXT-001 (ZGF_ICO_RECHR validation error
*Reference incorrect rec.x) where x ist the numebr of the incorrect
*record.
data: L_CHAR(1),
L_REF1 type ZGF_ICO_RECHR-REF,
L_ERR type OUTTAB_LINE_ERROR,
L_NUM type N,
L_KNB1 type KNB1,
L_TBSL type TBSL,
L_CSKS type CSKS,
L_LFB1 type LFB1.
l_flag(1).
clear: L_CHAR, L_NUM, VALID.
VALID = 'X'.
L_REF1 = L_REF-REF.
L_CHAR = L_REF1+0(1).
if not ( L_CHAR = 'M' or L_CHAR = 'Q'
or L_CHAR = 'Y' or L_CHAR = 'J').
MESSAGE E398(00) WITH TEXT-001 ' ' ' ' ' '.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-001.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
clear: L_CHAR, L_NUM.
L_CHAR = L_REF1+1(1).
L_NUM = L_CHAR.
if not L_CHAR = '0'.
if L_NUM = 0.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-001.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
endif.
clear: L_CHAR, L_NUM.
L_CHAR = L_REF1+2(1).
L_NUM = L_CHAR.
if not L_CHAR = '0'.
if L_NUM = 0.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-001.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
endif.
clear: L_CHAR, L_NUM.
L_CHAR = L_REF1+3(1).
L_NUM = L_CHAR.
if not L_CHAR = '0'.
if L_NUM = 0.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-001.
L_ERR-REC_NO = G_CNTR.
append L_ERR-ERR_MESG to GT_ZGF_ICO_RECHR_ERRORS.
VALID = 'F'.
endif.
endif.
if not ( L_REF-FREQ = 'M' or L_REF-FREQ = 'Q' or L_REF-FREQ = 'Y').
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-002.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
if not ( L_REF-CODE = 'A' or L_REF-CODE = 'B' or L_REF-CODE = 'C'
or L_REF-CODE = 'D' or L_REF-CODE = 'E'
or L_REF-CODE = 'F' ).
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-003.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
*Customer FROM must not be flagged for deletion in KNB1. (KNB1-LOEVM
*must be space), otherwise error message with TEXT-007. (ZGF_ICO_RECHR
*validation error From customer marked for deletion rec.x) where x
*ist the number of the incorrect record.
select single * from KNB1 into L_KNB1
where KUNNR = L_REF-CUSTFR.
if SY-SUBRC = 0.
if not L_KNB1-LOEVM is initial.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-007.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
if not L_KNB1-SPERR is initial.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-006.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
endif.
select single * from TBSL into L_TBSL
where BSCHL = L_REF-PKFRD.
if not L_TBSL-KOART = 'D'.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-008.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
select single * from TBSL into L_TBSL
where BSCHL = L_REF-PKFRS.
if not L_TBSL-KOART = 'S'.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-009.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
if not L_REF-PLTFR is initial.
select single * from CSKS into L_CSKS
where ZZWERKS = L_REF-PKFRS.
if SY-SUBRC <> 0.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-012.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
endif.
select single * from LFB1 into L_LFB1
where LIFNR = L_REF-CUSTTO.
if not L_LFB1-LOEVM is initial.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-018.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
if not LFB1-SPERR is initial.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-019.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
select single * from TBSL into L_TBSL
where BSCHL = L_REF-PKTOK.
if not L_TBSL-KOART = 'K'.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-020.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
select single * from TBSL into L_TBSL
where BSCHL = L_REF-PKTOS.
if not L_TBSL-KOART = 'S'.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-021.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
if not L_REF-TOTAL > 0.
clear L_ERR.
L_ERR = L_REF.
L_ERR-ERR_MESG = TEXT-017.
L_ERR-REC_NO = G_CNTR.
append L_ERR to GT_ZGF_ICO_RECHR_ERRORS.
append L_ERR-ERR_MESG to ERROR_TAB.
VALID = 'F'.
endif.
return valid.
endmethod. "check_validity
--- Method Post Invoice Start ---
method POST_INVOICE.
endmethod. "post_invoice
--- Method Post Invoice End ---
--- Method Filling Bapi Tables Start ---
method FILL_BAPI_TABLES.
*---- Populating Bapi for Customer
V_TOTAL = L_REF-TOTAL.
perform FILL_BAPI_CUSTOMER.
V_ERROR1 = 'N'.
V_ERROR2 = 'N'.
delete IT_ERROR where NODE_ID = L_SELECTED_NODE.
IS_ERROR-NODE_ID = L_SELECTED_NODE.
IS_ERROR-ERROR = SY-ULINE(30).
append IS_ERROR to IT_ERROR.
IS_ERROR-NODE_ID = L_SELECTED_NODE.
IS_ERROR-ERROR = L_REF-REF.
append IS_ERROR to IT_ERROR.
IS_ERROR-NODE_ID = L_SELECTED_NODE.
IS_ERROR-ERROR = SY-ULINE(30).
append IS_ERROR to IT_ERROR.
IS_ERROR-NODE_ID = L_SELECTED_NODE.
IS_ERROR-ERROR = '*** Checking Customer Document ***'.
append IS_ERROR to IT_ERROR.
clear IS_ERROR.
*---- Checking for 1st Document
call function 'BAPI_ACC_DOCUMENT_CHECK'
exporting
DOCUMENTHEADER = WA_DOCUMENTHEADER
tables
ACCOUNTGL = LT_ACCOUNTGL
ACCOUNTRECEIVABLE =
LT_ACCOUNTRECEIVABLE
ACCOUNTTAX = LT_ACCOUNTTAX
CURRENCYAMOUNT = LT_CURRENCYAMOUNT
RETURN = LT_RETURN.
loop at LT_RETURN into WA_RETURN.
if WA_RETURN-TYPE = 'E' or WA_RETURN-TYPE = 'A'.
V_ERROR1 = 'Y'.
endif.
IS_ERROR-NODE_ID = L_SELECTED_NODE.
concatenate WA_RETURN-TYPE WA_RETURN-MESSAGE into IS_ERROR-ERROR
separated by '-'.
append IS_ERROR to IT_ERROR.
endloop.
*--- Checking for 2nd Document
if V_ERROR1 = 'N'.
*---- Populating Bapi for Vendor
L_REF-TOTAL = V_TOTAL.
perform FILL_BAPI_VENDOR.
IS_ERROR-NODE_ID = L_SELECTED_NODE.
IS_ERROR-ERROR = '*** Checking for Vendor Document ***'.
append IS_ERROR to IT_ERROR.
clear IS_ERROR.
call function 'BAPI_ACC_DOCUMENT_CHECK'
exporting
DOCUMENTHEADER = WA_DOCUMENTHEADER2
tables
ACCOUNTGL = LT_ACCOUNTGL2
ACCOUNTPAYABLE = LT_ACCOUNTPAYABLE
ACCOUNTTAX = LT_ACCOUNTTAX2
CURRENCYAMOUNT = LT_CURRENCYAMOUNT2
RETURN = LT_RETURN2.
loop at LT_RETURN2 into WA_RETURN2.
if WA_RETURN-TYPE = 'E' or WA_RETURN-TYPE = 'A'.
V_ERROR2 = 'Y'.
endif.
IS_ERROR-NODE_ID = L_SELECTED_NODE.
concatenate WA_RETURN2-TYPE WA_RETURN2-MESSAGE into
IS_ERROR-ERROR separated by '-'.
append IS_ERROR to IT_ERROR.
endloop.
endif.
*--- CHECK WHETHER BOTH DOCUMENTS ARE CORRECT OR NOT returned SUCCESS
if V_ERROR1 = 'N' and V_ERROR2 = 'N'.
*--- Posting 1st Document - Customer
IS_ERROR-NODE_ID = L_SELECTED_NODE.
IS_ERROR-ERROR = '*** Posting Customer Document ***'.
append IS_ERROR to IT_ERROR.
clear IS_ERROR.
call function 'BAPI_ACC_DOCUMENT_POST'
exporting
DOCUMENTHEADER = WA_DOCUMENTHEADER
tables
ACCOUNTGL = LT_ACCOUNTGL
ACCOUNTRECEIVABLE =
LT_ACCOUNTRECEIVABLE
ACCOUNTTAX = LT_ACCOUNTTAX
CURRENCYAMOUNT = LT_CURRENCYAMOUNT
RETURN = LT_RETURN.
call function 'BAPI_TRANSACTION_COMMIT'.
loop at LT_RETURN into WA_RETURN.
IS_ERROR-NODE_ID = L_SELECTED_NODE.
concatenate WA_RETURN-TYPE WA_RETURN-MESSAGE into IS_ERROR-ERROR
separated by '-'.
append IS_ERROR to IT_ERROR.
endloop.
*--- Posting 2nd Document - Vendor
IS_ERROR-NODE_ID = L_SELECTED_NODE.
IS_ERROR-ERROR = '*** Posting Vendor Document ***'.
append IS_ERROR to IT_ERROR.
clear IS_ERROR.
call function 'BAPI_ACC_DOCUMENT_POST'
exporting
DOCUMENTHEADER = WA_DOCUMENTHEADER2
tables
ACCOUNTGL = LT_ACCOUNTGL2
ACCOUNTPAYABLE = LT_ACCOUNTPAYABLE
ACCOUNTTAX = LT_ACCOUNTTAX2
CURRENCYAMOUNT = LT_CURRENCYAMOUNT2
RETURN = LT_RETURN2.
call function 'BAPI_TRANSACTION_COMMIT'.
loop at LT_RETURN2 into WA_RETURN2.
IS_ERROR-NODE_ID = L_SELECTED_NODE.
concatenate WA_RETURN2-TYPE WA_RETURN2-MESSAGE into
IS_ERROR-ERROR separated by '-'.
append IS_ERROR to IT_ERROR.
endloop.
endif. "if V_ERROR1 = 'N' and V_ERROR2 = 'N'.
*--- Setting colour of node.
data: LO_REF type ref to LCL_REF,
IS_NODE_LAYOUT type LVC_S_LACN,
L_NODE_TEXT type LVC_VALUE,
WA_OREF type TY_REF.
clear :IS_NODE_LAYOUT,L_NODE_TEXT, WA_OREF, LO_REF.
create object LO_REF exporting IM_REF = LS_ZGF_ICO_RECHR.
IS_NODE_LAYOUT = LO_REF->GET_DIVAC( ).
read table GT_ZGF_ICO_RECHR into L_REF index L_SELECTED_NODE.
L_NODE_TEXT = L_REF-REF.
call method G_ALV_TREE->CHANGE_NODE
exporting
I_NODE_KEY = L_SELECTED_NODE
I_OUTTAB_LINE = L_REF
IS_NODE_LAYOUT = IS_NODE_LAYOUT
I_NODE_TEXT = L_NODE_TEXT
I_U_NODE_TEXT = 'X'
exceptions
NODE_NOT_FOUND = 1
others = 2.
call method G_ALV_TREE->FRONTEND_UPDATE.
call method CL_GUI_CFW=>FLUSH
exceptions
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2.
endmethod. "fill_int_tables
endclass. "lcl_ref IMPLEMENTATION
CLASS lcl_event_handler DEFINITION
class LCL_EVENT_HANDLER definition.
public section.
class-methods : ON_NODE_CLICK for event
NODE_DOUBLE_CLICK of CL_GUI_ALV_TREE
importing NODE_KEY.
methods: ON_FUNCTION_SELECTED
for event FUNCTION_SELECTED of CL_GUI_TOOLBAR
importing FCODE.
endclass. "lcl_event_handler DEFINITION
CLASS lcl_event_handler IMPLEMENTATION
class LCL_EVENT_HANDLER implementation.
method ON_NODE_CLICK.
endmethod. "on_node_click
method ON_FUNCTION_SELECTED.
data: LT_SELECTED_NODES type LVC_T_NKEY,
L_RC type C,
L_CAN type C,
L_REC type I,
WA_OREF type TY_REF,
L_LINE type SY-TABIX.
Determine which line is selected
call method G_ALV_TREE->GET_SELECTED_NODES
changing
CT_SELECTED_NODES = LT_SELECTED_NODES.
call method CL_GUI_CFW=>FLUSH.
remark: The user can not select more than one node since the
default value of NODE_SELECTION_MODE is
cl_gui_column_Tree=>NODE_SEL_MODE_SINGLE (see constructor).
describe table LT_SELECTED_NODES lines L_REC.
if L_REC = 0 and FCODE = 'ERROR'.
*--- Show log for all if nothing is selected then.
refresh LT_ERRORS.
clear LT_ERRORS.
loop at IT_ERROR into IS_ERROR.
IS_ERRORS-LINE = IS_ERROR-ERROR.
append IS_ERRORS to LT_ERRORS.
endloop.
call method G_LOGGER->SET_TEXT_AS_R3TABLE
exporting
TABLE = LT_ERRORS.
endif.
loop at LT_SELECTED_NODES into L_SELECTED_NODE.
clear : L_REF, WA_OREF.
L_LINE = SY-TABIX.
read table GT_OREF into WA_OREF index L_SELECTED_NODE.
read table GT_ZGF_ICO_RECHR into L_REF index L_SELECTED_NODE.
if SY-SUBRC = 0.
case FCODE.
when 'ERROR'.
refresh LT_ERRORS.
clear LT_ERRORS.
loop at IT_ERROR into IS_ERROR where NODE_ID =
L_SELECTED_NODE.
IS_ERRORS-LINE = IS_ERROR-ERROR.
append IS_ERRORS to LT_ERRORS.
endloop.
call method G_LOGGER->SET_TEXT_AS_R3TABLE
exporting
TABLE = LT_ERRORS.
when 'POST'.
if L_LINE = 1.
if WA_OREF-O_REF->IS_VALID( ) = 'X'.
clear L_RC.
call function 'POPUP_TO_CONFIRM_STEP'
exporting
TEXTLINE1 = 'Do you want to post' "(902)
TEXTLINE2 = '?' "(903)
TITEL = 'Confirmation' "(904)
CANCEL_DISPLAY = ' '
importing
ANSWER = L_RC.
else.
call function 'POPUP_TO_INFORM'
exporting
TITEL = 'Select Another Record..'
TXT1 = 'Data Wrong,'
TXT2 = 'Posting Can Not be Done'.
endif.
else.
L_RC = 'J'.
endif.
if L_RC eq 'J'.
*---Post Invoice.
if WA_OREF-O_REF->CAN_POST( ) = 'X'.
call method WA_OREF-O_REF->POST_INVOICE.
*---Printing Log.
refresh LT_ERRORS.
clear LT_ERRORS.
loop at IT_ERROR into IS_ERROR.
IS_ERRORS-LINE = IS_ERROR-ERROR.
append IS_ERRORS to LT_ERRORS.
endloop.
call method G_LOGGER->SET_TEXT_AS_R3TABLE
exporting
TABLE = LT_ERRORS.
endif.
endif.
when 'PRINT'.
call method WA_OREF-O_REF->PRINT_INVOICE.
endcase.
else.
message I000(0K) with 'Please select a node.'.
endif.
endloop.
endmethod. "on_function_selected
endclass. "lcl_event_handler IMPLEMENTATION
START-OF-SELECTION.
start-of-selection.
end-of-selection.
call screen 100.
*& Module STATUS_0100 OUTPUT
module STATUS_0100 output.
set pf-status 'MAIN100'.
set titlebar 'MAINTITLE'.
if G_ALV_TREE is initial.
perform INIT_TREE.
call method CL_GUI_CFW=>FLUSH
exceptions
CNTL_SYSTEM_ERROR = 1
CNTL_ERROR = 2.
if SY-SUBRC ne 0.
call function 'POPUP_TO_INFORM'
exporting
titel = 'Automation Queue failure'(801)
txt1 = 'Internal error:'(802)
txt2 = 'A method in the automation queue'(803)
txt3 = 'caused a failure.'(804).
endif.
endif.
endmodule. " STATUS_0100 OUTPUT
*& Form init_tree
text
--> p1 text
<-- p2 text
form INIT_TREE .
data: L_TREE_CONTAINER_NAME(30) type C.
*Reference tree
L_TREE_CONTAINER_NAME = 'ZCONTAINER'.
create object G_CUSTOM_CONTAINER
exporting
CONTAINER_NAME = L_TREE_CONTAINER_NAME
exceptions
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
if SY-SUBRC <> 0.
MESSAGE x208(00) WITH 'ERROR'(100).
endif.
create tree control
create object G_ALV_TREE
exporting
PARENT = G_CUSTOM_CONTAINER
NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_MULTIPLE
NODE_SELECTION_MODE = CL_GUI_COLUMN_TREE=>NODE_SEL_MODE_SINGLE
ITEM_SELECTION = 'X'
NO_HTML_HEADER = ''
NO_TOOLBAR = ''
exceptions
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
ILLEGAL_NODE_SELECTION_MODE = 5
FAILED = 6
ILLEGAL_COLUMN_NAME = 7.
if SY-SUBRC <> 0.
message X208(00) with 'ERROR'. "#EC NOTEXT
endif.
****logger
L_TREE_CONTAINER_NAME = 'ZLOGGER'.
create object G_TEXT_CONTAINER
exporting
CONTAINER_NAME = L_TREE_CONTAINER_NAME
exceptions
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
create object G_LOGGER
exporting PARENT = G_TEXT_CONTAINER
NAME = 'Error Log'.
call method G_LOGGER->SET_READONLY_MODE.
endlogger
data L_HIERARCHY_HEADER type TREEV_HHDR.
data: LT_LIST_COMMENTARY type SLIS_T_LISTHEADER,
L_LOGO type SDYDO_VALUE.
data : WA_FIELDCATALOG type LVC_S_FCAT.
perform BUILD_HIERARCHY_HEADER changing L_HIERARCHY_HEADER.
perform BUILD_COMMENT using LT_LIST_COMMENTARY
L_LOGO.
clear : WA_FIELDCATALOG, GT_FIELDCATALOG.
get fieldcatalog
call function 'LVC_FIELDCATALOG_MERGE'
exporting
I_STRUCTURE_NAME = 'ZGF_ICO_RECHR'
changing
CT_FIELDCAT = GT_FIELDCATALOG.
loop at GT_FIELDCATALOG into WA_FIELDCATALOG.
case WA_FIELDCATALOG-FIELDNAME.
when 'REF'.
WA_FIELDCATALOG-NO_OUT = 'X'.
endcase.
WA_FIELDCATALOG-OUTPUTLEN = 15.
modify GT_FIELDCATALOG from WA_FIELDCATALOG.
endloop.
call method G_ALV_TREE->SET_TABLE_FOR_FIRST_DISPLAY
exporting
IT_LIST_COMMENTARY = LT_LIST_COMMENTARY
I_LOGO = L_LOGO
i_structure_name = 'ZGF_ICO_RECHR'
IS_HIERARCHY_HEADER = L_HIERARCHY_HEADER
changing
IT_FIELDCATALOG = GT_FIELDCATALOG
IT_OUTTAB = GT_ZGF_ICO_RECHR. "table must be empty !
perform CREATE_HIERARCHY.
perform CHANGE_TOOLBAR.
perform REGISTER_EVENTS.
call method G_ALV_TREE->FRONTEND_UPDATE.
endform. " init_tree
*& Form build_hierarchy_header
form BUILD_HIERARCHY_HEADER changing
P_HIERARCHY_HEADER type TREEV_HHDR.
P_HIERARCHY_HEADER-HEADING = 'Reference Number'(300).
P_HIERARCHY_HEADER-TOOLTIP = 'Reference numbers for invoices'(400).
P_HIERARCHY_HEADER-WIDTH = 30.
P_HIERARCHY_HEADER-WIDTH_PIX = ' '.
endform. " build_hierarchy_header
*& Form create_hierarchy
form CREATE_HIERARCHY .
clear : LS_ZGF_ICO_RECHR, L_LAST_KEY.
§4a. Select data
refresh GT_ZGF_ICO_RECHR.
select * from ZGF_ICO_RECHR into table LT_ZGF_ICO_RECHR
where FREQ in SO_FREQ
and REF in SO_REF.
sort LT_ZGF_ICO_RECHR by REF.
Note: The top level nodes do not correspond to a field of the
output table. Instead we use data of the table to invent another
hierarchy level above the levels that can be build by sorting.
§4c. Add data to tree
G_CNTR = 1.
sort by oref->get_diva->image .
loop at LT_ZGF_ICO_RECHR into LS_ZGF_ICO_RECHR.
perform ADD_COMPLETE_LINE using LS_ZGF_ICO_RECHR
changing L_LAST_KEY.
G_CNTR = G_CNTR + 1.
perform add_node using ls_zgf_ico_rechr-ref
changing l_last_key.
endloop.
endform. " create_hierarchy
*& Module USER_COMMAND_0100 INPUT
module USER_COMMAND_0100 input.
SAVE_OK = OKCODE.
clear OKCODE.
case SAVE_OK.
when 'EXIT' or 'BACK' or 'CANC'.
perform EXIT_PROGRAM.
when others.
§6. Call dispatch to process toolbar functions
call method CL_GUI_CFW=>DISPATCH.
endcase.
call method CL_GUI_CFW=>FLUSH.
endmodule. " USER_COMMAND_0100 INPUT
*& Form exit_program
text
form EXIT_PROGRAM .
call method G_CUSTOM_CONTAINER->FREE.
leave to screen 0.
endform. " exit_program
*& Form add_complete_line
form ADD_COMPLETE_LINE using P_LS_ZGF_ICO_RECHR type ZGF_ICO_RECHR
P_RELAT_KEY type LVC_NKEY
changing P_NODE_KEY type LVC_NKEY.
data: L_NODE_TEXT type LVC_VALUE,
LO_REF type ref to LCL_REF,
L_NODE_LAYOUT type LVC_S_LAYN.
add leaf:
ALV Tree firstly inserts this node as a leaf if you do not provide
IS_NODE_LAYOUT with field ISFOLDER set.
Since these nodes will never get children they stay leaves
(as intended).
clear L_NODE_LAYOUT.
create object LO_REF exporting IM_REF = P_LS_ZGF_ICO_RECHR.
data : WA_OREF type TY_REF.
clear WA_OREF.
WA_OREF-O_REF = LO_REF.
append WA_OREF to GT_OREF.
L_NODE_LAYOUT = LO_REF->GET_DIVA( ).
L_NODE_TEXT = P_LS_ZGF_ICO_RECHR-REF.
call method G_ALV_TREE->ADD_NODE
exporting
I_RELAT_NODE_KEY = P_RELAT_KEY
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
IS_OUTTAB_LINE = P_LS_ZGF_ICO_RECHR "_REF
I_NODE_TEXT = L_NODE_TEXT
IS_NODE_LAYOUT = L_NODE_LAYOUT
importing
E_NEW_NODE_KEY = P_NODE_KEY.
endform. " add_complete_line
*& Form add_node
form ADD_NODE using P_REF
changing P_NODE_KEY type LVC_NKEY.
clear L_NODE_LAYOUT.
L_NODE_LAYOUT-ISFOLDER = ''.
L_NODE_LAYOUT-N_IMAGE = ICON_POSITIVE.
L_NODE_TEXT = 'Reference1'. " ps_sflight-carrid.
call method G_ALV_TREE->ADD_NODE
exporting
I_RELAT_NODE_KEY = '' " p_relat_key
I_RELATIONSHIP = CL_GUI_COLUMN_TREE=>RELAT_LAST_CHILD
I_NODE_TEXT = L_NODE_TEXT
IS_OUTTAB_LINE = P_REF
IS_NODE_LAYOUT = L_NODE_LAYOUT
importing
E_NEW_NODE_KEY = P_NODE_KEY.
endform. " add_node
*& Form register_events
form REGISTER_EVENTS .
data: LT_EVENTS type CNTL_SIMPLE_EVENTS,
L_EVENT type CNTL_SIMPLE_EVENT,
L_EVENT_RECEIVER type ref to LCL_EVENT_HANDLER.
call method G_ALV_TREE->GET_REGISTERED_EVENTS
importing
EVENTS = LT_EVENTS.
*NODE_DOUBLE_CLICK
clear L_EVENT.
move CL_GUI_COLUMN_TREE=>EVENTID_NODE_DOUBLE_CLICK to L_EVENT-EVENTID.
append L_EOk fine that can be acchived by setting the retention policy and by issuing delete obsolete command.That's perfect.If FRA is configured then even delete obsolete command is also not required.
but i want to keep the last full backup for 15 days and archived logs only for one day.In this case can we set seperate retention policy for full backup and backup of archived logs
for the time being i just want to modify my present existing OS script to acchive my task and i will conside changing RMAN script later on.Can u provide me the modified OS script so that my work gets finishes succesfully.
Thank You... -
Re: Data Source: 0CRM_PROD_OBJ_LIST
Dear All
We are using CRM data source:0CRM_PROD_OBJ_LIST(Delta) and ODS 0CRM_OL.
Issue: Data is loaded in to PSA correctly but when it is staged to ODS it is skipping some of the records.
Between this PSA and ODS their is a Start routine in Update rule.
Update rule name; 4ETV81OKAKCXHUFPSRYXMIVAT
Code in Start routine is attached.
1. Can Some one please check whether it is standard or Z? Because I had debugged the program I found no problem in it.
Sorry to attach the code here it is just to verify.
YPES: BEGIN OF new_data_structure,
item_guid(32) TYPE c,
item_changed_ts(8) TYPE p,
recordmode TYPE c,
END OF new_data_structure.
This global table contains information about relevant update
records. This table is filled when the first data package is
processed
DATA: gt_new_data TYPE SORTED TABLE OF new_data_structure
WITH NON-UNIQUE KEY item_guid item_changed_ts recordmode.
DATA: IN TYPE F,
OUT TYPE F,
DENOM TYPE F,
NUMER TYPE F.
data: rate like tcurr-UKURS.
constants: c_msgty_e value 'E'.
$$ end of global - insert your declaration only before this line -
The follow definition is new in the BW3.x
TYPES:
BEGIN OF DATA_PACKAGE_STRUCTURE.
INCLUDE STRUCTURE /BIC/CS0CRM_PROD_OBJ_LIST.
TYPES:
RECNO LIKE sy-tabix,
END OF DATA_PACKAGE_STRUCTURE.
DATA:
DATA_PACKAGE TYPE STANDARD TABLE OF DATA_PACKAGE_STRUCTURE
WITH HEADER LINE
WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
FORM startup
TABLES MONITOR STRUCTURE RSMONITOR "user defined monitoring
MONITOR_RECNO STRUCTURE RSMONITORS " monitoring with record n
DATA_PACKAGE STRUCTURE DATA_PACKAGE
USING RECORD_ALL LIKE SY-TABIX
SOURCE_SYSTEM LIKE RSUPDSIMULH-LOGSYS
CHANGING ABORT LIKE SY-SUBRC. "set ABORT <> 0 to cancel update
$$ begin of routine - insert your code only below this line -
fill the internal tables "MONITOR" and/or "MONITOR_RECNO",
to make monitor entries
**declaration
DATA: lt_active_data TYPE TABLE OF /bi0/acrm_ol00.
DATA: ls_active_data TYPE /bi0/acrm_ol00.
DATA: lt_active_data TYPE TABLE OF DATA_PACKAGE_structure.
DATA: ls_active_data TYPE DATA_PACKAGE_structure.
DATA: lv_fsname(60) TYPE c.
DATA: lv_psa_name TYPE rsodstech.
DATA: lv_dso_tabname TYPE tabname.
DATA: ls_new_data TYPE new_data_structure.
DATA: ls_new_data_pre TYPE new_data_structure.
DATA: ls_DATA_PACKAGE TYPE DATA_PACKAGE_structure.
DATA: help_index LIKE sy-tabix.
FIELD-SYMBOLS: <fs_minfo_requnr> TYPE ANY.
FIELD-SYMBOLS: <fs_minfo_datapakid> TYPE ANY.
FIELD-SYMBOLS: <fs_minfo_updmode> TYPE ANY.
FIELD-SYMBOLS: <fs_minfo_logsys> TYPE ANY.
**constants
CONSTANTS: lc_dso_name TYPE rsdodsobject VALUE '0CRM_OL'.
**end of declaration
**fetch request number
lv_fsname = 'g_s_minfo-requnr'.
ASSIGN (lv_fsname) TO <fs_minfo_requnr>.
**fetch data package number
lv_fsname = 'g_s_minfo-datapakid'.
ASSIGN (lv_fsname) TO <fs_minfo_datapakid>.
**fetch update mode
lv_fsname = 'g_s_minfo-updmode'.
ASSIGN (lv_fsname) TO <fs_minfo_updmode>.
**fetch source system
lv_fsname = 'g_s_minfo-logsys'.
ASSIGN (lv_fsname) TO <fs_minfo_logsys>.
**delete all data_package entries that...
**...are not object list elements
**...are dummy deletion records
**...are erroneous
DELETE DATA_PACKAGE WHERE flag NE 'O'.
OR
recordmode EQ 'D'.
**delta handling only processed for update modes 'delta' and 'repeat'
IF <fs_minfo_updmode> = 'D' OR <fs_minfo_updmode> = 'R'.
data selection and deletion handling only for the first data package
IF <fs_minfo_datapakid> = '000001'.
fetch technical name of actual PSA table
with I_SELTYPE = 'D' (Date)
CALL FUNCTION 'RSAR_ODS_NAME_GET'
EXPORTING
i_logsys = <fs_minfo_logsys>
i_isource = '0CRM_PROD_OBJ_LIST'
i_istype = 'D'
i_date = sy-datum
I_VERSION =
i_seltype = 'D'
I_SEGMENT_ID =
IMPORTING
E_ODSNAME =
e_odsname_db = lv_psa_name
E_ODS_TABTYPE =
E_S_ODS =
E_T_ODSFIELDS =
E_PARTITIONED =
EXCEPTIONS
parameter_failure = 1
no_ods_found = 2
no_fields_to_ods = 3
OTHERS = 4
IF sy-subrc = 0.
select new data from PSA Table
SELECT * FROM (lv_psa_name)
INTO CORRESPONDING FIELDS OF TABLE gt_new_data
only select data from actual request
...do not select erroneous records
...do not select object list records
WHERE request = <fs_minfo_requnr> AND
bwsttecsys2 NE '10' AND
flag_pl_ol NE 'P'.
IF sy-subrc = 0.
delete adjacent duplicates in gt_new_data
DELETE ADJACENT DUPLICATES FROM gt_new_data
COMPARING ALL FIELDS.
get technical name of active DSO table
CALL METHOD cl_rsd_odso=>get_tablnm
EXPORTING
i_odsobject = lc_dso_name
i_tabt = rsdod_c_tabt-active
IMPORTING
e_tablnm = lv_dso_tabname
E_TTYPENAME =
E_VIEWNM =
E_CHNGLOGNM =
E_INFOSOURCE =
E_DATASOURCE =
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
lv_dso_tabname = '/bi0/acrm_ol00'.
ENDIF.
select active data from ODS A-Table for relevant items
SELECT * FROM (lv_dso_tabname)
INTO CORRESPONDING FIELDS OF TABLE lt_active_data
FOR ALL ENTRIES IN gt_new_data
WHERE crm_itmgui = gt_new_data-item_guid.
delete older after images, only keep the latest one
LOOP AT gt_new_data INTO ls_new_data.
IF ls_new_data-item_guid EQ ls_new_data_pre-item_guid AND
( ls_new_data-item_changed_ts NE
ls_new_data_pre-item_changed_ts OR
for dummy deletion records on item level there could be
several entries with same value of item_changed_ts
because the changing date is not updated in case of
deletion of an item
in this case we only keep the dummy deletion record
itself
ls_new_data-recordmode = 'D' ).
help_index = sy-tabix - 1.
DELETE gt_new_data INDEX help_index.
ENDIF.
MOVE ls_new_data TO ls_new_data_pre.
ENDLOOP.
Now we delete all dummy deletion records in gt_new_data
DELETE gt_new_data WHERE recordmode = 'D'.
modify data of gt_active_data for field 'RECORDMODE' = 'D'
deletion records are written to the data package (Index 1)
LOOP AT lt_active_data INTO ls_active_data.
ls_active_data-recordmode = 'D'.
MOVE-CORRESPONDING ls_active_data TO ls_DATA_PACKAGE.
INSERT ls_DATA_PACKAGE INTO DATA_PACKAGE INDEX 1.
ENDLOOP.
delete records of older after images
do not consider deletion records
LOOP AT DATA_PACKAGE INTO ls_DATA_PACKAGE
WHERE recordmode NE 'D'.
help_index = sy-tabix.
relevant for update?
READ TABLE gt_new_data WITH KEY
item_guid = ls_DATA_PACKAGE-crm_itmgui
item_changed_ts = ls_DATA_PACKAGE-crm_itchts
BINARY SEARCH
TRANSPORTING NO FIELDS.
if not relevant, delete it!
IF sy-subrc <> 0.
DELETE DATA_PACKAGE INDEX help_index.
ENDIF.
CLEAR ls_DATA_PACKAGE.
CLEAR help_index.
ENDLOOP.
ENDIF.
ENDIF.
for data packages > 000001
ELSE.
delete records of older after images
LOOP AT DATA_PACKAGE INTO ls_DATA_PACKAGE.
help_index = sy-tabix.
relevant for update?
READ TABLE gt_new_data WITH KEY
item_guid = ls_DATA_PACKAGE-crm_itmgui
item_changed_ts = ls_DATA_PACKAGE-crm_itchts
BINARY SEARCH
TRANSPORTING NO FIELDS.
if not relevant, delete it!
IF sy-subrc <> 0.
DELETE DATA_PACKAGE INDEX help_index.
ENDIF.
CLEAR ls_DATA_PACKAGE.
CLEAR help_index.
ENDLOOP.
ENDIF.
ENDIF.
if abort is not equal zero, the update process will be canceled
ABORT = 0.
$$ end of routine - insert your code only before this line -
ENDFORM.
Analysis on it:
1. I read in the SAP help that u201CBefore you perform a delta update for this ODS object, ensure that data previously loaded into the ODS object is activated. Otherwise the delta update could lead to inconsistencies.u201D (http://help.sap.com/saphelp_tm80/helpdata/en/ba/21423fc657e07fe10000000a114084/frameset.htm). But I had seen in the ODS
(0CRM_OL) manage that number of requests are activated at once so I had deleted the ODS requests and reloaded one by one by activating them sequentially.
Till the request which has got problem that is SID of request 90949 (PSA) dated 06/09/2011. After loading the said request the contract number (0000132672) was still missing in the ODS. Then I had debugged the 9 data package of 90949 in which the contract number 0000132672 was present. I found that after the code for Start routine is completed the contract number was still existing in the internal table. But that is not updated into the New(Queue) Table of ODS.
Unable to debug the background job which is generated while updating the data from PSA to ODS, as no real data found at that time.
Code Process in Start Routine (It will use both the active table of ODS and PSA data (of relevant request )):
Conclusion: There is no problem in Start routine. (Seems it is standard routine (need to be confirmed)).
2. Found in Sap help that u201CWhen you use this InfoSource to load data into the ODS objects Product Lists (0CRM_PL) and Object Lists (0CRM_OL), you must set the processing method Only PSA with the option Update Subsequently in Data Targets in the corresponding InfoPackage. The update rules for the above ODS objects use a global table in their start routine to enable delta updates for this extractor. Once the data to be loaded has been distributed to multiple data packages, the contents of this global table are only retained if you have set the above processing method. If you set any other processing method, the contents of this global table are deleted between processing of data packagesu201D (http://help.sap.com/saphelp_bw33/helpdata/en/05/bb423fd9575003e10000000a114084/frameset.htm).
For this to implement need to delete data from ODS and from PSA so as to load the data with new info package (Process type Only PSA update sub sequential).
Edited by: sreekanth goud on Oct 25, 2011 8:02 AMHi Sreekanth,
First check whether you ur DSO had the right combination of key fields,once u r sure about it,check the start routine,please send the code. it's heavy to see.
Thanks & Regards
Rams Thota -
Write blob data from database to unix server
Hi all,
I need to send the attachment file into the mail. I have a header form in which I have implemented Download/Upload functionality using Apex user guide. When ever a user fill all the entries and submit the form then some field information along with attachment I need to send to the user.
I mean when ever user hit the submit button it should take blob data from my custom table tmp_downlod_files and send to the user as an attachment.
I have searched the post and got lot information but not able to get succeed.
I have implemented java stored procedure for sending automatic mail when user is submitting the form but what I need is to take blob content from database and send as an attachment.
1: So I need to write blob content from custom table to unix server in some location and from there I need to attach that file.
2: the java store which I have implemented for sending automatic mail is working and one argument is attachment which I am passing null for now. So mail is working how to write the file from database to unix server and send as an attachment.
What I did for writing file from database to unix server:
1:
CREATE OR REPLACE PROCEDURE trx_blob_to_file (l_header_id IN NUMBER)
IS
BEGIN
FOR rec_picture IN (SELECT ID
FROM TMP.tpx_download_files
WHERE header_id = l_header_id
AND mime_type LIKE ('image' || '%'))
LOOP
DECLARE
l_out_file UTL_FILE.file_type;
l_buffer RAW (32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_blob_len INTEGER;
p_data BLOB;
file_name VARCHAR2 (256);
BEGIN
SELECT blob_content, filename
INTO p_data, file_name
FROM tpx_download_files
WHERE ID = rec_picture.ID;
l_blob_len := DBMS_LOB.getlength (p_data);
l_out_file :=
UTL_FILE.fopen ('/home/oracle/interfaces/out/upld',
file_name,
'wb',
32767
WHILE l_pos < l_blob_len
LOOP
DBMS_LOB.READ (p_data, l_amount, l_pos, l_buffer);
IF l_buffer IS NOT NULL
THEN
UTL_FILE.put_raw (l_out_file, l_buffer, TRUE);
END IF;
l_pos := l_pos + l_amount;
END LOOP;
UTL_FILE.fclose (l_out_file);
EXCEPTION
WHEN OTHERS
THEN
IF UTL_FILE.is_open (l_out_file)
THEN
UTL_FILE.fclose (l_out_file);
END IF;
END;
END LOOP;
END;
2: I have written a PL/SQL process and calling the above procedure on SUBMIT:
DECLARE
l_header_id NUMBER;
l_filename VARCHAR2 (200);
BEGIN
SELECT header_id, filename
INTO l_header_id, l_filename
FROM tpx_download_files
WHERE header_id = :p35_sr_header_id;
trx_blob_to_file (l_header_id);
END;
But it is not writing the file from database to unix server.
If I can get how to make working to write file from database to unix server then I will hopefully can send an attachment.
3; I have given
GRANT EXECUTE ON TPX_BLOB_TO_FILE TO PUBLIC.
And
GRANT EXECUTE ON UTL_FILE TO PUBLIC.
Where I am doing wroung can anyone guide me or any other approach is appreciated.
I am already late so I need soon. Please help.Hi all,
I need to send the attachment file into the mail. I have a header form in which I have implemented Download/Upload functionality using Apex user guide. When ever a user fill all the entries and submit the form then some field information along with attachment I need to send to the user.
I mean when ever user hit the submit button it should take blob data from my custom table tmp_downlod_files and send to the user as an attachment.
I have searched the post and got lot information but not able to get succeed.
I have implemented java stored procedure for sending automatic mail when user is submitting the form but what I need is to take blob content from database and send as an attachment.
1: So I need to write blob content from custom table to unix server in some location and from there I need to attach that file.
2: the java store which I have implemented for sending automatic mail is working and one argument is attachment which I am passing null for now. So mail is working how to write the file from database to unix server and send as an attachment.
What I did for writing file from database to unix server:
1:
CREATE OR REPLACE PROCEDURE trx_blob_to_file (l_header_id IN NUMBER)
IS
BEGIN
FOR rec_picture IN (SELECT ID
FROM TMP.tpx_download_files
WHERE header_id = l_header_id
AND mime_type LIKE ('image' || '%'))
LOOP
DECLARE
l_out_file UTL_FILE.file_type;
l_buffer RAW (32767);
l_amount BINARY_INTEGER := 32767;
l_pos INTEGER := 1;
l_blob_len INTEGER;
p_data BLOB;
file_name VARCHAR2 (256);
BEGIN
SELECT blob_content, filename
INTO p_data, file_name
FROM tpx_download_files
WHERE ID = rec_picture.ID;
l_blob_len := DBMS_LOB.getlength (p_data);
l_out_file :=
UTL_FILE.fopen ('/home/oracle/interfaces/out/upld',
file_name,
'wb',
32767
WHILE l_pos < l_blob_len
LOOP
DBMS_LOB.READ (p_data, l_amount, l_pos, l_buffer);
IF l_buffer IS NOT NULL
THEN
UTL_FILE.put_raw (l_out_file, l_buffer, TRUE);
END IF;
l_pos := l_pos + l_amount;
END LOOP;
UTL_FILE.fclose (l_out_file);
EXCEPTION
WHEN OTHERS
THEN
IF UTL_FILE.is_open (l_out_file)
THEN
UTL_FILE.fclose (l_out_file);
END IF;
END;
END LOOP;
END;
2: I have written a PL/SQL process and calling the above procedure on SUBMIT:
DECLARE
l_header_id NUMBER;
l_filename VARCHAR2 (200);
BEGIN
SELECT header_id, filename
INTO l_header_id, l_filename
FROM tpx_download_files
WHERE header_id = :p35_sr_header_id;
trx_blob_to_file (l_header_id);
END;
But it is not writing the file from database to unix server.
If I can get how to make working to write file from database to unix server then I will hopefully can send an attachment.
3; I have given
GRANT EXECUTE ON TPX_BLOB_TO_FILE TO PUBLIC.
And
GRANT EXECUTE ON UTL_FILE TO PUBLIC.
Where I am doing wroung can anyone guide me or any other approach is appreciated.
I am already late so I need soon. Please help. -
Need Tutorial for Simple Voice Recording
I'm running for public office, and a local newspaper invited me to submit a statement along with a MP3 audio file. I asked a question on another forum about software that can be used to make MP3 files on a Leopard platform, and I was told to use GarageBand.
I viewed the video tutorial for Podcasts and also checked out another Apple tutorial, but they don't go very far. In contrast, GarageBand 3: Getting Started is overwhelming.
I would like to start by making a very simple audio - nothing more than a two-minute recording of my voice, with no overlaid music, no images, loops or other enhancements.
Can anyone list the steps I need to follow, from recording my speech to converting it to an MP3 file?
I've cliked the Male track, recorded my voice, stopped the recording (though probably incorrectly), then double-clicked on the file to play it back, but nothing happens.
Thanks.It's very easy:
• Create a "real instrument" track and select a voice preset or no effects at all.
• Hit "record" to record your voice, hit the record button again or the stop button to stop recording.
• Move the playhead to the appropriate position for playback.
• If you like your recording, select "Share to iTunes" from the menu and select compression with MP3. -
Rendering...Can anyone help???
I have 2 classes for rendering images. When i run the application, the images kept flashing, may i know how could i actually have 1 image appearing instead of many images flashing? In other words, i would like in a way similar to mosaic rendering process...Thanks alot
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
* TumbleItem.java requires these files:
* SwingWorker.java
* all the images in the images/tumble directory
* (or, if specified in the applet tag, another directory [dir]
* with images named T1.gif ... Tx.gif, where x is the total
* number of images [nimgs])
* the appropriate code to specify that the applet be executed,
* such as the HTML code in TumbleItem.html or TumbleItem.atag,
* or the JNLP code in TumbleItem.jnlp
public class TumbleItem extends JApplet
implements ActionListener {
int loopslot = -1; //the current frame number
String dir; //the directory relative to the codebase
//from which the images are loaded
javax.swing.Timer timer;
//the timer animating the images
int pause; //the length of the pause between revs
int offset; //how much to offset between loops
int off; //the current offset
int speed; //animation speed
int nimgs; //number of images to animate
int width; //width of the applet's content pane
Animator animator; //the applet's content pane
ImageIcon imgs[]; //the images
int maxWidth; //width of widest image
boolean finishedLoading = false;
JLabel statusLabel;
static Color[] labelColor = { Color.black, Color.black,
Color.black, Color.black,
Color.black, Color.black,
Color.white, Color.white,
Color.white, Color.white };
//Called by init.
protected void loadAppletParameters() {
//Get the applet parameters.
String at = getParameter("img");
dir = (at != null) ? at : "images/tumble";
at = getParameter("pause");
pause = (at != null) ? Integer.valueOf(at).intValue() : 1900;
at = getParameter("offset");
offset = (at != null) ? Integer.valueOf(at).intValue() : 0;
at = getParameter("speed");
speed = (at != null) ? (1000 / Integer.valueOf(at).intValue()) : 100;
at = getParameter("nimgs");
nimgs = (at != null) ? Integer.valueOf(at).intValue() : 16;
at = getParameter("maxwidth");
maxWidth = (at != null) ? Integer.valueOf(at).intValue() : 0;
* Create the GUI. For thread safety, this method should
* be invoked from the event-dispatching thread.
private void createGUI() {
//Animate from right to left if offset is negative.
width = getSize().width;
if (offset < 0) {
off = width - maxWidth;
//Custom component to draw the current image
//at a particular offset.
animator = new Animator();
animator.setOpaque(true);
animator.setBackground(Color.white);
setContentPane(animator);
//Put a "Loading Images..." label in the middle of
//the content pane. To center the label's text in
//the applet, put it in the center part of a
//BorderLayout-controlled container, and center-align
//the label's text.
statusLabel = new JLabel("Loading Images...",
JLabel.CENTER);
statusLabel.setForeground(labelColor[0]);
animator.add(statusLabel, BorderLayout.CENTER);
//Called when this applet is loaded into the browser.
public void init() {
loadAppletParameters();
//Execute a job on the event-dispatching thread:
//creating this applet's GUI.
try {
javax.swing.SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createGUI();
} catch (Exception e) {
System.err.println("createGUI didn't successfully complete");
//Set up the timer that will perform the animation.
timer = new javax.swing.Timer(speed, this);
timer.setInitialDelay(pause);
timer.setCoalesce(false);
timer.start(); //Start the animation.
//Loading the images can take quite a while, so to
//avoid staying in init() (and thus not being able
//to show the "Loading Images..." label) we'll
//load the images in a SwingWorker thread.
imgs = new ImageIcon[nimgs];
final SwingWorker worker = new SwingWorker() {
public Object construct() {
//Images are numbered 1 to nimgs,
//but fill array from 0 to nimgs-1.
for (int i = 0; i < nimgs; i++) {
imgs = loadImage(i+1);
finishedLoading = true;
return imgs;
//Executes in the event-dispatching thread.
public void finished() {
//Remove the "Loading images" label.
animator.removeAll();
loopslot = -1;
worker.start();
//The component that actually presents the GUI.
public class Animator extends JPanel {
public Animator() {
super(new BorderLayout());
protected void paintComponent(Graphics g) {
super.paintComponent(g);
if (finishedLoading &&
(loopslot > -1) && (loopslot < nimgs)) {
if (imgs != null && imgs[loopslot] != null) {
imgs[loopslot].paintIcon(this, g, off, 0);
//Update the the loopslot (frame number) and the offset.
//If it's the last frame, restart the timer to get a long
//pause between loops.
public void actionPerformed(ActionEvent e) {
loopslot++;
if (!finishedLoading) {
int colorIndex = loopslot % labelColor.length;
try {
statusLabel.setForeground(labelColor[colorIndex]);
} catch (NullPointerException exc) {}
return;
if (loopslot >= nimgs) {
loopslot = 0;
off += offset;
if (off < 0) {
off = width - maxWidth;
} else if (off + maxWidth > width) {
off = 0;
animator.repaint();
if (loopslot == nimgs - 1) {
timer.restart();
//Called to start the applet's execution.
public void start() {
if (finishedLoading && (nimgs > 1)) {
timer.restart();
//Called to stop (temporarily or permanently) the applet's execution.
public void stop() {
timer.stop();
protected ImageIcon loadImage(int imageNum) {
String path = dir + "/Image" + imageNum + ".jpg";
int MAX_IMAGE_SIZE = 2400; //Change this to the size of
//your biggest image, in bytes.
int count = 0;
BufferedInputStream imgStream = new BufferedInputStream(
this.getClass().getResourceAsStream(path));
if (imgStream != null) {
byte buf[] = new byte[MAX_IMAGE_SIZE];
try {
count = imgStream.read(buf);
imgStream.close();
} catch (java.io.IOException ioe) {
System.err.println("Couldn't read stream from file: " + path);
return null;
if (count <= 0) {
System.err.println("Empty file: " + path);
return null;
return new ImageIcon(Toolkit.getDefaultToolkit().createImage(buf));
} else {
System.err.println("Couldn't find file: " + path);
return null;
public String getAppletInfo() {
return "Title: TumbleItem v1.2, 23 Jul 1997\n"
+ "Author: Interactive Mosaic\n"
+ "A simple Item class to play an image loop.";
public String[][] getParameterInfo() {
String[][] info = {
{"img", "string", "the directory containing the images to loop"},
{"pause", "int", "pause between complete loops; default is 3900"},
{"offset", "int", "offset of each image to simulate left (-) or "
+ "right (+) motion; default is 0 (no motion)"},
{"speed", "int", "the speed at which the frames are looped; "
+ "default is 100"},
{"nimgs", "int", "the number of images to be looped; default is 16"},
{"maxwidth", "int", "the maximum width of any image in the loop; "
+ "default is 0"}
return info;
import javax.swing.SwingUtilities;
public abstract class SwingWorker {
private Object value; // see getValue(), setValue()
* Class to maintain reference to current worker thread
* under separate synchronization control.
private static class ThreadVar {
private Thread thread;
ThreadVar(Thread t) { thread = t; }
synchronized Thread get() { return thread; }
synchronized void clear() { thread = null; }
private ThreadVar threadVar;
* Get the value produced by the worker thread, or null if it
* hasn't been constructed yet.
protected synchronized Object getValue() {
return value;
* Set the value produced by worker thread
private synchronized void setValue(Object x) {
value = x;
* Compute the value to be returned by the <code>get</code> method.
public abstract Object construct();
* Called on the event dispatching thread (not on the worker thread)
* after the <code>construct</code> method has returned.
public void finished() {
* A new method that interrupts the worker thread. Call this method
* to force the worker to stop what it's doing.
public void interrupt() {
Thread t = threadVar.get();
if (t != null) {
t.interrupt();
threadVar.clear();
public Object get() {
while (true) {
Thread t = threadVar.get();
if (t == null) {
return getValue();
try {
t.join();
catch (InterruptedException e) {
Thread.currentThread().interrupt(); // propagate
return null;
* Start a thread that will call the <code>construct</code> method
* and then exit.
public SwingWorker() {
final Runnable doFinished = new Runnable() {
public void run() { finished(); }
Runnable doConstruct = new Runnable() {
public void run() {
try {
setValue(construct());
finally {
threadVar.clear();
SwingUtilities.invokeLater(doFinished);
Thread t = new Thread(doConstruct);
threadVar = new ThreadVar(t);
* Start the worker thread.
public void start() {
Thread t = threadVar.get();
if (t != null) {
t.start();
}Nobody pays any attention to those boundries ...
indeed many feel - and with good reason IMO - that
the response time is better on THIS forum.I don't agree. The Swing forum is followed by several
people who are very competent to answer Swing
questions. Questions posted there usually receive
good answers. Whereas this forum -- sure, people
answer questions here too. But it is also populated
by trolls and buffoons. And by people who don't have
the intelligence to figure out where a question
should be posted.
There are obvious reasons for having thirty forums
instead of one. I'm sure you can figure them out
without my help. So given that there should be more
than one forum, it follows that people should post in
the correct forum.I better quit while I can still stand, huh ;o)
Look I'll say it again ... I was not and am not suggesting that the camickr's point of view was wrong. I only questioned the weight that he appeared to be putting on it by outspokenly stating that swing questions ought to be posted to the swing forum only.
There are, as you state, a lot of other more specific forums; there are AWT forums and JDBC forums, etc., but I can't remember the last time someone posted that AWT, JDBC, or whatever threads ought ONLY be posted to their respective forums. In actual fact, in many/most cases they probably should be.
I had started a thread on - I think it was the AWT or some other forum - and found the response was not nearly so quick as it is on this forum. I'd noticed at least once that another well respected forum regular - not unlile yourself - did similarly.
My main point was - and at this point I am sorry that I even mentioned it I think - there alot of other issues that IMO - I image from what you wrote you don't agree, but in my opinion, take precedence.
Have a great weekend, and best regards,
~Bill -
How to install opensuse-arm-xfce-12.3 on Lenovo A3000 tab
Sir recently I have bought Lenovo A3000 tab which is having android version 4.2.2 and 16 GB internal memory, 1.2 giga hertz quad core processor and 1GB ram.
I want to use opensuse on my tab so I have downloaded the file opensuse-arm-xfce-12.3.tar.xz I have extracted successfully it and found .IMG file and opensuse.sh file.
Kindly suggest how to install the above os in my tab with dual booting ie., opensuse and android.
I am expecting the two operating systems to be on 16 GB internal memory and so suggest how to partition the internal memory.
I have searched the net and followed the procedure which is too difficult to understand even though I have performed some of the steps like becoming root, installing busy box,complete Linux installer etc.,.
when I launch the complete Linux installer app it is showing message as unable to mount the image loop device not working.
Regards,
Rupesh.
Regards,
Rupesh.hi Fabian,
Welcome to the Forums.
Can y0u check tjniko s post in this thread as he was able to successfully install Win8.1 on the device.
Regards
Did someone help you today? Press the star on the left to thank them with a Kudo!
If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
Follow @LenovoForums on Twitter!
Maybe you are looking for
-
Should I run my MacBook Pro in 64 bit mode?
Thoughts?
-
Organize By Thread not working in iOS 5 Mail
Since my iOS 5 update, viewing mail messages by thread no longer works for me (both on an iPhone 4s and an iPad 2). This happens with an imap account. (I don't know whether POP accounts are affected.) It's easy to test this: Send yourself a mail mess
-
What will happen to the data I´ve in my Key ring when migrating to iCloud
What will happen to the data I´ve in my Key ring when migrating to iCloud? Any feedback is appreciated Uwe
-
How to make config to Make GR before IR in Imports
Hi All, Our Client has configuration Imports Pricing procedure as per the flow:- 1. ME21N 2. MIRO - Customs 3. J1IEX Part 1 4. MIGO & Part 2 5. MIRO For Local PO 1. ME21N 2.GR 3.MIRO Now for one new scenario in imports we need to define the prici
-
"+" Over Applications, "?" Over Application Icons
Hey all, I just purchased a new Macbook Pro 15" (2.53GHz, 4GB, 320GB HDD). I was skeptical of using Migration Assistant to move all my stuff from my old G5 desktop (see signature) that was still in PowerPC world (3 years old this past May!). All went