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.
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();
}
}
}
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);
}
}
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();
}
}