示例#1
0
  public void paintComponent(Graphics g) {
    if (m.isPressed()) {
      t = colorCount - 1;
      g.setColor(pressed[t]);
      g.fillRect(0, 0, getSize().width - 1, getSize().height - 1);
      g.setColor(border[t]);

    } else {
      g.setColor(rollOver[t]);
      g.fillRect(0, 0, getSize().width - 1, getSize().height - 1);
      g.setColor(border[t]);
      if (m.isRollover()) {
        if (t < colorCount - 1 && !fadeIn.isRunning()) {
          fadeOut.stop();
          fadeIn.start();
        }
      } else {
        if (t > 0 && !fadeOut.isRunning()) {
          fadeIn.stop();
          fadeOut.start();
        }
      }
    }

    super.paintComponent(g);
  }
示例#2
0
 private boolean teleporting(ClientContext ctx) {
   if (ctx.players.local().animation() != -1) {
     t.reset(); // To account for small lag when the map changes and animation becomes -1
     return true;
   }
   return t.isRunning();
 }
示例#3
0
 protected final void restartTimer() {
   if (!myAutoSelectionTimer.isRunning()) {
     myAutoSelectionTimer.start();
   } else {
     myAutoSelectionTimer.restart();
   }
 }
 public void mouseExited(MouseEvent e) {
   if (!readOnly) {
     lastMouseExitTime = System.currentTimeMillis();
     if (timer != null && timer.isRunning()) {
       timer.stop();
     }
   }
 }
 @Override
 public void paintComponent(Graphics oldGraphics) {
   Graphics2D g = (Graphics2D) oldGraphics;
   if (painted && (isDisplayedWhenStopped || timer.isRunning())) {
     g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
     if (maxValue != 0) {
       paintPie(g);
     } else {
       paintBars(g);
     }
   }
 }
示例#6
0
 /**
  * Redraw all the images so that changes in options can take effect CAUTION: setupNestedStates
  * will hog up some of CPU's time but, it has to be performed to keep nesting upto date
  */
 void Refresh() {
   waitCursor();
   blink = false;
   blFlag = true;
   if (timer.isRunning()) timer.stop();
   int prevH = getPrev(currImg.imgIdH);
   int nextH = getNext(currImg.imgIdH);
   waitCursor();
   all_states.visible.SetupNestedStates();
   normalCursor();
   img[prevH].drawStuff();
   img[nextH].drawStuff();
   currImg.drawStuff();
   if (blink) timer.start();
   repaint();
   parent.vcanvas1.repaint();
   parent.vcanvas2.repaint();
   parent.vport.setViewPosition(new Point(panePosX, 0));
   debug.println("Refresh() : .parent.vport.setViewPosition(" + panePosX + ", 0)");
   normalCursor();
 }
