« Return to Thread: Scene Graph Demo Convert to JRuby Problem

Re: Scene Graph Demo Convert to JRuby Problem

by paulfras :: Rate this Message:

Reply to Author | View in Thread

Nick Sieger wrote:

> On Thu, Aug 7, 2008 at 6:44 PM, Paul Fraser <paulf@...> wrote:
>  
>> Hi All,
>>
>> Trying to convert a Scene Graph demo "Nodes" to JRuby.
>> https://scenegraph-demos.dev.java.net/demos.html
>> This line:
>> Composer.register(AffineTransform.class, TransformComposer.class)
>> gives this error:
>> C:/Users/paulAdmin/Documents/NetbeansProjects/scene_graph_work/lib/scene_graph.rb:1:
>> expected [java.lang.Class, java.lang.Class]; got:
>> [org.jruby.RubyClass,org.jruby.RubyClass]; error: argument type mismatch
>> (TypeError)
>>
>> I am probably out of my depth here, but are the experts able to help?
>> How do I "cast" an "org.jruby.RubyClass" to a "java.lang.Class" or what
>> procedure should be used in this case?
>>    
>
> What does the Ruby code you wrote look like?
>  
Hi Nick,

I did not write it, just converting it , this is how some of it looks at
present, a bit messy at this stage, but, does this help?

require 'java'

import com.sun.scenario.animation.Clip;
import com.sun.scenario.animation.Composer;
import com.sun.scenario.animation.Interpolators;
import com.sun.scenario.animation.Timeline;
import com.sun.scenario.scenegraph.JSGPanel;
import com.sun.scenario.scenegraph.SGComponent;
import com.sun.scenario.scenegraph.SGComposite;
import com.sun.scenario.scenegraph.SGGroup;
import com.sun.scenario.scenegraph.SGImage;
import com.sun.scenario.scenegraph.SGShape;
import com.sun.scenario.scenegraph.SGText;
import com.sun.scenario.scenegraph.SGTransform;
import com.sun.scenario.scenegraph.fx.FXNode;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.LinearGradientPaint;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.geom.AffineTransform;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.net.URL;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;


class TransformComposer < Composer
  #
  def initialize
    super(6)
  end
  #
  def decompose(o,v)
    o.getMatrix(v)
    return v
  end
  #
  def compose(v)
    return AffineTransform.new(v)
  end
end # class TransformComposer
#
#
class Nodes
  include ActionListener
  #
  SCREEN_W = 300, SCREEN_H = 400;
  FADE_DUR = 500;
  CLIP_DUR = 500;
  TEXT_X = 100;
  TEXT_Y = 40;
  IMAGE_X = 23;
  IMAGE_Y = 3;
  IMAGES_LABEL = "Images ";
  SHAPES_LABEL = "Shapes ";
  COMPONENTS_LABEL = "Components ";
  TEXT_LABEL = "Text ";
  ANIMATION_LABEL = "Animation ";
  TRANSLUCENCY_LABEL = "Translucency ";
  #
  #
  #
    Composer.register(AffineTransform.class, TransformComposer.class);  
<<<<<<<<<<<<<<<<<<<<<<<<<<<< trouble
  #
  #
  def initialize
    @rootNode = SGGroup.new
    #    #    JPanel controlPanel;
    #    #    SGTransform componentScaler;
    #    #    private Clip textFadeIn, textFadeOut;
    #    #    private Clip imageFadeIn, imageFadeOut;
    #    #    private Clip shapeFadeIn, shapeFadeOut;
    #    #    private Clip bgFadeIn, bgFadeOut;
    #    #    private Clip componentScaleOut, componentScaleIn;
    @nodeGroupMover = Timeline.new
    @numSelected = 0;
    #    #    private SGComposite componentTranslucency;
    #    #    private AffineTransform cpScaleLarge;
    @duke = nil
    #
    #    #        // preload image
    #    #        try {
    #    imageURL = getClass.getResource("images/duke.gif")
    #    duke = ImageIO.read(imageURL)
    #    #        } catch (Exception e) {
    #    #            System.out.println("problem loading image: " + e);
    #    #        }
    #    #
    #    #        // Create actual window frame
    f = JFrame.new("Nodes Demo")
    #    #        try {
    #    #            
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    #    #        } catch (Exception e) {
    #    #            System.out.println("problem with l&f: " + e);
    #    #        }
    f.setDefaultCloseOperation(JFrame::EXIT_ON_CLOSE)
    #    #
    setupNodes
    setupPanel(f)
    #    #
    f.invalidate
    f.pack
    f.setLocationRelativeTo(nil)
    f.setVisible(true)
    #    #
  end # def initialize


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Scene Graph Demo Convert to JRuby Problem