Ejemplo n.º 1
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);
        }
      }
    }
 @Override
 protected void paintComponent(Graphics g) {
   Insets insets = getInsets();
   UIUtil.drawImage(g, myImage, insets.left, insets.top, null);
 }
Ejemplo n.º 3
0
 public final void paint(final Graphics g) {
   final Rectangle bounds = getBounds();
   if (myAnchor == ToolWindowAnchor.LEFT) {
     if (myDirection == 1) {
       g.setClip(null);
       g.clipRect(myOffset, 0, bounds.width - myOffset, bounds.height);
       UIUtil.drawImage(g, myBottomImage, 0, 0, null);
       g.setClip(null);
       g.clipRect(0, 0, myOffset, bounds.height);
       UIUtil.drawImage(g, myTopImage, myOffset - bounds.width, 0, null);
     } else {
       g.setClip(null);
       g.clipRect(bounds.width - myOffset, 0, myOffset, bounds.height);
       UIUtil.drawImage(g, myBottomImage, 0, 0, null);
       g.setClip(null);
       g.clipRect(0, 0, bounds.width - myOffset, bounds.height);
       UIUtil.drawImage(g, myTopImage, -myOffset, 0, null);
     }
     myTopImage.flush();
   } else if (myAnchor == ToolWindowAnchor.RIGHT) {
     if (myDirection == 1) {
       g.setClip(null);
       g.clipRect(0, 0, bounds.width - myOffset, bounds.height);
       UIUtil.drawImage(g, myBottomImage, 0, 0, null);
       g.setClip(null);
       g.clipRect(bounds.width - myOffset, 0, myOffset, bounds.height);
       UIUtil.drawImage(g, myTopImage, bounds.width - myOffset, 0, null);
     } else {
       g.setClip(null);
       g.clipRect(0, 0, myOffset, bounds.height);
       UIUtil.drawImage(g, myBottomImage, 0, 0, null);
       g.setClip(null);
       g.clipRect(myOffset, 0, bounds.width - myOffset, bounds.height);
       UIUtil.drawImage(g, myTopImage, myOffset, 0, null);
     }
   } else if (myAnchor == ToolWindowAnchor.TOP) {
     if (myDirection == 1) {
       g.setClip(null);
       g.clipRect(0, myOffset, bounds.width, bounds.height - myOffset);
       UIUtil.drawImage(g, myBottomImage, 0, 0, null);
       g.setClip(null);
       g.clipRect(0, 0, bounds.width, myOffset);
       UIUtil.drawImage(g, myTopImage, 0, -bounds.height + myOffset, null);
     } else {
       g.setClip(null);
       g.clipRect(0, bounds.height - myOffset, bounds.width, myOffset);
       UIUtil.drawImage(g, myBottomImage, 0, 0, null);
       g.setClip(null);
       g.clipRect(0, 0, bounds.width, bounds.height - myOffset);
       UIUtil.drawImage(g, myTopImage, 0, -myOffset, null);
     }
   } else if (myAnchor == ToolWindowAnchor.BOTTOM) {
     if (myDirection == 1) {
       g.setClip(null);
       g.clipRect(0, 0, bounds.width, bounds.height - myOffset);
       UIUtil.drawImage(g, myBottomImage, 0, 0, null);
       g.setClip(null);
       g.clipRect(0, bounds.height - myOffset, bounds.width, myOffset);
       UIUtil.drawImage(g, myTopImage, 0, bounds.height - myOffset, null);
     } else {
       g.setClip(null);
       g.clipRect(0, 0, bounds.width, myOffset);
       UIUtil.drawImage(g, myBottomImage, 0, 0, null);
       g.setClip(null);
       g.clipRect(0, myOffset, bounds.width, bounds.height - myOffset);
       UIUtil.drawImage(g, myTopImage, 0, myOffset, null);
     }
   }
 }