Skip to content

Commit

Permalink
Set all Boolean GeneratorParameter to false.
Browse files Browse the repository at this point in the history
This is a workaround for an API to turn Generators on/off.
  • Loading branch information
olas committed Jun 30, 2010
1 parent 54104d9 commit d34bcc8
Showing 1 changed file with 21 additions and 25 deletions.
Expand Up @@ -253,31 +253,27 @@ public void selectionChanged( SelectionChangedEvent event ) {
}
}

private void turnOffAllExternalGenerators() {
//Switch off all other DS-generators!
List<IGenerator<IAtomContainer>> generators = ChoiceGenerator.getGeneratorsFromExtension();
for(IGenerator generator: generators) {
List<IGeneratorParameter<?>> params = generator.getParameters();
if(params.isEmpty()) continue;
for (IGeneratorParameter param : params){
if (param instanceof BlueRedColorScaleGenerator.Visibility) {
BlueRedColorScaleGenerator.Visibility v = (BlueRedColorScaleGenerator.Visibility) param;
v.setValue(false);
logger.debug("Turned off Generator: " + generator);
}
if (param instanceof PosNegIncColorGenerator.Visibility) {
PosNegIncColorGenerator.Visibility v = (PosNegIncColorGenerator.Visibility) param;
v.setValue(false);
logger.debug("Turned off Generator: " + generator);
}
// if (param instanceof IGeneratorParameter<Boolean>) {
// IGeneratorParameter<Boolean> bp= (IGeneratorParameter<Boolean>)param;
// model.set(bp, false);
// }
}
}
}

private void turnOffAllExternalGenerators() {
//Switch off all other DS-generators!
List<IGenerator<IAtomContainer>> generators = ChoiceGenerator.getGeneratorsFromExtension();

JChemPaintEditor jcp=getJCPfromActiveEditor();
if (jcp==null) return;

RendererModel model = jcp.getWidget().getRenderer2DModel();

for(IGenerator generator: generators) {
List<IGeneratorParameter<?>> params = generator.getParameters();
if(params.isEmpty()) continue;
for (IGeneratorParameter param : params){
if (param.getDefault() instanceof Boolean) {
IGeneratorParameter<Boolean> bp= (IGeneratorParameter<Boolean>)param;
model.set(bp.getClass(), false);
}
}
}
}

});

GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
Expand Down

0 comments on commit d34bcc8

Please sign in to comment.