Browse Source

ForEach zum path zeichnen

Jens
Jens Schuhmann 1 year ago
parent
commit
21f8bb449a

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

public void mouseReleased(MouseEvent evt) public void mouseReleased(MouseEvent evt)
{ {
model.endShape(); model.endShape();
// if (evt.getButton() == MouseEvent.BUTTON3)
// {
// view.doPrint();
// }
} }
} }

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

private Line2D.Float line; private Line2D.Float line;
private GrafikModel model; private GrafikModel model;
private Point from = null;
private Point to = null;
public GrafikView() public GrafikView()
{ {
pixel = new Rectangle2D.Float(); pixel = new Rectangle2D.Float();
} }
public void drawPath(List<Point> path, Graphics2D g2){ 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