X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.common%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fcommon%2FEvaluatorImpl.java;h=49268c6f65ff73c872951e909f2059ce7fd0e833;hp=ca9b41718a8a35dea0ebc1b9d96d7caf8b77873c;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/EvaluatorImpl.java b/bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/EvaluatorImpl.java index ca9b41718..49268c6f6 100644 --- a/bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/EvaluatorImpl.java +++ b/bundles/org.simantics.browsing.ui.common/src/org/simantics/browsing/ui/common/EvaluatorImpl.java @@ -1,177 +1,177 @@ -/******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management - * in Industry THTH ry. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * VTT Technical Research Centre of Finland - initial API and implementation - *******************************************************************************/ -package org.simantics.browsing.ui.common; - -import java.util.ArrayList; -import java.util.Collection; - -import org.simantics.browsing.ui.Tester; -import org.simantics.browsing.ui.common.EvaluatorData.Evaluator; -import org.simantics.browsing.ui.common.EvaluatorData.EvaluatorTree; -import org.simantics.browsing.ui.content.CheckedStateFactory; -import org.simantics.browsing.ui.content.ComparableContextFactory; -import org.simantics.browsing.ui.content.ImageDecoratorFactory; -import org.simantics.browsing.ui.content.ImagerFactory; -import org.simantics.browsing.ui.content.LabelDecoratorFactory; -import org.simantics.browsing.ui.content.LabelerFactory; -import org.simantics.browsing.ui.content.ViewpointFactory; - -/** - * @author Tuukka Lehtonen - */ -public class EvaluatorImpl implements Evaluator { - - private final EvaluatorTree viewpointTree = new EvaluatorTreeImpl("Viewpoint", Testers.PASS); - private final EvaluatorTree labelerTree = new EvaluatorTreeImpl("Labeler", Testers.PASS); - private final EvaluatorTree checkStateTree = new EvaluatorTreeImpl("Check state", Testers.PASS); - private final EvaluatorTree labelDecoratorTree = new EvaluatorTreeImpl("Label decorator", Testers.PASS); - private final EvaluatorTree imagerTree = new EvaluatorTreeImpl("Imager", Testers.PASS); - private final EvaluatorTree imageDecoratorTree = new EvaluatorTreeImpl("Image decorator", Testers.PASS); - private final EvaluatorTree comparableContextTree = new EvaluatorTreeImpl("Comparable", Testers.PASS); - - @Override - public Evaluator addViewpoint(ViewpointFactory factory, double preference) { - viewpointTree.addFactory(factory, preference); - return this; - } - @Override - public Evaluator addComparableContext(ComparableContextFactory factory, double preference) { - comparableContextTree.addFactory(factory, preference); - return this; - } - @Override - public Evaluator addLabeler(LabelerFactory factory, double preference) { - labelerTree.addFactory(factory, preference); - return this; - } - @Override - public Evaluator addCheckState(CheckedStateFactory factory, double preference) { - checkStateTree.addFactory(factory, preference); - return this; - } - @Override - public Evaluator addLabelDecorator(LabelDecoratorFactory factory, double preference) { - labelDecoratorTree.addFactory(factory, preference); - return this; - } - @Override - public Evaluator addComparator(ComparableContextFactory factory, double preference) { - comparableContextTree.addFactory(factory, preference); - return this; - } - @Override - public Evaluator addImager(ImagerFactory factory, double preference) { - imagerTree.addFactory(factory, preference); - return this; - } - @Override - public Evaluator addImageDecorator(ImageDecoratorFactory factory, double preference) { - imageDecoratorTree.addFactory(factory, preference); - return this; - } - - @Override - public EvaluatorTree getComparableContextTree() { - return comparableContextTree; - } - - @Override - public EvaluatorTree getImagerTree() { - return imagerTree; - } - - @Override - public EvaluatorTree getImageDecoratorTree() { - return imageDecoratorTree; - } - - @Override - public EvaluatorTree getLabelDecoratorTree() { - return labelDecoratorTree; - } - - @Override - public EvaluatorTree getLabelerTree() { - return labelerTree; - } - - @Override - public EvaluatorTree getCheckStateTree() { - return checkStateTree; - } - - @Override - public EvaluatorTree getViewpointTree() { - return viewpointTree; - } - - /** - * @param - */ - public class EvaluatorTreeImpl implements EvaluatorTree { - private final String factory; - private final Tester tester; - private final Collection> acceptedFactories = new ArrayList>(); - private final Collection> children = new ArrayList>(); - - public EvaluatorTreeImpl(String factory, Tester tester) { - if (tester == null) - throw new NullPointerException("null tester"); - this.tester = tester; - this.factory = factory; - } - - @Override - public EvaluatorTree addFactory(Factory factory, double preference) { - if (factory == null) - throw new NullPointerException("null factory"); - acceptedFactories.add(new Preference(factory, preference)); - return this; - } - - @Override - public EvaluatorTree addBranch(Tester tester) { - if (tester == null) - throw new NullPointerException("null tester"); - EvaluatorTree result = new EvaluatorTreeImpl(factory, tester); - children.add(result); - return result; - } - - @Override - public Collection> getAcceptedFactories() { - return acceptedFactories; - } - - @Override - public Collection> getChildren() { - return children; - } - - @Override - public Tester getTester() { - return tester; - } - - @Override - public String toString() { - return factory + " tree [" + tester + "]"; - } - - } - - @Override - public String toString() { - return "Evaluator"; - } - +/******************************************************************************* + * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * in Industry THTH ry. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * VTT Technical Research Centre of Finland - initial API and implementation + *******************************************************************************/ +package org.simantics.browsing.ui.common; + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.browsing.ui.Tester; +import org.simantics.browsing.ui.common.EvaluatorData.Evaluator; +import org.simantics.browsing.ui.common.EvaluatorData.EvaluatorTree; +import org.simantics.browsing.ui.content.CheckedStateFactory; +import org.simantics.browsing.ui.content.ComparableContextFactory; +import org.simantics.browsing.ui.content.ImageDecoratorFactory; +import org.simantics.browsing.ui.content.ImagerFactory; +import org.simantics.browsing.ui.content.LabelDecoratorFactory; +import org.simantics.browsing.ui.content.LabelerFactory; +import org.simantics.browsing.ui.content.ViewpointFactory; + +/** + * @author Tuukka Lehtonen + */ +public class EvaluatorImpl implements Evaluator { + + private final EvaluatorTree viewpointTree = new EvaluatorTreeImpl("Viewpoint", Testers.PASS); + private final EvaluatorTree labelerTree = new EvaluatorTreeImpl("Labeler", Testers.PASS); + private final EvaluatorTree checkStateTree = new EvaluatorTreeImpl("Check state", Testers.PASS); + private final EvaluatorTree labelDecoratorTree = new EvaluatorTreeImpl("Label decorator", Testers.PASS); + private final EvaluatorTree imagerTree = new EvaluatorTreeImpl("Imager", Testers.PASS); + private final EvaluatorTree imageDecoratorTree = new EvaluatorTreeImpl("Image decorator", Testers.PASS); + private final EvaluatorTree comparableContextTree = new EvaluatorTreeImpl("Comparable", Testers.PASS); + + @Override + public Evaluator addViewpoint(ViewpointFactory factory, double preference) { + viewpointTree.addFactory(factory, preference); + return this; + } + @Override + public Evaluator addComparableContext(ComparableContextFactory factory, double preference) { + comparableContextTree.addFactory(factory, preference); + return this; + } + @Override + public Evaluator addLabeler(LabelerFactory factory, double preference) { + labelerTree.addFactory(factory, preference); + return this; + } + @Override + public Evaluator addCheckState(CheckedStateFactory factory, double preference) { + checkStateTree.addFactory(factory, preference); + return this; + } + @Override + public Evaluator addLabelDecorator(LabelDecoratorFactory factory, double preference) { + labelDecoratorTree.addFactory(factory, preference); + return this; + } + @Override + public Evaluator addComparator(ComparableContextFactory factory, double preference) { + comparableContextTree.addFactory(factory, preference); + return this; + } + @Override + public Evaluator addImager(ImagerFactory factory, double preference) { + imagerTree.addFactory(factory, preference); + return this; + } + @Override + public Evaluator addImageDecorator(ImageDecoratorFactory factory, double preference) { + imageDecoratorTree.addFactory(factory, preference); + return this; + } + + @Override + public EvaluatorTree getComparableContextTree() { + return comparableContextTree; + } + + @Override + public EvaluatorTree getImagerTree() { + return imagerTree; + } + + @Override + public EvaluatorTree getImageDecoratorTree() { + return imageDecoratorTree; + } + + @Override + public EvaluatorTree getLabelDecoratorTree() { + return labelDecoratorTree; + } + + @Override + public EvaluatorTree getLabelerTree() { + return labelerTree; + } + + @Override + public EvaluatorTree getCheckStateTree() { + return checkStateTree; + } + + @Override + public EvaluatorTree getViewpointTree() { + return viewpointTree; + } + + /** + * @param + */ + public class EvaluatorTreeImpl implements EvaluatorTree { + private final String factory; + private final Tester tester; + private final Collection> acceptedFactories = new ArrayList>(); + private final Collection> children = new ArrayList>(); + + public EvaluatorTreeImpl(String factory, Tester tester) { + if (tester == null) + throw new NullPointerException("null tester"); + this.tester = tester; + this.factory = factory; + } + + @Override + public EvaluatorTree addFactory(Factory factory, double preference) { + if (factory == null) + throw new NullPointerException("null factory"); + acceptedFactories.add(new Preference(factory, preference)); + return this; + } + + @Override + public EvaluatorTree addBranch(Tester tester) { + if (tester == null) + throw new NullPointerException("null tester"); + EvaluatorTree result = new EvaluatorTreeImpl(factory, tester); + children.add(result); + return result; + } + + @Override + public Collection> getAcceptedFactories() { + return acceptedFactories; + } + + @Override + public Collection> getChildren() { + return children; + } + + @Override + public Tester getTester() { + return tester; + } + + @Override + public String toString() { + return factory + " tree [" + tester + "]"; + } + + } + + @Override + public String toString() { + return "Evaluator"; + } + } \ No newline at end of file