• Resolved dingeman

    (@dingeman)


    I am trying to include some visualizations I created using Processing into my posts. Processing exports the visualisation as a java-object and also generates some code you can use to include the java-object on a webpage (see below for an example of the code generated by Processing). However, I have trouble including this code in WordPress.

    I switched to the HTML-editor instead of the visual editor. Removing all of the linebreaks in the code helped as WordPress stopped inserting <br /> into the code. However, WordPress still causes problems with the comments as the –‘s are replaced by m/ndashes.

    So how do I include this code? I would have expected this question to have been asked before, by I could not find it in the archives. Help is appreciated.

    Regards,
    Jan

    The html-code generated by Processing:

    <!--[if !IE]> -->
      <object classid="java:test.class" type="application/x-java-applet"
          archive="test.jar" width="700" height="800"
          standby="Loading Processing software..." >
        <param name="archive" value="test.jar" />
        <param name="mayscript" value="true" />
        <param name="scriptable" value="true" />
        <param name="image" value="loading.gif" />
        <param name="boxmessage" value="Loading Processing software..." />
        <param name="boxbgcolor" value="#FFFFFF" />
        <param name="test_string" value="outer" />
    <!--<![endif]-->
      <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
          codebase="https://java.sun.com/update/1.5.0/jinstall-1_5_0_15-windows-i586.cab"
          width="700" height="800" standby="Loading Processing software..."  >
        <param name="code" value="test" />
        <param name="archive" value="test.jar" />
        <param name="mayscript" value="true" />
        <param name="scriptable" value="true" />
        <param name="image" value="loading.gif" />
        <param name="boxmessage" value="Loading Processing software..." />
        <param name="boxbgcolor" value="#FFFFFF" />
        <param name="test_string" value="inner" />
        <p>
          <strong>This browser does not have a Java Plug-in.<br />
          <a href="https://www.java.com/getjava" title="Download Java Plug-in">
          Get the latest Java Plug-in here. </a></strong>
        </p>
      </object>
    <!--[if !IE]> -->
    </object>
    <!--<![endif]-->
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter dingeman

    (@dingeman)

    OK I have solved the problem by using Shortcode.

    I created the following functions.php in my theme directory:

    <?php
      function processing_object($atts, $content = null) {
        extract(shortcode_atts(array('jar' => '', 'class' => '',
            'width' => 700, 'height' => '800'), $atts));
        if ($jar == '' || $class == '') return '<p>Syntax error</p>';
        $result = <<<EOD
    <div id="processing_container">
      <!--[if !IE]> -->
        <object classid="java:$class.class"
            type="application/x-java-applet"
            archive="$jar"
            width="$width" height="$height"
            standby="Loading Processing software..." >
          <param name="archive" value="$jar" />
          <param name="mayscript" value="true" />
          <param name="scriptable" value="true" />
          <param name="image" value="loading.gif" />
          <param name="boxmessage" value="Loading Processing software..." />
          <param name="boxbgcolor" value="#FFFFFF" />
          <param name="test_string" value="outer" />
      <!--<![endif]-->
        <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
            codebase="https://java.sun.com/update/1.5.0/jinstall-1_5_0_15-windows-i586.cab"
            width="$width" height="$height"
            standby="Loading Processing software..."  >
          <param name="code" value="$class" />
          <param name="archive" value="$jar" />
          <param name="mayscript" value="true" />
          <param name="scriptable" value="true" />
          <param name="image" value="loading.gif" />
          <param name="boxmessage" value="Loading Processing software..." />
          <param name="boxbgcolor" value="#FFFFFF" />
          <param name="test_string" value="inner" />
          <p><strong>This browser does not have a Java Plug-in.<br />
            <a href="https://www.java.com/getjava" title="Download Java Plug-in">Get the latest Java Plug-in here.</a></strong>
          </p>
        </object>
      <!--[if !IE]> -->
        </object>
      <!--<![endif]-->
    </div>
    EOD;
        return $result;
      }
    
      add_shortcode('processing', 'processing_object');
    ?>

    And could then include the java object by using

    [processing jar="test.jar" class="test"]

    in my post.

    Regards,
    Jan

    Thanks – worked like a charm. Lifesaver.
    Possibly make this a plugin — This will break when I switch to a different theme, right?

    Matt

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Include java object in post’ is closed to new replies.