Autor Thema: Diagramm erzeugen  (Gelesen 5300 mal)

TomLudwig

  • Gast
Diagramm erzeugen
« am: 04.07.07 - 13:09:13 »
Hallo zusammen,

ich habe die Aufgabe über einen BackEndAgenten ein Diagramm zu erzeugen. Dies dann anschließend an den betroffenen User als Mail zu verschicken. Ich wollte JFreeChart benutzten. Habe es aber nicht zum laufen bekommen.
Kann mir da jemand weiter helfen? Oder hat jemand von euch eine andere Lösung parat?

Danke euch vielmals für eure Hilfe.

Tom

P.S.: Domino Server Version 6.5.1

Log des Agenten mit JFreeChart:

AMgr: Agent ('Test' in 'TEST.nsf') error message: java.lang.ExceptionInInitializerError:
AMgr: Agent ('Test' in 'TEST.nsf') error message: java.security.AccessControlException: access denied (java.lang.RuntimePermission getClassLoader)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:286)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at java.security.AccessController.checkPermission(AccessController.java:413)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at java.lang.SecurityManager.checkPermission(SecurityManager.java:565)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at java.lang.Thread.getContextClassLoader(Thread.java:1139)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.util.ObjectUtilities.getClassLoader(ObjectUtilities.java:263)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.util.ObjectUtilities.isJDK14(ObjectUtilities.java:436)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.text.TextUtilities.<clinit>(TextUtilities.java:102)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.chart.title.TextTitle.arrangeRR(TextTitle.java:499)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.chart.title.TextTitle.arrange(TextTitle.java:460)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.chart.JFreeChart.drawTitle(JFreeChart.java:1300)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1190)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1388)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1368)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at org.jfree.chart.JFreeChart.createBufferedImage(JFreeChart.java:1353)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at agent.Test.JavaAgent.NotesMain(JavaAgent.java:44)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at lotus.domino.AgentBase.runNotes(Unknown Source)
AMgr: Agent ('Test' in 'Test.nsf') error message:    at lotus.domino.NotesThread.run(NotesThread.java:215)

Offline m3

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.102
  • Geschlecht: Männlich
  • Non ex transverso sed deorsum!
    • leyrers online pamphlet
Re: Diagramm erzeugen
« Antwort #1 am: 04.07.07 - 13:17:04 »
Dein Agent hat keine ausreichenden Rechte. Kontaktiere Deinen Admin.
HTH
m³ aka. Martin -- leyrers online pamphlet | LEYON - All things Lotus (IBM Collaborations Solutions)

All programs evolve until they can send email.
Except Microsoft Exchange.
    - Memorable Quotes from Alt.Sysadmin.Recovery

"Lotus Notes ist wie ein Badezimmer, geht ohne Kacheln, aber nicht so gut." -- Peter Klett

"If there isn't at least a handful of solutions for any given problem, it isn't IBM"™ - @notessensai

TomLudwig

  • Gast
Re: Diagramm erzeugen
« Antwort #2 am: 04.07.07 - 13:25:52 »
Ich habe volle Rechte zum Ausführen beschränkter und unbeschränkter Agenten.

Ich habe gelesen, dass eine java.policy Datei verändert werden muss, wenn die JAR Files nicht im Agenten sondern auf der Platte hinterlegt sind.

--> Da die JAR Files im Agenten hinterlegt sind, habe ich diesen Ansatz nicht weiter verfolgt.
--> Zudem weiß ich leider nicht, was in diese Datei eingetragen werden müsste.

Hat den noch niemand JFreeChart periodisch laufen lassen im Hintergrund?
Kann es an der NotesVersion liegen? JFreeChart setzt mindestens Java 1.3.1 vorraus, was Notes 6.5 ja mitliefert.

Nachtrag:
Es stoßen mehr auf das Problem, welches anscheinend kein Rechteproblem ist. Ich finde aber leider nirgendswo eine Lösung.
http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/65b6aaceb98e493985257108005ebeef?OpenDocument
« Letzte Änderung: 04.07.07 - 13:29:47 von TomLudwig »

Offline flaite

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.966
    • mein del.icio.us
Re: Diagramm erzeugen
« Antwort #3 am: 06.07.07 - 11:17:25 »
Hast du in der Eigenschaftsbox des Agenten im 2. Reiter das rot eingekreiste so eingestellt wie in diesem Bild  ???
Der angemeckerte Aufruf ist letztlich der:
Code
AMgr: Agent ('Test' in 'Test.nsf') error message:    at java.lang.Thread.getContextClassLoader(Thread.java:1139)
Das sollte mit der Einstellung erlaubt sein.

