public code v1
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
<?flintstones.helper.data.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.valuation.numeric.real.interval</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
<name>[bundle] Interval</name>
|
||||
<organization>
|
||||
<name>Sinbad2</name>
|
||||
</organization>
|
||||
</project>
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>flintstones.valuation.numeric.real.interval</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>1779484362751</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,21 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Interval
|
||||
Bundle-SymbolicName: flintstones.valuation.numeric.real.interval;singleton:=true
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: Sinbad2
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.valuation.numeric;visibility:=reexport,
|
||||
flintstones.entity.valuation,
|
||||
flintstones.model.valuation.service,
|
||||
flintstones.domain.fuzzyset,
|
||||
flintstones.domain.numeric.real,
|
||||
flintstones.helper.data.wxml,
|
||||
flintstones.model.domain.service,
|
||||
javax.inject,
|
||||
flintstones.entity.domain,
|
||||
org.apache.commons.lang,
|
||||
flintstones.valuation,
|
||||
flintstones.helper.data
|
||||
Automatic-Module-Name: flintstones.valuation.real.interval
|
||||
Export-Package: flintstones.valuation.numeric.real.interval
|
||||
@@ -0,0 +1,5 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.,\
|
||||
plugin.xml
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<?eclipse version="3.4"?>
|
||||
<plugin>
|
||||
<extension
|
||||
point="flintstones.valuation">
|
||||
<valuation
|
||||
domain="flintstones.domain.numeric.real.intervalar"
|
||||
uid="flintstones.valuation.real.interval"
|
||||
implementation="flintstones.valuation.numeric.real.interval.RealIntervalValuation"
|
||||
is_intermediate="false"
|
||||
name="Real interval">
|
||||
</valuation>
|
||||
</extension>
|
||||
|
||||
</plugin>
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
package flintstones.valuation.numeric.real.interval;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamWriter;
|
||||
|
||||
import org.apache.commons.lang.builder.EqualsBuilder;
|
||||
import org.apache.commons.lang.builder.HashCodeBuilder;
|
||||
import org.eclipse.e4.core.services.nls.Translation;
|
||||
|
||||
import flintstones.domain.numeric.NumericDomain;
|
||||
import flintstones.domain.numeric.real.NumericRealDomain;
|
||||
import flintstones.entity.extensionenum.ExtensionEnum;
|
||||
import flintstones.entity.valuation.Valuation;
|
||||
import flintstones.helper.DoubleHelper;
|
||||
import flintstones.helper.data.wxml.WNode;
|
||||
import flintstones.helper.validator.Validator;
|
||||
import flintstones.model.domain.service.IDomainService;
|
||||
import flintstones.model.valuation.service.IValuationService;
|
||||
import flintstones.valuation.numeric.NumericIntervalarValuation;
|
||||
import flintstones.valuation.numeric.real.interval.messages.Messages;
|
||||
|
||||
/**
|
||||
* The Class RealIntervalValuation.
|
||||
*/
|
||||
public class RealIntervalValuation extends NumericIntervalarValuation {
|
||||
|
||||
/** The domain service. */
|
||||
@Inject
|
||||
IDomainService domainService;
|
||||
|
||||
/** The valuation service. */
|
||||
@Inject
|
||||
IValuationService valuationService;
|
||||
|
||||
/** The messages. */
|
||||
@Inject
|
||||
@Translation
|
||||
private Messages messages;
|
||||
|
||||
/** The Constant ID. */
|
||||
public static final String ID = "flintstones.valuation.real.interval"; //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* The Enum Fields.
|
||||
*/
|
||||
public enum Fields implements ExtensionEnum {
|
||||
/** The min. */
|
||||
min,
|
||||
/** The max. */
|
||||
max
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new real interval valuation.
|
||||
*/
|
||||
public RealIntervalValuation() {
|
||||
super();
|
||||
this._min = 0;
|
||||
this._max = 0;
|
||||
setId(ID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initFromString(String value) {
|
||||
double dValue = DoubleHelper.ParseDouble(value);
|
||||
setValue(dValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize.
|
||||
*
|
||||
* @return the valuation
|
||||
*/
|
||||
public Valuation normalize() {
|
||||
RealIntervalValuation result = (RealIntervalValuation) this.valuationService.create(this.domain);
|
||||
|
||||
NumericRealDomain domain = (NumericRealDomain) this.domainService.create(NumericRealDomain.ID);
|
||||
|
||||
domain.setMinMax(domain.getMin(), domain.getMax());
|
||||
domain.setInRange(domain.getInRange());
|
||||
|
||||
result.setDomain(domain);
|
||||
result.setMinMax(this._min, this._max);
|
||||
|
||||
return this.normalizeInterval(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize interval.
|
||||
*
|
||||
* @param result the result
|
||||
* @return the valuation
|
||||
*/
|
||||
public Valuation normalizeInterval(RealIntervalValuation result) {
|
||||
double min, max, intervalSize;
|
||||
|
||||
min = ((NumericRealDomain) (NumericDomain) this.domain).getMin();
|
||||
max = ((NumericRealDomain) (NumericDomain) this.domain).getMax();
|
||||
intervalSize = max - min;
|
||||
|
||||
double maxNormalized = (this._max - min) / intervalSize;
|
||||
double minNormalized = (this._min - min) / intervalSize;
|
||||
|
||||
((NumericRealDomain) (NumericDomain) result.domain).setMinMax(0d, 1d);
|
||||
|
||||
result._min = minNormalized;
|
||||
result._max = maxNormalized;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.valuation.Valuation#negateValuation() */
|
||||
@Override
|
||||
public Valuation negateValuation() {
|
||||
RealIntervalValuation result = (RealIntervalValuation) this.clone();
|
||||
|
||||
double aux = ((NumericRealDomain) (NumericDomain) this.domain).getMin() + ((NumericRealDomain) (NumericDomain) this.domain).getMax();
|
||||
result.setMinMax(aux - this._max, aux - this._min);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#toString() */
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("Real interval[" + this._min + "," + this._max + "] in" + this.domain.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object) */
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
if (this == obj)
|
||||
return true;
|
||||
|
||||
if (obj == null)
|
||||
return false;
|
||||
|
||||
if (obj.getClass() != this.getClass())
|
||||
return false;
|
||||
|
||||
final RealIntervalValuation other = (RealIntervalValuation) obj;
|
||||
|
||||
EqualsBuilder eb = new EqualsBuilder();
|
||||
eb.append(this._max, other._max);
|
||||
eb.append(this._min, other._min);
|
||||
eb.append(this.domain, other.domain);
|
||||
|
||||
return eb.isEquals();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode() */
|
||||
@Override
|
||||
public int hashCode() {
|
||||
HashCodeBuilder hcb = new HashCodeBuilder(17, 31);
|
||||
hcb.append(this._max);
|
||||
hcb.append(this._min);
|
||||
hcb.append(this.domain);
|
||||
return hcb.toHashCode();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Comparable#compareTo(java.lang.Object) */
|
||||
@Override
|
||||
public int compareTo(Valuation other) {
|
||||
Validator.notNull(other);
|
||||
Validator.notIllegalElementType(other, new String[] { Integer.class.toString() });
|
||||
|
||||
if (this.domain.equals(other.getDomain())) {
|
||||
double middle = (this._max + this._min) / 2l;
|
||||
double otherMidle = (((RealIntervalValuation) other)._max + ((RealIntervalValuation) other)._min) / 2d;
|
||||
return Double.compare(middle, otherMidle);
|
||||
} else
|
||||
throw new IllegalArgumentException(this.messages.Differentdomains);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.valuation.Valuation#clone() */
|
||||
@Override
|
||||
public Object clone() {
|
||||
RealIntervalValuation result = null;
|
||||
result = (RealIntervalValuation) super.clone();
|
||||
result._min = Double.valueOf(this._min);
|
||||
result._max = Double.valueOf(this._max);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.valuation.Valuation#changeFormatValuationToString() */
|
||||
@Override
|
||||
public String changeFormatValuationToString() {
|
||||
return "[" + Double.toString(Math.round(this._min * 100d) / 100d) + ", " + Double.toString(Math.round(this._max * 100d) / 100d) + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* flintstones.valuation.Valuation#write(javax.xml.stream.XMLStreamWriter) */
|
||||
@Override
|
||||
public void write(XMLStreamWriter writer) throws XMLStreamException {
|
||||
writer.writeAttribute(Fields.min.toString(), Double.toString(this._min));
|
||||
writer.writeAttribute(Fields.max.toString(), Double.toString(this._max));
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
*
|
||||
* @see flintstones.valuation.Valuation#read(flintstones.helper.wxml.WNode) */
|
||||
@Override
|
||||
public void read(WNode node) {
|
||||
this._min = Double.parseDouble(node.getAttribute(Fields.min.toString()));
|
||||
this._max = Double.parseDouble(node.getAttribute(Fields.max.toString()));
|
||||
}
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
// This file has been auto-generated
|
||||
package flintstones.valuation.numeric.real.interval.messages;
|
||||
|
||||
import org.eclipse.e4.core.services.nls.Message;
|
||||
|
||||
@Message
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Messages {
|
||||
|
||||
public String Not_BLTS_fuzzy_set;
|
||||
public String Differentdomains;
|
||||
|
||||
}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Different_domains=Different domains
|
||||
Not_BLTS_fuzzy_set=Not BLTS fuzzy set.
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
Different_domains=Diferentes dominios
|
||||
Not_BLTS_fuzzy_set=No BLTS fuzzy establecido.
|
||||
Reference in New Issue
Block a user