本文整理汇总了Java中com.xeiam.xchart.SwingWrapper类的典型用法代码示例。如果您正苦于以下问题:Java SwingWrapper类的具体用法?Java SwingWrapper怎么用?Java SwingWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SwingWrapper类属于com.xeiam.xchart包,在下文中一共展示了SwingWrapper类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContainer
import com.xeiam.xchart.SwingWrapper; //导入依赖的package包/类
/**
* Container for chart.
*
* @param chart
* chart
* @return Container
*/
public static Container getContainer(final Chart chart) {
// Wrap the chart in a JFrame and hide the frame
JFrame frame = new SwingWrapper(chart).displayChart();
frame.addWindowListener(new HideWindowAdapter());
return frame.getContentPane();
}
示例2: drawGraph
import com.xeiam.xchart.SwingWrapper; //导入依赖的package包/类
/**
* Draw a graph of the loss values as a functions of the iterations
* @param scores an array list of the loss values
* @param save a flag indicates whether or not to save the img
*/
public void drawGraph(ArrayList<Double> scores, boolean save) {
try {
// setting the data fit for the plotting
double[] xData = new double[scores.size()];
double[] yData = new double[scores.size()];
for(int i=0 ; i<scores.size() ; i++){
yData[i] = scores.get(i);
xData[i] = i+1;
}
// Create Chart
Chart chart = QuickChart.getChart(TITLE, X_TITLE, Y_TITLE, SERIES_NAME, xData, yData);
// Show it
new SwingWrapper(chart).displayChart();
if (save) {
// or save it in high-res
Logger.info("=========================");
Logger.info("Saving image: " + IMG_PATH);
Logger.info("=========================");
File imgDir = new File(IMG_DIR);
// if the directory does not exist, create it
if (!imgDir.exists()) {
Logger.info("creating directory: img/");
boolean result = false;
try{
result = imgDir.mkdir();
}
catch(SecurityException se){
Logger.error("There is no permission to write the error image.");
}
if(result) {
Logger.info("DIR created");
BitmapEncoder.saveBitmapWithDPI(chart, IMG_PATH, BitmapEncoder.BitmapFormat.PNG.PNG, 300);
}
}
BitmapEncoder.saveBitmapWithDPI(chart, IMG_PATH, BitmapEncoder.BitmapFormat.PNG.PNG, 300);
}
}catch (Exception e){
e.printStackTrace();
}
}
示例3: show
import com.xeiam.xchart.SwingWrapper; //导入依赖的package包/类
public static void show() {
new SwingWrapper(CHART).displayChart();
}