How to access specific java.awt.Color constructor?

2011-04-09 Thread stu
Hi,

I'm trying to create a java.awt.Color class instance from within
Clojure, using this constructor:

Color(ColorSpace cspace, float[] components, float alpha)

But always end up with a No matching ctor found for class
java.awt.Color exception.

I can create the ColorSpace instance as I expected, but I think I'm
missing something with the rest of the Color constructor.  I've tried
changing the components to a vector of floats or a Java array of
floats with no luck.

This is with Clojure 1.2 and the Java Platform SE 6 AWT classes.

Any advice much appreciated.

Stu

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: How to access specific java.awt.Color constructor?

2011-04-09 Thread Sean Corfield
Can you show a bit more of the code you have so we can see what you've tried?

On Sat, Apr 9, 2011 at 3:13 PM, stu stuart.hungerf...@gmail.com wrote:
 I'm trying to create a java.awt.Color class instance from within
 Clojure, using this constructor:

 Color(ColorSpace cspace, float[] components, float alpha)

 But always end up with a No matching ctor found for class
 java.awt.Color exception.

 I can create the ColorSpace instance as I expected, but I think I'm
 missing something with the rest of the Color constructor.  I've tried
 changing the components to a vector of floats or a Java array of
 floats with no luck.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: How to access specific java.awt.Color constructor?

2011-04-09 Thread Alan
You probably weren't putting it into a java float array, but instead a
Float array (boxed type). Here's a repl session doing what you want. I
don't know anything about colorspaces so it's probably nonsense, but
it creates a Color with that constructor.

user= (import '(java.awt.color ICC_Profile ColorSpace ICC_ColorSpace)
java.awt.Color)
java.awt.Color
user= (def prf (ICC_Profile/getInstance (ColorSpace/CS_sRGB)))
#'user/prf
user= (def spc (ICC_ColorSpace. prf))
#'user/spc
user= (class spc)
java.awt.color.ICC_ColorSpace

;; the magic words
user= (def c (Color. spc (float-array [1 1 1]) (float 1)))
#'user/c
user= (def c (Color. spc (into-array Float/TYPE [1 1 1]) (float 1)))
#'user/c


On Apr 9, 3:21 pm, Sean Corfield seancorfi...@gmail.com wrote:
 Can you show a bit more of the code you have so we can see what you've tried?







 On Sat, Apr 9, 2011 at 3:13 PM, stu stuart.hungerf...@gmail.com wrote:
  I'm trying to create a java.awt.Color class instance from within
  Clojure, using this constructor:

  Color(ColorSpace cspace, float[] components, float alpha)

  But always end up with a No matching ctor found for class
  java.awt.Color exception.

  I can create the ColorSpace instance as I expected, but I think I'm
  missing something with the rest of the Color constructor.  I've tried
  changing the components to a vector of floats or a Java array of
  floats with no luck.

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: How to access specific java.awt.Color constructor?

2011-04-09 Thread stu
On Apr 10, 8:35 am, Alan a...@malloys.org wrote:

 You probably weren't putting it into a java float array, but instead a
 Float array (boxed type). Here's a repl session doing what you want. I
 don't know anything about colorspaces so it's probably nonsense, but
 it creates a Color with that constructor.

   Thanks Alan -- I realize now there's a subtle but important
distinction there when doing Java interop.

Stu

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en