There are 4 code examples for java.awt.AlphaComposite.

The API names are highlighted below. You can use suckoo button to vote the code example(s) you like. The best code example will be ranked first next time. Thanks a lot for your feedback.

Project Name: jFreeChart Package: org.jfree.chart

Source Code: ClipPath.java (Click to view .java file)

Method Code:
vote
like

/** 
 * Constructor for ClipPath.
 * The fillPaint is set to Color.GRAY, the drawColor is Color.BLUE, the
 * stroke is BasicStroke(1) and the composite is AlphaComposite.Src.
 * @param xValue  x coordinates of curved to be created
 * @param yValue  y coordinates of curved to be created
 * @param clip  clip?
 * @param fillPath  whether the path is to filled
 * @param drawPath  whether the path is to drawn as an outline
 */
public ClipPath(double[] xValue,double[] yValue,boolean clip,boolean fillPath,boolean drawPath){
  this.xValue=xValue;
  this.yValue=yValue;
  this.clip=clip;
  this.fillPath=fillPath;
  this.drawPath=drawPath;
  this.fillPaint=java.awt.Color.gray;
  this.drawPaint=java.awt.Color.blue;
  this.drawStroke=new BasicStroke(1);
  this.composite=java.awt.AlphaComposite.Src;
}
 

Project Name: jbidwatcher Package: com.jbidwatcher.ui

Source Code: AuctionsUIModel.java (Click to view .java file)

Method Code:
vote
like

public void paintComponent(Graphics g){
  super.paintComponent(g);
  if (image != null && _table.getRowCount() == 0) {
    int imageW=image.getWidth(null);
    int imageH=image.getHeight(null);
    Graphics2D g2d=(Graphics2D)g;
    AlphaComposite comp=AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.5f);
    Composite oldComp=g2d.getComposite();
    g2d.setComposite(comp);
    int xloc=getWidth() / 2 - imageW / 2 - 2;
    int yloc=getHeight() / 2 - imageH / 2 - 2;
    g2d.drawImage(image,xloc,yloc,this);
    g2d.setComposite(oldComp);
  }
}
 

Project Name: jbidwatcher Package: com.jbidwatcher.util

Source Code: IconFactory.java (Click to view .java file)

Method Code:
vote
like

private static BufferedImage createResizedCopy(Image originalImage,int scaledWidth,int scaledHeight){
  BufferedImage scaledBI=new BufferedImage(scaledWidth,scaledHeight,BufferedImage.TYPE_INT_RGB);
  Graphics2D g=scaledBI.createGraphics();
  g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BICUBIC);
  if (true) {
    g.setComposite(AlphaComposite.Src);
  }
  g.drawImage(originalImage,0,0,scaledWidth,scaledHeight,null);
  g.dispose();
  return scaledBI;
}
 

Project Name: rmoffice Package: net.sf.rmoffice.ui.panels

Source Code: ProgressGlassPane.java (Click to view .java file)

Method Code:
vote
like

@Override protected void paintComponent(Graphics g){
  Graphics2D g2=(Graphics2D)g;
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  Rectangle clip=g.getClipBounds();
  AlphaComposite alpha=AlphaComposite.SrcOver.derive(0.65f);
  Composite composite=g2.getComposite();
  g2.setComposite(alpha);
  g2.setColor(getBackground());
  g2.fillRect(clip.x,clip.y,clip.width,clip.height);
  FontMetrics metrics=g.getFontMetrics();
  int x=(getWidth() - BAR_WIDTH) / 2;
  int y=(getHeight() - BAR_HEIGHT - metrics.getDescent()) / 2;
  g2.setColor(TEXT_COLOR);
  g2.drawString(message,x,y);
  y+=metrics.getDescent();
  int w=(int)(BAR_WIDTH * (progress / 100.0f));
  int h=BAR_HEIGHT;
  Paint paint=g2.getPaint();
  Paint gradient=new GradientPaint(x,y,GRADIENT_COLOR1,x,y + h,GRADIENT_COLOR2);
  g2.setPaint(gradient);
  g2.fillRect(x,y,BAR_WIDTH,BAR_HEIGHT);
  gradient=new LinearGradientPaint(x,y,x,y + h,GRADIENT_FRACTIONS,GRADIENT_COLORS);
  g2.setPaint(gradient);
  g2.fillRect(x,y,w,h);
  g2.setPaint(paint);
  g2.drawRect(x,y,BAR_WIDTH,BAR_HEIGHT);
  g2.setComposite(composite);
}