dcel rdy for test
This commit is contained in:
parent
9b986b74f2
commit
6df2c38c14
11
pom.xml
11
pom.xml
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -28,5 +28,12 @@
|
||||||
<artifactId>jfreechart</artifactId>
|
<artifactId>jfreechart</artifactId>
|
||||||
<version>1.0.14</version>
|
<version>1.0.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.12</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -14,13 +14,13 @@ import javax.swing.*;
|
||||||
public class App {
|
public class App {
|
||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
MainFrame view = new MainFrame();
|
MainFrame view = new MainFrame();
|
||||||
view.setPresenter(new Presenter(new Arrangement(), view));
|
view.setPresenter(new Presenter(new Arrangement(), view));
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,16 +14,16 @@ public class Arrangement {
|
||||||
private LinkedList<Coordinates> nodes;
|
private LinkedList<Coordinates> nodes;
|
||||||
private LinkedList<Coordinates> lines;
|
private LinkedList<Coordinates> lines;
|
||||||
|
|
||||||
public Arrangement(){
|
public Arrangement() {
|
||||||
nodes = new LinkedList<>();
|
nodes = new LinkedList<>();
|
||||||
lines = new LinkedList<>();
|
lines = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNode(Coordinates node){
|
public void addNode(Coordinates node) {
|
||||||
this.nodes.add(node);
|
this.nodes.add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLine(Coordinates line){
|
public void addLine(Coordinates line) {
|
||||||
this.lines.add(line);
|
this.lines.add(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,5 +40,4 @@ public class Arrangement {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,13 @@ public class Coordinates implements Comparable<Coordinates> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Coordinates o) {
|
public int compareTo(Coordinates o) {
|
||||||
if(this.getX() == o.getX()){
|
if (this.getX() == o.getX()) {
|
||||||
if (this.getY() <= o.getY()){
|
if (this.getY() <= o.getY()) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
} else if (this.getX() < o.getX()){
|
} else if (this.getX() < o.getX()) {
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -15,13 +15,13 @@ public class DoublyConnectedEdgeList {
|
||||||
private LinkedList<Edge> edges;
|
private LinkedList<Edge> edges;
|
||||||
private LinkedList<Face> faces;
|
private LinkedList<Face> faces;
|
||||||
|
|
||||||
public DoublyConnectedEdgeList(){
|
public DoublyConnectedEdgeList() {
|
||||||
this.nodes = new LinkedList<>();
|
this.nodes = new LinkedList<>();
|
||||||
this.edges = new LinkedList<>();
|
this.edges = new LinkedList<>();
|
||||||
this.faces = new LinkedList<>();
|
this.faces = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node createNode(Coordinates point, String id){
|
public Node createNode(Coordinates point, String id) {
|
||||||
|
|
||||||
Node node = new Node();
|
Node node = new Node();
|
||||||
node.setCoordinates(point);
|
node.setCoordinates(point);
|
||||||
|
@ -30,15 +30,17 @@ public class DoublyConnectedEdgeList {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Edge createEdge(Node source, Node destination, String id){
|
public Edge createEdge(Node source, Node destination, String id) {
|
||||||
|
|
||||||
Edge edge = new Edge();
|
Edge edge = new Edge();
|
||||||
Edge twin = new Edge();
|
Edge twin = new Edge();
|
||||||
|
|
||||||
edge.setOrigin(source);
|
edge.setOrigin(source);
|
||||||
edge.setID(id);
|
edge.setID(id);
|
||||||
|
edge.setTwin(twin);
|
||||||
twin.setOrigin(destination);
|
twin.setOrigin(destination);
|
||||||
twin.setID("#"+id);
|
twin.setID("#" + id);
|
||||||
|
twin.setTwin(edge);
|
||||||
|
|
||||||
source.setIncidentEdge(edge);
|
source.setIncidentEdge(edge);
|
||||||
destination.setIncidentEdge(twin);
|
destination.setIncidentEdge(twin);
|
||||||
|
@ -46,14 +48,14 @@ public class DoublyConnectedEdgeList {
|
||||||
return edge;
|
return edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Face createFace(Edge outerComponent, Edge innerComponent, String id){
|
public Face createFace(Edge outerComponent, Edge innerComponent, String id) {
|
||||||
|
|
||||||
Face face = new Face();
|
Face face = new Face();
|
||||||
face.setOuterComponent(outerComponent);
|
face.setOuterComponent(outerComponent);
|
||||||
face.setID(id);
|
face.setID(id);
|
||||||
Edge tempEdge;
|
Edge tempEdge;
|
||||||
|
|
||||||
if (!outerComponent.equals(null)){
|
if (outerComponent != null) {
|
||||||
tempEdge = outerComponent;
|
tempEdge = outerComponent;
|
||||||
do {
|
do {
|
||||||
tempEdge.setIncidentFace(face);
|
tempEdge.setIncidentFace(face);
|
||||||
|
@ -61,8 +63,9 @@ public class DoublyConnectedEdgeList {
|
||||||
} while (!tempEdge.equals(outerComponent));
|
} while (!tempEdge.equals(outerComponent));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!innerComponent.equals(null)){
|
if (innerComponent != null) {
|
||||||
LinkedList<Edge> componentlist = face.getInnerComponents();
|
LinkedList<Edge> componentlist;
|
||||||
|
componentlist = face.getInnerComponents();
|
||||||
componentlist.add(innerComponent);
|
componentlist.add(innerComponent);
|
||||||
tempEdge = innerComponent;
|
tempEdge = innerComponent;
|
||||||
do {
|
do {
|
||||||
|
@ -74,12 +77,32 @@ public class DoublyConnectedEdgeList {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createConnection(Edge edge, Edge pred){
|
public void createConnection(Edge edge, Edge succ) {
|
||||||
edge.setPrev(pred);
|
edge.setNext(succ);
|
||||||
pred.setNext(edge);
|
succ.setPrev(edge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinkedList<Node> getNodes() {
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodes(LinkedList<Node> nodes) {
|
||||||
|
this.nodes = nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<Edge> getEdges() {
|
||||||
|
return edges;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEdges(LinkedList<Edge> edges) {
|
||||||
|
this.edges = edges;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<Face> getFaces() {
|
||||||
|
return faces;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFaces(LinkedList<Face> faces) {
|
||||||
|
this.faces = faces;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,11 @@ public class Edge {
|
||||||
private Edge prev;
|
private Edge prev;
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
public Edge(){
|
public Edge() {
|
||||||
new Edge(null, null, null, null, null);
|
new Edge(null, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Edge(Node origin, Edge twin, Edge next, Edge prev, Face incidentFace){
|
public Edge(Node origin, Edge twin, Edge next, Edge prev, Face incidentFace) {
|
||||||
this.origin = origin;
|
this.origin = origin;
|
||||||
this.twin = twin;
|
this.twin = twin;
|
||||||
this.next = next;
|
this.next = next;
|
||||||
|
@ -68,8 +68,8 @@ public class Edge {
|
||||||
this.prev = prev;
|
this.prev = prev;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasNext(){
|
public boolean hasNext() {
|
||||||
if (getNext() == null){
|
if (getNext() == null) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
|
@ -77,7 +77,7 @@ public class Edge {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Edge insertNode(Node node){
|
public Edge insertNode(Node node) {
|
||||||
|
|
||||||
Edge edge = new Edge();
|
Edge edge = new Edge();
|
||||||
Edge twin = new Edge();
|
Edge twin = new Edge();
|
||||||
|
@ -107,11 +107,11 @@ public class Edge {
|
||||||
return edge;
|
return edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getID(){
|
public String getID() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setID(String id){
|
public void setID(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package Model;
|
package Model;
|
||||||
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -16,11 +15,12 @@ public class Face {
|
||||||
private Edge outerComponent;
|
private Edge outerComponent;
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
public Face(){
|
public Face() {
|
||||||
new Face(null, null);
|
new Face(null, null);
|
||||||
|
this.innerComponents = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Face(Edge outerComponent, LinkedList<Edge> innerComponents){
|
public Face(Edge outerComponent, LinkedList<Edge> innerComponents) {
|
||||||
this.outerComponent = outerComponent;
|
this.outerComponent = outerComponent;
|
||||||
this.innerComponents = innerComponents;
|
this.innerComponents = innerComponents;
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,9 @@ public class Face {
|
||||||
this.outerComponent = outerComponent;
|
this.outerComponent = outerComponent;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Face insertEdge(Edge edgeWithSameDestination, Edge edgeToMySource){
|
public Face insertEdge(Edge edgeWithSameDestination, Edge edgeToMySource) {
|
||||||
|
|
||||||
if (edgeWithSameDestination.getIncidentFace().equals(this) || edgeToMySource.getIncidentFace().equals(this)){
|
if (edgeWithSameDestination.getIncidentFace().equals(this) || edgeToMySource.getIncidentFace().equals(this)) {
|
||||||
LinkedList<Edge> components = new LinkedList<Edge>();
|
LinkedList<Edge> components = new LinkedList<Edge>();
|
||||||
for (Edge e : innerComponents) {
|
for (Edge e : innerComponents) {
|
||||||
components.add(e);
|
components.add(e);
|
||||||
|
@ -65,12 +65,12 @@ public class Face {
|
||||||
Edge tempEdge = edge.getNext();
|
Edge tempEdge = edge.getNext();
|
||||||
Edge tempTwin = twin.getNext();
|
Edge tempTwin = twin.getNext();
|
||||||
//kreis umlaufen um festzustellen welche fläche kleiner ist
|
//kreis umlaufen um festzustellen welche fläche kleiner ist
|
||||||
while ((tempEdge.equals(edge) == false) && (tempTwin.equals(twin) == false)){
|
while ((tempEdge.equals(edge) == false) && (tempTwin.equals(twin) == false)) {
|
||||||
tempEdge = tempEdge.getNext();
|
tempEdge = tempEdge.getNext();
|
||||||
tempTwin = tempTwin.getNext();
|
tempTwin = tempTwin.getNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tempEdge.equals(edge)){
|
if (tempEdge.equals(edge)) {
|
||||||
setOuterComponent(twin);
|
setOuterComponent(twin);
|
||||||
twin.setIncidentFace(this);
|
twin.setIncidentFace(this);
|
||||||
face.setOuterComponent(edge);
|
face.setOuterComponent(edge);
|
||||||
|
@ -80,18 +80,18 @@ public class Face {
|
||||||
face.setOuterComponent(twin);
|
face.setOuterComponent(twin);
|
||||||
}
|
}
|
||||||
|
|
||||||
LinkedList<Edge> bla = new LinkedList<Edge>();
|
LinkedList<Edge> bla = new LinkedList<Edge>();
|
||||||
Edge iterEdge = face.getOuterComponent();
|
Edge iterEdge = face.getOuterComponent();
|
||||||
bla.add(face.getOuterComponent());
|
bla.add(face.getOuterComponent());
|
||||||
|
|
||||||
while (iterEdge.hasNext()){
|
while (iterEdge.hasNext()) {
|
||||||
bla.add(iterEdge.getNext());
|
bla.add(iterEdge.getNext());
|
||||||
iterEdge = iterEdge.getNext();
|
iterEdge = iterEdge.getNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Edge e : face.getInnerComponents()) {
|
for (Edge e : face.getInnerComponents()) {
|
||||||
iterEdge = e;
|
iterEdge = e;
|
||||||
while (iterEdge.hasNext()){
|
while (iterEdge.hasNext()) {
|
||||||
bla.add(iterEdge.getNext());
|
bla.add(iterEdge.getNext());
|
||||||
iterEdge = iterEdge.getNext();
|
iterEdge = iterEdge.getNext();
|
||||||
}
|
}
|
||||||
|
@ -107,11 +107,11 @@ public class Face {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getID(){
|
public String getID() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setID(String id){
|
public void setID(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,11 +13,11 @@ public class Node {
|
||||||
private Edge incidentEdge;
|
private Edge incidentEdge;
|
||||||
private String id;
|
private String id;
|
||||||
|
|
||||||
public Node(){
|
public Node() {
|
||||||
new Node(null, null);
|
new Node(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Node(Coordinates coordinates, Edge incidentEdge){
|
public Node(Coordinates coordinates, Edge incidentEdge) {
|
||||||
this.coordinates = coordinates;
|
this.coordinates = coordinates;
|
||||||
this.incidentEdge = incidentEdge;
|
this.incidentEdge = incidentEdge;
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,11 @@ public class Node {
|
||||||
this.incidentEdge = incidentEdge;
|
this.incidentEdge = incidentEdge;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getID(){
|
public String getID() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setID(String id){
|
public void setID(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package Presenter;
|
||||||
|
|
||||||
import Model.Arrangement;
|
import Model.Arrangement;
|
||||||
import Model.Coordinates;
|
import Model.Coordinates;
|
||||||
import View.*;
|
import View.MainFrame;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -24,28 +24,28 @@ public class Presenter {
|
||||||
private Double max;
|
private Double max;
|
||||||
private Double min;
|
private Double min;
|
||||||
|
|
||||||
public Presenter(Arrangement model, MainFrame view){
|
public Presenter(Arrangement model, MainFrame view) {
|
||||||
this.model = model;
|
this.model = model;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
|
|
||||||
|
|
||||||
Double[] x = {1d,2d,3d,4d,10d,12d,18d};
|
Double[] x = {1d, 2d, 3d, 4d, 10d, 12d, 18d};
|
||||||
Double[] y = {9d,15d,19d,20d,45d,55d,78d};
|
Double[] y = {9d, 15d, 19d, 20d, 45d, 55d, 78d};
|
||||||
// Float[] x = {18f,24f,30f,34f,38f};
|
// Float[] x = {18f,24f,30f,34f,38f};
|
||||||
// Float[] y = {18f,26f,30f,40f,70f};
|
// Float[] y = {18f,26f,30f,40f,70f};
|
||||||
// Double[] x = {1d,3d,4d,5d,8d};
|
// Double[] x = {1d,3d,4d,5d,8d};
|
||||||
// Double[] y = {4d,2d,1d,0d,0d};
|
// Double[] y = {4d,2d,1d,0d,0d};
|
||||||
view.log("Koordinaten der Punkte:");
|
view.log("Koordinaten der Punkte:");
|
||||||
for (int j=0;j<7;j++){
|
for (int j = 0; j < 7; j++) {
|
||||||
Coordinates p = new Coordinates(x[j], y[j]);
|
Coordinates p = new Coordinates(x[j], y[j]);
|
||||||
view.log("f(x) = "+p.getX()+"* x + "+p.getY());
|
view.log("f(x) = " + p.getX() + "* x + " + p.getY());
|
||||||
this.model.addLine(p);
|
this.model.addLine(p);
|
||||||
}
|
}
|
||||||
view.log("");
|
view.log("");
|
||||||
calcArrangementNodes();
|
calcArrangementNodes();
|
||||||
//print
|
//print
|
||||||
for (Coordinates p : model.getNodes()) {
|
for (Coordinates p : model.getNodes()) {
|
||||||
view.log(p.getX()+", "+p.getY());
|
view.log(p.getX() + ", " + p.getY());
|
||||||
}
|
}
|
||||||
extractBounds();
|
extractBounds();
|
||||||
}
|
}
|
||||||
|
@ -66,11 +66,11 @@ public class Presenter {
|
||||||
view.createArrangement();
|
view.createArrangement();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startScatterPlotVisualization(){
|
public void startScatterPlotVisualization() {
|
||||||
view.createPlot();
|
view.createPlot();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractBounds(){
|
private void extractBounds() {
|
||||||
Coordinates pmax = Collections.max(model.getLines());
|
Coordinates pmax = Collections.max(model.getLines());
|
||||||
Coordinates pmin = Collections.min(model.getLines());
|
Coordinates pmin = Collections.min(model.getLines());
|
||||||
|
|
||||||
|
@ -78,11 +78,11 @@ public class Presenter {
|
||||||
min = pmin.getX() <= pmin.getY() ? pmin.getX() : pmin.getY();
|
min = pmin.getX() <= pmin.getY() ? pmin.getX() : pmin.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Coordinates calcIntersection(Coordinates a, Coordinates b){
|
public Coordinates calcIntersection(Coordinates a, Coordinates b) {
|
||||||
Coordinates p1;
|
Coordinates p1;
|
||||||
Coordinates p2;
|
Coordinates p2;
|
||||||
|
|
||||||
if (a.compareTo(b) > 0){
|
if (a.compareTo(b) > 0) {
|
||||||
p1 = a;
|
p1 = a;
|
||||||
p2 = b;
|
p2 = b;
|
||||||
} else {
|
} else {
|
||||||
|
@ -92,17 +92,17 @@ public class Presenter {
|
||||||
|
|
||||||
Double x = (p1.getY() - p2.getY()) / (p2.getX() - p1.getX());
|
Double x = (p1.getY() - p2.getY()) / (p2.getX() - p1.getX());
|
||||||
Double y = ((p1.getX() * p2.getY()) - (p2.getX() * p1.getY())) / (p1.getX() - p2.getX());
|
Double y = ((p1.getX() * p2.getY()) - (p2.getX() * p1.getY())) / (p1.getX() - p2.getX());
|
||||||
System.out.printf("RESULT: (%3.3f, %3.3f)\n",x, y);
|
System.out.printf("RESULT: (%3.3f, %3.3f)\n", x, y);
|
||||||
|
|
||||||
return new Coordinates(x,y);
|
return new Coordinates(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calcArrangementNodes(){
|
public void calcArrangementNodes() {
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (int i=0;i<getLines().size();i++){
|
for (int i = 0; i < getLines().size(); i++) {
|
||||||
for (int j=i;j<getLines().size();j++){
|
for (int j = i; j < getLines().size(); j++) {
|
||||||
if (i != j)
|
if (i != j)
|
||||||
model.addNode(calcIntersection(getLines().get(j), getLines().get(i)));
|
model.addNode(calcIntersection(getLines().get(j), getLines().get(i)));
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,7 @@ public class Presenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************************************************************
|
/***************************************************************************************************************************
|
||||||
* Getter und Setter Methoden
|
* Getter und Setter Methoden
|
||||||
***************************************************************************************************************************/
|
***************************************************************************************************************************/
|
||||||
|
|
|
@ -4,16 +4,15 @@ import Model.Coordinates;
|
||||||
import org.jfree.chart.ChartFactory;
|
import org.jfree.chart.ChartFactory;
|
||||||
import org.jfree.chart.ChartPanel;
|
import org.jfree.chart.ChartPanel;
|
||||||
import org.jfree.chart.JFreeChart;
|
import org.jfree.chart.JFreeChart;
|
||||||
|
import org.jfree.chart.axis.ValueAxis;
|
||||||
import org.jfree.chart.plot.PlotOrientation;
|
import org.jfree.chart.plot.PlotOrientation;
|
||||||
import org.jfree.chart.plot.XYPlot;
|
import org.jfree.chart.plot.XYPlot;
|
||||||
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
|
import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
|
||||||
import org.jfree.chart.axis.ValueAxis;
|
|
||||||
import org.jfree.data.xy.XYSeries;
|
import org.jfree.data.xy.XYSeries;
|
||||||
import org.jfree.data.xy.XYSeriesCollection;
|
import org.jfree.data.xy.XYSeriesCollection;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,12 +33,12 @@ public class ArrangementDialog extends JPanel {
|
||||||
private double domainMin, domainMax;
|
private double domainMin, domainMax;
|
||||||
private double rangeMin, rangeMax;
|
private double rangeMin, rangeMax;
|
||||||
|
|
||||||
public ArrangementDialog(){
|
public ArrangementDialog() {
|
||||||
super();
|
super();
|
||||||
this.setPreferredSize(new Dimension(800,500));
|
this.setPreferredSize(new Dimension(800, 500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrameters(Double pmax, Double pmin, LinkedList<Coordinates> lines, LinkedList<Coordinates> points){
|
public void setPrameters(Double pmax, Double pmin, LinkedList<Coordinates> lines, LinkedList<Coordinates> points) {
|
||||||
this.max = pmax;
|
this.max = pmax;
|
||||||
this.min = pmin;
|
this.min = pmin;
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
|
@ -50,11 +49,11 @@ public class ArrangementDialog extends JPanel {
|
||||||
this.rangeMax = Double.MIN_VALUE;
|
this.rangeMax = Double.MIN_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createArrangement(){
|
public void createArrangement() {
|
||||||
XYSeriesCollection dataset = new XYSeriesCollection();
|
XYSeriesCollection dataset = new XYSeriesCollection();
|
||||||
|
|
||||||
for (Coordinates p : lines) {
|
for (Coordinates p : lines) {
|
||||||
XYSeries series = new XYSeries(p.getX()+p.getY());
|
XYSeries series = new XYSeries(p.getX() + p.getY());
|
||||||
series.add((-1 * this.max), (((-1 * this.max) * p.getX()) + p.getY()));
|
series.add((-1 * this.max), (((-1 * this.max) * p.getX()) + p.getY()));
|
||||||
series.add(this.max, ((this.max * p.getX()) + p.getY()));
|
series.add(this.max, ((this.max * p.getX()) + p.getY()));
|
||||||
dataset.addSeries(series);
|
dataset.addSeries(series);
|
||||||
|
@ -72,14 +71,14 @@ public class ArrangementDialog extends JPanel {
|
||||||
|
|
||||||
chart = ChartFactory.createXYLineChart(
|
chart = ChartFactory.createXYLineChart(
|
||||||
null, null, null, dataset,
|
null, null, null, dataset,
|
||||||
PlotOrientation.HORIZONTAL, false, false, false );
|
PlotOrientation.HORIZONTAL, false, false, false);
|
||||||
|
|
||||||
final XYPlot plot = chart.getXYPlot();
|
final XYPlot plot = chart.getXYPlot();
|
||||||
ValueAxis domain = plot.getDomainAxis();
|
ValueAxis domain = plot.getDomainAxis();
|
||||||
ValueAxis range = plot.getRangeAxis();
|
ValueAxis range = plot.getRangeAxis();
|
||||||
|
|
||||||
domain.setRange(domainMin-1,domainMax+1);
|
domain.setRange(domainMin - 1, domainMax + 1);
|
||||||
range.setRange(rangeMin-1,rangeMax+1);
|
range.setRange(rangeMin - 1, rangeMax + 1);
|
||||||
plot.setBackgroundPaint(Color.WHITE);
|
plot.setBackgroundPaint(Color.WHITE);
|
||||||
plot.setDomainGridlinePaint(Color.white);
|
plot.setDomainGridlinePaint(Color.white);
|
||||||
plot.setRangeGridlinePaint(Color.white);
|
plot.setRangeGridlinePaint(Color.white);
|
||||||
|
@ -93,6 +92,4 @@ public class ArrangementDialog extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class MainFrame extends JFrame {
|
||||||
private ArrangementDialog arrangement;
|
private ArrangementDialog arrangement;
|
||||||
private PlotDialog plot;
|
private PlotDialog plot;
|
||||||
|
|
||||||
public MainFrame(){
|
public MainFrame() {
|
||||||
initGUI();
|
initGUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class MainFrame extends JFrame {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void createArrangement() {
|
public void createArrangement() {
|
||||||
if (arrangement == null){
|
if (arrangement == null) {
|
||||||
arrangement = new ArrangementDialog();
|
arrangement = new ArrangementDialog();
|
||||||
arrangement.setPrameters(getPresenter().getMax(), getPresenter().getMin(), getPresenter().getLines(), getPresenter().getModel().getNodes());
|
arrangement.setPrameters(getPresenter().getMax(), getPresenter().getMin(), getPresenter().getLines(), getPresenter().getModel().getNodes());
|
||||||
arrangement.createArrangement();
|
arrangement.createArrangement();
|
||||||
|
@ -70,7 +70,7 @@ public class MainFrame extends JFrame {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPlot() {
|
public void createPlot() {
|
||||||
if (plot == null){
|
if (plot == null) {
|
||||||
plot = new PlotDialog();
|
plot = new PlotDialog();
|
||||||
plot.createPlot(getPresenter().getLines());
|
plot.createPlot(getPresenter().getLines());
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
|
@ -90,7 +90,7 @@ public class MainFrame extends JFrame {
|
||||||
* log Methode
|
* log Methode
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void log(String s){
|
public void log(String s) {
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -102,9 +102,9 @@ public class MainFrame extends JFrame {
|
||||||
/**
|
/**
|
||||||
* init GUI
|
* init GUI
|
||||||
*/
|
*/
|
||||||
protected void initGUI(){
|
protected void initGUI() {
|
||||||
this.setTitle("MainFrame");
|
this.setTitle("MainFrame");
|
||||||
this.setSize(500,400);
|
this.setSize(500, 400);
|
||||||
this.setLayout(new BorderLayout());
|
this.setLayout(new BorderLayout());
|
||||||
pane = new JPanel();
|
pane = new JPanel();
|
||||||
pane.setLayout(new FlowLayout());
|
pane.setLayout(new FlowLayout());
|
||||||
|
@ -112,9 +112,9 @@ public class MainFrame extends JFrame {
|
||||||
menupanel = new MenuPanel();
|
menupanel = new MenuPanel();
|
||||||
|
|
||||||
arrangementDialog = new JDialog();
|
arrangementDialog = new JDialog();
|
||||||
plotDialog = new JDialog();
|
plotDialog = new JDialog();
|
||||||
arrangementDialog.setSize(new Dimension(700,470));
|
arrangementDialog.setSize(new Dimension(700, 470));
|
||||||
plotDialog.setSize(new Dimension(700,470));
|
plotDialog.setSize(new Dimension(700, 470));
|
||||||
arrangementDialog.setTitle("Arrangement Dialog");
|
arrangementDialog.setTitle("Arrangement Dialog");
|
||||||
plotDialog.setTitle("Scatter Plot Dialog");
|
plotDialog.setTitle("Scatter Plot Dialog");
|
||||||
arrangementDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
arrangementDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package View;
|
package View;
|
||||||
|
|
||||||
import org.jfree.ui.action.ActionMenuItem;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
|
@ -12,17 +10,17 @@ import java.awt.*;
|
||||||
* @Email: a_wolf28@uni-muenster.de
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
* @Date: 29.05.2017.
|
* @Date: 29.05.2017.
|
||||||
*/
|
*/
|
||||||
public class MenuPanel extends JPanel{
|
public class MenuPanel extends JPanel {
|
||||||
|
|
||||||
private JMenuBar menuBar;
|
private JMenuBar menuBar;
|
||||||
private JMenu menu;
|
private JMenu menu;
|
||||||
private JMenuItem item;
|
private JMenuItem item;
|
||||||
|
|
||||||
public MenuPanel(){
|
public MenuPanel() {
|
||||||
this.setLayout(new BorderLayout());
|
this.setLayout(new BorderLayout());
|
||||||
this.menuBar = new JMenuBar();
|
this.menuBar = new JMenuBar();
|
||||||
this.menu = new JMenu("File");
|
this.menu = new JMenu("File");
|
||||||
this.item = new JMenuItem("Exit");
|
this.item = new JMenuItem("Exit");
|
||||||
|
|
||||||
|
|
||||||
menu.add(item);
|
menu.add(item);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class PlotDialog extends JPanel {
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
convertData(points);
|
convertData(points);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
thread.start();
|
thread.start();
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package Model;
|
||||||
|
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
||||||
|
*
|
||||||
|
* @Author: Armin Wolf
|
||||||
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
|
* @Date: 30.05.2017.
|
||||||
|
*/
|
||||||
|
public class DoublyConnectedEdgeListTest {
|
||||||
|
|
||||||
|
private static DoublyConnectedEdgeList dcel;
|
||||||
|
private static Node v1, v2, v3 ,v4, v5;
|
||||||
|
private static Edge e1, e2, e3, e4, e5, e6;
|
||||||
|
private static Face f1, f2, f3;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setUp() throws Exception {
|
||||||
|
dcel = new DoublyConnectedEdgeList();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCases(){
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue