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,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.linguistic.unbalanced.phase.calculaterepresentation.ui</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
<name>[bundle] Ui</name>
</project>
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>flintstones.method.linguistic.unbalanced.phase.calculaterepresentation.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>1779484362684</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,22 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Ui
Bundle-SymbolicName: flintstones.method.linguistic.unbalanced.phase.calculaterepresentation.ui;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: flintstones.method.unbalanced.phase.calculaterepresentation.ui
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Import-Package: flintstones.method.linguistic.unbalanced.phase.calculaterepresentation
Require-Bundle: org.eclipse.swt,
flintstones.helper.ui,
javax.inject,
flintstones.domain.fuzzyset.unbalanced,
flintstones.domain.numeric.real,
flintstones.domain.fuzzyset.ui.dialog,
flintstones.domain.fuzzyset.unbalanced.ui.dialog,
org.eclipse.e4.core.contexts,
org.eclipse.e4.core.di,
flintstones.domain.fuzzyset.ui.chart,
flintstones.domain.fuzzyset.unbalanced.ui.chart,
flintstones.model.ui.service,
flintstones.entity.method.phase,
flintstones.entity.method.phase.ui
@@ -0,0 +1,5 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="flintstones.phasemethod.ui">
<phasemethod_ui
uid="flintstones.method.unbalanced.phase.calculaterepresentation.ui"
implementation="flintstones.method.linguistic.unbalanced.phase.calculaterepresentation.ui.CalculateRepresentationUI"
phasemethod="flintstones.method.unbalanced.phase.calculaterepresentation">
</phasemethod_ui>
</extension>
</plugin>
@@ -0,0 +1,330 @@
package flintstones.method.linguistic.unbalanced.phase.calculaterepresentation.ui;
import javax.inject.Inject;
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import flintstones.domain.fuzzyset.ui.chart.PlainFuzzySetChart;
import flintstones.domain.fuzzyset.unbalanced.Unbalanced;
import flintstones.domain.fuzzyset.unbalanced.ui.chart.LHChart;
import flintstones.domain.numeric.real.NumericRealDomain;
import flintstones.entity.method.phase.ui.PhaseMethodUI;
import flintstones.method.linguistic.unbalanced.phase.calculaterepresentation.CalculateRepresentationModel;
import flintstones.model.ui.service.UiService;
public class CalculateRepresentationUI extends PhaseMethodUI {
@Inject
IEclipseContext context;
CalculateRepresentationModel phaseMethod;
// FS3
private Composite _parent;
private Composite _representationPanel;
private Composite _chartPanel;
private TableViewer _representationViewer;
private TableViewerColumn _colorColumn;
private TableViewerColumn _labelColumn;
private TableViewerColumn _lhColumn;
private TableViewerColumn _bridColumn;
private LHChart _chart;
private ControlAdapter _controlListener;
private int _selectionPos;
private Unbalanced _domain;
private int[] _lh;
@Override
public void init() {
phaseMethod = (CalculateRepresentationModel) this.getModel();
Composite parent = this.getBaseComposite();
createPartControl(parent);
activate();
}
@Override
public void refresh() {
activate();
}
@Override
public boolean isForwardEnabled() {
return true;
}
public void createPartControl(Composite parent) {
_parent = parent;
UiService.setGridLayout(_parent, 2, true);
UiService.setGridData(_parent, 9, 9, true, true);
Composite left = new Composite(_parent, SWT.NONE);
UiService.setGridLayout(left, 1);
UiService.setGridData(left, 9, 9, true, true);
createRepresentationInfo(left);
Composite right = new Composite(_parent, SWT.BORDER);
UiService.setGridLayout(right, 1);
UiService.setGridData(right, 9, 9, true, true);
createChart(right);
}
private void createRepresentationInfo(Composite left) {
_representationPanel = left;
// _representationPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 6, 1));
// GridLayout layout = new GridLayout(1, false);
// layout.marginBottom = 0;
// layout.marginTop = 0;
// layout.verticalSpacing = 0;
// layout.marginHeight = 0;
// layout.marginWidth = 0;
// layout.horizontalSpacing = 0;
// _representationPanel.setLayout(layout);
_representationViewer = new TableViewer(_representationPanel, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gridData.verticalIndent = 0;
_representationViewer.getTable().setLayoutData(gridData);
_representationViewer.getTable().setHeaderVisible(true);
_representationViewer.setContentProvider(new IStructuredContentProvider() {
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
@Override
public void dispose() {}
@Override
public Object[] getElements(Object inputElement) {
Unbalanced domain = (Unbalanced) inputElement;
Object[] result = new Object[domain.getLabelSet().getCardinality()];
Object[] element;
int r, g, b;
for(int i = 0; i < result.length; i++) {
element = new Object[4];
java.awt.Color color = PlainFuzzySetChart.getColor(i);
r = color.getRed();
g = color.getGreen();
b = color.getBlue();
element[0] = new Color(Display.getCurrent(), r, g, b);
element[1] = domain.getLabelSet().getLabel(i).getName();
StringBuilder LHS = null;
boolean brid = false;
int other = -1;
boolean find;
int t;
for(Integer pos : domain.getLabel(i).keySet()) {
find = false;
t = 0;
do {
if(pos == _lh[t]) {
find = true;
} else {
t++;
}
} while (!find);
t++;
if(LHS == null) {
brid = false;
LHS = new StringBuilder("s" + domain.getLabel(i).get(pos) + " l(" + t + "," + pos + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
other = pos;
} else {
brid = true;
NumericRealDomain center = _domain.getLabelSet().getLabel(i).getSemantic().getCenter();
NumericRealDomain coverage = _domain.getLabelSet().getLabel(i).getSemantic().getCoverage();
double left = center.getMin() - coverage.getMin();
double right = coverage.getMax() - center.getMax();
if(((left > right) && (other < pos)) || ((left < right) && (other > pos))) {
LHS.append(" " + "or" + " s" + domain.getLabel(i).get(pos) + " l(" + t + "," + pos + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
} else {
String aux = LHS.toString();
LHS = new StringBuilder("s" + domain.getLabel(i).get(pos) + " l(" + t + "," + pos + ") " + "or" + " " + aux); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
}
}
}
element[2] = LHS.toString();
element[3] = Boolean.toString(brid);
result[i] = element;
}
return result;
}
});
_colorColumn = new TableViewerColumn(_representationViewer, SWT.NONE);
_colorColumn.getColumn().setWidth(25);
_colorColumn.getColumn().setResizable(false);
_colorColumn.getColumn().setMoveable(false);
_colorColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ""; //$NON-NLS-1$
}
@Override
public Color getBackground(Object element) {
return (Color) ((Object[]) element)[0];
}
});
_labelColumn = new TableViewerColumn(_representationViewer, SWT.NONE);
_labelColumn.getColumn().setWidth(100);
_labelColumn.getColumn().setText("S"); //$NON-NLS-1$
_labelColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return (String) ((Object[]) element)[1];
}
});
_lhColumn = new TableViewerColumn(_representationViewer, SWT.NONE);
_lhColumn.getColumn().setWidth(100);
_lhColumn.getColumn().setText("LH_S"); //$NON-NLS-1$
_lhColumn.getColumn().setAlignment(SWT.CENTER);
_lhColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return (String) ((Object[]) element)[2];
}
});
_bridColumn = new TableViewerColumn(_representationViewer, SWT.NONE);
_bridColumn.getColumn().setWidth(100);
_bridColumn.getColumn().setText("Brid"); //$NON-NLS-1$
_bridColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((String) ((Object[]) element)[3]).toUpperCase();
}
});
_representationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = _representationViewer.getSelection();
String selectLabel = (String) ((Object[]) ((IStructuredSelection) selection).getFirstElement())[1];
_selectionPos = _domain.getLabelSet().getPos(selectLabel);
_chart.select(_selectionPos);
}
});
}
private void createChart(Composite right) {
_chartPanel = right;
// GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true, 8, 1);
// _chartPanel.setLayoutData(gridData);
}
private void calculateRepresentation() {
if(_domain == null) {
_domain = phaseMethod.getFinalUnifiedDomain();
}
if(_lh == null) {
generateLH();
}
_representationViewer.setInput(_domain);
_labelColumn.getColumn().pack();
_labelColumn.getColumn().setWidth(_labelColumn.getColumn().getWidth() + 10);
_lhColumn.getColumn().pack();
_lhColumn.getColumn().setWidth(_lhColumn.getColumn().getWidth() + 10);
_bridColumn.getColumn().pack();
_bridColumn.getColumn().setWidth(_bridColumn.getColumn().getWidth() + 10);
String representation = _domain.getInfo();
if (representation != null) {
// TODO Quizás es necesario para limitar el paso a la siguiente fase
boolean _completed = true;
_completed = !_completed;
_completed = !_completed;
} else {
_domain = null;
_selectionPos = -1;
}
}
private void generateLH() {
_lh = _domain.getLh();
if(_lh != null) {
_chart = ContextInjectionFactory.make(LHChart.class, context);
_chart.initLHChart(_lh, _chartPanel, _chartPanel.getSize().x, _chartPanel.getSize().y - 1, _domain);
if(_controlListener == null) {
_controlListener = new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
_chart.dispose();
generateLH();
}
};
_chartPanel.addControlListener(_controlListener);
}
if(_selectionPos != -1) {
_chart.select(_selectionPos);
}
} else {
if(_chart != null) {
_chart.dispose();
_chart = null;
_selectionPos = -1;
}
}
}
public void activate() {
if(_domain == null) {
calculateRepresentation();
}
_representationPanel.layout();
_chartPanel.layout();
// phaseMethod.setFinalUnifiedDomain(_domain);
}
}