示例#7
0
  public void paintComponent(Graphics g) {
    // We request keyboard focus out here so that we can catch events for locking zoom, etc.
    requestFocus();

    // 3 Images are painted each time. The reason we use images rather than directly drawing
    // onto the graphics context is that the drawings of one image can be taking place
    // concurrently with the other using threads into offscreen graphic contexts assoc.
    // with the respective images. While printing we do the opposite

    if (setupComplete && currImg != null) {
      int prevH = getPrev(currImg.imgIdH);
      int nextH = getNext(currImg.imgIdH);

      if (blFlag || !timer.isRunning()) {
        img[prevH].paintStuff1(0, g, this);
        currImg.paintStuff1(_xPix, g, this);
        img[nextH].paintStuff1(_xPix + _xPix, g, this);

        /*g.drawImage (img [prevH].img, 0, 0, this);
        g.drawImage (img [prevH].timeimg, 0, _yPix, this);

        g.drawImage (currImg.img, _xPix, 0, this);
        g.drawImage (currImg.timeimg, _xPix, _yPix, this);

        g.drawImage (img [nextH].img, _xPix + _xPix, 0, this);
        g.drawImage (img [nextH].timeimg, _xPix + _xPix, _yPix, this);*/
      } else {
        img[prevH].paintStuff2(0, g, this);
        currImg.paintStuff2(_xPix, g, this);
        img[nextH].paintStuff2(_xPix + _xPix, g, this);

        /*g.drawImage (img [prevH].img1, 0, 0, this);
        g.drawImage (img [prevH].timeimg, 0, _yPix, this);

        g.drawImage (currImg.img1, _xPix, 0, this);
        g.drawImage (currImg.timeimg, _xPix, _yPix, this);

        g.drawImage (img [nextH].img1, _xPix + _xPix, 0, this);
        g.drawImage (img [nextH].timeimg, _xPix + _xPix, _yPix, this);*/
      }
    }

    if (zoomLkLineDispStatus && zXTime >= begTime && zXTime <= endTime) {
      int xcord = panePosX + getEvtXCord(zXTime - begTime);
      g.setColor(Color.white);
      g.drawLine(xcord, 0, xcord, _yPix);
      g.fillRect(xcord, _yPix - lineSize, zLockStrW + 2, lineSize);
      g.setColor(Color.black);
      g.drawRect(xcord, _yPix - lineSize, zLockStrW + 1, lineSize - 1);
      g.setColor(Color.red);
      g.drawString("Zoom Lock", xcord + 1, _yPix - fDescent);
    }

    if (elTLineDispStatus && elapsedPoint >= begTime && elapsedPoint <= endTime) {
      int xcord = panePosX + getEvtXCord(elapsedPoint - begTime);
      g.setColor(Color.white);
      g.drawLine(xcord, 0, xcord, _yPix);
      g.fillRect(xcord, _yPix - lineSize, elTimeStrW + 2, lineSize);
      g.setColor(Color.black);
      g.drawRect(xcord, _yPix - lineSize, elTimeStrW + 1, lineSize - 1);
      g.setColor(Color.red);
      g.drawString("Elapsed Time", xcord + 1, _yPix - fDescent);
    }
  }
  /**
   * This method gets called when user performs a mouse click. It decodes whether it is a single
   * click or part of a multiple click (double click, triple click etc.) and inserts appropriate
   * command to the current editor.
   *
   * @param e a MouseEvent describing the mouse click.
   */
  public void mouseClicked(MouseEvent e) {
    if (enabled && !readOnly) {
      if (timer != null && timer.isRunning()) {
        timer.stop();
      }
      if (enableMouseClicks) {
        int count = 1;
        MouseEvent e2;

        long lastEventTime = e.getWhen();

        // This cycle is to determine multiple clicks like double click, triple click etc.
        // We go through the vector of events and check whether there are events corresponding to
        // multiple clicks.
        for (int i = 0; i < events.size() && events.get(i) instanceof MouseEvent; i++) {
          e2 = (MouseEvent) events.get(i);

          // The events are considered to be a multiple click when:
          // 1. Coordinates are equal
          // 2. Modifiers are equal
          // 3. Button is equal
          // 4. Delay between two subsequent clicks is lower than given number of miliseconds
          if (e2.getX() == e.getX()
              && e2.getY() == e.getY()
              && e2.getModifiers() == e.getModifiers()
              && (lastEventTime - e2.getWhen() < mouseMultiDelay)
              && e.getButton() == e2.getButton()
              && e2.getID() == e.getID()) {
            count++;
            lastEventTime = e2.getWhen();
          } else {
            break;
          }
        }

        // Generate the command string
        String s = "Mouse " + MouseCommand.MOUSE_CLICK;

        // Insert the button identifier if other than left button was pressed
        if (e.getButton() != MouseEvent.BUTTON1) {
          s += " " + MouseCommand.PARAM_BUTTON_SHORT + "=" + parser.buttonToString(e.getButton());
        }

        // Insert modifiers if there are any
        String modifiers = parser.modifiersToString(e.getModifiers());
        if (modifiers.length() > 0) {
          s += " " + MouseCommand.PARAM_MODIFIER + "=" + modifiers;
        }

        // Generate the count parameter
        if (count > 1) {
          s += " " + MouseCommand.PARAM_COUNT + "=" + count;
        }

        // This will determine whether this click is preceded by a mouse
        // move command with the same coordinates.
        // It will be replaced if yes.
        boolean replaceLastMove = false;
        //                if (enableMouseMoves) {
        //                    if (events.size() > 0 && events.get(events.size() - 1) instanceof
        // MouseEvent) {
        //                        MouseEvent me = (MouseEvent) events.get(events.size() - 1);
        //                        if (me.getID() == MouseEvent.MOUSE_MOVED && e.getX() == me.getX()
        // && e.getY() == me.getY()) {
        //                            replaceLastMove = true;
        //                        }
        //                    }
        //                }

        // Generate coordinates
        s += " " + MouseCommand.PARAM_TO + "=" + parser.pointToString(e.getPoint());

        // Insert the command to the current editor
        insertLine(s, count > 1 || replaceLastMove, true, false);
        dragInProgress = false;
      }
      insertEvent(e);
    }
  }
  public void mouseWheelMoved(MouseWheelEvent e) {
    if (enabled && !readOnly) {
      if (timer != null && timer.isRunning()) {
        timer.stop();
      }
      if (enableMouseWheel) {
        int count = 1;
        MouseWheelEvent e2;

        long lastEventTime = e.getWhen();
        int steps = 0;
        int r;

        // This cycle is to determine multiple clicks like double wheel, triple wheel event etc.
        // We go through the vector of events and check whether there are events corresponding to
        // multiple events.
        for (int i = 0; i < events.size() && events.get(i) instanceof MouseWheelEvent; i++) {
          e2 = (MouseWheelEvent) events.get(i);

          // The events are considered to be a multiple click when:
          // 1. Coordinates are equal
          // 2. Modifiers are equal
          // 3. Both events are wheel up or down
          // 4. Delay between two subsequent clicks is lower than given number of miliseconds
          r = e2.getWheelRotation();
          if (e2.getX() == e.getX()
              && e2.getY() == e.getY()
              && e2.getModifiers() == e.getModifiers()
              && (lastEventTime - e2.getWhen() < mouseMultiDelay)
              && e2.getID() == e.getID()
              && ((r > 0 && e.getWheelRotation() > 0) || (r < 0 && e.getWheelRotation() < 0))) {
            count++;
            lastEventTime = e2.getWhen();
            steps += Math.abs(r);
          } else {
            break;
          }
        }

        steps += Math.abs(e.getWheelRotation());

        // Generate the command string
        String s =
            "Mouse "
                + (e.getWheelRotation() > 0
                    ? MouseCommand.MOUSE_WHEEL_DOWN
                    : MouseCommand.MOUSE_WHEEL_UP);

        // Insert modifiers if there are any
        String modifiers = parser.modifiersToString(e.getModifiers());
        if (modifiers.length() > 0) {
          s += " " + MouseCommand.PARAM_MODIFIER + "=" + modifiers;
        }

        // Generate the count parameter
        if (count > 1) {
          s += " " + MouseCommand.PARAM_COUNT + "=" + Math.abs(steps);
        }

        // This will determine whether this event is preceded by a mouse move command with the same
        // coordinates.
        // It will be replaced if yes.
        boolean replaceLastMove = false;
        if (enableMouseMoves) {
          if (events.size() > 0 && events.get(events.size() - 1) instanceof MouseEvent) {
            MouseEvent me = (MouseEvent) events.get(events.size() - 1);
            if (me.getID() == MouseEvent.MOUSE_MOVED
                && e.getX() == me.getX()
                && e.getY() == me.getY()) {
              replaceLastMove = true;
            }
          }
        }

        // Generate coordinates
        s += " " + MouseCommand.PARAM_TO + "=" + parser.pointToString(e.getPoint());

        // Insert the command to the current editor
        insertLine(s, count > 1 || replaceLastMove, true, false);
        dragInProgress = false;
      }
      insertEvent(e);
    }
  }
