konstruiere DCEL Struktur
This commit is contained in:
parent
6940ebbe62
commit
f5e0322f70
|
@ -11,15 +11,15 @@ import java.util.LinkedList;
|
||||||
*/
|
*/
|
||||||
public class Arrangement {
|
public class Arrangement {
|
||||||
|
|
||||||
private LinkedList<Pair> nodes;
|
private LinkedList<Model.Coordinates> nodes;
|
||||||
private LinkedList<Pair> lines;
|
private LinkedList<Model.Coordinates> lines;
|
||||||
|
|
||||||
public Arrangement(){
|
public Arrangement(){
|
||||||
nodes = new LinkedList<>();
|
nodes = new LinkedList<>();
|
||||||
lines = new LinkedList<>();
|
lines = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addNode(Pair node){
|
public void addNode(Model.Coordinates node){
|
||||||
this.nodes.add(node);
|
this.nodes.add(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,11 +27,11 @@ public class Arrangement {
|
||||||
this.nodes.remove(index);
|
this.nodes.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeNode(Pair node){
|
public void removeNode(Model.Coordinates node){
|
||||||
this.nodes.remove(node);
|
this.nodes.remove(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addLine(Pair line){
|
public void addLine(Model.Coordinates line){
|
||||||
this.lines.add(line);
|
this.lines.add(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,23 +39,23 @@ public class Arrangement {
|
||||||
this.lines.remove(index);
|
this.lines.remove(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeLine(Pair line){
|
public void removeLine(Model.Coordinates line){
|
||||||
this.lines.remove(line);
|
this.lines.remove(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedList<Pair> getNodes() {
|
public LinkedList<Model.Coordinates> getNodes() {
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNodes(LinkedList<Pair> nodes) {
|
public void setNodes(LinkedList<Model.Coordinates> nodes) {
|
||||||
this.nodes = nodes;
|
this.nodes = nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedList<Pair> getLines() {
|
public LinkedList<Model.Coordinates> getLines() {
|
||||||
return lines;
|
return lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLines(LinkedList<Pair> lines) {
|
public void setLines(LinkedList<Model.Coordinates> lines) {
|
||||||
this.lines = lines;
|
this.lines = lines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,12 +7,12 @@ package Model;
|
||||||
* @Email: a_wolf28@uni-muenster.de
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
* @Date: 28.05.2017.
|
* @Date: 28.05.2017.
|
||||||
*/
|
*/
|
||||||
public class Pair implements Comparable<Pair> {
|
public class Coordinates implements Comparable<Coordinates> {
|
||||||
|
|
||||||
private Double x;
|
private Double x;
|
||||||
private Double y;
|
private Double y;
|
||||||
|
|
||||||
public Pair(Double x, Double y) {
|
public Coordinates(Double x, Double y) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,7 @@ public class Pair implements Comparable<Pair> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Pair 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;
|
|
@ -0,0 +1,108 @@
|
||||||
|
package Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
||||||
|
*
|
||||||
|
* @Author: Armin Wolf
|
||||||
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
|
* @Date: 30.05.2017.
|
||||||
|
*/
|
||||||
|
public class Edge {
|
||||||
|
|
||||||
|
private Node origin;
|
||||||
|
private Edge twin;
|
||||||
|
private Face incidentFace;
|
||||||
|
private Edge next;
|
||||||
|
private Edge prev;
|
||||||
|
|
||||||
|
public Edge(){
|
||||||
|
new Edge(null, null, null, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Edge(Node origin, Edge twin, Edge next, Edge prev, Face incidentFace){
|
||||||
|
this.origin = origin;
|
||||||
|
this.twin = twin;
|
||||||
|
this.next = next;
|
||||||
|
this.prev = prev;
|
||||||
|
this.incidentFace = incidentFace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node getOrigin() {
|
||||||
|
return origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrigin(Node origin) {
|
||||||
|
this.origin = origin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Edge getTwin() {
|
||||||
|
return twin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTwin(Edge twin) {
|
||||||
|
this.twin = twin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Face getIncidentFace() {
|
||||||
|
return incidentFace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncidentFace(Face incidentFace) {
|
||||||
|
this.incidentFace = incidentFace;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Edge getNext() {
|
||||||
|
return next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNext(Edge next) {
|
||||||
|
this.next = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Edge getPrev() {
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPrev(Edge prev) {
|
||||||
|
this.prev = prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasNext(){
|
||||||
|
if (getNext() == null){
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Edge insertNode(Node node){
|
||||||
|
|
||||||
|
Edge edge = new Edge();
|
||||||
|
Edge twin = new Edge();
|
||||||
|
|
||||||
|
edge.setOrigin(node);
|
||||||
|
edge.setNext(this.getNext());
|
||||||
|
edge.setPrev(this);
|
||||||
|
edge.setTwin(twin);
|
||||||
|
edge.setIncidentFace(this.getIncidentFace());
|
||||||
|
|
||||||
|
twin.setOrigin(this.getTwin().getOrigin());
|
||||||
|
twin.setPrev(this.getTwin().getPrev());
|
||||||
|
twin.setNext(this.getTwin());
|
||||||
|
twin.setTwin(edge);
|
||||||
|
twin.setIncidentFace(this.getTwin().getIncidentFace());
|
||||||
|
|
||||||
|
Node twinOrigin = this.getTwin().getOrigin();
|
||||||
|
twinOrigin.setIncidentEdge(twin);
|
||||||
|
node.setIncidentEdge(edge);
|
||||||
|
|
||||||
|
this.getTwin().setOrigin(node);
|
||||||
|
this.getTwin().getPrev().setNext(twin);
|
||||||
|
this.getNext().setPrev(edge);
|
||||||
|
this.setNext(edge);
|
||||||
|
this.getTwin().setPrev(twin);
|
||||||
|
|
||||||
|
return edge;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,104 @@
|
||||||
|
package Model;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
||||||
|
*
|
||||||
|
* @Author: Armin Wolf
|
||||||
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
|
* @Date: 30.05.2017.
|
||||||
|
*/
|
||||||
|
public class Face {
|
||||||
|
|
||||||
|
private LinkedList<Edge> innerComponents;
|
||||||
|
private Edge outerComponent;
|
||||||
|
|
||||||
|
public Face(Edge outerComponent, LinkedList<Edge> innerComponents){
|
||||||
|
this.outerComponent = outerComponent;
|
||||||
|
this.innerComponents = innerComponents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinkedList<Edge> getInnerComponents() {
|
||||||
|
return innerComponents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInnerComponents(LinkedList<Edge> innerComponents) {
|
||||||
|
this.innerComponents = innerComponents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Edge getOuterComponent() {
|
||||||
|
return outerComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOuterComponent(Edge outerComponent) {
|
||||||
|
this.outerComponent = outerComponent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Face insertEdge(Edge edgeWithSameDestination, Edge edgeToMySource){
|
||||||
|
|
||||||
|
if (edgeWithSameDestination.getIncidentFace().equals(this) || edgeToMySource.getIncidentFace().equals(this)){
|
||||||
|
LinkedList<Edge> components = new LinkedList<Edge>();
|
||||||
|
for (Edge e : innerComponents) {
|
||||||
|
components.add(e);
|
||||||
|
}
|
||||||
|
Face face = new Face(getOuterComponent(), components);
|
||||||
|
Edge edge = new Edge();
|
||||||
|
Edge twin = new Edge();
|
||||||
|
|
||||||
|
edge.setOrigin(edgeWithSameDestination.getOrigin());
|
||||||
|
edge.setTwin(twin);
|
||||||
|
edge.setNext(edgeToMySource);
|
||||||
|
edge.setPrev(edgeWithSameDestination.getPrev());
|
||||||
|
|
||||||
|
twin.setOrigin(edgeToMySource.getOrigin());
|
||||||
|
twin.setTwin(edge);
|
||||||
|
twin.setNext(edgeWithSameDestination);
|
||||||
|
twin.setPrev(edgeToMySource.getPrev());
|
||||||
|
|
||||||
|
Edge tempEdge = edge.getNext();
|
||||||
|
Edge tempTwin = twin.getNext();
|
||||||
|
//kreis umlaufen um festzustellen welche fläche kleiner ist
|
||||||
|
while ((tempEdge.equals(edge) == false) && (tempTwin.equals(twin) == false)){
|
||||||
|
tempEdge = tempEdge.getNext();
|
||||||
|
tempTwin = tempTwin.getNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tempEdge.equals(edge)){
|
||||||
|
setOuterComponent(twin);
|
||||||
|
twin.setIncidentFace(this);
|
||||||
|
face.setOuterComponent(edge);
|
||||||
|
} else {
|
||||||
|
setOuterComponent(edge);
|
||||||
|
edge.setIncidentFace(this);
|
||||||
|
face.setOuterComponent(twin);
|
||||||
|
}
|
||||||
|
|
||||||
|
LinkedList<Edge> bla = new LinkedList<Edge>();
|
||||||
|
Edge iterEdge = face.getOuterComponent();
|
||||||
|
bla.add(face.getOuterComponent());
|
||||||
|
|
||||||
|
while (iterEdge.hasNext()){
|
||||||
|
bla.add(iterEdge.getNext());
|
||||||
|
iterEdge = iterEdge.getNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Edge e : face.getInnerComponents()) {
|
||||||
|
iterEdge = e;
|
||||||
|
while (iterEdge.hasNext()){
|
||||||
|
bla.add(iterEdge.getNext());
|
||||||
|
iterEdge = iterEdge.getNext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Edge e : bla) {
|
||||||
|
e.setIncidentFace(face);
|
||||||
|
}
|
||||||
|
return face;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("Die angegebenen Kanten haben keinen zusammenhang mit der Fläche!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package Model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementierung verschiedener Algorithmen zur Berechnung von Ausgleichsgeraden.
|
||||||
|
*
|
||||||
|
* @Author: Armin Wolf
|
||||||
|
* @Email: a_wolf28@uni-muenster.de
|
||||||
|
* @Date: 30.05.2017.
|
||||||
|
*/
|
||||||
|
public class Node {
|
||||||
|
|
||||||
|
private Coordinates coordinates;
|
||||||
|
private Edge incidentEdge;
|
||||||
|
|
||||||
|
public Node(){
|
||||||
|
new Node(null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Node(Coordinates coordinates, Edge incidentEdge){
|
||||||
|
this.coordinates = coordinates;
|
||||||
|
this.incidentEdge = incidentEdge;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Coordinates getCoordinates() {
|
||||||
|
return coordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoordinates(Coordinates coordinates) {
|
||||||
|
this.coordinates = coordinates;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Edge getIncidentEdge() {
|
||||||
|
return incidentEdge;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIncidentEdge(Edge incidentEdge) {
|
||||||
|
this.incidentEdge = incidentEdge;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,10 +1,9 @@
|
||||||
package Presenter;
|
package Presenter;
|
||||||
|
|
||||||
import Model.Arrangement;
|
import Model.Arrangement;
|
||||||
import Model.Pair;
|
import Model.Coordinates;
|
||||||
import View.*;
|
import View.*;
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
@ -38,14 +37,14 @@ public class Presenter {
|
||||||
// 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++){
|
||||||
Pair p = new Pair(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 (Pair p : model.getNodes()) {
|
for (Coordinates p : model.getNodes()) {
|
||||||
view.log(p.getX()+", "+p.getY());
|
view.log(p.getX()+", "+p.getY());
|
||||||
}
|
}
|
||||||
extractBounds();
|
extractBounds();
|
||||||
|
@ -72,18 +71,18 @@ public class Presenter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void extractBounds(){
|
private void extractBounds(){
|
||||||
Pair pmax = Collections.max(model.getLines());
|
Coordinates pmax = Collections.max(model.getLines());
|
||||||
Pair pmin = Collections.min(model.getLines());
|
Coordinates pmin = Collections.min(model.getLines());
|
||||||
|
|
||||||
max = pmax.getX() >= pmax.getY() ? pmax.getX() : pmax.getY();
|
max = pmax.getX() >= pmax.getY() ? pmax.getX() : pmax.getY();
|
||||||
min = pmin.getX() <= pmin.getY() ? pmin.getX() : pmin.getY();
|
min = pmin.getX() <= pmin.getY() ? pmin.getX() : pmin.getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair calcIntersection(Pair a, Pair b){
|
public Coordinates calcIntersection(Coordinates a, Coordinates b){
|
||||||
Pair p1;
|
Coordinates p1;
|
||||||
Pair p2;
|
Coordinates p2;
|
||||||
|
|
||||||
if (b.compareTo(a) > 0){
|
if (a.compareTo(b) > 0){
|
||||||
p1 = a;
|
p1 = a;
|
||||||
p2 = b;
|
p2 = b;
|
||||||
} else {
|
} else {
|
||||||
|
@ -91,10 +90,11 @@ public class Presenter {
|
||||||
p2 = a;
|
p2 = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
Double x = (p1.getY() - p2.getY()) / (p1.getX() - p2.getX());
|
Double x = (p1.getY() - p2.getY()) / (p2.getX() - p1.getX());
|
||||||
Double y = ((p2.getX() * p1.getY()) - (p1.getX() * p2.getY())) / (p2.getX() - p1.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 Pair(x,y);
|
|
||||||
|
return new Coordinates(x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calcArrangementNodes(){
|
public void calcArrangementNodes(){
|
||||||
|
@ -104,7 +104,7 @@ public class Presenter {
|
||||||
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(i), getLines().get(j)));
|
model.addNode(calcIntersection(getLines().get(j), getLines().get(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -138,11 +138,11 @@ public class Presenter {
|
||||||
this.view = view;
|
this.view = view;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkedList<Pair> getLines() {
|
public LinkedList<Coordinates> getLines() {
|
||||||
return this.model.getLines();
|
return this.model.getLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLines(LinkedList<Pair> lines) {
|
public void setLines(LinkedList<Coordinates> lines) {
|
||||||
this.model.setLines(lines);
|
this.model.setLines(lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
package View;
|
package View;
|
||||||
|
|
||||||
import Model.Pair;
|
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.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;
|
||||||
|
|
||||||
|
@ -24,37 +25,47 @@ import java.util.LinkedList;
|
||||||
*/
|
*/
|
||||||
public class ArrangementDialog extends JPanel {
|
public class ArrangementDialog extends JPanel {
|
||||||
|
|
||||||
private LinkedList<Pair> lines;
|
private LinkedList<Coordinates> lines;
|
||||||
private LinkedList<Pair> points;
|
private LinkedList<Coordinates> points;
|
||||||
private double max;
|
private double max;
|
||||||
private double min;
|
private double min;
|
||||||
private JFreeChart chart;
|
private JFreeChart chart;
|
||||||
private ChartPanel panel;
|
private ChartPanel panel;
|
||||||
|
private double domainMin, domainMax;
|
||||||
|
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<Pair> lines, LinkedList<Pair> 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;
|
||||||
this.points = points;
|
this.points = points;
|
||||||
|
this.domainMin = Double.MAX_VALUE;
|
||||||
|
this.domainMax = Double.MIN_VALUE;
|
||||||
|
this.rangeMin = Double.MAX_VALUE;
|
||||||
|
this.rangeMax = Double.MIN_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createArrangement(){
|
public void createArrangement(){
|
||||||
XYSeriesCollection dataset = new XYSeriesCollection();
|
XYSeriesCollection dataset = new XYSeriesCollection();
|
||||||
|
|
||||||
for (Pair 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
XYSeries intersections = new XYSeries("intersections");
|
XYSeries intersections = new XYSeries("intersections");
|
||||||
for (Pair p : points) {
|
for (Coordinates p : points) {
|
||||||
|
domainMax = domainMax < p.getX() ? p.getX() : domainMax;
|
||||||
|
domainMin = domainMin > p.getX() ? p.getX() : domainMin;
|
||||||
|
rangeMax = rangeMax < p.getY() ? p.getY() : rangeMax;
|
||||||
|
rangeMin = rangeMin > p.getY() ? p.getY() : rangeMin;
|
||||||
intersections.add(p.getX(), p.getY());
|
intersections.add(p.getX(), p.getY());
|
||||||
}
|
}
|
||||||
dataset.addSeries(intersections);
|
dataset.addSeries(intersections);
|
||||||
|
@ -62,7 +73,13 @@ 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 range = plot.getRangeAxis();
|
||||||
|
|
||||||
|
domain.setRange(domainMin-1,domainMax+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);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package View;
|
package View;
|
||||||
|
|
||||||
import Model.Pair;
|
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;
|
||||||
|
@ -34,7 +34,7 @@ public class PlotDialog extends JPanel {
|
||||||
this.setPreferredSize(new Dimension(800, 500));
|
this.setPreferredSize(new Dimension(800, 500));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createPlot(LinkedList<Pair> points) {
|
public void createPlot(LinkedList<Coordinates> points) {
|
||||||
|
|
||||||
Thread thread = new Thread(new Runnable() {
|
Thread thread = new Thread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,11 +75,11 @@ public class PlotDialog extends JPanel {
|
||||||
//TODO Line Estimator
|
//TODO Line Estimator
|
||||||
}
|
}
|
||||||
|
|
||||||
private void convertData(LinkedList<Pair> points) {
|
private void convertData(LinkedList<Coordinates> points) {
|
||||||
|
|
||||||
datapoints = new XYSeriesCollection();
|
datapoints = new XYSeriesCollection();
|
||||||
series = new XYSeries("");
|
series = new XYSeries("");
|
||||||
for (Pair p : points) {
|
for (Coordinates p : points) {
|
||||||
series.add(p.getX(), p.getY());
|
series.add(p.getX(), p.getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue