Ejemplo n.º 1
0
 private void remove(int x, int y, Color c) {
   if (c.equals(Color.RED)) {
     numRedCheckers--;
   } else {
     numBlackCheckers--;
   }
 }
Ejemplo n.º 2
0
 /**
  * selectClickable -- a recursive function which searches the game board for game balls of the
  * same color as the one selected, and 'selects' them as well.
  */
 public void selectClickable(int m, int n) {
   Color home = balls[m][n].getColor();
   balls[m][n].select();
   scount += 1;
   if ((n - 1) >= 0) {
     Color north = balls[m][n - 1].getColor();
     if ((home.equals(north)) && !(balls[m][n - 1].isSelected())) selectClickable(m, (n - 1));
   }
   if ((m - 1) >= 0) {
     Color west = balls[m - 1][n].getColor();
     if ((home.equals(west)) && !(balls[m - 1][n].isSelected())) selectClickable((m - 1), n);
   }
   if ((n + 1) < B_HEIGHT) {
     Color south = balls[m][n + 1].getColor();
     if ((home.equals(south)) && !(balls[m][n + 1].isSelected())) selectClickable(m, (n + 1));
   }
   if ((m + 1) < B_WIDTH) {
     Color east = balls[m + 1][n].getColor();
     if ((home.equals(east)) && !(balls[m + 1][n].isSelected())) selectClickable((m + 1), n);
   }
 }
Ejemplo n.º 3
0
 // Overridden for performance reasons. ---->
 @Override
 public boolean isOpaque() {
   Color back = getBackground();
   Component p = getParent();
   if (Objects.nonNull(p)) {
     p = p.getParent();
   } // p should now be the JTable.
   boolean colorMatch =
       Objects.nonNull(back)
           && Objects.nonNull(p)
           && back.equals(p.getBackground())
           && p.isOpaque();
   return !colorMatch && super.isOpaque();
 }
Ejemplo n.º 4
0
  @Override
  public void colorChanged(Color color, Object source) {
    if (color != null && !color.equals(myColor)) {
      myColor = color;

      applyColor(color);

      if (source != myHex) {
        applyColorToHEX(color);
      }
      myPreviewComponent.setColor(color);
      fireColorChanged(color);
    }
  }
Ejemplo n.º 5
0
  private void updatePreview(Color color, boolean fromHex) {
    if (color != null && !color.equals(myColor)) {
      myColor = color;
      myPreviewComponent.setColor(color);
      myColorWheelPanel.setColor(color, fromHex ? myHex : null);

      if (fromHex) {
        applyColor(color);
      } else {
        applyColorToHEX(color);
      }

      fireColorChanged(color);
    }
  }
  /** {@inheritDoc} */
  public void setBackgroundColor(Color color) {
    if (color == null) {
      String message = Logging.getMessage("nullValue.ColorIsNull");
      Logging.logger().severe(message);
      throw new IllegalArgumentException(message);
    }

    // Only set the color if it actually changed
    if (!color.equals(this.getBackgroundColor())) {
      this.backgroundColor = color;

      // Convert the color to an RGB hex triplet string that the WebBrowser will understand
      int rgb =
          (color.getRed() & 0xFF) << 16 | (color.getGreen() & 0xFF) << 8 | (color.getBlue() & 0xFF);
      String colorString = String.format("#%06X", rgb);

      WindowsWebViewJNI.setBackgroundColor(this.webViewWindowPtr, colorString);
    }
  }
Ejemplo n.º 7
0
 private boolean canDoubleJump(GameObj obj) {
   doubleJumpSpots = new ArrayList<Tuple<Integer, Integer>>();
   if (obj.isTile()) {
     return false;
   }
   int x = obj.getX();
   int y = obj.getY();
   if (obj.isQueen()) {
     return doubleJumpProcess(obj, x + 2, y + 2)
         || doubleJumpProcess(obj, x - 2, y + 2)
         || doubleJumpProcess(obj, x + 2, y - 2)
         || doubleJumpProcess(obj, x - 2, y - 2);
   } else {
     if (turn.equals(Color.RED)) {
       return doubleJumpProcess(obj, x + 2, y - 2) || doubleJumpProcess(obj, x - 2, y - 2);
     } else {
       return doubleJumpProcess(obj, x + 2, y + 2) || doubleJumpProcess(obj, x - 2, y + 2);
     }
   }
 }
Ejemplo n.º 8
0
    private void updatePipette() {
      Dialog pickerDialog = getPickerDialog();
      if (pickerDialog != null && pickerDialog.isShowing()) {
        Point mouseLoc = updateLocation();
        if (mouseLoc == null) return;
        final Color c = getPixelColor(mouseLoc);
        if (!c.equals(getColor()) || !mouseLoc.equals(myPreviousLocation)) {
          setColor(c);
          myPreviousLocation.setLocation(mouseLoc);
          myCaptureRect.setBounds(
              mouseLoc.x - HOT_SPOT.x + SIZE / 2 - 2, mouseLoc.y - HOT_SPOT.y + SIZE / 2 - 2, 5, 5);

          BufferedImage capture = myRobot.createScreenCapture(myCaptureRect);

          // Clear the cursor graphics
          myGraphics.setComposite(AlphaComposite.Src);
          myGraphics.setColor(UIUtil.TRANSPARENT_COLOR);
          myGraphics.fillRect(0, 0, myImage.getWidth(), myImage.getHeight());

          myGraphics.drawImage(
              capture, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);

          // cropping round image
          myGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OUT));
          myGraphics.drawImage(
              myMaskImage, myZoomRect.x, myZoomRect.y, myZoomRect.width, myZoomRect.height, this);

          // paint magnifier
          myGraphics.setComposite(AlphaComposite.SrcOver);

          UIUtil.drawImage(
              myGraphics, myPipetteImage, SIZE - AllIcons.Ide.Pipette.getIconWidth(), 0, this);

          pickerDialog.setCursor(
              myParent.getToolkit().createCustomCursor(myImage, HOT_SPOT, "ColorPicker"));
          notifyListener(c, 300);
        }
      }
    }