Permalink
Browse files

Switched to Generator-based rendering of results in JCP.

  • Loading branch information...
1 parent 7fffc87 commit a5a33d6ce0eef175c45315cd1819da10cea495a0 @olas committed Apr 22, 2010
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry excluding="net/bioclipse/ds/model/impl/QsarTest.java|net/bioclipse/ds/model/impl/SmartsInclusiveExclusiveTest.java|net/bioclipse/ds/model/impl/SmartsMatchingTest.java|net/bioclipse/ds/model/impl/SmartsMatchingTestMatch.java|net/bioclipse/ds/model/TestEntry.java|net/bioclipse/ds/model/ErrorResult.java|net/bioclipse/ds/impl/SDFNearestNeighborCDKFP.java|net/bioclipse/ds/impl/SDFExactMatchFP.java|net/bioclipse/ds/impl/SDFExactMatchInchi.java|net/bioclipse/ds/impl/SmartsInclusiveExclusive.java|net/bioclipse/ds/impl/SmartsMatching.java" kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
@@ -6,6 +6,11 @@
</projects>
<buildSpec>
<buildCommand>
+ <name>org.eclipse.wst.common.project.facet.core.builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
@@ -24,5 +29,6 @@
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
@@ -1,8 +1,3 @@
-#Mon May 18 09:32:51 CEST 2009
+#Wed Apr 21 13:26:53 CEST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
-org.eclipse.jdt.core.compiler.compliance=1.5
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.source=1.5
@@ -25,6 +25,7 @@
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
+import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.smiles.smarts.SMARTSQueryTool;
@@ -244,18 +245,20 @@ private boolean isValidSmarts( String smarts ) {
matchingAtoms.addAll( atomIndices );
}
+ //Toxicophores are by definition positive
+ SmartsMatch match=new SmartsMatch(
+ smartsName, ITestResult.POSITIVE);
+
//Create new ac to hold substructure
IAtomContainer subAC=ac.getBuilder().newAtomContainer();
for (int aindex : matchingAtoms){
- // subAC.addAtom( ac.getAtom( aindex ) );
- subAC.addAtom( cdkmol.getAtomContainer().getAtom( aindex ) );
+ IAtom atom=cdkmol.getAtomContainer().getAtom( aindex );
+ subAC.addAtom( atom );
+ match.putAtomResult( atom, 100 );
}
-
- //Toxicophores are by definition positive
- SmartsMatch match=new SmartsMatch(
- smartsName, ITestResult.POSITIVE);
match.setAtomContainer( subAC );
match.setSmartsString( currentSmarts );
+ match.writeResultsAsProperties( cdkmol.getAtomContainer(), "SMARTS");
results.add( match );
}
@@ -0,0 +1,61 @@
+package net.bioclipse.ds.impl.result;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IAtomContainer;
+
+import net.bioclipse.ds.DSConstants;
+
+/**
+ *
+ * @author ola
+ */
+public class ScaledResultMatch extends SubStructureMatch{
+
+ private Map<IAtom, Integer> resultMap;
+
+ public ScaledResultMatch(String name, int resultStatus) {
+ super( name, resultStatus );
+ }
+
+ public void setResultMap( Map<IAtom, Integer> resulMap ) {
+ this.resultMap = resulMap;
+ }
+
+ public Map<IAtom, Integer> getResultMap() {
+ return resultMap;
+ }
+
+ public void putAtomResult( IAtom atomToAdd, Integer result ) {
+ if (resultMap==null) resultMap=new HashMap<IAtom, Integer>();
+ resultMap.put( atomToAdd, result );
+
+ }
+
+ /**
+ * Serialize resultmap to property on AC
+ */
+ public void writeResultsAsProperties(IAtomContainer ac, String propertyKey){
+
+ if (ac==null) return;
+ if (resultMap==null || resultMap.isEmpty()) return;
+
+ String prop="";
+ for (IAtom atom : resultMap.keySet()){
+ int no=ac.getAtomNumber( atom );
+ int res=resultMap.get( atom );
+ if (prop.length()==0){ //first
+ prop=prop+ no + "," + res;
+ }else{
+ prop=prop+ ";" + no + "," + res;
+ }
+ }
+
+ ac.getProperties().put( propertyKey, prop );
+ setResultProperty( propertyKey );
+
+ }
+
+}
@@ -37,6 +37,7 @@
private String name;
private int classification;
private String detailedMessage;
+ private String resultProperty; //Used to link a result to a certain property on AC
public SimpleResult(String name, int classification) {
@@ -147,4 +148,12 @@ public String getSuffix(){
return "";
}
+ public String getResultProperty() {
+ return resultProperty;
+ }
+
+ public void setResultProperty( String propertyKey ) {
+ resultProperty=propertyKey;
+ }
+
}
@@ -16,7 +16,7 @@
* @author ola
*
*/
-public class SmartsMatch extends SubStructureMatch{
+public class SmartsMatch extends ScaledResultMatch{
public SmartsMatch(String name, int resultStatus) {
super( name, resultStatus );
@@ -55,5 +55,9 @@
public void setDetailedMessage( String detailedMessage );
String getSuffix();
+
+ public String getResultProperty();
+ public void setResultProperty( String propertyKey );
+
}
@@ -18,6 +18,7 @@
import net.bioclipse.ds.Activator;
import net.bioclipse.ds.DSConstants;
import net.bioclipse.ds.ui.prefs.DSPrefs;
+import net.bioclipse.ds.ui.views.DSView;
import org.eclipse.jface.preference.IPreferenceStore;
import org.openscience.cdk.interfaces.IAtom;
@@ -47,19 +48,21 @@ public BlueRedColorScaleGenerator() {
public IRenderingElement generate( IAtomContainer ac,
RendererModel model ) {
-// System.out.println("Generator found AC: " + ac);
-
ElementGroup group = new ElementGroup();
- Object o = ac.getProperty( DSConstants.SCALED_RESULT_PROPERTY );
- System.out.println("DS-RES:" + ac.hashCode() + "="+o);
+
+ String currentProperty=DSView.getInstance().getCurrentResultProperty();
+ if (currentProperty==null) return group;
+
+ Object o = ac.getProperty( currentProperty );
+// System.out.println("DS-RES:" + ac.hashCode() + "="+o);
if (o==null) return group;
//Read prefs for rendering params and compute real values
IPreferenceStore store=Activator.getDefault().getPreferenceStore();
int circleRadiusPref = store.getInt( DSPrefs.CIRCLE_RADIUS );
double circleRadius=(double)circleRadiusPref / 10;
if (circleRadius<=0 || circleRadius >1)
- circleRadius=0.4;
+ circleRadius=1.2;
Map<Integer, Integer> atomResMap = DSResultHelper
.getResultsFromProperty( (String)o );
@@ -81,6 +84,9 @@ public IRenderingElement generate( IAtomContainer ac,
atom.getPoint2d().y,
circleRadius,true, drawColor ));
}
+ group.add( new OvalElement( atom.getPoint2d().x,
+ atom.getPoint2d().y,
+ circleRadius,true, drawColor ));
}
}
@@ -39,7 +39,7 @@ public static Color getBlueRedColor( int resValue ) {
//Set up map from scaled value 1-100 to a color
//Blue is 0000FF, Red is FF0000,
blueRedScale=new HashMap<Integer, Color>();
- for (int i=0; i<99; i++){
+ for (int i=0; i<100; i++){
int red=255-i*(255/100);
int blue=i*(255/100);
Color color=new Color( red, 0, blue, DSConstants.OVAL_ALPHA );
@@ -119,6 +119,8 @@
*/
private IStructuredSelection storedSelection;
+ private String selectedProperty;
+
private Action autoRunAction;
private boolean autorun;
@@ -176,8 +178,15 @@ public void createPartControl(Composite parent) {
// viewer.setSorter(new ViewerSorter());
viewer.addFilter( new HideNotVisbleFilter() );
viewer.addSelectionChangedListener( new ISelectionChangedListener(){
+
public void selectionChanged( SelectionChangedEvent event ) {
updateActionStates();
+ Object obj = ((IStructuredSelection)event.getSelection()).getFirstElement();
+ if ( obj instanceof ITestResult ) {
+ ITestResult tr = (ITestResult) obj;
+ selectedProperty=tr.getResultProperty();
+
+ }
}
});
@@ -821,15 +830,16 @@ public void run() {
//from the cloned
for (Object obj : clonedMol.getAtomContainer()
.getProperties().keySet()){
-// System.out.println("OBJ found: " + obj);
+ System.out.println("OBJ found: " + obj);
+ System.out.println("Existing: " + originalMol.getAtomContainer().getProperties());
if (!originalMol.getAtomContainer()
.getProperties().containsKey( obj )){
originalMol.getAtomContainer()
.getProperties().put(
obj, clonedMol.getAtomContainer()
.getProperties().get( obj ) );
-// System.out.println("DS-RES set on:" + clonedMol.getAtomContainer().hashCode() + "="+ clonedMol.getAtomContainer()
-// .getProperties().get( obj ));
+ System.out.println("DS-RES set on:" + clonedMol.getAtomContainer().hashCode() + "="+ clonedMol.getAtomContainer()
+ .getProperties().get( obj ));
}
}
@@ -1438,6 +1448,10 @@ public void contextManagerChanged( ContextManagerEvent contextManagerEvent ) {
if (editor!=null)
partActivated( editor );
}
+ }
+
+ public String getCurrentResultProperty() {
+ return selectedProperty;
}
}

0 comments on commit a5a33d6

Please sign in to comment.