Kannst du vielleicht mal den Source Code posten?
« Letzte Änderung: 06.07.07 - 11:35:29 von Axel Janssen »
Ich stimm nicht mit allen überein, aber mit vielen und sowieso unterhaltsam -> https://www.youtube.com/channel/UCr9qCdqXLm2SU0BIs6d_68Q

---

Aquí no se respeta ni la ley de la selva.
(Hier respektiert man nicht einmal das Gesetz des Dschungels)

Nicanor Parra, San Fabian, Región del Bio Bio, República de Chile

TomLudwig

  • Gast
Re: Diagramm erzeugen
« Antwort #4 am: 06.07.07 - 11:39:54 »
Den Haken hab ich gesetzt. Ich habs auch schon mit der 3ten Option ausprobiert.
Hier der Quellcode, den ich aus einem Beispiel kopiert und minimals modifiziert hab. Habe lediglich die Eingabe durch den User auskommentiert.

Code
package agent.lastTest; 

import lotus.domino.*; 
public class JavaAgent extends AgentBase { 
	public void NotesMain() { 
		try { 

			Session session = getSession();
			AgentContext agentContext = session.getAgentContext();
			
			// create the new PieChartWrapper object
			PieChartWrapper myPie = new PieChartWrapper();
			
			// give it a title
			myPie.setTitle("My Test Pie Chart");
			
			// you can add some data manually like this
			myPie.addData("Java", 20);
			myPie.addData("LotusScript", 50);
			myPie.addData("Formula", 10);
			
			// or prompt the user with our special GetPieDataDialog
//			GetPieDataDialog dialog = new GetPieDataDialog();
//			while (true) {
//				dialog.display();
//				if (dialog.wasCancelClicked()) { break; }
//				myPie.addData(dialog.getLabel(), dialog.getData());
//			}
			
			// show the finished pie chart to the user
			//myPie.displayAsDialog(500, 275);
//			myPie.displayAsDialog(850, 550);
			
			
			// just for fun, let's save this as a file and send it in an e-mail
			String fileName = "C:\\Dokumente und Einstellungen\\FZiegler.IS\\Desktop\\test.jpg";
			myPie.sendToJpgFile(fileName, 600, 400);
			
			// create the doc we're going to send
			session.setConvertMIME(false);
			Database db = agentContext.getCurrentDatabase();
			Document doc = db.createDocument();
			doc.replaceItemValue("Form", "Memo");
			
			// create the MIME body and add a subject (we're using
			// MIME instead of a regular RichTextItem here because
			// with a MIME field the image will be displayed inline
			// instead of as an attachment)
			MIMEEntity body = doc.createMIMEEntity("Body");
			MIMEHeader header = body.createHeader("Subject");
			header.setHeaderVal("Here's that report you wanted");
			
			// add the JPEG file to the body
			Stream stream = session.createStream();
			stream.open(fileName, "binary");
			body.setContentFromBytes(stream, "image/jpeg",
				MIMEEntity.ENC_IDENTITY_BINARY);
			stream.close();
			
			// and send the doc off
			try {
				doc.send("Felix Ziegler/NUE/DE/ISGROUP");
			} catch (Exception se) {
				// if sending the message failed, just store the doc
				// in this database
				try { doc.save(true, true); } catch (Exception ignored) {}
			}
			session.setConvertMIME(true);
			
			
		} 
		catch(Exception e) { 
			e.printStackTrace(); 
		} 
	} 
} 

Code
package agent.lastTest;

/*
This script library has the jfreechart and jcommon JAR files that
are used to create charts and graphs with the JFreeChart libraries.
Click the "Edit Project" button at the bottom of the agent window
to see, if you don't believe me.

These libraries are free and open source, licensed for use under
the GNU Lesser General Public License (you can read about it at
http://www.jfree.org/lgpl.php )

For more information on the libraries themselves, please visit:
http://www.jfree.org/jfreechart

For a LOT of code examples of how to create charts with JFreeChart,
please see http://www.object-refinery.com/jfreechart/guide.html
*/

import java.io.*;
import org.jfree.chart.*;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import java.awt.image.BufferedImage;

