The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

"display plot view result in java application"

tapankhistetapankhiste Member Posts: 4 Contributor I
edited June 2019 in Help
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
Tagged:

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    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
  • juasu56juasu56 Member Posts: 6 Contributor I

    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 

  • arulganesanarasarulganesanaras Member Posts: 3 Contributor I
    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
    // ;)XJ
    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
Sign In or Register to comment.