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)
|
public void mouseReleased(MouseEvent evt)
|
||||||
{
|
{
|
||||||
model.endShape();
|
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 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();
|
||||||
@ -85,15 +88,17 @@ public class GrafikView extends JComponent implements Printable
|
|||||||
}
|
}
|
||||||
|
|
||||||
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++)
|
path.forEach(point->
|
||||||
{
|
{
|
||||||
Point from = path.get(i);
|
to = point;
|
||||||
Point to = path.get(i+1);
|
line.setLine(from,to);
|
||||||
|
g2.draw(line);
|
||||||
line.setLine(from,to);
|
from = to;
|
||||||
g2.draw(line);
|
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user