Permalink
Browse files

add license, new jimport stuff

  • Loading branch information...
1 parent 306790d commit 1f2ead45e39d04d36d9e0c8eb7da6932da8bb2ad @slyrus committed Mar 30, 2012
Showing with 83 additions and 37 deletions.
  1. +83 −37 abcl-cdk-hacking.lisp
View
@@ -1,24 +1,72 @@
+;;; file: abcl-cdk-hacking.lisp
+;;;
+;;; Copyright (c) 2012 Cyrus Harmon (ch-lisp@bobobeach.com)
+;;; All rights reserved.
+;;;
+;;; Redistribution and use in source and binary forms, with or without
+;;; modification, are permitted provided that the following conditions
+;;; are met:
+;;;
+;;; * Redistributions of source code must retain the above copyright
+;;; notice, this list of conditions and the following disclaimer.
+;;;
+;;; * Redistributions in binary form must reproduce the above
+;;; copyright notice, this list of conditions and the following
+;;; disclaimer in the documentation and/or other materials
+;;; provided with the distribution.
+;;;
+;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
+;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+;;; ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-(cl:require 'abcl-contrib)
-(cl:require 'abcl-asdf)
-(cl:require :extensible-sequences)
-(cl:require :java-collections)
+
+(eval-when (:compile-toplevel :load-toplevel :execute)
+ (cl:require :extensible-sequences)
+ (cl:require :java-collections))
(cl:defpackage :abcl-cdk-hacking
(:use :common-lisp))
(cl:in-package :abcl-cdk-hacking)
-(defmacro jimport (package class)
- `(defparameter ,(intern class) (concatenate 'string ,package "." ,class)))
+(defmacro jimport (java-package class &optional package)
+ `(defparameter ,(apply #'intern class
+ (when package (list package)))
+ (concatenate 'string (symbol-name (quote ,java-package))
+ "."
+ (symbol-name (quote ,class)))))
+
+(jimport |org.openscience.cdk.smiles| |SmilesParser|)
+(jimport |org.openscience.cdk| |DefaultChemObjectBuilder|)
+
+(jimport |org.openscience.cdk.renderer| |AtomContainerRenderer|)
+(jimport |org.openscience.cdk.renderer.generators| |BasicAtomGenerator|)
+(jimport |org.openscience.cdk.renderer.generators| |BasicBondGenerator|)
+(jimport |org.openscience.cdk.renderer.generators| |BasicSceneGenerator|)
-(jimport "org.openscience.cdk.smiles" "SmilesParser")
-(jimport "org.openscience.cdk" "DefaultChemObjectBuilder")
+(jimport |org.openscience.cdk.renderer.font| |AWTFontManager|)
+(jimport |org.freehep.graphicsio.svg| |SVGGraphics2D|)
+(jimport |org.freehep.graphicsio.pdf| |PDFGraphics2D|)
+(jimport |org.openscience.cdk.renderer.visitor| |AWTDrawVisitor|)
+(jimport |org.openscience.cdk.layout| |StructureDiagramGenerator|)
+
+(jimport |java.util| |Vector|)
+(jimport |java.awt| |Rectangle|)
+(jimport |java.awt| |Dimension|)
+(jimport |java.awt.geom| |Rectangle2D$Double|)
(defparameter *smiles-parser*
- (java:jnew "org.openscience.cdk.smiles.SmilesParser"
+ (java:jnew |SmilesParser|
(java:jcall
- (java:jmethod (java:jclass "org.openscience.cdk.DefaultChemObjectBuilder")
+ (java:jmethod (java:jclass |DefaultChemObjectBuilder|)
"getInstance")
nil)))
@@ -27,30 +75,30 @@
(defun jlist (&rest initial-contents)
(sequence:make-sequence-like
- (java:jnew "java.util.Vector") (length initial-contents)
+ (java:jnew |Vector|) (length initial-contents)
:initial-contents initial-contents))
(defun mol-to-svg (mol pathname)
(with-open-file (out-stream pathname :direction :output
:if-exists :supersede
:element-type :default)
(let*
- ((r (java:jnew
- "org.openscience.cdk.renderer.AtomContainerRenderer"
- (jlist
- (java:jnew "org.openscience.cdk.renderer.generators.BasicAtomGenerator")
- (java:jnew "org.openscience.cdk.renderer.generators.BasicBondGenerator")
- (java:jnew "org.openscience.cdk.renderer.generators.BasicSceneGenerator")) (java:jnew "org.openscience.cdk.renderer.font.AWTFontManager")))
- (vg (java:jnew "org.freehep.graphicsio.svg.SVGGraphics2D"
+ ((r (java:jnew |AtomContainerRenderer|
+ (jlist
+ (java:jnew |BasicAtomGenerator|)
+ (java:jnew |BasicBondGenerator|)
+ (java:jnew |BasicSceneGenerator|))
+ (java:jnew |AWTFontManager|)))
+ (vg (java:jnew |SVGGraphics2D|
(java:jcall "getWrappedOutputStream" out-stream)
- (java:jnew "java.awt.Dimension" 320 320)))
- (adv (java:jnew "org.openscience.cdk.renderer.visitor.AWTDrawVisitor" vg)))
+ (java:jnew |Dimension| 320 320)))
+ (adv (java:jnew |AWTDrawVisitor| vg)))
(java:jcall "startExport" vg)
(java:jcall "generateCoordinates"
- (java:jnew "org.openscience.cdk.layout.StructureDiagramGenerator" mol))
- (java:jcall "setup" r mol (java:jnew "java.awt.Rectangle" 0 0 100 100))
+ (java:jnew |StructureDiagramGenerator| mol))
+ (java:jcall "setup" r mol (java:jnew |Rectangle| 0 0 100 100))
(java:jcall "paint" r mol adv
- (java:jnew (java:jconstructor "java.awt.geom.Rectangle2D$Double" 4)
+ (java:jnew (java:jconstructor |Rectangle2D$Double| 4)
10 10 300 300)
java:+true+)
(java:jcall "endExport" vg))))
@@ -60,28 +108,26 @@
:if-exists :supersede
:element-type :default)
(let*
- ((r (java:jnew
- "org.openscience.cdk.renderer.AtomContainerRenderer"
- (jlist
- (java:jnew "org.openscience.cdk.renderer.generators.BasicAtomGenerator")
- (java:jnew "org.openscience.cdk.renderer.generators.BasicBondGenerator")
- (java:jnew "org.openscience.cdk.renderer.generators.BasicSceneGenerator"))
- (java:jnew "org.openscience.cdk.renderer.font.AWTFontManager")))
- (vg (java:jnew "org.freehep.graphicsio.pdf.PDFGraphics2D"
+ ((r (java:jnew |AtomContainerRenderer|
+ (jlist
+ (java:jnew |BasicAtomGenerator|)
+ (java:jnew |BasicBondGenerator|)
+ (java:jnew |BasicSceneGenerator|))
+ (java:jnew |AWTFontManager|)))
+ (vg (java:jnew |PDFGraphics2D|
(java:jcall "getWrappedOutputStream" out-stream)
- (java:jnew "java.awt.Dimension" 320 320)))
- (adv (java:jnew "org.openscience.cdk.renderer.visitor.AWTDrawVisitor" vg)))
+ (java:jnew |Dimension| 320 320)))
+ (adv (java:jnew |AWTDrawVisitor| vg)))
(java:jcall "startExport" vg)
(java:jcall "generateCoordinates"
- (java:jnew "org.openscience.cdk.layout.StructureDiagramGenerator" mol))
- (java:jcall "setup" r mol (java:jnew "java.awt.Rectangle" 0 0 100 100))
+ (java:jnew |StructureDiagramGenerator| mol))
+ (java:jcall "setup" r mol (java:jnew |Rectangle| 0 0 100 100))
(java:jcall "paint" r mol adv
- (java:jnew (java:jconstructor "java.awt.geom.Rectangle2D$Double" 4)
+ (java:jnew (java:jconstructor |Rectangle2D$Double| 4)
10 10 300 300)
java:+true+)
(java:jcall "endExport" vg))))
-
(defparameter *tam* (getmol "CCC(=C(C1=CC=CC=C1)C2=CC=C(C=C2)OCCN(C)C)C3=CC=CC=C3"))
(mol-to-svg *tam* "/tmp/tam.svg")

0 comments on commit 1f2ead4

Please sign in to comment.