Permalink
Browse files

clean up svn files and add Viewer mode

  • Loading branch information...
chemhack committed Jul 22, 2009
1 parent f1f9260 commit 1afe000aeb33c8b22eb3714c67f125863bdf8ab8
Showing with 287 additions and 4,288 deletions.
  1. +154 −0 build.xml
  2. +13 −0 src/com/chemhack/jsMolEditor/Viewer.gwt.xml
  3. +39 −0 src/com/chemhack/jsMolEditor/client/Viewer.java
  4. +55 −0 src/com/chemhack/jsMolEditor/client/controller/ViewerController.java
  5. +0 −35 src/com/chemhack/jsMolEditor/client/jre/emulation/java/awt/geom/svn/all-wcprops
  6. +0 −205 src/com/chemhack/jsMolEditor/client/jre/emulation/java/awt/geom/svn/entries
  7. +0 −1 src/com/chemhack/jsMolEditor/client/jre/emulation/java/awt/geom/svn/format
  8. +0 −3,089 ...emhack/jsMolEditor/client/jre/emulation/java/awt/geom/svn/text-base/AffineTransform.java.svn-base
  9. +0 −11 ...com/chemhack/jsMolEditor/client/jre/emulation/java/awt/geom/svn/text-base/Dimension.java.svn-base
  10. +0 −22 ...or/client/jre/emulation/java/awt/geom/svn/text-base/NoninvertibleTransformException.java.svn-base
  11. +0 −36 src/com/chemhack/jsMolEditor/client/jre/emulation/java/awt/geom/svn/text-base/Point2D.java.svn-base
  12. +0 −47 ...m/chemhack/jsMolEditor/client/jre/emulation/java/awt/geom/svn/text-base/Rectangle2D.java.svn-base
  13. +0 −5 src/com/chemhack/jsMolEditor/client/jre/emulation/java/awt/svn/all-wcprops
  14. +0 −38 src/com/chemhack/jsMolEditor/client/jre/emulation/java/awt/svn/entries
  15. +0 −1 src/com/chemhack/jsMolEditor/client/jre/emulation/java/awt/svn/format
  16. +0 −17 src/com/chemhack/jsMolEditor/client/jre/emulation/java/event/svn/all-wcprops
  17. +0 −103 src/com/chemhack/jsMolEditor/client/jre/emulation/java/event/svn/entries
  18. +0 −1 src/com/chemhack/jsMolEditor/client/jre/emulation/java/event/svn/format
  19. +0 −20 src/com/chemhack/jsMolEditor/client/jre/emulation/java/event/svn/text-base/ChangeEvent.java.svn-base
  20. +0 −6 ...m/chemhack/jsMolEditor/client/jre/emulation/java/event/svn/text-base/ChangeListener.java.svn-base
  21. +0 −17 src/com/chemhack/jsMolEditor/client/jre/emulation/java/io/svn/all-wcprops
  22. +0 −103 src/com/chemhack/jsMolEditor/client/jre/emulation/java/io/svn/entries
  23. +0 −1 src/com/chemhack/jsMolEditor/client/jre/emulation/java/io/svn/format
  24. +0 −35 src/com/chemhack/jsMolEditor/client/jre/emulation/java/io/svn/text-base/IOException.java.svn-base
  25. +0 −87 ...om/chemhack/jsMolEditor/client/jre/emulation/java/io/svn/text-base/LineNumberReader.java.svn-base
  26. +0 −11 src/com/chemhack/jsMolEditor/client/jre/emulation/java/lang/svn/all-wcprops
  27. +0 −69 src/com/chemhack/jsMolEditor/client/jre/emulation/java/lang/svn/entries
  28. +0 −1 src/com/chemhack/jsMolEditor/client/jre/emulation/java/lang/svn/format
  29. +0 −21 ...com/chemhack/jsMolEditor/client/jre/emulation/java/lang/svn/text-base/InternalError.java.svn-base
  30. +0 −11 src/com/chemhack/jsMolEditor/client/jre/emulation/java/util/regex/svn/all-wcprops
  31. +0 −69 src/com/chemhack/jsMolEditor/client/jre/emulation/java/util/regex/svn/entries
  32. +0 −1 src/com/chemhack/jsMolEditor/client/jre/emulation/java/util/regex/svn/format
  33. +0 −177 ...com/chemhack/jsMolEditor/client/jre/emulation/java/util/regex/svn/text-base/Pattern.java.svn-base
  34. +0 −5 src/com/chemhack/jsMolEditor/client/jre/emulation/java/util/svn/all-wcprops
  35. +0 −38 src/com/chemhack/jsMolEditor/client/jre/emulation/java/util/svn/entries
  36. +0 −1 src/com/chemhack/jsMolEditor/client/jre/emulation/java/util/svn/format
  37. +3 −0 src/com/chemhack/jsMolEditor/client/renderer/CanvasRenderer.java
  38. BIN src/com/chemhack/jsMolEditor/client/resources/hexagonSmall.png
  39. BIN src/com/chemhack/jsMolEditor/client/resources/pentagonSmall.png
  40. BIN src/com/chemhack/jsMolEditor/client/resources/squareSmall.png
  41. BIN src/com/chemhack/jsMolEditor/client/resources/squareSmalll.gif
  42. BIN src/com/chemhack/jsMolEditor/client/resources/triangleSmall.png
  43. +2 −4 src/com/chemhack/jsMolEditor/public/Editor.css
  44. +21 −0 src/com/chemhack/jsMolEditor/public/Viewer.html
