Example #1
0
 /**
  * Draws a Line object on the GrapherPanel as a 1 pixel wide line ending on the points defining
  * the Line object.
  *
  * @param The Line to paint.
  */
 private void paintLine(Line l) {
   g.setColor(Color.YELLOW);
   g.drawLine(
       250 + (int) (l.getPointA().getX() * 25),
       250 - (int) (l.getPointA().getY() * 25),
       250 + (int) (l.getPointB().getX() * 25),
       250 - (int) (l.getPointB().getY() * 25));
 }
Example #2
0
 /**
  * Draws a Polygon object on the GrapherPanel as a series of 1 pixel wide lines contained in the
  * polygon's sides variable.
  *
  * @param The Polygon to paint.
  */
 private void paintPolygon(Polygon p) {
   g.setColor(Color.GREEN);
   for (Line l : p.getSides()) {
     g.drawLine(
         250 + (int) (l.getPointA().getX() * 25),
         250 - (int) (l.getPointA().getY() * 25),
         250 + (int) (l.getPointB().getX() * 25),
         250 - (int) (l.getPointB().getY() * 25));
   }
 }
Example #3
0
 /**
  * Draws a Triangle object on the GrapherPanel as a series of 1 pixel wide lines contained in the
  * Triangle's sides variable.
  *
  * @param The Triangle to paint.
  */
 private void paintTriangle(Triangle t) {
   g.setColor(Color.GREEN);
   for (Line l : t.getSides()) {
     g.drawLine(
         250 + (int) (l.getPointA().getX() * 25),
         250 - (int) (l.getPointA().getY() * 25),
         250 + (int) (l.getPointB().getX() * 25),
         250 - (int) (l.getPointB().getY() * 25));
   }
 }