ForEach zum path zeichnen
This commit is contained in:
parent
6bdad9c08a
commit
21f8bb449a
@ -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();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -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++)
|
||||
path.forEach(point->
|
||||
{
|
||||
Point from = path.get(i);
|
||||
Point to = path.get(i+1);
|
||||
|
||||
to = point;
|
||||
line.setLine(from,to);
|
||||
g2.draw(line);
|
||||
}
|
||||
from = to;
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user