public code v1

This commit is contained in:
Francisco Jesús Martínez Mimbrera
2026-05-23 00:32:57 +02:00
commit 759a8968a2
4357 changed files with 163763 additions and 0 deletions
@@ -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,17 @@
<?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.entity.sensitiveanalysismodel.ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Sensitve analysis model ui</name>
<organization>
<name>Sinbad2</name>
</organization>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.entity.sensitiveanalysismodel.ui</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>1779484362576</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>
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
@@ -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
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
@@ -0,0 +1,19 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Sensitve analysis model ui
Bundle-SymbolicName: flintstones.entity.sensitiveanalysismodel.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Vendor: Sinbad2
Automatic-Module-Name: flintstones.entity.sensitiveanalysismodel.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: flintstones.helper.html,
flintstones.model.ui.service,
flintstones.entity.extensionenum,
org.eclipse.swt,
javax.inject,
org.eclipse.e4.core.di.annotations,
flintstones.entity.sensitiveanalysismodel,
flintstones.model.problemelement.service,
org.jfree.chart.jfreechart
Export-Package: flintstones.entity.sensitiveanalysismodel.ui,
flintstones.entity.sensitiveanalysismodel.ui.chart
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension-point id="flintstones.entity.sensitiveanalysismodel.ui.extension" name="Sensitive analysis model ui extension point" schema="schema/flintstones.entity.sensitiveanalysismodel.ui.extension.exsd"/>
</plugin>
@@ -0,0 +1,119 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="flintstones.entity.sensitiveanalysismodel.ui" xmlns="http://www.w3.org/2001/XMLSchema">
<annotation>
<appinfo>
<meta.schema plugin="flintstones.entity.sensitiveanalysismodel.ui" id="flintstones.entity.sensitiveanalysismodel.ui.extension" name="Sensitive analysis model ui extension point"/>
</appinfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<annotation>
<appinfo>
<meta.element />
</appinfo>
</annotation>
<complexType>
<choice minOccurs="1" maxOccurs="unbounded">
<element ref="sensitivemodel_ui"/>
</choice>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute translatable="true"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="sensitivemodel_ui">
<complexType>
<attribute name="uid" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="sensitivemodel" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="identifier" basedOn="flintstones.entity.sensitiveanalysismodel.extension/model/@uid"/>
</appinfo>
</annotation>
</attribute>
<attribute name="implementation" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appinfo>
<meta.attribute kind="java" basedOn="flintstones.entity.sensitiveanalysismodel.ui.SensitiveAnalysisModelUi:"/>
</appinfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appinfo>
<meta.section type="since"/>
</appinfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="examples"/>
</appinfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="apiinfo"/>
</appinfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appinfo>
<meta.section type="implementation"/>
</appinfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
</schema>
@@ -0,0 +1,153 @@
package flintstones.entity.sensitiveanalysismodel.ui;
import java.util.LinkedList;
import java.util.List;
import javax.inject.Inject;
import org.eclipse.swt.widgets.Composite;
import flintstones.entity.extensionenum.ExtensionEnum;
import flintstones.entity.problemelement.entities.Alternative;
import flintstones.entity.problemelement.entities.Criterion;
import flintstones.entity.problemelement.entities.ProblemElement;
import flintstones.entity.problemelement.entities.ProblemElementHelper;
import flintstones.entity.sensitiveanalysismodel.SensitiveAnalysisModel;
import flintstones.entity.sensitiveanalysismodel.SensitiveAnalysisModel.FieldsChanges;
import flintstones.entity.sensitiveanalysismodel.ui.chart.RankingEvolutionChart;
import flintstones.helper.html.table.HtmlTextTable;
import flintstones.model.problemelement.service.IProblemElementService;
public abstract class SensitiveAnalysisModelUi {
public static final String EXTENSION_POINT = "flintstones.entity.sensitiveanalysismodel.ui.extension";
protected HtmlTextTable dmTable;
protected HtmlTextTable rankingTable;
protected HtmlTextTable changesTable;
protected RankingEvolutionChart chart;
protected SensitiveAnalysisModel model;
@Inject
IProblemElementService problemService;
/**
* The Class Fields.
*/
public enum Fields implements ExtensionEnum {
/** The id. */
uid,
/** The model. */
sensitivemodel,
/** The implementation. */
implementation
}
public SensitiveAnalysisModel getModel() {
return model;
}
public void setModel(SensitiveAnalysisModel model) {
this.model = model;
}
public HtmlTextTable createDecisionMatrixTable(Composite decisionMatrixSection) {
String[] rowHeader = getShortenedAlternativesNames();
String[] colHeader = getShortenedCriteriaNames();
String[][] valuesSTR = new String [rowHeader.length][colHeader.length];
Double[][] values = model.getDecisionMatrix();
for(int i = 0; i < valuesSTR.length; i++) {
for(int j = 0; j < valuesSTR[i].length; j++)
valuesSTR[i][j] = "" + values[i][j];
}
dmTable = new HtmlTextTable(decisionMatrixSection, valuesSTR, colHeader, rowHeader);
return dmTable;
}
public abstract HtmlTextTable createRankingTable(Composite rankingSection);
public abstract HtmlTextTable createChangesTable(Composite changesSection, FieldsChanges typeChange);
public void refreshDecisionMatrixTable() {
Double[][] newValues = model.getDecisionMatrix();
String[][] valuesSTR = new String[dmTable.getNumberOfRows()][dmTable.getNumberOfColumns()];
for(int i = 0; i < valuesSTR.length; i++) {
for(int j = 0; j < valuesSTR[i].length; j++) {
valuesSTR[i][j] = "" + newValues[i][j];
}
}
dmTable.refresh(valuesSTR);
dmTable.render();
}
public abstract void refreshRankingTable();
public abstract void refreshChangesTable(FieldsChanges typeChange);
public String[] getShortenedCriteriaNames() {
Criterion[] allCriteria = ProblemElementHelper.asCriterions(problemService.getMainElements(Criterion.Type));
String[] str = new String[allCriteria.length];
for(int i = 0; i < allCriteria.length; i++)
str[i] = "C" + (i + 1);
return str;
}
public String[] getShortenedAlternativesNames() {
Alternative[] allAlternatives = ProblemElementHelper.asAlternatives(problemService.getAll(Alternative.Type));
String[] str = new String[allAlternatives.length];
for(int i = 0; i < allAlternatives.length; i++)
str[i] = "A" + (i + 1);
return str;
}
public String[] getShortenedPairAlternativesNames() {
Alternative[] allAlternatives = ProblemElementHelper.asAlternatives(problemService.getAll(Alternative.Type));
List<String> str = new LinkedList<>();
for(int i = 0; i < allAlternatives.length - 1; i++) {
for(int j = i + 1; j < allAlternatives.length; ++j) {
str.add("A" + (i + 1) + "-" + "A" + (j + 1));
}
}
return str.toArray(new String[0]);
}
public String[] getShortenedAllPairAlternativesNames() {
Alternative[] allAlternatives = ProblemElementHelper.asAlternatives(problemService.getAll(Alternative.Type));
List<String> str = new LinkedList<>();
for(int i = 0; i < allAlternatives.length - 1; i++) {
for(int j = 0; j < allAlternatives.length; ++j) {
if(i != j)
str.add("A" + (i + 1) + "-" + "A" + (j + 1));
}
}
return str.toArray(new String[0]);
}
public abstract RankingEvolutionChart createRankingEvolutionChart(Composite container, ProblemElement[] criteria, Criterion criterion, int width, int height, int style);
public String[] getCriteriaIds() {
String[] ids = new String[problemService.getMainElements(Criterion.Type).length];
int cont = 0;
for(ProblemElement pe: problemService.getMainElements(Criterion.Type)) {
ids[cont] = pe.getName();
cont++;
}
return ids;
}
}
@@ -0,0 +1,173 @@
package flintstones.entity.sensitiveanalysismodel.ui.chart;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
import java.awt.Stroke;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import org.eclipse.swt.widgets.Composite;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.axis.NumberTickUnit;
import org.jfree.chart.labels.XYToolTipGenerator;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.ValueMarker;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
import org.jfree.chart.swt.ChartComposite;
import org.jfree.chart.ui.RectangleAnchor;
import org.jfree.chart.ui.RectangleInsets;
import org.jfree.data.xy.XYDataset;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;
import flintstones.entity.problemelement.entities.Criterion;
import flintstones.entity.problemelement.entities.ProblemElement;
import flintstones.entity.sensitiveanalysismodel.SensitiveAnalysisModel;
public abstract class RankingEvolutionChart {
protected SensitiveAnalysisModel model;
protected Criterion criterion;
protected ProblemElement[] criteria;
protected JFreeChart chart;
protected ChartComposite chartComposite;
protected XYSeriesCollection dataset;
protected ValueMarker currentWeightMarker;
public void refreshChart(Criterion criterion) {
this.criterion = criterion;
if (this.chart == null)
this.chart = this.createChart(this.createDataset());
else
this.chart.getXYPlot()
.setDataset(this.createDataset());
currentWeightMarker.setValue(model.getCriteriaWeights().get(criterion));
updateRange();
}
private JFreeChart createChart(XYDataset dataset) {
JFreeChart chart = ChartFactory.createXYLineChart("Ranking exchanges among alternatives", null, null, dataset,
PlotOrientation.VERTICAL, true, true, false);
chart.setBackgroundPaint(Color.white);
XYPlot plot = chart.getXYPlot();
plot.setBackgroundPaint(Color.white);
plot.setDomainGridlinesVisible(true);
plot.setRangeGridlinesVisible(true);
setDefaultRanges(plot);
setRenderer(plot);
setMarker(plot);
chart.getTitle().setFont(new Font("SansSerif", Font.BOLD, 12));
return chart;
}
private void setDefaultRanges(XYPlot plot) {
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setRange(0, 1);
rangeAxis.setTickUnit(new NumberTickUnit(0.1));
NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
domainAxis.setRange(0.01, 1);
domainAxis.setTickUnit(new NumberTickUnit(0.05));
}
private void setRenderer(XYPlot plot) {
@SuppressWarnings("serial")
XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer() {
Stroke dashed = new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 7.0f,
new float[] { 7.0f }, 0.0f);
@Override
public Stroke getItemStroke(int row, int column) {
return dashed;
}
};
renderer.setDefaultShapesVisible(true);
renderer.setDefaultShapesFilled(true);
renderer.setDefaultStroke(new BasicStroke(2));
renderer.setDefaultLegendTextFont(new Font("sans-serif", Font.BOLD, 8));
renderer.setDefaultToolTipGenerator(createToolTipGenerator());
plot.setRenderer(renderer);
}
private XYToolTipGenerator createToolTipGenerator() {
XYToolTipGenerator xyToolTipGenerator = new XYToolTipGenerator() {
public String generateToolTip(XYDataset dataset, int series, int item) {
StringBuffer sb = new StringBuffer();
double x = dataset.getX(series, item).doubleValue();
double y = dataset.getY(series, item).doubleValue();
String coordX = Double.toString(Math.round(x * 10000d) / 10000d);
String coordY = Double.toString(Math.round(y * 10000d) / 10000d);
sb.append("(" + coordX + ", " + coordY + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return sb.toString();
}
};
return xyToolTipGenerator;
}
private void setMarker(XYPlot plot) {
currentWeightMarker = new ValueMarker(0);
currentWeightMarker.setLabelFont(new java.awt.Font("SansSerif", Font.BOLD, 9)); //$NON-NLS-1$
currentWeightMarker.setLabel("Current weight");
currentWeightMarker.setPaint(Color.red);
currentWeightMarker.setStroke(new BasicStroke(2));
currentWeightMarker.setLabelOffset(new RectangleInsets(10, 10, 10, 50));
currentWeightMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
currentWeightMarker.setLabelBackgroundColor(new Color(255, 255, 255));
plot.addDomainMarker(currentWeightMarker);
}
private void updateRange() {
XYPlot plot = chart.getXYPlot();
List<Double> preferences = new LinkedList<>();
for(int i = 0; i < dataset.getSeries().size(); ++i) {
XYSeries serie = dataset.getSeries(i);
preferences.add(serie.getMaxY());
}
Collections.sort(preferences);
double max = 1;
double tickUnit = 0.1;
if(preferences.get(preferences.size() - 1) > 1) {
max = preferences.get(preferences.size() - 1) + 1;
tickUnit = max / 10d;
}
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setRange(0, 1);
rangeAxis.setTickUnit(new NumberTickUnit(tickUnit));
}
public abstract XYDataset createDataset();
public void initialize(SensitiveAnalysisModel model, ProblemElement[] criteria, Criterion criterion,
Composite container, int width, int height, int style) {
this.model = model;
this.criteria = criteria;
this.criterion = criterion;
refreshChart(this.criterion);
this.chartComposite = new ChartComposite(container, style, this.chart, true);
this.chartComposite.setSize(width, height);
}
}