示例#10
0
文件: LJ3MDApp.java 项目: eskilj/mvp
  public void actionPerformed(ActionEvent e) {
    Object src = e.getSource();
    if (src == timer) {
      for (int i = 0; i < speed; i++) // integrate a few steps
      md.vv();
      repaint();
      return;
    }

    boolean adjCanvasScale = false;

    if (src == bTstat) md.thermostat = !md.thermostat;

    if (src == bPot) {
      md.ljPotential = !md.ljPotential;
      md.clearData();

      if (timer.isRunning()) timer.stop();
      bStart.setSelected(false);
      bStart.setText("Start");
      md.init(md.rho);
    }

    if (src == tTemp || src == bReset) {
      double kT = Double.parseDouble(tTemp.getText().trim());
      if (kT < 1e-8) {
        kT = 1e-8;
        tTemp.setText("  " + kT);
      }
      md.kT = kT;
      md.clearData();
    }

    if (src == tRho || src == bReset) {
      double rho = Double.parseDouble(tRho.getText().trim());
      if (rho < 1e-3) {
        rho = 1e-3;
        tRho.setText("   " + rho);
      }
      if (rho > 1.2) {
        rho = 1.2;
        tRho.setText("   " + rho);
      }
      md.setDensity(rho);
      md.clearData();
      adjCanvasScale = true;
    }

    if (src == tSpeed || src == bReset) {
      speed = Integer.parseInt(tSpeed.getText().trim());
      if (speed < 1) {
        speed = 1;
        tSpeed.setText("   " + speed);
      }
    }

    if (src == bRetime) md.clearData();

    if (src == bStart) {
      boolean on = bStart.isSelected();
      if (on) {
        timer.restart();
        bStart.setText("Pause");
      } else {
        timer.stop();
        bStart.setText("Resume");
      }
    }

    if (src == tNum) {
      int n = Integer.parseInt(tNum.getText().trim());
      if (n < 2) {
        n = 2;
        tNum.setText(" " + n);
      }
      md.N = n;
      md.init(md.rho);
      adjCanvasScale = true;
    }

    if (src == bReset) {
      if (timer.isRunning()) timer.stop();
      bStart.setSelected(false);
      bStart.setText("Start");
      md.init(md.rho);
    }

    canvas.refresh(md.getXWrap(), md.N, true, adjCanvasScale);

    repaint();
  }