Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Implemented new dynamic settings for all usages
Change-Id: Ie282ccc381e8f0d959abbdf953266fdab75d1c2b
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
johnmay authored and egonw committed Mar 24, 2012
1 parent 175bb47 commit d5e718a
Show file tree
Hide file tree
Showing 17 changed files with 102 additions and 246 deletions.
20 changes: 6 additions & 14 deletions src/main/org/openscience/cdk/io/CDKSourceCodeWriter.java
Expand Up @@ -244,17 +244,17 @@ public int getRequiredDataFeatures() {
}

private void initIOSettings() {
write2DCoordinates = new BooleanIOSetting("write2DCoordinates", IOSetting.Importance.LOW,
write2DCoordinates = addSetting(new BooleanIOSetting("write2DCoordinates", IOSetting.Importance.LOW,
"Should 2D coordinates be added?",
"true");
"true"));

write3DCoordinates = new BooleanIOSetting("write3DCoordinates", IOSetting.Importance.LOW,
write3DCoordinates = addSetting(new BooleanIOSetting("write3DCoordinates", IOSetting.Importance.LOW,
"Should 3D coordinates be added?",
"true");
"true"));

builder = new StringIOSetting("builder", IOSetting.Importance.LOW,
builder = addSetting(new StringIOSetting("builder", IOSetting.Importance.LOW,
"Which IChemObjectBuilder should be used?",
"DefaultChemObjectBuilder");
"DefaultChemObjectBuilder"));
}

private void customizeJob() {
Expand All @@ -263,14 +263,6 @@ private void customizeJob() {
fireIOSettingQuestion(builder);
}

public IOSetting[] getIOSettings() {
IOSetting[] settings = new IOSetting[3];
settings[0] = write2DCoordinates;
settings[1] = write3DCoordinates;
settings[2] = builder;
return settings;
}

}


40 changes: 14 additions & 26 deletions src/main/org/openscience/cdk/io/CMLWriter.java
Expand Up @@ -292,33 +292,33 @@ public void write(IChemObject object) throws CDKException {
}

private void initIOSettings() {
cmlIds = new BooleanIOSetting("CMLIDs", IOSetting.Importance.LOW,
cmlIds = addSetting(new BooleanIOSetting("CMLIDs", IOSetting.Importance.LOW,
"Should the output use CML identifiers?",
"true");
"true"));

namespacedOutput = new BooleanIOSetting("NamespacedOutput", IOSetting.Importance.LOW,
namespacedOutput = addSetting(new BooleanIOSetting("NamespacedOutput", IOSetting.Importance.LOW,
"Should the output use namespaced output?",
"true");
"true"));

namespacePrefix = new StringIOSetting("NamespacePrefix", IOSetting.Importance.LOW,
namespacePrefix = addSetting(new StringIOSetting("NamespacePrefix", IOSetting.Importance.LOW,
"What should the namespace prefix be? [empty is no prefix]",
"");
""));

schemaInstanceOutput = new BooleanIOSetting("SchemaInstance", IOSetting.Importance.LOW,
schemaInstanceOutput = addSetting(new BooleanIOSetting("SchemaInstance", IOSetting.Importance.LOW,
"Should the output use the Schema-Instance attribute?",
"false");
"false"));

instanceLocation = new StringIOSetting("InstanceLocation", IOSetting.Importance.LOW,
instanceLocation = addSetting(new StringIOSetting("InstanceLocation", IOSetting.Importance.LOW,
"Where is the schema found?",
"");
""));

indent = new BooleanIOSetting("Indenting", IOSetting.Importance.LOW,
indent = addSetting(new BooleanIOSetting("Indenting", IOSetting.Importance.LOW,
"Should the output be indented?",
"true");
"true"));

xmlDeclaration = new BooleanIOSetting("XMLDeclaration", IOSetting.Importance.LOW,
xmlDeclaration = addSetting(new BooleanIOSetting("XMLDeclaration", IOSetting.Importance.LOW,
"Should the output contain an XML declaration?",
"true");
"true"));
}

private void customizeJob() {
Expand All @@ -335,16 +335,4 @@ private void customizeJob() {
fireIOSettingQuestion(xmlDeclaration);
}

public IOSetting[] getIOSettings() {
IOSetting[] settings = new IOSetting[7];
settings[0] = cmlIds;
settings[1] = namespacedOutput;
settings[2] = namespacePrefix;
settings[3] = schemaInstanceOutput;
settings[4] = instanceLocation;
settings[5] = indent;
settings[6] = xmlDeclaration;
return settings;
}

}
15 changes: 2 additions & 13 deletions src/main/org/openscience/cdk/io/Gaussian98Reader.java
Expand Up @@ -548,26 +548,15 @@ private String parseLevelOfTheory(String line) {


private void initIOSettings() {
readOptimizedStructureOnly = new BooleanIOSetting("ReadOptimizedStructureOnly", IOSetting.Importance.LOW,
readOptimizedStructureOnly = addSetting(new BooleanIOSetting("ReadOptimizedStructureOnly", IOSetting.Importance.LOW,
"Should I only read the optimized structure from a geometry optimization?",
"false");
"false"));
}

private void customizeJob() {
fireIOSettingQuestion(readOptimizedStructureOnly);
}


/**
* Gets the iOSettings attribute of the Gaussian98Reader object
*
*@return The iOSettings value
*/
public IOSetting[] getIOSettings() {
IOSetting[] settings = new IOSetting[1];
settings[0] = readOptimizedStructureOnly;
return settings;
}

}

