Browse Source

ForEach zum path zeichnen

Jens
Jens Schuhmann 1 year ago
parent
commit
21f8bb449a
2 changed files with 13 additions and 12 deletions
  1. 0
    4
      src/mvcgrafik/controller/GrafikController.java
  2. 13
    8
      src/mvcgrafik/view/GrafikView.java

+ 0
- 4
src/mvcgrafik/controller/GrafikController.java View File

@@ -50,9 +50,5 @@ public class GrafikController extends MouseAdapter implements MouseMotionListene
public void mouseReleased(MouseEvent evt)
{
model.endShape();
// if (evt.getButton() == MouseEvent.BUTTON3)
// {
// view.doPrint();
// }
}
}

+ 13
- 8
src/mvcgrafik/view/GrafikView.java View File

@@ -38,6 +38,9 @@ public class GrafikView extends JComponent implements Printable
private Line2D.Float line;
private GrafikModel model;
private Point from = null;
private Point to = null;
public GrafikView()
{
pixel = new Rectangle2D.Float();
@@ -85,15 +88,17 @@ public class GrafikView extends JComponent implements Printable
}
public void drawPath(List<Point> path, Graphics2D g2){
from = path.getFirst();
to = null;
for(int i=0; i < path.size()-1; i++)
{
Point from = path.get(i);
Point to = path.get(i+1);
line.setLine(from,to);
g2.draw(line);
}
path.forEach(point->
{
to = point;
line.setLine(from,to);
g2.draw(line);
from = to;
});
}

Loading…
Cancel
Save