Ejemplo n.º 1
0
 public static void drawImage(int[][][] pixels, int startX, int startY) {
   // Key idea: draw a bunch (lots of rectangles) with the appropriate color
   DrawObject R = new DrawObject();
   R.pixels = pixels;
   R.startX = startX;
   R.startY = startY;
   R.sequenceNum = currentSequenceNum;
   images.add(R);
   // Rescale if needed.
   int leftX = startX;
   int rightX = startX + pixels.length;
   int lowY = startY;
   int highY = startY + pixels[0].length;
   if (minX > leftX) {
     minX = leftX;
   }
   if (maxX < rightX) {
     maxX = rightX;
   }
   if (minY > lowY) {
     minY = lowY;
   }
   if (maxY < highY) {
     maxY = highY;
   }
   drawArea.repaint();
 }
Ejemplo n.º 2
0
 static void handleMouseDragged(MouseEvent e) {
   DrawObject L = new DrawObject();
   L.scribbleX = e.getX();
   L.scribbleY = e.getY();
   L.scribbleNum = currentScribbleNum;
   scribbles.add(L);
   drawArea.repaint();
 }
Ejemplo n.º 3
0
 public static void drawLabel(double x, double y, String str) {
   DrawObject L = new DrawObject();
   L.color = labelColor;
   L.x = x;
   L.y = y;
   L.str = str;
   L.sequenceNum = currentSequenceNum;
   if (animationMode) {
     synchronized (animLabels) {
       animLabels.add(L);
     }
   } else {
     synchronized (labels) {
       labels.add(L);
     }
   }
   drawArea.repaint();
 }
Ejemplo n.º 4
0
 public static void drawPoint(double x, double y) {
   DrawObject p = new DrawObject();
   p.color = pointColor;
   p.x = x;
   p.y = y;
   p.diameter = pointDiameter;
   p.sequenceNum = currentSequenceNum;
   if (animationMode) {
     synchronized (animPoints) {
       animPoints.add(p);
     }
   } else {
     synchronized (points) {
       points.add(p);
     }
   }
   drawArea.repaint();
 }
Ejemplo n.º 5
0
 public static void drawRectangle(double x1, double y1, double width, double height) {
   DrawObject R = new DrawObject();
   R.color = rectangleColor;
   R.x = x1;
   R.y = y1;
   R.width = width;
   R.height = height;
   R.sequenceNum = currentSequenceNum;
   R.drawStroke = drawStroke;
   if (animationMode) {
     synchronized (animRectangles) {
       animRectangles.add(R);
     }
   } else {
     synchronized (rectangles) {
       rectangles.add(R);
     }
   }
   drawArea.repaint();
 }
Ejemplo n.º 6
0
 public static void drawLineFromEquation(double a, double b, double c) {
   // Draw the equation ax+by+c=0 in the available range.
   DrawObject L = new DrawObject();
   L.color = lineEqnColor;
   L.a = a;
   L.b = b;
   L.c = c;
   L.sequenceNum = currentSequenceNum;
   L.drawStroke = drawStroke;
   synchronized (eqnLines) {
     eqnLines.add(L);
   }
   drawArea.repaint();
 }
Ejemplo n.º 7
0
 public static void drawLine(double x1, double y1, double x2, double y2, boolean isArrow) {
   DrawObject L = new DrawObject();
   L.color = lineColor;
   L.x = x1;
   L.y = y1;
   L.x2 = x2;
   L.y2 = y2;
   if (isArrow) {
     L.color = arrowColor;
     L.isArrow = true;
   }
   L.sequenceNum = currentSequenceNum;
   L.drawStroke = drawStroke;
   if (animationMode) {
     synchronized (animLines) {
       animLines.add(L);
     }
   } else {
     synchronized (lines) {
       lines.add(L);
     }
   }
   drawArea.repaint();
 }
Ejemplo n.º 8
0
  // ErtanO 12.03.2004
  public static java.util.List getAvailablePLAF() {
    java.util.List l = new java.util.ArrayList();
    l.add("System");
    l.add("TinyLAF");
    l.add("JGoodiesLAF-PlasticXP");
    l.add("JGoodiesLAF-Plastic");
    l.add("JGoodiesLAF-Plastic3D");
    l.add("JGoodiesLAF-ExtWindows");

    javax.swing.UIManager.LookAndFeelInfo[] lfinfo =
        javax.swing.UIManager.getInstalledLookAndFeels();

    for (int i = 0; i < lfinfo.length; ++i) {
      l.add(lfinfo[i].getName());
    }

    return l;
  }
Ejemplo n.º 9
0
  private void playerSetup() {

    players = new ArrayList(twoPlayerRB.isSelected() ? 2 : 1);
    if (mouseRB.isSelected()) {
      MouseControlledPlayer p1 =
          new MouseControlledPlayer(width / 2, height / 2, 3, true, this, 3, 1, width);
      addMouseMotionListener(p1);
      addMouseListener(p1);
      players.add(p1);
    } else {
      KeyboardControlledPlayer p1 =
          new KeyboardControlledPlayer(
              width / 2,
              height / 2,
              3,
              true,
              this,
              3,
              KeyEvent.VK_W,
              KeyEvent.VK_A,
              KeyEvent.VK_S,
              KeyEvent.VK_D,
              keyboardSpeedS1.getValue(),
              KeyEvent.VK_SPACE,
              KeyEvent.VK_F,
              1,
              width);
      KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(p1);
      players.add(p1);
    }

    if (twoPlayerRB.isSelected()) {
      if (mouseRB.isSelected()) {
        KeyboardControlledPlayer p2 =
            new KeyboardControlledPlayer(
                width / 2,
                height / 2,
                3,
                true,
                this,
                3,
                KeyEvent.VK_W,
                KeyEvent.VK_A,
                KeyEvent.VK_S,
                KeyEvent.VK_D,
                keyboardSpeedS2.getValue(),
                KeyEvent.VK_SPACE,
                KeyEvent.VK_F,
                2,
                width);
        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(p2);
        players.add(p2);
      } else {
        KeyboardControlledPlayer p2 =
            new KeyboardControlledPlayer(
                width / 2,
                height / 2,
                3,
                true,
                this,
                3,
                KeyEvent.VK_NUMPAD8,
                KeyEvent.VK_NUMPAD4,
                KeyEvent.VK_NUMPAD5,
                KeyEvent.VK_NUMPAD6,
                keyboardSpeedS2.getValue(),
                KeyEvent.VK_NUMPAD0,
                KeyEvent.VK_NUMPAD1,
                2,
                width);
        KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(p2);
        players.add(p2);
      }
    }
  }