5 changes: 1 addition & 4 deletions src/main/org/openscience/cdk/io/MDLRXNV3000Reader.java
Expand Up @@ -300,9 +300,6 @@ public void close() throws IOException {

private void initIOSettings() {
}

public IOSetting[] getIOSettings() {
return new IOSetting[0];
}


}
9 changes: 2 additions & 7 deletions src/main/org/openscience/cdk/io/MDLReader.java
Expand Up @@ -604,19 +604,14 @@ public void close() throws IOException {
}

private void initIOSettings() {
forceReadAs3DCoords = new BooleanIOSetting("ForceReadAs3DCoordinates", IOSetting.Importance.LOW,
forceReadAs3DCoords = addSetting(new BooleanIOSetting("ForceReadAs3DCoordinates", IOSetting.Importance.LOW,
"Should coordinates always be read as 3D?",
"false");
"false"));
}

public void customizeJob() {
fireIOSettingQuestion(forceReadAs3DCoords);
}

public IOSetting[] getIOSettings() {
IOSetting[] settings = new IOSetting[1];
settings[0] = forceReadAs3DCoords;
return settings;
}
}

20 changes: 7 additions & 13 deletions src/main/org/openscience/cdk/io/MDLV2000Reader.java
Expand Up @@ -973,24 +973,18 @@ public void close() throws IOException {
}

private void initIOSettings() {
forceReadAs3DCoords = new BooleanIOSetting("ForceReadAs3DCoordinates", IOSetting.Importance.LOW,
forceReadAs3DCoords = addSetting(new BooleanIOSetting("ForceReadAs3DCoordinates", IOSetting.Importance.LOW,
"Should coordinates always be read as 3D?",
"false");
interpretHydrogenIsotopes = new BooleanIOSetting("InterpretHydrogenIsotopes", IOSetting.Importance.LOW,
"false"));
interpretHydrogenIsotopes = addSetting(new BooleanIOSetting("InterpretHydrogenIsotopes", IOSetting.Importance.LOW,
"Should D and T be interpreted as hydrogen isotopes?",
"true");
"true"));
}

public void customizeJob() {
fireIOSettingQuestion(forceReadAs3DCoords);
fireIOSettingQuestion(interpretHydrogenIsotopes);
}

public IOSetting[] getIOSettings() {
IOSetting[] settings = new IOSetting[2];
settings[0] = forceReadAs3DCoords;
settings[1] = interpretHydrogenIsotopes;
return settings;
for(IOSetting setting : getSettings()){
fireIOSettingQuestion(setting);
}
}