public class PieChartWrapper {
/* This is just a simple wrapper class to allow you to easily create a
  3-D pie chart with JFreeChart. It probably needs a little more error
  handling and functionality.
  
  version 1.0
  December 3, 2005
  Julian Robichaux -- http://www.nsftools.com
*/

private DefaultPieDataset data;
private JFreeChart chart;
private String chartTitle = "";
private boolean dataChanged = false;


public PieChartWrapper () {
	data = new DefaultPieDataset();
}


/*
 Give the chart a title.
*/
public void setTitle (String title) {
	chartTitle = title;
}


/*
 Add some new data (a label and numeric value) to the pie chart.
*/
public void addData (String label, double value) {
	data.setValue(label, new Double(value));
	dataChanged = true;
}


/*
 Clear any data you've already added.
*/
public void clearData () {
	data = new DefaultPieDataset();
	dataChanged = true;
}


private void createChart () {
	if ((chart == null) || dataChanged) {
		chart = ChartFactory.createPieChart3D(chartTitle, data, true, false, false);
		// this is what creates the cool transparency effect
		PiePlot3D pieplot3d = (PiePlot3D)chart.getPlot();
		pieplot3d.setForegroundAlpha(0.5F);
		dataChanged = false;
	}
}


/*
 Return the current pie chart as a BufferedImage.
*/
public BufferedImage getAsBufferedImage (int width, int height) {
	createChart();
	return chart.createBufferedImage (width, height);
}


/*
 Save the current pie chart as a JPEG file. For example:
     mypie.sendToJpgFile("c:\\test.jpg", 850, 500);
*/
public void sendToJpgFile (String fileName, int width, int height) 
	throws FileNotFoundException, IOException {
	createChart();
	NotesChartHelper.sendToJpgFile(chart, fileName, width, height);
}


/*
 Display the current pie chart in a dialog window. A good value 
 for width/height is 850 and 550 for a larger window, or 500 and 275
 for a smaller one.
*/
public void displayAsDialog (int width, int height) {
	createChart();
	NotesChartHelper.displayAsDialog(chart, chartTitle, width, height);
}
}




Code
package agent.lastTest;


import java.io.*;
import org.jfree.ui.*;
import org.jfree.chart.*;
import javax.swing.*;
import java.awt.image.BufferedImage;
import com.sun.image.codec.jpeg.*;

/*
These are a few helper functions to allow you to easily work with
JFreeChart charts in Notes.
*/
public class NotesChartHelper {
	/*
	    Save the current chart as a JPEG file.
	  */
	public static void sendToJpgFile (JFreeChart chart, String fileName, int width, int height) 
		throws FileNotFoundException, IOException {
		BufferedImage bi = chart.createBufferedImage (width, height);
		FileOutputStream out = new FileOutputStream(fileName);
		JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
		JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam (bi);
		param.setQuality(0.75f, false);
		encoder.encode(bi, param);
		out.close();
	}
	
	
	/*
	    Display the current chart in a dialog window.
	  */
	public static void displayAsDialog (JFreeChart chart, String chartTitle, 
			int width, int height) {
/*		
		// this is the "right" way to display the chart to the user; however,
		// in Notes there's something about the code that causes
		// java.lang.SecurityException errors -- the chart will still display,
		// but the errors will pile up in the background, which is usually
		// not a good thing
		ApplicationFrame frame = new ApplicationFrame(chartTitle);
		ChartPanel chartPanel = new ChartPanel(chart);
		chartPanel.setPreferredSize(new java.awt.Dimension(width, height));
		frame.setContentPane(chartPanel);
		
		frame.pack();
		RefineryUtilities.centerFrameOnScreen(frame);
		frame.setVisible(true);
		frame.toFront();
*/
		
		// instead, we'll display the chart this way (the JFreeChart way
		// has some additional cool options like a right-click menu,
		// but it's not worth it to deal with the errors that get generated
		// and that might bite you later on)
		
		// create the frame
		JFrame frame = new JFrame(chartTitle);
		
		// create the panel that displays the chart
		JPanel panel = new JPanel();
		panel.add(new JLabel(
				new ImageIcon(chart.createBufferedImage (width, height))));
		
		// add the panel to the frame
		frame.setContentPane(panel);
		frame.pack();
		
		// center the frame and display it
		RefineryUtilities.centerFrameOnScreen(frame);
		frame.setVisible(true);
		frame.toFront();
	}
	

}


 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz