RapidMiner

display plot view result in java application

Contributor II

display plot view result in java application

When we called process of rapidminer in java program so it return example set as result.but if i want display plot view result in my java application so how can i get plot view result of partucular rapidminer processes in java application..give me java code to display process plot view result in java
3 REPLIES
RMStaff

Re: display plot view result in java application

Hi,

this thread should help you: http://rapid-i.com/rapidforum/index.php/topic,6760.0.html

I cannot give you fully fledged out example code.

Regards,
Marco
_________________________________________________________
Team Lead Software Engineering | RapidMiner GmbH
Contributor

Re: display plot view result in java application

Hi marco

 

that link isn't working anymore, do you have another link about the same topic ? i haven't found anything about it. 

 

thank you 

Contributor II

Re: display plot view result in java application

private static IOObject myExampleSet; public static void main(String[] args) throws Exception { JFrame frame = new JFrame("Decision Tree Renderer Test"); frame.setLocation(0, 0); JLabel label = new JLabel(); frame.add(new JScrollPane(label)); // Path to process-definition // final String processPath = // "/C:/Users/Administrator/.RapidMiner/repositories/Local // Repository/processes/filter1.rmp"; final String processPath = "/C:/Users/Administrator/.RapidMiner/repositories/Local Repository/processes/clustermodel.rmp"; // final String processPath = // "/C:/Users/Administrator/.RapidMiner/repositories/Local // Repository/processes/joinaggregate.rmp"; // String processPath = // "/C:/Users/Administrator/.RapidMiner/repositories/Local // Repository/processes/Desctree.rmp"; try { // Init RapidMiner RapidMiner.setExecutionMode(ExecutionMode.EMBEDDED_WITH_UI); Plugin.setInitPlugins(true); RapidMiner.init(); // Load process final com.rapidminer.Process process = new com.rapidminer.Process(new File(processPath)); IOContainer ioResult = process.run(); IOObject result = ioResult.getElementAt(0); // or whatever index you // need String name = RendererService.getName(result.getClass()); List renderers = RendererService.getRenderers(name); for (Renderer renderer : renderers) { // you don't really need to // iterate over this, it's // probably only one anyway // Smiley WinkXJ IOContainer dummy = new IOContainer(); // edit size of image here int imgWidth = 1000; int imgHeight = 800; Reportable reportable = renderer.createReportable(result, ioResult, imgWidth, imgHeight); if (reportable instanceof Renderable) { Renderable renderable = (Renderable) reportable; renderable.prepareRendering(); int preferredWidth = renderable.getRenderWidth(400); int preferredHeight = renderable.getRenderHeight(400); final BufferedImage img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = (Graphics2D) img.getGraphics(); graphics.setColor(Color.WHITE); graphics.fillRect(0, 0, imgWidth, imgHeight); // scale to whatever you need graphics.scale(2, 2); renderable.render(graphics, preferredWidth, preferredHeight); label.setIcon(new ImageIcon(img)); } } frame.setVisible(true); frame.pack(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); System.out.println(ioResult); } catch (Exception ex) { } Hi, please try this ,here i have attached rmp process file you can download and use it

Attachments