View
154 build.xml
@@ -0,0 +1,154 @@
<?xml version="1.0"?>
<project name="jsMolEditor" default="all" basedir=".">
<!--Change this to your path of gwt-->
<property name="gwt.home" value="/Applications/gwt-mac-1.5.3"/>
<property name="gwt.module" value="com.chemhack.jsMolEditor.Editor"/>
<property name="debug" value="off"/>
<property name="deprecation" value="on"/>
<property name="optimization" value="on"/>
<path id="classpath.base">
<pathelement path="src"/>
<pathelement path="test"/>
<fileset dir="lib">
<include name="**/*.jar"/>
</fileset>
<fileset dir="${gwt.home}">
<include name="**/*.jar"/>
</fileset>
</path>
<path id="classpath.test">
<pathelement path="dist/java-output"/>
<path refid="classpath.base"/>
</path>
<target name="clean" description="Cleans Output">
<delete dir="dist"/>
</target>
<target name="cleanTempFiles" description="Cleans Output">
<delete dir="dist/gwt-output"/>
<delete dir="dist/java-output"/>
</target>
<target name="mkdir" description="Make Necessary Directory">
<mkdir dir="dist"/>
</target>
<target name="deploy" depends="gwt-compile" description="Compile JavaScript library">
<mkdir dir="dist/deploy/js"/>
<copy todir="dist/deploy/js">
<fileset dir="dist/gwt-output/${gwt.module}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="demo" description="Compile JavaScript library">
<mkdir dir="dist/demo"/>
<copy todir="dist/demo">
<fileset dir="demo">
<include name="**/*.*"/>
</fileset>
</copy>
<copy todir="dist/demo/js">
<fileset dir="dist/gwt-output/${gwt.module}">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="dist" description="Distribute Source Code">
<mkdir dir="dist/source/src"/>
<mkdir dir="dist/source/test"/>
<copy todir="dist/source/src">
<fileset dir="src">
<include name="**/*.*"/>
</fileset>
</copy>
<copy todir="dist/source/test">
<fileset dir="test">
<include name="**/*.*"/>
</fileset>
</copy>
</target>
<target name="all" description="Make Necessary Directory">
<antcall target="clean"/>
<antcall target="deploy"/>
<antcall target="demo"/>
<antcall target="dist"/>
<antcall target="test"/>
<antcall target="cleanTempFiles"/>
</target>
<target id="checkPlatforms" name="checkPlatforms">
<condition property="isMacOsX">
<and>
<os family="mac"/>
<os family="unix"/>
</and>
</condition>
</target>
<target name="javac-compile" description="Invoke javac">
<mkdir dir="dist/java-output"/>
<javac srcdir="src:test" destdir="dist/java-output/" optimize="${optimization}" debug="${debug}"
deprecation="${deprecation}">
<classpath refid="classpath.base"/>
</javac>
</target>
<target name="test" depends="javac-compile,checkPlatforms" description="Run Unit Tests">
<mkdir dir="dist/test/xml"/>
<antcall target="test-normal"/>
<antcall target="test-mac"/>
</target>
<target name="test-mac" description="Run Unit Tests-MACOS" if="isMacOsX">
<echo message="Starting Unit Test in Mac OS X Mode..."/>
<junit printsummary="yes" haltonfailure="no" fork="yes" forkMode="perBatch" maxmemory="256m">
<classpath refid="classpath.test"/>
<batchtest todir="dist/test/xml">
<fileset dir="dist/java-output" includes="**/client/test/*.class" />
</batchtest>
<formatter type="xml"/>
<jvmarg line="-XstartOnFirstThread"/>
</junit>
<junitreport toDir="dist/test">
<fileset dir="dist/test/xml"/>
<report format="frames" todir="dist/test"/>
</junitreport>
</target>
<target name="test-normal" description="Run Unit Tests" unless="isMacOsX">
<echo message="Starting Unit Test..."/>
<junit printsummary="yes" haltonfailure="no" fork="yes" forkMode="perBatch" maxmemory="256m">
<classpath refid="classpath.test"/>
<batchtest todir="dist/test/xml">
<fileset dir="dist/java-output" includes="**/client/test/*.class" />
</batchtest>
<formatter type="xml"/>
</junit>
<junitreport toDir="dist/test">
<fileset dir="dist/test/xml"/>
<report format="frames" todir="dist/test"/>
</junitreport>
</target>
<target name="gwt-compile" description="Invoke GWT Compiler">
<mkdir dir="dist/gwt-output"/>
<echo message="Invoking GWT Compiler"/>
<java classname="com.google.gwt.dev.GWTCompiler" fork="true">
<classpath refid="classpath.base"/>
<jvmarg value="-Xmx512m"/>
<jvmarg value="-Xms256m"/>
<arg value="-out"/>
<arg value="dist/gwt-output"/>
<arg value="${gwt.module}"/>
</java>
</target>
</project>
@@ -0,0 +1,13 @@
<module>
<inherits name='com.google.gwt.user.User'/>
<inherits name="gwt.canvas.gwt-canvas"/>
<inherits name='com.google.gwt.json.JSON'/>
<inherits name='com.google.gwt.xml.XML'/>
<inherits name="com.google.gwt.junit.JUnit"/>
<script src="jsmoleditor.js"/>
<stylesheet src="Editor.css"/>
<entry-point class='com.chemhack.jsMolEditor.client.Viewer'/>
</module>
@@ -0,0 +1,39 @@
package com.chemhack.jsMolEditor.client;
import com.google.gwt.core.client.EntryPoint;
import com.chemhack.jsMolEditor.client.controller.ViewerController;
import java.util.HashMap;
public class Viewer implements EntryPoint {
static HashMap<String, ViewerController> controllers =new HashMap<String,ViewerController>();
static Editor editor;
public void onModuleLoad() {
injectJSMethods();
}
public static void initEditor(String divID, int width, int height) {
// if(controllers.get(divID)==null){
controllers.put(divID,new ViewerController(divID, width, height));
// }else{
// controllers.get(divID)=new EditorController(divID, width, height);
// }
}
public static void importMolFile(String divID,String fileContent) {
controllers.get(divID).importMolFile(fileContent);
}
private static native void injectJSMethods()/*-{
$wnd.__importMolFile =function(divID,fileContent){
@com.chemhack.jsMolEditor.client.Viewer::importMolFile(Ljava/lang/String;Ljava/lang/String;)(divID,fileContent);
};
$wnd.__initEditor =function(divID, width, height){
@com.chemhack.jsMolEditor.client.Viewer::initEditor(Ljava/lang/String;II)(divID, width, height);
};
}-*/;
}
@@ -0,0 +1,55 @@
package com.chemhack.jsMolEditor.client.controller;
import com.chemhack.jsMolEditor.client.renderer.CanvasRenderer;
import com.chemhack.jsMolEditor.client.renderer.GeometryTools;
import com.chemhack.jsMolEditor.client.model.Molecule;
import com.chemhack.jsMolEditor.client.model.DefaultMolecule;
import com.chemhack.jsMolEditor.client.model.Bond;
import com.chemhack.jsMolEditor.client.widget.ExtendedCanvas;
import com.chemhack.jsMolEditor.client.jre.emulation.java.awt.geom.Dimension;
import com.chemhack.jsMolEditor.client.jre.emulation.java.awt.geom.Point2D;
import com.chemhack.jsMolEditor.client.io.mdl.MolfileReader;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.Window;
public class ViewerController {
CanvasRenderer renderer;
Molecule molecule = new DefaultMolecule();
public ViewerController(String divID, int width, int height) {
ExtendedCanvas canvas = new ExtendedCanvas(width, height);
renderer = new CanvasRenderer(canvas);
RootPanel rootPanel = RootPanel.get(divID);
rootPanel.setPixelSize(width, height);
rootPanel.add(canvas);
}
public void setMolecule(Molecule molecule) {
GeometryTools.translateAllPositive(molecule);
GeometryTools.center(molecule, new Dimension(renderer.getCanvas().getWidth(), renderer.getCanvas().getHeight()));
this.molecule = molecule;
calcAverageBondLength();
renderer.paintNewMolecule(molecule);
// renderer.getTransformer().dumpMatrix();
}
public void calcAverageBondLength() {
double total = 0;
for (int i = 0; i < molecule.countBonds(); i++) {
Bond bond = molecule.getBond(i);
total += GeometryTools.calcDistance(new Point2D(bond.getSource().getX(), bond.getSource().getY()), new Point2D(bond.getTarget().getX(), bond.getTarget().getY()));
}
renderer.getRendererModel().setDefaultBondLength(total / molecule.countBonds());
}
public void importMolFile(String fileContent) {
MolfileReader reader = new MolfileReader();
Molecule molecule = new DefaultMolecule();
try {
reader.read(molecule, fileContent);
setMolecule(molecule);
} catch (Exception e) {
Window.alert("Error occured: " + e.getMessage());
}
}
}

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 1afe000

Please sign in to comment.