Exemplo n.º 1
0
 public void actionPerformed(ActionEvent e) {
   String cmd = e.getActionCommand();
   if (cmd.equals(F_TO_C)) {
     int f = fTextField.getValue();
     int c = GMath.round((5.0 / 9.0) * (f - 32));
     cTextField.setValue(c);
   } else if (cmd.equals(C_TO_F)) {
     int c = cTextField.getValue();
     int f = GMath.round((9.0 / 5.0) * c + 32);
     fTextField.setValue(f);
   }
 }
Exemplo n.º 2
0
 /**
  * Creates a new GStar centered at the origin with the indicated horizontal width.
  *
  * @param width The width of the star
  */
 public GStar(double width) {
   double dx = width / 2;
   double dy = dx * GMath.tanDegrees(18);
   double edge = width / 2 - dy * GMath.tanDegrees(36);
   addVertex(-dx, -dy);
   int angle = 0;
   for (int i = 0; i < 5; i++) {
     addPolarEdge(edge, angle);
     addPolarEdge(edge, angle + 72);
     angle -= 72;
   }
   markAsComplete();
 }