Generate data and make a graph

This example shows you how to generate a simple data channel in jBEAM and how to display the generated data. The most of code of this example is combined from different code snippets above.

The first thing you have to do is to start your jBEAM. After startup, you can enter the example code. So you have to click on Extra -> Miscellaneous -> Scripting. After clicking, you see the Script-Editor. There you can choose the prefered scripting language and paste the code from this example. You can also test the pasted code with the Test Script Button before executing. After click on “ok” the script will be executed.

This script does the following things:

  • generating a numeric double channel with values of the RAINFLOW_TEST
  • create a UniversalCurveGraph
  • add the generated value channel to the UniversalCurveGraph
import java.awt.Color;
import java.awt.geom.*;
import com.AMS.jBEAM.*;

// new Numeric Channel Generator Component
NumericChannelGenerator numChanGen = (NumericChannelGenerator) jC.newComponent(jbComponentIF.GEN_DOUBLE_CHANNEL);
// setting of function to generate, here Rain flow function
numChanGen.setFunction (NumericChannelGenerator.Function.RAINFLOW_TEST);
// definition of how many values to be created
numChanGen.setRequestedValues (100);
// setting of delta x
// important to display the delete button in the modification dialog of the channel
// validate framework to import file and get a valid jBEAM
// If parameter block is true, validation runs in main thread if operationMode is set to jbDataItemManagerIF.NOT_THREADED until the validation is finished

// get the graphic window from jBEAM
GraphLayoutFrame layoutFrame = jG.getTopMostGraphFrame();

AbstractGraphicPanel activeGraphicPanel = layoutFrame.getActiveGraphicPanel();
// create new bounds for the graph
Rectangle2D.Float diagramBounds = new Rectangle2D.Float();
// creates a new graph and add it to the graphicpanel
UniversalCurveGraph u2DGraph = (UniversalCurveGraph) activeGraphicPanel.addNewGraph(jbVisualObjectIF.UNI_CURVE_GRAPH, diagramBounds, false);

// size values
int graphWidth = 500;
int graphHeight = 400;

// sets position and size
u2DGraph.setScreenBounds(0, 0, graphWidth, graphHeight);
// makes the graph modifyable in jBEAM
// makes the graph moveable
// makes the graph resizeable
// makes the graph printable -> important for PDF-Export
// used for index in border
// to hide the legend
// set title of the graph
// delets all existing curves from the graph

// creates a new XY_Curve
XY_Curve curve = new XY_Curve(u2DGraph);
// sets the input data from the generator to the curve
// sets the line color of the curve
// adds curve to the graph


After the execution of this code you see a curvegraph, which displays the generated RAINFLOW_TEST data as a curve. If you now want to export this curve, e.g. as PDF, you can use the script Create Reports.

For further details have a look at the code documentation above or look at the JAVADOC of jBEAM.

Copyright by Kistler Chemnitz GmbH 2021
XWiki Enterprise 4.4 - Documentation