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.entity.sorting.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.entity.sorting.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>1779484362589</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,10 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Ui
|
||||
Bundle-SymbolicName: flintstones.entity.sorting.ui
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Automatic-Module-Name: flintstones.entity.sorting.ui
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
|
||||
Require-Bundle: flintstones.helper.html,
|
||||
flintstones.entity.problemelement
|
||||
Export-Package: flintstones.entity.sorting.ui
|
||||
@@ -0,0 +1,4 @@
|
||||
source.. = src/
|
||||
output.. = bin/
|
||||
bin.includes = META-INF/,\
|
||||
.
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
package flintstones.entity.sorting.ui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import flintstones.entity.problemelement.entities.SortingClass;
|
||||
import flintstones.entity.problemelement.entities.SortingProfile;
|
||||
import flintstones.helper.html.svg.Svg;
|
||||
import flintstones.helper.html.svg.SvgCanvas;
|
||||
import flintstones.helper.html.svg.Tag;
|
||||
|
||||
public class SortingDiagram extends SvgCanvas {
|
||||
|
||||
Tag svg;
|
||||
|
||||
int tWidth;
|
||||
int tHeight;
|
||||
|
||||
int hspace;
|
||||
int vspace;
|
||||
|
||||
int width = 500;
|
||||
int height = 1000;
|
||||
|
||||
int ts;
|
||||
|
||||
List<SortingClass> classes = new ArrayList<>();
|
||||
List<SortingProfile> profiles = new ArrayList<>();
|
||||
|
||||
public SortingDiagram() {
|
||||
|
||||
vspace = height / 10;
|
||||
hspace = width / 10;
|
||||
ts = height / 25;
|
||||
|
||||
tHeight = height + vspace*2;
|
||||
tWidth = width + hspace*2;
|
||||
|
||||
|
||||
|
||||
|
||||
// Tag upLine = Svg.getHorizontalLine(hspace, vspace, width);
|
||||
// svg.add(upLine);
|
||||
//
|
||||
|
||||
// Tag bottomLine = Svg.getHorizontalLine(hspace, tHeight - vspace, width);
|
||||
// svg.add(bottomLine);
|
||||
|
||||
}
|
||||
|
||||
public void setProfiles(List<SortingProfile> list) {
|
||||
profiles = list;
|
||||
}
|
||||
|
||||
private int realocateY(double first, double last, double y) {
|
||||
|
||||
boolean isAscending = first < last;
|
||||
|
||||
double ny = isAscending ? y - first : first - y;
|
||||
double max = isAscending ? last : first;
|
||||
double min = isAscending ? first : last;
|
||||
|
||||
double down = max - min;
|
||||
|
||||
double r = ny / down;
|
||||
int val = (int) (r * height);
|
||||
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
svg = (Tag) new Tag("svg")
|
||||
.attr("xmlns","http://www.w3.org/2000/svg")
|
||||
.attr("viewbox", "0 0 " + tWidth + " " + tHeight)
|
||||
.attr("width", "100%")
|
||||
.attr("height", "100%");
|
||||
|
||||
// Vertical Line
|
||||
Tag vline = Svg.getVerticalLine(tWidth/2, vspace, height);
|
||||
svg.add(vline);
|
||||
|
||||
double[] values = profiles.stream().map(k -> k.getValue()).mapToDouble(Number::doubleValue).toArray();
|
||||
|
||||
Double up = null;
|
||||
Double down = null;
|
||||
if(values.length > 0)
|
||||
up = values[0];
|
||||
|
||||
if(values.length > 1)
|
||||
down = values[values.length-1];
|
||||
|
||||
if(values.length < 2)
|
||||
return "";
|
||||
|
||||
|
||||
for(double value : values) {
|
||||
int y = realocateY(up, down, value);
|
||||
|
||||
Tag hLine = Svg.getHorizontalLine(hspace, vspace + y, width);
|
||||
svg.add(hLine);
|
||||
|
||||
Tag text = Svg.getText(hspace, vspace + y -vspace/4, ts, value+"");
|
||||
svg.add(text);
|
||||
}
|
||||
|
||||
|
||||
return svg.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user