Re: 2D graphics options with Clojure?

2011-04-30 Thread Nathan Sorenson
Batik can serialize to both PNG and PDF. http://xmlgraphics.apache.org/batik/

I currently use Batik in a clojure project doing a lot of drawing of
2d vector-based images. It's a very extensive library but it suits my
needs well.

On Apr 29, 9:26 pm, stu stuart.hungerf...@gmail.com wrote:
 Hi,

 I'm developing a Clojure project that loads and creates a bunch of
 simple 2D geometry (lines, polygons, beziers, text etc). I need to
 create in a batch-style way high quality 2D renderings of that
 geometry, firstly as PNG files and secondly as PDF files.

 What are my options for doing this from Clojure?

 So far I can see it might be done with Java2D as I think this can be
 used server-side to create the PNG files, but not sure about the
 PDFs.  I believe I can use Incanter's wrapping of the Processing
 libraries for the PNG and again I'm not sure about the PDF option.

 The Cairo toolkit is also an option via the Gnome Java bindings and
 Java interop?

 Are there other options that I'm missing that anyone would like to
 report on?

 Thanks in advance,

 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


Declarative Data Models

2011-04-30 Thread David Jagoe
G'day everyone,

Are there any libraries or projects that are similar to Python Traits
or Zope Schemas (http://pypi.python.org/pypi/zope.schema) for clojure.
I am developing a compojure application and there is a lot of
duplication between areas of the codebase, e.g.

- Fields listed on the defrecords
- Fields listed on the public constructor function
- Fields listed on forms and again on handlers

So it is a lot of effort to e.g. add a new field to the data model. I
would like something declarative from which I can generate forms,
validators etc.


Cheers,
David

-- 
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: swank-cdt: Using Slime with the Clojure Debugging Toolkit

2011-04-30 Thread Christian Schuhegger
I am using maven directly to work with clojure and I had the problem
with the tools.jar, too. I resolved it by adding the following block
to my pom.xml:

  profiles
profile
  iddefault-tools.jar/id
  activation
property
  namejava.vendor/name
  valueSun Microsystems Inc./value
/property
  /activation
  dependencies
dependency
  groupIdcom.sun/groupId
  artifactIdtools/artifactId
  version1.6.0/version
  scopesystem/scope
  systemPath${java.home}/../lib/tools.jar/systemPath
/dependency
  /dependencies
/profile
  /profiles

After that it is still complaining: warning: unabled to add tools.jar
to classpath. This may cause CDT initialization to fail.
But this does not seem to cause a problem.

Just wanted to share this bit of information with you,
Christian

-- 
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: Declarative Data Models

2011-04-30 Thread Ambrose Bonnaire-Sergeant
Hi David,

I can only comment on a subset of your post.

Records can be cumbersome to work with during early stages of development,
when
everything is rather volatile (when isn't it?).

You might like to try using maps instead. They are easier to work with when
you are
working out what properties you need in your records. It's also
straightforward to convert
from maps to records.

Of course there are downsides to this (speed, lack of types) but it can be a
useful strategy.

Thanks,
Ambrose

On Sat, Apr 30, 2011 at 4:46 PM, David Jagoe davidja...@gmail.com wrote:

 G'day everyone,

 Are there any libraries or projects that are similar to Python Traits
 or Zope Schemas (http://pypi.python.org/pypi/zope.schema) for clojure.
 I am developing a compojure application and there is a lot of
 duplication between areas of the codebase, e.g.

 - Fields listed on the defrecords
 - Fields listed on the public constructor function
 - Fields listed on forms and again on handlers

 So it is a lot of effort to e.g. add a new field to the data model. I
 would like something declarative from which I can generate forms,
 validators etc.


 Cheers,
 David

 --
 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

-- 
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: SubVector's (via 'subvec') do not support 'transient'

2011-04-30 Thread Armando Blancas
Check this out: http://clojure.org/Transients

On Apr 29, 10:54 am, Nathan Sorenson n...@sfu.ca wrote:
 (transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
 exception. Is this expected/unavoidable? How do I know whether the
 vectors I'm passed are regular vectors or come via subvec?

 I'm assuming I lose all the performance benefits of subvec if I
 defensively pour all vectors into a new vector before calling
 transient?

 I'm on clojure 1.3.0-alpha4

-- 
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: 2D graphics options with Clojure?

2011-04-30 Thread Dave Ray
I've also had success with Batik for server-side image generation. As
long as you don't mind SVG.

Dave

On Saturday, April 30, 2011, Nathan Sorenson n...@sfu.ca wrote:
 Batik can serialize to both PNG and PDF. http://xmlgraphics.apache.org/batik/

 I currently use Batik in a clojure project doing a lot of drawing of
 2d vector-based images. It's a very extensive library but it suits my
 needs well.

 On Apr 29, 9:26 pm, stu stuart.hungerf...@gmail.com wrote:
 Hi,

 I'm developing a Clojure project that loads and creates a bunch of
 simple 2D geometry (lines, polygons, beziers, text etc). I need to
 create in a batch-style way high quality 2D renderings of that
 geometry, firstly as PNG files and secondly as PDF files.

 What are my options for doing this from Clojure?

 So far I can see it might be done with Java2D as I think this can be
 used server-side to create the PNG files, but not sure about the
 PDFs.  I believe I can use Incanter's wrapping of the Processing
 libraries for the PNG and again I'm not sure about the PDF option.

 The Cairo toolkit is also an option via the Gnome Java bindings and
 Java interop?

 Are there other options that I'm missing that anyone would like to
 report on?

 Thanks in advance,

 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

-- 
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: Parallelism

2011-04-30 Thread Armando Blancas
 does access to
 lets say second part of partitioned range cause first part to be
 materialized or no?

Yes, it does.

 My second question is connected to first. If we have 4 cores and *pmap *starts
 4 threads to perform our function on 4 parts of partitioned range, is this
 happening in parallel, or it is not (because of partitioned ranges
 dependence or something else)?

It's all lazy processing, so you'll get one initial thread (I believe
because of a destructuring in pmap). The rest of the threads will
start as apply gets elements from result, which may or may not be in
parallel depending on scheduling and how much work needs to be done,
in this case it isn't much. (partition) will produce four ranges in
order, as (future) calls on each are setup by pmap, That is, pmap
launches threads sequentially, each already having a range from the
partition.

-- 
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: 2D graphics options with Clojure?

2011-04-30 Thread Brenton
Stu,

Just a quick thought, you can use Java2D for the images and then iText
to create the PDFs.

Brenton

On Apr 29, 9:26 pm, stu stuart.hungerf...@gmail.com wrote:
 Hi,

 I'm developing a Clojure project that loads and creates a bunch of
 simple 2D geometry (lines, polygons, beziers, text etc). I need to
 create in a batch-style way high quality 2D renderings of that
 geometry, firstly as PNG files and secondly as PDF files.

 What are my options for doing this from Clojure?

 So far I can see it might be done with Java2D as I think this can be
 used server-side to create the PNG files, but not sure about the
 PDFs.  I believe I can use Incanter's wrapping of the Processing
 libraries for the PNG and again I'm not sure about the PDF option.

 The Cairo toolkit is also an option via the Gnome Java bindings and
 Java interop?

 Are there other options that I'm missing that anyone would like to
 report on?

 Thanks in advance,

 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: SubVector's (via 'subvec') do not support 'transient'

2011-04-30 Thread Nathan Sorenson
I've read that, and the claim seems to be that Vectors support
transience. Within Clojure's abstraction SubVectors are Vectores:
(vector? (subvec [1 2 3] 0 2)) = true.

On Apr 30, 8:27 am, Armando Blancas armando_blan...@yahoo.com wrote:
 Check this out:http://clojure.org/Transients

 On Apr 29, 10:54 am, Nathan Sorenson n...@sfu.ca wrote:







  (transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
  exception. Is this expected/unavoidable? How do I know whether the
  vectors I'm passed are regular vectors or come via subvec?

  I'm assuming I lose all the performance benefits of subvec if I
  defensively pour all vectors into a new vector before calling
  transient?

  I'm on clojure 1.3.0-alpha4

-- 
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: SubVector's (via 'subvec') do not support 'transient'

2011-04-30 Thread Ken Wesson
On Sat, Apr 30, 2011 at 11:27 AM, Armando Blancas
armando_blan...@yahoo.com wrote:
 On Apr 29, 10:54 am, Nathan Sorenson n...@sfu.ca wrote:
 (transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
 exception. Is this expected/unavoidable? How do I know whether the
 vectors I'm passed are regular vectors or come via subvec?

 I'm assuming I lose all the performance benefits of subvec if I
 defensively pour all vectors into a new vector before calling
 transient?

 I'm on clojure 1.3.0-alpha4

 Check this out: http://clojure.org/Transients

There is no mention of subvec on that page.

-- 
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: SubVector's (via 'subvec') do not support 'transient'

2011-04-30 Thread Nathan Sorenson
Yes but the contract of subvec is that it returns a persistent
vector and the resulting data structure returns true under the
vector? predicate. I know that subvec returns a different type
because I've looked at the Java source code but that's a leaky
abstraction.

On Apr 30, 10:57 am, Ken Wesson kwess...@gmail.com wrote:
 On Sat, Apr 30, 2011 at 11:27 AM, Armando Blancas

 armando_blan...@yahoo.com wrote:
  On Apr 29, 10:54 am, Nathan Sorenson n...@sfu.ca wrote:
  (transient (subvec [1 2 3 4 5] 0 2)) fails with a class cast
  exception. Is this expected/unavoidable? How do I know whether the
  vectors I'm passed are regular vectors or come via subvec?

  I'm assuming I lose all the performance benefits of subvec if I
  defensively pour all vectors into a new vector before calling
  transient?

  I'm on clojure 1.3.0-alpha4

  Check this out:http://clojure.org/Transients

 There is no mention of subvec on that page.

-- 
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: Declarative Data Models

2011-04-30 Thread Paul deGrandis
I'm not exactly sure of your specific use case, but you should take a
look at clojure.template.  It could be what you're looking for.

http://clojuredocs.org/clojure_core/clojure.template

Paul


On Apr 30, 3:39 am, Ambrose Bonnaire-Sergeant
abonnaireserge...@gmail.com wrote:
 Hi David,

 I can only comment on a subset of your post.

 Records can be cumbersome to work with during early stages of development,
 when
 everything is rather volatile (when isn't it?).

 You might like to try using maps instead. They are easier to work with when
 you are
 working out what properties you need in your records. It's also
 straightforward to convert
 from maps to records.

 Of course there are downsides to this (speed, lack of types) but it can be a
 useful strategy.

 Thanks,
 Ambrose







 On Sat, Apr 30, 2011 at 4:46 PM, David Jagoe davidja...@gmail.com wrote:
  G'day everyone,

  Are there any libraries or projects that are similar to Python Traits
  or Zope Schemas (http://pypi.python.org/pypi/zope.schema) for clojure.
  I am developing a compojure application and there is a lot of
  duplication between areas of the codebase, e.g.

  - Fields listed on the defrecords
  - Fields listed on the public constructor function
  - Fields listed on forms and again on handlers

  So it is a lot of effort to e.g. add a new field to the data model. I
  would like something declarative from which I can generate forms,
  validators etc.

  Cheers,
  David

  --
  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

-- 
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: Parallelism

2011-04-30 Thread Miki
I think you'll find http://blip.tv/file/4645227 relevant to the subject. I 
shows the inner working of pmap.

-- 
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: swank-cdt: Using Slime with the Clojure Debugging Toolkit

2011-04-30 Thread George Jahad
With Lance's help, I've gotten a better understanding of why CDT fails
with Cake.  The problem is that Cake makes use of Classlojure,
(https://github.com/ninjudd/classlojure), which allows multiple
versions of clojure to be loaded in the same vm simultaneously. (It's
pretty cool!)

Anyways that breaks certain assumptions that CDT makes about what
classes are loaded; it shouldn't be too hard to fix but will require a
bit of a redesign of cdt, so it will probably be a week or two before
I have a fix available.

Thanks to Lance for helping me understand.

g

On Apr 25, 9:41 pm, lance bradley lancebrad...@gmail.com wrote:
 I'll keep at it too. Make sure you do a manual checkout and use the
 develop branch. I suspected this would be the fix, but I was wrong- it
 could still be necessary 
 though:https://github.com/ninjudd/cake/commit/8d70cb88fd83e6aec17a0dac05e97f...

 On Apr 25, 9:30 pm, George Jahad cloj...@blackbirdsystems.net wrote:

  not using openjdk.  and the tools.jar issue is probably a red
  herring.  i'll try installing cake and see if i can notice anything.
  definitely want to keep cake users happy!

  On Apr 25, 8:33 pm, lance bradley lancebrad...@gmail.com wrote:

   Hey guys-
   I spent some time trying to get this working today. My experiences
   mirror Sam's. I'm on a mac, running the jdk that ships with xcode4.
   According 
   tohttp://developer.apple.com/library/mac/#documentation/Java/Conceptual...
   , tools.jar does not exist in the xcode jdk. George, are you perhaps
   using the openjdk? Once I get this straightened out, I'll confirm that
   cake's classloader hanky panky doesn't cause any other issues :)

   -lance

   On Apr 25, 12:12 pm, Sam Aaron samaa...@gmail.com wrote:

On 25 Apr 2011, at 19:34, George Jahad wrote:

 When I press e the mini buffer prompts me to Eval in frame: and I
 propmpty type s1 to see the following error in the minibuffer:
 Unexpected exception generated: java.lang.IllegalArgumentException:
 Invalid method This stuff is all new to me, so I'm likely to be
 doing something silly.

 I doubt that.  Most likely you have a fairly complicated installation,
 whose problems i haven't experienced yet.

That's pretty unlikely unless it is specifically cake that's the issue. 
I was running in a completely new and empty project with nothing except 
clojure and swank-clojure as deps.

 Sam, can I suggest we eliminate those installation issues by
 experimenting with a known working project, e.g. logos and seeing if
 that works for you?

This seems to work perfectly :-) No tools.jar errors and I can examine 
the contents of s1 and s2 - Great stuff! This is really exciting :-)

However, if I create a fresh new logos clone, modify the project.clj 
again, and pull the deps with cake, add the .cake/config jvm.opts line 
and start a swank server I get the same issues I saw before:

* A tools.jar warning
* An exception when trying to eval s1

I think that this is pretty clearly a cake issue. I do think it would 
be cool if this worked out of the box with both lein and cake. I like 
lein, but cake has better native dependency support which I find 
extremely useful for my projects.

Have any of the cake devs tried the CDT stuff yet? How might I help 
debug this?

Sam

---http://sam.aaron.name

-- 
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