public List<IAtom> getAtomsByLinePosition() {
Expand Down
31 changes: 12 additions & 19 deletions src/main/org/openscience/cdk/io/MDLV2000Writer.java
Expand Up @@ -111,7 +111,7 @@ public class MDLV2000Writer extends DefaultChemObjectWriter {
private BufferedWriter writer;

/**
* Constructs a new MDLWriter that can write an {@link IMolecule}
* Constructs a new MDLWriter that can write an {@link IAtomContainer}
* to the MDL molfile format.
*
* @param out The Writer to write to
Expand All @@ -126,7 +126,7 @@ public MDLV2000Writer(Writer out) {
}

/**
* Constructs a new MDLWriter that can write an {@link IMolecule}
* Constructs a new MDLWriter that can write an {@link IAtomContainer}
* to a given OutputStream.
*
* @param output The OutputStream to write to
Expand Down Expand Up @@ -180,7 +180,7 @@ public boolean accepts(Class classObject) {
/**
* Writes a {@link IChemObject} to the MDL molfile formated output.
* It can only output ChemObjects of type {@link IChemFile},
* {@link IMolecule} and {@link IAtomContainer}.
* {@link IChemObject} and {@link IAtomContainer}.
*
* @param object {@link IChemObject} to write
*
Expand Down Expand Up @@ -555,39 +555,32 @@ protected static String formatMDLString(String s, int le) {
* so a 'query file' is created if the container has aromatic bonds and this settings is true.
*/
private void initIOSettings() {
forceWriteAs2DCoords = new BooleanIOSetting(
forceWriteAs2DCoords = addSetting(new BooleanIOSetting(
"ForceWriteAs2DCoordinates",
IOSetting.Importance.LOW,
"Should coordinates always be written as 2D?",
"false"
);
writeAromaticBondTypes = new BooleanIOSetting(
));
writeAromaticBondTypes = addSetting(new BooleanIOSetting(
"WriteAromaticBondTypes",
IOSetting.Importance.LOW,
"Should aromatic bonds be written as bond type 4?",
"false"
);
writeQueryFormatValencies = new BooleanIOSetting(
));
writeQueryFormatValencies = addSetting(new BooleanIOSetting(
"WriteQueryFormatValencies",
IOSetting.Importance.LOW,
"Should valencies be written in the MDL Query format?",
"false"
);
));
}

public void customizeJob() {
fireIOSettingQuestion(forceWriteAs2DCoords);
fireIOSettingQuestion(writeAromaticBondTypes);
fireIOSettingQuestion(writeQueryFormatValencies);
for(IOSetting setting : getSettings()){
fireIOSettingQuestion(setting);
}
}

public IOSetting[] getIOSettings() {
IOSetting[] settings = new IOSetting[3];
settings[0] = forceWriteAs2DCoords;
settings[1] = writeAromaticBondTypes;
settings[2] = writeQueryFormatValencies;
return settings;
}
}


5 changes: 1 addition & 4 deletions src/main/org/openscience/cdk/io/MDLV3000Reader.java
Expand Up @@ -592,9 +592,6 @@ public void close() throws IOException {

private void initIOSettings() {
}

public IOSetting[] getIOSettings() {
return new IOSetting[0];
}


}
25 changes: 9 additions & 16 deletions src/main/org/openscience/cdk/io/PDBReader.java
Expand Up @@ -751,29 +751,22 @@ public void close() throws IOException {
}

private void initIOSettings() {
useRebondTool = new BooleanIOSetting("UseRebondTool", IOSetting.Importance.LOW,
useRebondTool = addSetting(new BooleanIOSetting("UseRebondTool", IOSetting.Importance.LOW,
"Should the PDBReader deduce bonding patterns?",
"false");
readConnect = new BooleanIOSetting("ReadConnectSection", IOSetting.Importance.LOW,
"false"));
readConnect = addSetting(new BooleanIOSetting("ReadConnectSection", IOSetting.Importance.LOW,
"Should the CONECT be read?",
"true");
useHetDictionary = new BooleanIOSetting("UseHetDictionary", IOSetting.Importance.LOW,
"true"));
useHetDictionary = addSetting(new BooleanIOSetting("UseHetDictionary", IOSetting.Importance.LOW,
"Should the PDBReader use the HETATM dictionary for atom types?",
"false");
"false"));
}

public void customizeJob() {
fireIOSettingQuestion(useRebondTool);
fireIOSettingQuestion(readConnect);
fireIOSettingQuestion(useHetDictionary);
for(IOSetting setting : getSettings()){
fireIOSettingQuestion(setting);
}
}

public IOSetting[] getIOSettings() {
IOSetting[] settings = new IOSetting[3];
settings[0] = useRebondTool;
settings[1] = readConnect;
settings[2] = useHetDictionary;
return settings;
}

}
31 changes: 11 additions & 20 deletions src/main/org/openscience/cdk/io/PDBWriter.java
Expand Up @@ -97,17 +97,17 @@ public PDBWriter(Writer out) {
}
} catch (Exception exc) {
}
writeAsHET = new BooleanIOSetting("WriteAsHET", IOSetting.Importance.LOW,
"Should the output file use HETATM", "false");
useElementSymbolAsAtomName = new BooleanIOSetting(
writeAsHET = addSetting(new BooleanIOSetting("WriteAsHET", IOSetting.Importance.LOW,
"Should the output file use HETATM", "false"));
useElementSymbolAsAtomName = addSetting(new BooleanIOSetting(
"UseElementSymbolAsAtomName", IOSetting.Importance.LOW,
"Should the element symbol be written as the atom name", "false");
writeCONECTRecords = new BooleanIOSetting("WriteCONECT", IOSetting.Importance.LOW,
"Should the bonds be written as CONECT records?", "true");
writeTERRecord = new BooleanIOSetting("WriteTER", IOSetting.Importance.LOW,
"Should a TER record be put at the end of the atoms?", "false");
writeENDRecord = new BooleanIOSetting("WriteEND", IOSetting.Importance.LOW,
"Should an END record be put at the end of the file?", "true");
"Should the element symbol be written as the atom name", "false"));
writeCONECTRecords = addSetting(new BooleanIOSetting("WriteCONECT", IOSetting.Importance.LOW,
"Should the bonds be written as CONECT records?", "true"));
writeTERRecord = addSetting(new BooleanIOSetting("WriteTER", IOSetting.Importance.LOW,
"Should a TER record be put at the end of the atoms?", "false"));
writeENDRecord = addSetting(new BooleanIOSetting("WriteEND", IOSetting.Importance.LOW,
"Should an END record be put at the end of the file?", "true"));
}

public PDBWriter(OutputStream output) {
Expand Down Expand Up @@ -341,15 +341,6 @@ public void writeCrystal(ICrystal crystal) throws CDKException {
public void close() throws IOException {
writer.close();
}

public IOSetting[] getIOSettings() {
IOSetting[] settings = new IOSetting[7];
settings[0] = writeAsHET;
settings[1] = useElementSymbolAsAtomName;
settings[2] = writeCONECTRecords;
settings[3] = writeTERRecord;
settings[4] = writeENDRecord;
return settings;
}


}

0 comments on commit d5e718a

Please sign in to comment.