显示Java应用程序中不同属性的图表
进口java.awt。*;
进口java.awt.event.ActionEvent;
进口java.awt.event.ActionListener;
进口java.awt.event.MouseEvent;
进口java.awt.event.MouseListener;
进口java.awt.image.BufferedImage;
进口java.io.File;
进口com.rapidminer.RapidMiner;
进口com.rapidminer.RepositoryProcessLocation;
进口com.rapidminer.belt.table.Table;
进口com.rapidminer.example.Attribute;
进口com.rapidminer.example.Attributes;
进口com.rapidminer.example.Example;
进口com.rapidminer.example.ExampleSet;
进口com.rapidminer.example.table.ExampleTable;
进口com.rapidminer.example.table.MemoryExampleTable;
进口com.rapidminer.example.table.ResultSetDataRowReader;
进口com.rapidminer.gui.RapidMinerGUI;
进口com.rapidminer.gui.ToolbarGUIStartupListener;
进口com.rapidminer.gui.renderer.Renderer;
进口com.rapidminer.gui.renderer.RendererService;
进口com.rapidminer.operator.ExecutionMode;
进口com.rapidminer.operator.IOContainer;
进口com.rapidminer.operator.IOObject;
进口com.rapidminer.tools.PlatformUtilities;
进口com.rapidminer.Process;
进口com.rapidminer.RapidMiner;
进口com.rapidminer.operator.Operator;
进口com.rapidminer.operator.OperatorException;
进口com.rapidminer.operator.learner.tree.DecisionTreeLeafCreator;
进口com.rapidminer.report.Renderable;
进口com.rapidminer.report.Reportable;
进口com.rapidminer.repository.IOObjectEntry;
进口com.rapidminer.repository.MalformedRepositoryLocationException;
进口com.rapidminer.repository.ProcessEntry;
进口com.rapidminer.repository.Repository;
进口com.rapidminer.repository.RepositoryException;
进口com.rapidminer.repository.RepositoryLocation;
进口com.rapidminer.repository.RepositoryManager;
进口com.rapidminer.tools.XMLException;
进口com.rapidminer.tools.plugin.Plugin;
进口com.rapidminer.operator.concurrency。*;
进口com.rapidminer.operator.concurrency.internal。*;
进口java.io.File;
进口java.io.IOException;
导入java . lang . object;
进口java.nio.file.Paths;
进口java.util.ArrayList;
进口java.util.Collection;
进口java.util.Iterator;
进口java.util.Scanner;
进口java.util.Vector;
进口javax.imageio.ImageIO;
进口javax.swing。*;
进口javax.swing.filechooser.FileSystemView;
进口javax.swing.table.DefaultTableModel;
公共类GUILauncher实现ActionListener{
JFrame mainFrame = new JFrame("App");
JFrame imageFrame = new JFrame("Image");
JTable tData = new JTable();
JScrollPane span = new JScrollPane(tData);
DefaultTableModel dtm = new DefaultTableModel();
JLabel s = new JLabel();
JPanel bPanel = new JPanel(new FlowLayout());
JButton b25 = new JButton("25%");
JButton b30 = new JButton("30%");
JButton b50 = new JButton("50%");
JFileChooser文件= new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
JPanel textPanel = new JPanel(new GridLayout(1,3));
JPanel filePanel = new JPanel(new FlowLayout());
JPanel imagePanel = new JPanel(new GridLayout(1,1));
JTextArea = new JTextArea(25,5);
JTextArea bText = new JTextArea(25,5);
JTextArea = new JTextArea(25,5);
公共GUILauncher () {
mainFrame.setVisible(真正的);
大型机。setSize(720、500);
mainFrame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
mainFrame.setLocationRelativeTo(空);
textPanel.add (aText);
textPanel.add (bText);
textPanel.add (cText);
imagePanel.add(年代);
bPanel.add (b25);
bPanel.add (b30);
bPanel.add (b50);
aText.setLineWrap(真正的);
bText.setLineWrap(真正的);
cText.setLineWrap(真正的);
filePanel.add(文件);
大型机。add (bPanel BorderLayout.CENTER);
大型机。add (textPanel BorderLayout.NORTH);
imageFrame。add (imagePanel BorderLayout.CENTER);
b25.addActionListener(这个);
b30.addActionListener(这个);
b50.addActionListener(这个);
System.setProperty (PlatformUtilities。PROPERTY_RAPIDMINER_HOME Paths.get (" ") .toAbsolutePath () .toString ());
RapidMiner.setExecutionMode (RapidMiner.ExecutionMode.COMMAND_LINE);
RapidMiner.init ();
插件。setPluginLocation(“D: / RapidMiner工作室/ lib /插件”);
插件。addAdditionalExtensionDir(“D: / RapidMiner工作室/ lib /插件”);
Plugin.setInitPlugins(真正的);
}
public static void main(String args[])抛出异常{
新GUILauncher ();
}
public void actionPerformed(ActionEvent arg0) {
if(arg0.getSource() == b25){
库回购;
Process Process = null;
RepositoryProcessLocation processLocation;
IOContainer iresult = null;
尝试{
repo = RepositoryManager.getInstance(null). getrerepository ("Projects");
processLocation = new RepositoryProcessLocation(new RepositoryLocation(repo.getLocation(), "Process_25%"));
process = processLocation.load(null);
iresult = process.run();
} catch (RepositoryException | IOException | XMLException | operatoreexception e) {
// TODO自动生成捕获块
e.printStackTrace ();
}
iobject result = iresult . getelementat (2);
字符串名称= RendererService.getName(result.getClass());
java.util。List
imageFrame.setVisible(真正的);
imageFrame。setSize(400、500);
imageFrame.setDefaultCloseOperation (JFrame.HIDE_ON_CLOSE);
imageFrame.setLocationRelativeTo(空);
(渲染器渲染器渲染器):{
IOContainer dummy = new IOContainer();
int imgWidth = 400;
int imgHeight = 400;
Reportable = renderer。createReportable(result, dummy, imgWidth, imgHeight);
if(reportableinstanceofrenderable){
Renderable = (Renderable)可报告;
renderable.prepareRendering ();
int preferredWidth = renderable.getRenderWidth(800);
int preferredHeight = renderable.getRenderHeight(800);
final buffereimage img = new buffereimage (imgWidth, imgHeight, BufferedImage. type_int_rgb);
Graphics2D图形= (Graphics2D) img.getGraphics();
graphics.setColor (Color.WHITE);
图形。fillRect(0,0, imgWidth, imgHeight);
double scale = Math.min((double) imgWidth / (double) preferredWidth, (double) imgHeight / (double) preferredHeight);
图形。规模(规模、规模);
可渲染的。渲染(图形,preferredWidth, preferredHeight);
s.setIcon(新ImageIcon (img));
}
}
String result = iresult . getelementat (0).toString();
String result1 = iresult . getelementat (1).toString();
String result2 = iresult . getelementat (2).toString();
aText.setText (result0);
bText.setText (result1)编写此表达式;
cText.setText (result2);
}
如果(arg0.getSource() == b30){
库回购;
Process Process = null;
RepositoryProcessLocation processLocation;
IOContainer iresult = null;
尝试{
repo = RepositoryManager.getInstance(null). getrerepository ("Projects");
processLocation = new RepositoryProcessLocation(new RepositoryLocation(repo.getLocation(), "Process_30%"));
process = processLocation.load(null);
iresult = process.run();
} catch (RepositoryException | IOException | XMLException | operatoreexception e) {
// TODO自动生成捕获块
e.printStackTrace ();
}
iobject result = iresult . getelementat (2);
字符串名称= RendererService.getName(result.getClass());
java.util。List
imageFrame.setVisible(真正的);
imageFrame。setSize(400、600);
imageFrame.setDefaultCloseOperation (JFrame.HIDE_ON_CLOSE);
imageFrame.setLocationRelativeTo(空);
(渲染器渲染器渲染器):{
IOContainer dummy = new IOContainer();
int imgWidth = 400;
int imgHeight = 450;
Reportable = renderer。createReportable(result, dummy, imgWidth, imgHeight);
if(reportableinstanceofrenderable){
Renderable = (Renderable)可报告;
renderable.prepareRendering ();
int preferredWidth = renderable.getRenderWidth(800);
int preferredHeight = renderable.getRenderHeight(800);
final buffereimage img = new buffereimage (imgWidth, imgHeight, BufferedImage. type_int_rgb);
Graphics2D图形= (Graphics2D) img.getGraphics();
graphics.setColor (Color.WHITE);
图形。fillRect(0,0, imgWidth, imgHeight);
double scale = Math.min((double) imgWidth / (double) preferredWidth, (double) imgHeight / (double) preferredHeight);
图形。规模(规模、规模);
可渲染的。渲染(图形,preferredWidth, preferredHeight);
s.setIcon(新ImageIcon (img));
}
}
String result = iresult . getelementat (0).toString();
String result1 = iresult . getelementat (1).toString();
String result2 = iresult . getelementat (2).toString();
aText.setText (result0);
bText.setText (result1)编写此表达式;
cText.setText (result2);
}
如果(arg0.getSource() == b50){
库回购;
Process Process = null;
RepositoryProcessLocation processLocation;
IOContainer iresult = null;
尝试{
repo = RepositoryManager.getInstance(null). getrerepository ("Projects");
processLocation = new RepositoryProcessLocation(new RepositoryLocation(repo.getLocation(), "Process_50%"));
process = processLocation.load(null);
iresult = process.run();
} catch (RepositoryException | IOException | XMLException | operatoreexception e) {
// TODO自动生成捕获块
e.printStackTrace ();
}
iobject result = iresult . getelementat (2);
字符串名称= RendererService.getName(result.getClass());
java.util。List
imageFrame.setVisible(真正的);
imageFrame。setSize(400、600);
imageFrame.setDefaultCloseOperation (JFrame.HIDE_ON_CLOSE);
imageFrame.setLocationRelativeTo(空);
(渲染器渲染器渲染器):{
IOContainer dummy = new IOContainer();
int imgWidth = 400;
int imgHeight = 450;
Reportable = renderer。createReportable(result, dummy, imgWidth, imgHeight);
if(reportableinstanceofrenderable){
Renderable = (Renderable)可报告;
renderable.prepareRendering ();
int preferredWidth = renderable.getRenderWidth(800);
int preferredHeight = renderable.getRenderHeight(800);
final buffereimage img = new buffereimage (imgWidth, imgHeight, BufferedImage. type_int_rgb);
Graphics2D图形= (Graphics2D) img.getGraphics();
graphics.setColor (Color.WHITE);
图形。fillRect(0,0, imgWidth, imgHeight);
double scale = Math.min((double) imgWidth / (double) preferredWidth, (double) imgHeight / (double) preferredHeight);
图形。规模(规模、规模);
可渲染的。渲染(图形,preferredWidth, preferredHeight);
s.setIcon(新ImageIcon (img));
}
}
String result = iresult . getelementat (0).toString();
String result1 = iresult . getelementat (1).toString();
String result2 = iresult . getelementat (2).toString();
aText.setText (result0);
bText.setText (result1)编写此表达式;
cText.setText (result2);
}
}
}
答案
斯科特