WIP: alternative gui
This commit is contained in:
parent
22bb11a7d6
commit
dfcc6a15cb
|
@ -57,7 +57,6 @@ public class Presenter {
|
|||
view.logHeading("Koordinaten der Punkte");
|
||||
view.createTable(heading, rows);
|
||||
view.logSuccess("Berechnung wurde Erfolgreich durchgeführt");
|
||||
extractBounds();
|
||||
}
|
||||
|
||||
public void getDataFromModel() {
|
||||
|
@ -81,11 +80,47 @@ public class Presenter {
|
|||
}
|
||||
|
||||
private void extractBounds() {
|
||||
Coordinates pmax = Collections.max(model.getLines());
|
||||
Coordinates pmin = Collections.min(model.getLines());
|
||||
// Coordinates pmax = Collections.max(model.getLines());
|
||||
// Coordinates pmin = Collections.min(model.getLines());
|
||||
//
|
||||
// max = pmax.getX() >= pmax.getY() ? pmax.getX() : pmax.getY();
|
||||
// min = pmin.getX() <= pmin.getY() ? pmin.getX() : pmin.getY();
|
||||
LinkedList<Double> xCoordinates = new LinkedList<>();
|
||||
LinkedList<Double> yCoordinates = new LinkedList<>();
|
||||
|
||||
max = pmax.getX() >= pmax.getY() ? pmax.getX() : pmax.getY();
|
||||
min = pmin.getX() <= pmin.getY() ? pmin.getX() : pmin.getY();
|
||||
for (Coordinates point : model.getNodes()) {
|
||||
xCoordinates.add(point.getX());
|
||||
yCoordinates.add(point.getY());
|
||||
System.out.println(point.getX() + ", " + point.getY());
|
||||
}
|
||||
|
||||
Collections.sort(xCoordinates);
|
||||
Collections.sort(yCoordinates);
|
||||
|
||||
double xmin, xmax;
|
||||
double ymin, ymax;
|
||||
|
||||
xmin = xCoordinates.getFirst();
|
||||
xmax = xCoordinates.getLast();
|
||||
ymin = yCoordinates.getFirst();
|
||||
ymax = yCoordinates.getLast();
|
||||
|
||||
System.out.println("x: "+xmin+", "+xmax+"\t"+ymin+", "+ymax);
|
||||
|
||||
for (Coordinates p : model.getLines()) {
|
||||
p.setX(scale(p.getX(), xmin, xmax, 0, 100));
|
||||
p.setY(scale(p.getY(), ymin, ymax, 0, 100));
|
||||
view.log(p.getX() + ", "+p.getY());
|
||||
}
|
||||
}
|
||||
|
||||
public double scale(
|
||||
double x,
|
||||
double old_min, double old_max,
|
||||
double new_min, double new_max) {
|
||||
double old_range = Math.abs(old_max - old_min);
|
||||
double new_range = Math.abs(new_max - new_min);
|
||||
return (new_min + x - old_min) * (new_range / old_range);
|
||||
}
|
||||
|
||||
public Coordinates calcIntersection(Coordinates a, Coordinates b) {
|
||||
|
@ -117,6 +152,7 @@ public class Presenter {
|
|||
model.addNode(calcIntersection(getLines().get(j), getLines().get(i)));
|
||||
}
|
||||
}
|
||||
extractBounds();
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
|
|
|
@ -21,6 +21,9 @@ public class ArrangementDialog2 extends JPanel {
|
|||
private int max = 600;
|
||||
private int zero = max/2;
|
||||
|
||||
private int low;
|
||||
private int high;
|
||||
|
||||
private Dimension dimension;
|
||||
private LinkedList<Coordinates> lines;
|
||||
private LinkedList<Coordinates> points;
|
||||
|
@ -32,26 +35,16 @@ public class ArrangementDialog2 extends JPanel {
|
|||
this.setPreferredSize(dimension);
|
||||
}
|
||||
|
||||
public void setPrameters(Double pmax, Double pmin, LinkedList<Coordinates> lines, LinkedList<Coordinates> points) {
|
||||
this.scale = max / (Math.abs(pmin) - Math.abs(pmax));
|
||||
public void setPrameters(LinkedList<Coordinates> lines, LinkedList<Coordinates> points) {
|
||||
this.lines = lines;
|
||||
this.points = points;
|
||||
|
||||
scalePoints();
|
||||
//scalePoints();
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
private void scalePoints(){
|
||||
for (Coordinates c : lines) {
|
||||
c.setX(c.getX() * scale);
|
||||
c.setY(c.getY() * scale);
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(null,points.size());
|
||||
for (Coordinates c : points) {
|
||||
c.setX((c.getX() * scale) + zero);
|
||||
c.setY((c.getY()* scale) + zero);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class MainFrame extends JFrame {
|
|||
public void createArrangement() {
|
||||
if (arrangement == null) {
|
||||
arrangement = new ArrangementDialog2();
|
||||
arrangement.setPrameters(getPresenter().getMax(), getPresenter().getMin(), getPresenter().getLines(), getPresenter().getModel().getNodes());
|
||||
arrangement.setPrameters(getPresenter().getLines(), getPresenter().getModel().getNodes());
|
||||
// arrangement.createArrangement();
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue