コード例 #1
0
ファイル: Screen.java プロジェクト: Baefulwrath/RPG_Society
 public void paint(Graphics g) {
   try {
     Graphics2D g2d = (Graphics2D) g;
     g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
     g2d.setColor(Color.BLACK);
     g2d.fill(new Rectangle2D.Float(0, 0, getWidth(), getHeight()));
     drawWorld(g2d, Main.world);
     g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f));
     g2d.setColor(Color.BLUE);
     g2d.drawRect(
         Main.brush.getR().x,
         Main.brush.getR().y,
         Main.brush.getR().width,
         Main.brush.getR().height);
     g2d.setColor(Color.DARK_GRAY);
     g2d.fill(new Rectangle2D.Float(getWidth() - 200, 0, 200, getHeight()));
     g2d.setColor(Color.LIGHT_GRAY);
     g2d.fill(new Rectangle2D.Float(getWidth() - 200, 0, 5, getHeight()));
     g2d.drawImage(Assets.getTileImage(Main.brush.type), getWidth() - 170, 60, 32, 32, null);
     for (int i = 0; i < Main.infoBoxes.size(); i++) {
       drawInfoBox(g2d, Main.infoBoxes.get(i));
     }
     for (int i = 0; i < Main.buttons.size(); i++) {
       drawButton(g2d, Main.buttons.get(i));
     }
     g2d.drawImage(Assets.overlay, 0, 0, getWidth(), getHeight(), null);
   } catch (Exception ex) {
     // ex.printStackTrace();
   }
 }
コード例 #2
0
  @Override
  public void paintComponent(Graphics graphics) {
    super.paintComponent(graphics);
    //		 painting only if approved
    if (show) {
      // init graphics
      Graphics2D g = (Graphics2D) graphics;

      int pixWidth = getWidth() - 2 * MARGIN;
      int pixHeight = getHeight() - 2 * MARGIN;

      // painting background
      g.drawImage(this.image, MARGIN, MARGIN, pixWidth, pixHeight, Color.WHITE, null);

      // painting transparent class overlay
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alphaLevel));
      g.drawImage(this.classImage, MARGIN, MARGIN, pixWidth, pixHeight, Color.WHITE, null);
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
      // painting points
      drawPoints(g);

      // painting Legend
      drawLegend(graphics, this.dataTable, colorColumn);

      // paint Tooltip
      drawToolTip((Graphics2D) graphics);
    }
  }
コード例 #3
0
ファイル: BlendComposite.java プロジェクト: svn2github/icepdf
 // todo consider composite cache.
 public static Composite getInstance(Name modeName, float alpha) {
   // check for -1, value not set and default should be used.
   if (alpha == -1) {
     alpha = 1;
   }
   if (modeName.equals(NORMAL_VALUE) || modeName.equals(COMPATIBLE_VALUE)) {
     return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
     //            return new BlendComposite(BlendingMode.NORMAL, alpha);
   } else if (modeName.equals(MULTIPLY_VALUE)) {
     return new BlendComposite(BlendingMode.MULTIPLY, alpha);
   } else if (modeName.equals(SCREEN_VALUE)) {
     return new BlendComposite(BlendingMode.SCREEN, alpha);
   } else if (modeName.equals(OVERLAY_VALUE)) {
     return new BlendComposite(BlendingMode.OVERLAY, alpha);
   } else if (modeName.equals(DARKEN_VALUE)) {
     return new BlendComposite(BlendingMode.DARKEN, alpha);
   } else if (modeName.equals(LIGHTEN_VALUE)) {
     return new BlendComposite(BlendingMode.LIGHTEN, alpha);
   } else if (modeName.equals(COLOR_DODGE_VALUE)) {
     return new BlendComposite(BlendingMode.SOFT_DODGE, alpha);
   } else if (modeName.equals(COLOR_BURN_VALUE)) {
     return new BlendComposite(BlendingMode.SOFT_BURN, alpha);
   } else if (modeName.equals(HARD_LIGHT_VALUE)) {
     return new BlendComposite(BlendingMode.HARD_LIGHT, alpha);
   } else if (modeName.equals(SOFT_LIGHT_VALUE)) {
     return new BlendComposite(BlendingMode.SOFT_LIGHT, alpha);
   } else if (modeName.equals(DIFFERENCE_VALUE)) {
     return new BlendComposite(BlendingMode.DIFFERENCE, alpha);
   } else if (modeName.equals(EXCLUSION_VALUE)) {
     return new BlendComposite(BlendingMode.EXCLUSION, alpha);
   }
   //        return new BlendComposite(BlendingMode.NORMAL, alpha);
   return AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
 }
コード例 #4
0
  @Override
  public void nextFrame(long time) {
    // TODO Auto-generated method stub

    // draw
    Graphics2D g2d = getImage().createGraphics();
    // fill with black
    g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 1.0f));
    g2d.setColor(Color.BLACK);
    g2d.fillRect(0, 0, getImage().getWidth(), getImage().getHeight());

    g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, thisAlpha));
    // g2d.setColor(c);

    // this.setImage(textImage);
    g2d.drawImage(textImage, 0, 0, null);

    // some hacky math here to get a hold and then fast fade
    thisAlpha = 1.5f - (float) deathTimer.percentDone() * 1.5f;
    // thisAlpha = thisAlpha - .005f;
    // System.out.println(deathTimer.timeElapsed());

    // thisAlpha = 1.0f;

    if (thisAlpha <= 0) {
      kill();
    } else if (thisAlpha > 1.0f) {
      thisAlpha = 1.0f;
    }

    if (deathTimer.isDone()) {
      kill();
    }
  }
コード例 #5
0
ファイル: Page.java プロジェクト: palary18/openblocks
  /** renders this JComponent */
  @Override
  public void paintComponent(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    // paint page
    super.paintComponent(g);
    // set label color
    if (this.getBackground().getBlue()
            + this.getBackground().getGreen()
            + this.getBackground().getRed()
        > 400) {
      g.setColor(Color.DARK_GRAY);
    } else {
      g.setColor(Color.LIGHT_GRAY);
    }

    // paint label at correct position
    if (fullview) {
      int xpos =
          (int)
              (this.getWidth() * 0.5
                  - g.getFontMetrics().getStringBounds(this.getName(), g).getCenterX());
      g.drawString(this.getName(), xpos, getHeight() / 2);
      g.drawString(this.getName(), xpos, getHeight() / 4);
      g.drawString(this.getName(), xpos, getHeight() * 3 / 4);

      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.33F));
      int imageX = (int) (this.getWidth() / 2 - IMAGE_WIDTH / 2 * Page.zoom);
      int imageWidth = (int) (IMAGE_WIDTH * Page.zoom);
      g.drawImage(this.getImage(), imageX, getHeight() / 2 + 5, imageWidth, imageWidth, null);
      g.drawImage(this.getImage(), imageX, getHeight() / 4 + 5, imageWidth, imageWidth, null);
      g.drawImage(this.getImage(), imageX, getHeight() * 3 / 4 + 5, imageWidth, imageWidth, null);
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
    }
  }
コード例 #6
0
ファイル: ModelViewScreen.java プロジェクト: nullx002/oripa
  // Scaling relative to the center of the screen
  @Override
  public void paintComponent(Graphics g) {
    super.paintComponent(g);

    if (bufferImage == null) {
      bufferImage = createImage(getWidth(), getHeight());
      bufferg = (Graphics2D) bufferImage.getGraphics();

      updateAffineTransform();
      preSize = getSize();
    }
    bufferg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    bufferg.setTransform(new AffineTransform());
    bufferg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
    bufferg.setColor(Color.WHITE);
    bufferg.fillRect(0, 0, getWidth(), getHeight());

    bufferg.setTransform(affineTransform);

    Graphics2D g2d = bufferg;

    if (ORIPA.doc.hasModel) {
      g2d.setStroke(Config.STROKE_CUT);
      if (Globals.modelDispMode == Constants.ModelDispMode.FILL_ALPHA) {
        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f));
      }
      drawModel(g2d);
      g.drawImage(bufferImage, 0, 0, this);
    }
  }
コード例 #7
0
 protected void drawImageMosaic(Graphics2D g2) {
   // Break the image up into tiles. Draw each
   //   tile with its own transparency, allowing
   //   the background to show through to varying
   //   degrees.
   int side = 36;
   int width = mImage.getWidth();
   int height = mImage.getHeight();
   for (int y = 0; y < height; y += side) {
     for (int x = 0; x < width; x += side) {
       // Calculate an appropriate transparency value.
       float xBias = (float) x / (float) width;
       float yBias = (float) y / (float) height;
       float alpha = 1.0f - Math.abs(xBias - yBias);
       g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
       // Draw the subimage.
       int w = Math.min(side, width - x);
       int h = Math.min(side, height - y);
       BufferedImage tile = mImage.getSubimage(x, y, w, h);
       g2.drawImage(tile, x, y, null);
     }
   }
   // Reset the composite.
   g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
 }
コード例 #8
0
/**
 * Graphics constants.
 *
 * @author David Underhill
 */
public abstract class Constants {
  public static final Color cmap(Color c) {
    if (!Options.USE_LIGHT_COLOR_SCHEME)
      return new Color(255 - c.getRed(), 255 - c.getGreen(), 255 - c.getBlue(), c.getAlpha());
    else return c;
  }

  public static final BasicStroke STROKE_DEFAULT =
      new BasicStroke(1.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
  public static final BasicStroke STROKE_THICK =
      new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER);
  public static final Color COLOR_DEFAULT = cmap(Color.BLACK);
  public static final Color BG_DEFAULT = cmap(Color.WHITE);
  public static final Color COLOR_SELECTED = cmap(new Color(128, 255, 128));
  public static final Color COLOR_HOVERING = cmap(new Color(255, 255, 128));
  public static final Paint PAINT_DEFAULT = COLOR_DEFAULT;
  public static final Font FONT_DEFAULT = new Font("Tahoma", Font.BOLD, 14);
  public static final Font FONT_TI = new Font("Tahoma", Font.BOLD, 44);
  public static final Color FONT_TI_FILL = cmap(Color.GRAY);
  public static final Color FONT_TI_OUTLINE = cmap(Color.BLACK);
  public static final Composite COMPOSITE_OPAQUE =
      AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f);
  public static final Composite COMPOSITE_HALF =
      AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
  public static final Composite COMPOSITE_QUARTER =
      AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.25f);
}
コード例 #9
0
  @Override
  public final void paint(Graphics g) {

    super.paint(g);
    Graphics2D g2 = (Graphics2D) g;
    Composite old = g2.getComposite(); // Store non-transparent composite

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f)); // 40% transparency
    g2.drawRect(0, 0, getWidth() - 1, getHeight() - 1);

    Font drawFont = g2.getFont();
    g2.setFont(notificationFont);
    adaptDimensions();

    int textX = 5;
    int textY = (getHeight() / 2 + 3);
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.7f)); // 70% transparency
    g2.drawString(message, textX, textY);

    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.05f)); // 5% transparency
    g2.setColor(java.awt.Color.blue);
    g2.fillRect(0, 0, this.getWidth() - 1, this.getHeight() - 1);
    g2.setComposite(old);
    g2.setFont(drawFont);
  }
コード例 #10
0
ファイル: LayerManager.java プロジェクト: denisefan28/Wind
 private void paintBackground(WmsRequest request, Graphics2D g) {
   g.setColor(request.getBackgroundColor());
   g.setBackground(request.getBackgroundColor());
   if (request.isTransparent()) g.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR));
   else g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.0f));
   g.fillRect(0, 0, 100, 100);
   g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
 }
コード例 #11
0
  @Override
  protected BufferedImage renderOffscreen() {
    BufferedImage bimage = null;

    if (getOrientation() == SwingConstants.HORIZONTAL) {

      bimage = new BufferedImage(DEFAULT_WIDTH, 10, BufferedImage.TYPE_4BYTE_ABGR);
      Graphics2D g2d = bimage.createGraphics();
      int ncolors = colorMap.getMapSize();
      double distance = colorMap.getMaximumValue() - colorMap.getMinimumValue();

      double start = colorMap.getMinimumValue();

      for (int i = 0; i < ncolors; i++) {
        ColorInterval ci = colorMap.getInterval(i);
        double size = ((ci.getMaximum() - ci.getMinimum()) / distance);
        double xpos = (ci.getMinimum() - start) / distance;

        Rectangle2D rect =
            new Rectangle2D.Double(xpos * DEFAULT_WIDTH, 0, size * DEFAULT_WIDTH, 10);
        float trans = (float) ci.getAlpha();

        AlphaComposite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, trans / 255f);

        g2d.setComposite(comp);
        g2d.setPaint(ci.getColor());
        g2d.fill(rect);
      }
    } else {
      bimage = new BufferedImage(10, DEFAULT_HEIGHT, BufferedImage.TYPE_4BYTE_ABGR);
      int ncolors = colorMap.getMapSize();
      double distance = colorMap.getMaximumValue() - colorMap.getMinimumValue();
      double start = colorMap.getMinimumValue();

      Graphics2D g2d = bimage.createGraphics();
      for (int i = 0; i < ncolors; i++) {
        ColorInterval ci = colorMap.getInterval(i);
        double size = ((ci.getMaximum() - ci.getMinimum()) / distance);
        double ypos = (ci.getMinimum() - start) / distance;

        Rectangle2D rect =
            new Rectangle2D.Double(0, ypos * DEFAULT_HEIGHT, 10, size * DEFAULT_HEIGHT);
        float trans = (float) ci.getAlpha();

        AlphaComposite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, trans / 255f);

        g2d.setComposite(comp);
        g2d.setPaint(ci.getColor());
        g2d.fill(rect);
      }
    }

    cachedImage = bimage;
    return cachedImage;
  }
コード例 #12
0
ファイル: Gutachten.java プロジェクト: jannyp/thera-pi-2
 GutachtenPanel() {
   super();
   setOpaque(false);
   hgicon = SystemConfig.hmSysIcons.get("historie");
   // hgicon = new ImageIcon(Reha.proghome+"icons/ChipKarte.png");
   // hgicon = new ImageIcon(Reha.proghome+"icons/Chip.png");
   icx = hgicon.getIconWidth() / 2;
   icy = hgicon.getIconHeight() / 2;
   xac1 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.075f);
   xac2 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f);
 }
コード例 #13
0
ファイル: GraphicsUtil.java プロジェクト: adufour/Icy-Kernel
  public static void mixAlpha(Graphics2D g, int rule, float factor) {
    final Composite composite = g.getComposite();

    if (composite instanceof AlphaComposite) {
      final AlphaComposite alphaComposite = (AlphaComposite) composite;
      final float alpha = Math.min(1f, Math.max(0f, alphaComposite.getAlpha() * factor));

      if (rule == 0) g.setComposite(AlphaComposite.getInstance(alphaComposite.getRule(), alpha));
      else g.setComposite(AlphaComposite.getInstance(rule, alpha));
    }
  }
コード例 #14
0
ファイル: Explosion.java プロジェクト: androidTD/androidTD
  @Override
  public void dessiner(Graphics2D g2) {
    // style
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));

    // dessin
    g2.drawImage(EXPLOSION[indiceAnim], x, y, null);

    // retabli la transparence
    g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.f));
  }
コード例 #15
0
ファイル: Texto.java プロジェクト: pdtfilho/MortalSurvivor
  @Override
  public void DesenhaSe(Graphics2D dbg, int XMundo, int YMundo) {
    // TODO Auto-generated method stub

    Font oldfont = dbg.getFont();

    dbg.setFont(big);
    if (tipo == 1) {
      dbg.setFont(big);
      dbg.setColor(Color.black);

      dbg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
      dbg.drawString("+" + xp + " XP ", (int) getX() - XMundo, (int) getY() - YMundo);

      dbg.setColor(Color.yellow);

      dbg.drawString("+" + xp + " XP ", (int) getX() - 2 - XMundo, (int) getY() - 2 - YMundo);
      dbg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
    }

    //			if (tipo==2) {
    //
    //
    //				dbg.setColor(Color.red);
    //			    dbg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
    //
    //				dbg.drawString("+Level UP "+GamePanel.minhaNave.nivel, (int)X, (int)Y);
    //
    //				dbg.setColor(Color.yellow);
    //
    //				dbg.drawString("+Level UP "+GamePanel.minhaNave.nivel, (int)X-5, (int)Y-5);
    //			    dbg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
    //
    //
    //		}

    if (tipo == 3) {

      dbg.setColor(Color.DARK_GRAY);

      dbg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
      dbg.drawString("+" + (int) getLife() + " life ", (int) getX(), (int) getY());

      dbg.setColor(Color.green);

      dbg.drawString("+" + (int) getLife() + " life ", (int) getX() - 3, (int) getY() - 3);
      dbg.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1));
      System.out.println(alpha);
    }

    dbg.setFont(oldfont);
  }
コード例 #16
0
 @Override
 public void paintBorder(Graphics g, Component c, CssShape shape) {
   Graphics2D g2 = (Graphics2D) g.create();
   if (source != null) {
     g2.setComposite(AlphaComposite.getInstance(AlphaComposite.DST_OVER, transition));
     source.paintBorder(g2, c, shape);
   }
   if (target != null) {
     g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, transition));
     target.paintBorder(g2, c, shape);
   }
   g2.dispose();
 }
コード例 #17
0
ファイル: GlancePanel.java プロジェクト: Natinux/CodeGlance
  private void paintVisibleWindow(Graphics2D g) {
    Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
    int firstVisibleLine = getMapYFromEditorY((int) visibleArea.getMinY());
    int height =
        coords.linesToPixels(
            (int) ((visibleArea.getMaxY() - visibleArea.getMinY()) / editor.getLineHeight()));

    // Draw the current viewport
    g.setColor(viewportColor);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.50f));
    g.drawRect(0, firstVisibleLine, getWidth(), height);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.20f));
    g.fillRect(0, firstVisibleLine, getWidth(), height);
  }
コード例 #18
0
    @Override
    protected void paintComponent(Graphics g) {
      Graphics2D g2d = (Graphics2D) g;

      final Dimension size = getSize();
      int _size = Math.min(size.width, size.height);
      _size = Math.min(_size, 600);

      if (myImage != null && myShouldInvalidate) {
        if (myImage.getWidth(null) != _size) {
          myImage = null;
        }
      }

      myShouldInvalidate = false;

      if (myImage == null) {
        myImage =
            createImage(
                new ColorWheelImageProducer(
                    _size - BORDER_SIZE * 2, _size - BORDER_SIZE * 2, myBrightness));
        myWheel =
            new Rectangle(
                BORDER_SIZE, BORDER_SIZE, _size - BORDER_SIZE * 2, _size - BORDER_SIZE * 2);
      }

      g.setColor(UIManager.getColor("Panel.background"));
      g.fillRect(0, 0, getWidth(), getHeight());

      g2d.setComposite(
          AlphaComposite.getInstance(AlphaComposite.SRC_OVER, ((float) myOpacity) / 255f));
      g.drawImage(myImage, myWheel.x, myWheel.y, null);

      g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f));

      int mx = myWheel.x + myWheel.width / 2;
      int my = myWheel.y + myWheel.height / 2;
      //noinspection UseJBColor
      g.setColor(Color.WHITE);
      int arcw = (int) (myWheel.width * mySaturation / 2);
      int arch = (int) (myWheel.height * mySaturation / 2);
      double th = myHue * 2 * Math.PI;
      final int x = (int) (mx + arcw * Math.cos(th));
      final int y = (int) (my - arch * Math.sin(th));
      g.fillRect(x - 2, y - 2, 4, 4);
      //noinspection UseJBColor
      g.setColor(Color.BLACK);
      g.drawRect(x - 2, y - 2, 4, 4);
    }
コード例 #19
0
ファイル: BoardView.java プロジェクト: OpenJML/OpenJML
  @Override
  public void paint(Graphics g) {

    if (g instanceof Graphics2D)
      ((Graphics2D) g)
          .setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    final Color evenColor = new Color(0xfece9e);
    final Color oddColor = new Color(0xd08c47);

    for (int y = 0; y < Board.height; y++) {
      for (int x = 0; x < Board.width; x++) {
        if (((x ^ y) & 1) == 0) g.setColor(evenColor);
        else g.setColor(oddColor);

        g.fillRect(x * 32, y * 32, 32, 32);
      }
    }

    for (int y = 0; y < Board.height; y++) {
      for (int x = 0; x < Board.width; x++) {
        if (currentMove == null || currentMove.piece.x != x || currentMove.piece.y != y)
          drawPiece(g, x * 32, y * 32, board.get(x, y));
      }
    }

    if (currentMove != null) {

      if (g instanceof Graphics2D) {

        ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));

        if (currentMove.possibleMoves != null)
          for (Move m : currentMove.possibleMoves) {
            drawPiece(
                g, m.p1.x * 32, m.p1.y * 32, board.get(currentMove.piece.x, currentMove.piece.y));
          }

        ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
      }

      drawPiece(
          g,
          currentMove.position.x + currentMove.offset.x,
          currentMove.position.y + currentMove.offset.y,
          board.get(currentMove.piece.x, currentMove.piece.y));
    }
  }
コード例 #20
0
ファイル: BaseSliderUI.java プロジェクト: recon88/Botnak
 public void paintThumb(Graphics g) {
   Icon icon = null;
   if (slider.getOrientation() == JSlider.HORIZONTAL) {
     if (isRollover && slider.isEnabled()) {
       icon = getThumbHorIconRollover();
     } else {
       icon = getThumbHorIcon();
     }
   } else {
     if (isRollover && slider.isEnabled()) {
       icon = getThumbVerIconRollover();
     } else {
       icon = getThumbVerIcon();
     }
   }
   Graphics2D g2D = (Graphics2D) g;
   Composite savedComposite = g2D.getComposite();
   if (!slider.isEnabled()) {
     g.setColor(AbstractLookAndFeel.getBackgroundColor());
     g.fillRect(thumbRect.x + 1, thumbRect.y + 1, thumbRect.width - 2, thumbRect.height - 2);
     AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
     g2D.setComposite(alpha);
   }
   icon.paintIcon(null, g, thumbRect.x, thumbRect.y);
   g2D.setComposite(savedComposite);
 }
コード例 #21
0
 public void paintBorder(Component c, Graphics g, int x, int y, int w, int h) {
   if (((JToolBar) c).isFloatable()) {
     Graphics2D g2D = (Graphics2D) g;
     Composite savedComposite = g2D.getComposite();
     AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
     g2D.setComposite(alpha);
     if (((JToolBar) c).getOrientation() == HORIZONTAL) {
       if (!JTattooUtilities.isLeftToRight(c)) {
         x += w - 15;
       }
       g.setColor(Color.white);
       g.drawLine(x + 3, y + 4, x + 3, h - 5);
       g.drawLine(x + 6, y + 3, x + 6, h - 4);
       g.drawLine(x + 9, y + 4, x + 9, h - 5);
       g.setColor(shadow);
       g.drawLine(x + 4, y + 4, x + 4, h - 5);
       g.drawLine(x + 7, y + 3, x + 7, h - 4);
       g.drawLine(x + 10, y + 4, x + 10, h - 5);
     } else {
       // vertical
       g.setColor(Color.white);
       g.drawLine(x + 3, y + 3, w - 4, y + 3);
       g.drawLine(x + 3, y + 6, w - 4, y + 6);
       g.drawLine(x + 3, y + 9, w - 4, y + 9);
       g.setColor(shadow);
       g.drawLine(x + 3, y + 4, w - 4, y + 4);
       g.drawLine(x + 3, y + 7, w - 4, y + 7);
       g.drawLine(x + 3, y + 10, w - 4, y + 10);
     }
     g2D.setComposite(savedComposite);
   }
 }
コード例 #22
0
    @Override
    public void paintIcon(final Component component, final Graphics g, final int i, final int j) {
      final int iconWidth = getIconWidth();
      final int iconHeight = getIconHeight();
      if (myColor != null) {
        g.setColor(myColor);
        g.fillRect(i, j, iconWidth, iconHeight);
      } else if (myColours != null) {
        final Color top = myColours[0];
        g.setColor(top);
        g.fillRect(i, j, iconWidth, 2);

        final Color right = myColours[1];
        g.setColor(right);
        g.fillRect(i + iconWidth / 2, j + 2, iconWidth / 2, iconHeight / 2);

        final Color bottom = myColours[2];
        g.setColor(bottom);
        g.fillRect(i, j + iconHeight - 2, iconWidth, 2);

        final Color left = myColours[3];
        g.setColor(left);
        g.fillRect(i, j + 2, iconWidth / 2, iconHeight / 2);
      }

      final Composite old = ((Graphics2D) g).getComposite();
      ((Graphics2D) g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.1f));
      g.setColor(Color.BLACK);
      g.drawRect(i, j, iconWidth - 1, iconHeight - 1);
      ((Graphics2D) g).setComposite(old);
    }
コード例 #23
0
  private void drawShape(Shuttle shuttle) {
    Graphics2D g = shuttle.g;
    Shape oldclip = shuttle.g.getClip();
    g.setClip(shuttle.clip);
    Composite oldcomposite = g.getComposite();
    if (shuttle.opacity != 1f) {
      g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, shuttle.opacity));
    }

    AffineTransform oldtr = g.getTransform();
    g.setTransform(shuttle.transform);

    Stroke oldStroke = g.getStroke();
    Stroke newStroke =
        new BasicStroke(shuttle.strokeWidth, shuttle.linecap.stroke(), shuttle.linejoin.stroke());
    g.setStroke(newStroke);

    if (shuttle.fill != null) {
      g.setPaint(shuttle.fill);
      g.fill(shuttle.shape);
    }
    if (shuttle.stroke != null) {
      g.setPaint(shuttle.stroke);
      g.draw(shuttle.shape);
    }
    g.setClip(oldclip);
    g.setStroke(oldStroke);
    g.setTransform(oldtr);
    g.setComposite(oldcomposite);
  }
コード例 #24
0
ファイル: BaseMenuUI.java プロジェクト: JanOveSaltvedt/kbot
 protected void paintBackground(Graphics g, JComponent c, int x, int y, int w, int h) {
   JMenuItem b = (JMenuItem) c;
   ButtonModel model = b.getModel();
   if (c.getParent() instanceof JMenuBar) {
     if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
       g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor());
       g.fillRect(x, y, w, h);
     }
   } else {
     if (model.isArmed() || (c instanceof JMenu && model.isSelected())) {
       g.setColor(AbstractLookAndFeel.getMenuSelectionBackgroundColor());
       g.fillRect(x, y, w, h);
     } else if (!AbstractLookAndFeel.getTheme().isMenuOpaque()) {
       Graphics2D g2D = (Graphics2D) g;
       Composite composite = g2D.getComposite();
       AlphaComposite alpha =
           AlphaComposite.getInstance(
               AlphaComposite.SRC_OVER, AbstractLookAndFeel.getTheme().getMenuAlpha());
       g2D.setComposite(alpha);
       g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
       g.fillRect(x, y, w, h);
       g2D.setComposite(composite);
     } else {
       g.setColor(AbstractLookAndFeel.getMenuBackgroundColor());
       g.fillRect(x, y, w, h);
     }
   }
   if (menuItem.isSelected() && menuItem.isArmed()) {
     g.setColor(AbstractLookAndFeel.getMenuSelectionForegroundColor());
   } else {
     g.setColor(AbstractLookAndFeel.getMenuForegroundColor());
   }
 }
コード例 #25
0
ファイル: SWTGraphics2D.java プロジェクト: asig/kidpython
 /**
  * Creates a new instance.
  *
  * @param gc the graphics context.
  */
 public SWTGraphics2D(GC gc) {
   super();
   this.gc = gc;
   this.hints = new RenderingHints(null);
   this.composite = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f);
   setStroke(new BasicStroke());
 }
コード例 #26
0
  private boolean evaluateComposite() {
    final Expression opacity = styleElement.getOpacity();

    if (GO2Utilities.isStatic(opacity)) {
      float j2dOpacity = GO2Utilities.evaluate(opacity, null, 1f, 0f, 1f);

      // we return false, opacity is 0 no need to cache or draw anything
      if (j2dOpacity == 0) {
        isStaticVisible = VisibilityState.UNVISIBLE;
        return false;
      }

      // this style is visible
      if (isStaticVisible == VisibilityState.NOT_DEFINED) isStaticVisible = VisibilityState.VISIBLE;

      // we cache the composite
      cachedComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, j2dOpacity);
    } else {
      // this style visibility is dynamic
      if (isStaticVisible != VisibilityState.UNVISIBLE) isStaticVisible = VisibilityState.DYNAMIC;
      isStatic = false;
      GO2Utilities.getRequieredAttributsName(opacity, requieredAttributs);
    }

    return true;
  }
コード例 #27
0
ファイル: MarkerAxisBand.java プロジェクト: bruno-sales/PCS
  /**
   * Draws the band.
   *
   * @param g2 the graphics device.
   * @param plotArea the plot area.
   * @param dataArea the data area.
   * @param x the x-coordinate.
   * @param y the y-coordinate.
   */
  public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, double x, double y) {

    double h = getHeight(g2);
    Iterator iterator = this.markers.iterator();
    while (iterator.hasNext()) {
      IntervalMarker marker = (IntervalMarker) iterator.next();
      double start = Math.max(marker.getStartValue(), this.axis.getRange().getLowerBound());
      double end = Math.min(marker.getEndValue(), this.axis.getRange().getUpperBound());
      double s = this.axis.valueToJava2D(start, dataArea, RectangleEdge.BOTTOM);
      double e = this.axis.valueToJava2D(end, dataArea, RectangleEdge.BOTTOM);
      Rectangle2D r =
          new Rectangle2D.Double(
              s, y + this.topOuterGap, e - s, h - this.topOuterGap - this.bottomOuterGap);

      Composite originalComposite = g2.getComposite();
      g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, marker.getAlpha()));
      g2.setPaint(marker.getPaint());
      g2.fill(r);
      g2.setPaint(marker.getOutlinePaint());
      g2.draw(r);
      g2.setComposite(originalComposite);

      g2.setPaint(Color.black);
      drawStringInRect(g2, r, this.font, marker.getLabel());
    }
  }
コード例 #28
0
ファイル: MenuUtils.java プロジェクト: javasparx/PhyloUz
  public static synchronized void drawDoubleGradientRect(
      MenuItem item, float x, float y, float width, float height) {
    PGraphicsJava2D buff = item.menu.buff;
    MenuStyle style = item.getStyle();
    Menu menu = item.menu;

    float ro = style.getF("f.roundOff");

    roundRect.setRoundRect(x, y, width, height, ro, ro);

    /*
     * Draw the first gradient: a full-height gradient.
     */
    buff.g2.setPaint(style.getGradient(MenuItem.UP, x, y, x, y + height));
    buff.g2.fill(roundRect);
    /*
     * Draw a translucent gradient on top of the first, starting halfway and
     * going to the bottom.
     */
    Composite oldC = buff.g2.getComposite();
    AlphaComposite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f * menu.alpha);
    buff.g2.setComposite(c);
    buff.g2.setPaint(style.getGradient(MenuItem.UP, x, y + height, x, y + height / 3));
    buff.g2.fillRect((int) x, (int) (y + height / 2), (int) width, (int) height / 2);
    buff.g2.setComposite(oldC);
    /*
     * Finally, draw the stroke on top of everything.
     */
    drawRoundOutline(item, roundRect);
  }
コード例 #29
0
ファイル: QRCode.java プロジェクト: Fossel/QRTest
  /*
   * create QR code with overlay
   */
  public static void createQRCode(
      String qrCodeData,
      String outputFilePath,
      String overlayFilePath,
      String charset,
      Map<EncodeHintType, ErrorCorrectionLevel> hintMap,
      int qrCodeheight,
      int qrCodewidth)
      throws WriterException, IOException {

    // create QR code <BufferedImage>
    QRCodeWriter qrWriter = new QRCodeWriter();
    BitMatrix matrix =
        qrWriter.encode(qrCodeData, BarcodeFormat.QR_CODE, qrCodewidth, qrCodeheight, hintMap);
    BufferedImage image = MatrixToImageWriter.toBufferedImage(matrix);

    // read overlay image
    BufferedImage overlay = ImageIO.read(new File(overlayFilePath));

    // Draw the new image
    int deltaHeight = image.getHeight() - overlay.getHeight();
    int deltaWidth = image.getWidth() - overlay.getWidth();

    BufferedImage combined =
        new BufferedImage(qrCodeheight, qrCodewidth, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = (Graphics2D) combined.getGraphics();
    g.drawImage(image, 0, 0, null);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1f));
    g.drawImage(overlay, (int) Math.round(deltaWidth / 2), (int) Math.round(deltaHeight / 2), null);

    ImageIO.write(combined, "PNG", new File(outputFilePath));
  }
コード例 #30
0
ファイル: Renderer.java プロジェクト: gvtools/gvtools-legacy
  /**
   * Renders an image on the device
   *
   * @param tx the image location on the screen, x coordinate
   * @param ty the image location on the screen, y coordinate
   * @param img the image
   * @param rotation the image rotatation
   */
  private static void renderImage(
      Graphics2D graphics, double x, double y, Image image, double rotation, float opacity) {
    AffineTransform temp = graphics.getTransform();
    AffineTransform markAT = new AffineTransform();
    Point2D mapCentre = new java.awt.geom.Point2D.Double(x, y);
    Point2D graphicCentre = new java.awt.geom.Point2D.Double();
    temp.transform(mapCentre, graphicCentre);
    markAT.translate(graphicCentre.getX(), graphicCentre.getY());

    double shearY = temp.getShearY();
    double scaleY = temp.getScaleY();

    double originalRotation = Math.atan(shearY / scaleY);

    markAT.rotate(rotation);
    graphics.setTransform(markAT);
    graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity));

    // we moved the origin to the centre of the image.
    graphics.drawImage(image, -image.getWidth(null) / 2, -image.getHeight(null) / 2, null);

    graphics.setTransform(temp);

    return;
  }