public code v1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?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/JavaSE-1.8"/>
|
||||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>flintstones.group</groupId>
|
||||
<artifactId>flintstones.bundles</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>flintstones.method.sorting.phase.gatheringreferencepoint</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Gatheringreferencepoint</name>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.method.sorting.phase.gatheringreferencepoint</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.ManifestBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.pde.SchemaBuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.pde.PluginNature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
<filteredResources>
|
||||
<filter>
|
||||
<id>1779484362696</id>
|
||||
<name></name>
|
||||
<type>30</type>
|
||||
<matcher>
|
||||
<id>org.eclipse.core.resources.regexFilterMatcher</id>
|
||||
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
|
||||
</matcher>
|
||||
</filter>
|
||||
</filteredResources>
|
||||
</projectDescription>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
||||
@@ -0,0 +1,26 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Gatheringreferencepoint
|
||||
Bundle-SymbolicName: flintstones.method.sorting.phase.gatheringreferencepoint;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.method.sorting.phase.gatheringreferencepoint
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Require-Bundle: flintstones.entity.problemelement.ui,
|
||||
flintstones.helper.ui,
|
||||
flintstones.model.problemelement.service,
|
||||
javax.inject,
|
||||
flintstones.model.domain.service,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.operator,
|
||||
flintstones.model.ui.service,
|
||||
flintstones.entity.problemelement,
|
||||
flintstones.helper.data,
|
||||
flintstones.model.ahp.referencepoint.service,
|
||||
flintstones.entity.valuation,
|
||||
flintstones.valuation.numeric.real,
|
||||
flintstones.operator.aggregation.min,
|
||||
org.apache.commons.lang,
|
||||
flintstones.operator.aggregation.max,
|
||||
flintstones.entity.method.phase.ui,
|
||||
flintstones.entity.method.phase,
|
||||
flintstones.entity.operator
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="flintstones.phasemethod.extensionpoint">
|
||||
<phase
|
||||
implementation="flintstones.method.sorting.phase.gatheringreferencepoint.ReferencePointGatheringModel"
|
||||
uid="flintstones.method.sorting.phase.gatheringreferencepoint">
|
||||
</phase>
|
||||
</extension>
|
||||
<extension
|
||||
point="flintstones.phasemethod.ui">
|
||||
<phasemethod_ui
|
||||
implementation="flintstones.method.sorting.phase.gatheringreferencepoint.ReferencePointGatheringUI"
|
||||
phasemethod="flintstones.method.sorting.phase.gatheringreferencepoint"
|
||||
uid="flintstones.method.sorting.phase.gatheringreferencepoint.ui">
|
||||
</phasemethod_ui>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package flintstones.method.sorting.phase.gatheringreferencepoint;
|
||||
|
||||
import flintstones.entity.method.phase.PhaseMethod;
|
||||
|
||||
public class ReferencePointGatheringModel extends PhaseMethod {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RP Gathering";
|
||||
}
|
||||
|
||||
}
|
||||
+232
@@ -0,0 +1,232 @@
|
||||
package flintstones.method.sorting.phase.gatheringreferencepoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Label;
|
||||
import flintstones.entity.method.phase.ui.PhaseMethodUI;
|
||||
import flintstones.entity.operator.AggregationOperator;
|
||||
import flintstones.entity.problemelement.entities.Criterion;
|
||||
import flintstones.entity.problemelement.entities.ProblemElement;
|
||||
import flintstones.entity.problemelement.ui.widget.ProblemElementSelector;
|
||||
import flintstones.entity.problemelement.ui.widget.listener.IProblemElementChangedListener;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.DoubleHelper;
|
||||
import flintstones.helper.data.HashMapList;
|
||||
import flintstones.helper.ui.components.SliderCollector;
|
||||
import flintstones.helper.ui.components.listeners.WEvent;
|
||||
import flintstones.helper.ui.components.listeners.WItemBeforeOperation;
|
||||
import flintstones.helper.ui.components.listeners.WItemChanged;
|
||||
import flintstones.model.ahp.referencepoint.service.IReferencePointService;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
import flintstones.model.problemelement.service.IProblemElementService;
|
||||
import flintstones.model.ui.service.UiService;
|
||||
import flintstones.model.valuation.service.IValuationService;
|
||||
import flintstones.operator.aggregation.max.Max;
|
||||
import flintstones.operator.aggregation.min.Min;
|
||||
import flintstones.operator.service.IOperatorService;
|
||||
import flintstones.valuation.numeric.real.RealValuation;
|
||||
|
||||
public class ReferencePointGatheringUI extends PhaseMethodUI
|
||||
implements IProblemElementChangedListener, WItemChanged, WItemBeforeOperation {
|
||||
|
||||
@Inject
|
||||
IProblemElementService problemService;
|
||||
|
||||
@Inject
|
||||
IDomainService domainService;
|
||||
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
@Inject
|
||||
IOperatorService operatorService;
|
||||
|
||||
@Inject
|
||||
IReferencePointService referencePointService;
|
||||
|
||||
private ProblemElementSelector criterionCombo;
|
||||
|
||||
private Label rangeLabel;
|
||||
SliderCollector collector;
|
||||
|
||||
private HashMapList<ProblemElement, Double> data = new HashMapList<>();
|
||||
private HashMap<ProblemElement, Double> mins = new HashMap<>();
|
||||
private HashMap<ProblemElement, Double> maxs = new HashMap<>();
|
||||
ProblemElement[] criterions;
|
||||
|
||||
int numberOfCutsx = 6;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
createControls(getBaseComposite());
|
||||
}
|
||||
|
||||
private void createControls(Composite base) {
|
||||
|
||||
UiService.setGridLayout(base, 1, true);
|
||||
UiService.setGridDataAuto(base);
|
||||
|
||||
Composite row1 = new Composite(base, 0);
|
||||
UiService.setGridLayout(row1, 3, false);
|
||||
UiService.setGridData(row1, 9, 0, true, false);
|
||||
|
||||
criterions = problemService.getAll(Criterion.Type);
|
||||
|
||||
criterionCombo = new ProblemElementSelector(row1, criterions);
|
||||
|
||||
for (ProblemElement criterion : criterions) {
|
||||
Double[] values = getReferencePoints(criterion);
|
||||
data.put(criterion, new ArrayList<Double>(Arrays.asList(values)));
|
||||
save(criterion);
|
||||
}
|
||||
|
||||
Double[] currentData = getCurrentData();
|
||||
double min = currentData.length > 0 ? currentData[0] : Double.MIN_VALUE;
|
||||
double max = currentData.length > 0 ? currentData[currentData.length - 1] : Double.MAX_VALUE;
|
||||
rangeLabel = new Label(row1, 0);
|
||||
UiService.setGridDataAuto(rangeLabel);
|
||||
|
||||
collector = new SliderCollector(base, min, max, 2);
|
||||
|
||||
collector.setHeaders(getHeaders());
|
||||
collector.setValues(currentData);
|
||||
|
||||
refreshRange(criterions[0]);
|
||||
|
||||
collector.setBeforeOperationListener(this);
|
||||
collector.setChangeListener(this);
|
||||
criterionCombo.setListener(this);
|
||||
|
||||
}
|
||||
|
||||
public ProblemElement getCurrentCriterion() {
|
||||
return criterionCombo.getSelectedElement();
|
||||
}
|
||||
|
||||
private Double[] getReferencePoints(ProblemElement criterion) {
|
||||
|
||||
// Compute min-max for each criterion
|
||||
|
||||
Valuation[] valuations = valuationService.getAllValuationsWith(criterion);
|
||||
valuations = Arrays.stream(valuations) //
|
||||
.map(k -> ((RealValuation) k)) //
|
||||
.toArray(Valuation[]::new);
|
||||
|
||||
AggregationOperator max = operatorService.getAggregationOperator(Max.class.getPackage().getName(), valuations[0].getId());
|
||||
AggregationOperator min = operatorService.getAggregationOperator(Min.class.getPackage().getName(), valuations[0].getId());
|
||||
Valuation maxV = max.computeAggregation(Arrays.asList(valuations), null);
|
||||
Valuation minV = min.computeAggregation(Arrays.asList(valuations), null);
|
||||
|
||||
double minValue = ((RealValuation) minV).getValue();
|
||||
double maxValue = ((RealValuation) maxV).getValue();
|
||||
|
||||
mins.put(criterion, minValue);
|
||||
maxs.put(criterion, maxValue);
|
||||
|
||||
// Try to load the items from memory
|
||||
Double[] items = referencePointService.getAsRange((Criterion) criterion);
|
||||
if (items.length == 0) {
|
||||
// If it is not possible, do the cuts by hand
|
||||
int numberOfCuts = numberOfCutsx;
|
||||
|
||||
double[] parts = DoubleHelper.ToRange(minValue, maxValue, numberOfCuts - 1, true);
|
||||
|
||||
items = ArrayUtils.toObject(parts);
|
||||
}
|
||||
|
||||
criterionCombo.setStatus(criterion, items.length == numberOfCutsx);
|
||||
return items;
|
||||
|
||||
}
|
||||
|
||||
private String[] getCurrentDataS() {
|
||||
return Arrays.stream(getCurrentData()).map(k -> k + "").toArray(String[]::new);
|
||||
}
|
||||
|
||||
private Double[] getCurrentData() {
|
||||
return data.getSafe(getCurrentCriterion()).toArray(new Double[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void problemElementChanged(ProblemElement pe) {
|
||||
Double[] values = Arrays.stream(getCurrentDataS()).map(k -> Double.parseDouble(k)).toArray(Double[]::new);
|
||||
|
||||
refreshRange(pe);
|
||||
|
||||
collector.setValues(values);
|
||||
|
||||
}
|
||||
|
||||
private void refreshRange(ProblemElement pe) {
|
||||
Double min = mins.get(pe);
|
||||
Double max = maxs.get(pe);
|
||||
|
||||
rangeLabel.setText("[" + DoubleHelper.Draw(min) + " - " + DoubleHelper.Draw(max) + "]");
|
||||
|
||||
collector.reSet(min, max, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWidgetChange() {
|
||||
Double[] dataArr = collector.getData();
|
||||
Arrays.sort(dataArr);
|
||||
|
||||
collector.setValues(dataArr);
|
||||
data.put(getCurrentCriterion(), new ArrayList<Double>(Arrays.asList(dataArr)));
|
||||
criterionCombo.setStatus(getCurrentCriterion(), dataArr.length == numberOfCutsx);
|
||||
|
||||
save(getCurrentCriterion());
|
||||
}
|
||||
|
||||
private void save(ProblemElement c) {
|
||||
|
||||
Double[] values = data.get(c).toArray(new Double[0]);
|
||||
referencePointService.addOrUpdate((Criterion) c, values);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldBeExecuted(WEvent operationType, String before, String after) {
|
||||
|
||||
if (operationType.equals(WEvent.ADD)) {
|
||||
Double[] data = collector.getData();
|
||||
Double newValue = DoubleHelper.ParseDouble(before);
|
||||
|
||||
if (data.length >= numberOfCutsx)
|
||||
return false;
|
||||
|
||||
if (Arrays.asList(data).contains(newValue))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private String[] getHeaders() {
|
||||
String[] headers = new String[numberOfCutsx];
|
||||
for (int i = 0; i < numberOfCutsx; i++)
|
||||
headers[i] = "R.P." + (i + 1);
|
||||
return headers;
|
||||
}
|
||||
|
||||
public SliderCollector getCollector() {
|
||||
return collector;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
System.out.println("IDK");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isForwardEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user