本文整理匯總了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();
}