当前位置: 首页>>代码示例>>Java>>正文


Java AlphaComposite.getInstance方法代码示例

本文整理汇总了Java中java.awt.AlphaComposite.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java AlphaComposite.getInstance方法的具体用法?Java AlphaComposite.getInstance怎么用?Java AlphaComposite.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.awt.AlphaComposite的用法示例。


在下文中一共展示了AlphaComposite.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: paintComponent

import java.awt.AlphaComposite; //导入方法依赖的package包/类
/**
 * Paints the current state (i.e. the state corresponding to the current
 * phase) of the given component.
 *
 * @param g graphics context.
 * @param comp component to paint.
 */
private void paintComponent(Graphics g, Component comp) {
    Rectangle bounds = currentBounds(comp);
    float alpha = currentAlpha(comp);
    Graphics gg = g.create(bounds.x, bounds.y, bounds.width, bounds.height);
    if (alpha != 1f) {
        AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
        ((Graphics2D)gg).setComposite(alphaComposite);
    }
    comp.setBounds(bounds);
    comp.validate();
    // Intentionally using print instead of paint.
    // Print doesn't use double buffering and it solves some mysterious
    // problems with modified clip during painting of containers.
    // BTW: animated transitions library also uses print()
    if (comp instanceof JComponent) {
        comp.print(gg);
    } else {
        java.awt.peer.ComponentPeer peer = FakePeerSupport.getPeer(comp);
        if (peer != null) {
            peer.paint(gg);
        }
    }
    gg.dispose();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:AnimationLayer.java

示例2: graphicsImage

import java.awt.AlphaComposite; //导入方法依赖的package包/类
/**
 * 画随机码图
 * @param fontcolor 随机字体颜色
 * @param strs 字符数组
 * @param flag 透明度使用
 * @return BufferedImage
 */
private BufferedImage graphicsImage(Color[] fontcolor,char[] strs,int flag)
{
    BufferedImage image = new BufferedImage(width, height,BufferedImage.TYPE_INT_RGB);
    //或得图形上下文
    //Graphics2D g2d=image.createGraphics();
    Graphics2D g2d = (Graphics2D)image.getGraphics();
    //利用指定颜色填充背景
    g2d.setColor(Color.WHITE);
    g2d.fillRect(0, 0, width, height);
    AlphaComposite ac3;
    int h  = height - ((height - font.getSize()) >>1) ;
    int w = width/len;
    g2d.setFont(font);
    for(int i=0;i<len;i++)
    {
        ac3 = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getAlpha(flag, i));
        g2d.setComposite(ac3);
        g2d.setColor(fontcolor[i]);
        g2d.drawOval(num(width), num(height), 5+num(10), 5+num(10));
        g2d.drawString(strs[i]+"", (width-(len-i)*w)+(w-font.getSize())+1, h-4);
    }
    g2d.dispose();
    return image;
}
 
开发者ID:zhiqiang94,项目名称:BasicsProject,代码行数:32,代码来源:GifCaptcha.java

示例3: drawShadowPoint

import java.awt.AlphaComposite; //导入方法依赖的package包/类
/**
 * It draw a temporary point when a point is moved in another place
 * @param g The graphic object
 * @param p The position of the point
 * @param c The color of the point
 * @param size The size of the point
 */
public void drawShadowPoint(Graphics2D g, Point p, Color c, int size) {
	g.setColor(c);

	int fontSize = 7 + pointSize;
	Font f = new Font("Arial", Font.PLAIN, fontSize);
	g.setFont(f);
	double x = Math.max((p.getX() - tran_x) / scale, 0);
	double y = Math.max((-p.getY() + tran_y) / scale, 0);
	double X = (x * scale) + tran_x;
	double Y = -((y * scale) - tran_y);

	g.drawString("(" + format2Dec.format(x) + ", " + format2Dec.format(y) + ")", (int) (X - (fontSize * 3)), (int) Y - 5 - pointSize);

	g.drawOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);

	g.setColor(Color.GRAY);
	Composite oldComp = g.getComposite();
	Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
	g.setComposite(alphaComp);
	g.fillOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);
	g.setComposite(oldComp);

}
 
开发者ID:max6cn,项目名称:jmt,代码行数:31,代码来源:PainterConvex2D.java

示例4: drawFiltArea

import java.awt.AlphaComposite; //导入方法依赖的package包/类
/**
 * Draw a semi-trasparent area that is the filtered area
 * @param g The graphic object
 * @param filteredArea The filtered area
 */
public void drawFiltArea(Graphics2D g, Area filtArea) {
	AffineTransform t = new AffineTransform();
	t.scale(scale / 100, scale / 100);
	AffineTransform t2 = new AffineTransform();
	t2.translate(tran_x, tran_y);

	filtArea.transform(t);
	filtArea.transform(t2);

	Stroke oldStro = g.getStroke();
	Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
	g.setStroke(stroke);

	g.setColor(Color.GRAY);
	Composite oldComp = g.getComposite();
	Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
	g.setComposite(alphaComp);

	g.fill(filtArea);
	g.setComposite(oldComp);
	g.setStroke(oldStro);
}
 
开发者ID:max6cn,项目名称:jmt,代码行数:28,代码来源:PainterConvex2D.java

示例5: drawDragArea

import java.awt.AlphaComposite; //导入方法依赖的package包/类
/**
 * Draw a semi-trasparet area
 * @param g The graphic object
 * @param dragPoint The first point
 * @param beginPoint The second point
 * @param c The color of the area
 */
public void drawDragArea(Graphics2D g, Point dragPoint, Point beginPoint, Color c) {
	g.setColor(c);

	Polygon poly = new Polygon();

	poly.addPoint((int) beginPoint.getX(), (int) beginPoint.getY());
	poly.addPoint((int) beginPoint.getX(), (int) dragPoint.getY());
	poly.addPoint((int) dragPoint.getX(), (int) dragPoint.getY());
	poly.addPoint((int) dragPoint.getX(), (int) beginPoint.getY());

	//Set the widths of the shape's outline
	Stroke oldStro = g.getStroke();
	Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
	g.setStroke(stroke);
	g.drawPolygon(poly);
	g.setStroke(oldStro);

	//Set the trasparency of the iside of the rectangle
	Composite oldComp = g.getComposite();
	Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
	g.setComposite(alphaComp);
	g.fillPolygon(poly);
	g.setComposite(oldComp);

}
 
开发者ID:max6cn,项目名称:jmt,代码行数:33,代码来源:PainterConvex2D.java

示例6: drawShadowPoint

import java.awt.AlphaComposite; //导入方法依赖的package包/类
/**
 * It draw a temporary point when a point is moved in another place
 * @param g The graphic object
 * @param p The position of the point
 * @param c The color of the point
 * @param size The size of the point
 */
public void drawShadowPoint(Graphics2D g, Point p, Color c, int size) {
	g.setColor(c);

	int fontSize = 7 + pointSize;
	Font f = new Font("Arial", Font.PLAIN, fontSize);
	g.setFont(f);
	double x = Math.max((p.getX() - tran_x) / scale, 0);
	double y = Math.max((-p.getY() + tran_y) / scale, 0);
	double X = (x * scale) + tran_x;
	double Y = -((y * scale) - tran_y);

	g.drawString("(" + format2Dec.format(x) + ", " + format2Dec.format(y) + ")", (int) (X - (fontSize * 3)), (int) Y - 5 - pointSize);

	g.drawOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);

	g.setColor(Color.gray);
	Composite oldComp = g.getComposite();
	Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
	g.setComposite(alphaComp);
	g.fillOval((int) X - (((size / 2))), (int) Y - (((size / 2))), size, size);
	g.setComposite(oldComp);

}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:31,代码来源:PainterConvex2D.java

示例7: drawFiltArea

import java.awt.AlphaComposite; //导入方法依赖的package包/类
/**
 * Draw a semi-trasparent area that is the filtered area
 * @param g The graphic object
 * @param filteredArea The filtered area
 */
public void drawFiltArea(Graphics2D g, Area filtArea) {
	AffineTransform t = new AffineTransform();
	t.scale(scale / 100, scale / 100);
	AffineTransform t2 = new AffineTransform();
	t2.translate(tran_x, tran_y);

	filtArea.transform(t);
	filtArea.transform(t2);

	Stroke oldStro = g.getStroke();
	Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
	g.setStroke(stroke);

	g.setColor(Color.gray);
	Composite oldComp = g.getComposite();
	Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
	g.setComposite(alphaComp);

	g.fill(filtArea);
	g.setComposite(oldComp);
	g.setStroke(oldStro);
}
 
开发者ID:HOMlab,项目名称:QN-ACTR-Release,代码行数:28,代码来源:PainterConvex2D.java

示例8: render

import java.awt.AlphaComposite; //导入方法依赖的package包/类
public void render(Graphics g) {
	Graphics2D g2d = (Graphics2D) g;
	AlphaComposite orig = (AlphaComposite) g2d.getComposite();
	if (fading) {
		float alpha = 1f - (float) (((double) System.currentTimeMillis() - (double) startFadeTime) / (double) fadeTime);
		if (alpha < 0f)
			alpha = 0f;
		AlphaComposite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
		g2d.setComposite(comp);
	}
	g2d.setColor(MainGui.gui.getTheme().getColor(Theme.COL_INFO_WINDOW_BG));
	g2d.fillRect(x, y, MainGui.INFO_WINDOW_WIDTH, h);
	g2d.setColor(MainGui.gui.getTheme().getColor(Theme.COL_INFO_WINDOW_BG).darker());
	g2d.fillRect(x, y + (h - MainGui.SPACER_SIZE / 2), MainGui.INFO_WINDOW_WIDTH, MainGui.SPACER_SIZE / 2);
	g2d.drawRect(x, y, MainGui.INFO_WINDOW_WIDTH - 1, (h - MainGui.SPACER_SIZE / 2));
	GameRenderer.renderFormattedText(g2d, text, Theme.FONT_TEXT, x + MainGui.SPACER_SIZE, y + MainGui.SPACER_SIZE, 1, MainGui.INFO_WINDOW_WIDTH - (MainGui.SPACER_SIZE * 2));
	g2d.setComposite(orig);
}
 
开发者ID:Keabot-Studios,项目名称:Caritemere,代码行数:19,代码来源:InfoWindow.java

示例9: paintIcon

import java.awt.AlphaComposite; //导入方法依赖的package包/类
@Override
public void paintIcon(Component destination, Graphics g) {
	if (!isSelectable() && g instanceof Graphics2D) {
		Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
		((Graphics2D) g).setComposite(c);
	}

	if (icon == null) {
		g.setColor(new Color(255, 128, 128));
		g.fillRect(4, 4, 8, 8);
		g.setColor(Color.BLACK);
		g.drawLine(4, 4, 12, 12);
		g.drawLine(4, 12, 12, 4);
		g.drawRect(4, 4, 8, 8);
	} else {
		icon.paintIcon(destination, g, 0, 1);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:19,代码来源:LogisimToolbarItem.java

示例10: paintGhost

import java.awt.AlphaComposite; //导入方法依赖的package包/类
@Override
public void paintGhost(InstancePainter painter) {
	Graphics g = painter.getGraphics();
	Color fg = g.getColor();
	int v = fg.getRed() + fg.getGreen() + fg.getBlue();
	Composite oldComposite = null;
	if (g instanceof Graphics2D && v > 50) {
		oldComposite = ((Graphics2D) g).getComposite();
		Composite c = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
		((Graphics2D) g).setComposite(c);
	}
	paintBase(painter, g);
	if (oldComposite != null) {
		((Graphics2D) g).setComposite(oldComposite);
	}
}
 
开发者ID:LogisimIt,项目名称:Logisim,代码行数:17,代码来源:SubcircuitFactory.java

示例11: SwingSpyGlassPane

import java.awt.AlphaComposite; //导入方法依赖的package包/类
public SwingSpyGlassPane(RootPaneContainer rootPaneContainer) {
    super(null);
 setName("SwingSpyGlass");
    this.rootPaneContainer = rootPaneContainer;
    this.fontColor = Color.RED.darker();
    this.highlightColor = new Color(0xFFDDDD);
    this.font = new Font("sansserif", Font.BOLD, 14);
    this.alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
    setOpaque(false);
}
 
开发者ID:igr,项目名称:swingspy,代码行数:11,代码来源:SwingSpyGlassPane.java

示例12: paint

import java.awt.AlphaComposite; //导入方法依赖的package包/类
@Override
		public void paint( Graphics2D g, PanMouseAdaptor ma ) {

			{
				Composite old = g.getComposite();
				Composite comp = AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.5f );
				g.setComposite( comp );

				// draw rectified image at the width of the ortho image...
				
				double height = getRectified().getHeight() / 40.;

				g.drawImage( getRectified(), 
						ma.toX( Math.min( start, end ) ), 
						ma.toY( 0 - height ), 
						ma.toZoom( Math.abs(start - end) ), 
						ma.toZoom( height ), null );
				g.setComposite( old );
			}

//			for ( int i = 0; i < miniFacades.size(); i++ )
//				miniFacades.get( i ).paint( g, ma );

			//			for (double d : o.windowCuts)
			//				g.drawLine( ma.toX(d), 0, ma.toX(d), 10000 );
			//			
			g.setColor( Color.orange );
			//			
			//			for (double d : o.classCuts)
			//				g.drawLine( ma.toX(d), 0, ma.toX(d), 10000 );
			//		
			//			g.setColor( new Color(255, 100,100, 255) );
			//			if (o.windows != null)
			//			for (Rectangle2D.Double w : o.windows) {
			//				g.drawRect( ma.toX( w.x ), ma.toY (-w.y-w.height), ma.toZoom( w.width ), ma.toZoom( w.height ) );
			//			}
		}
 
开发者ID:twak,项目名称:chordatlas,代码行数:38,代码来源:FeatureCache.java

示例13: getAlphaComposite

import java.awt.AlphaComposite; //导入方法依赖的package包/类
/**
 * Returns the alpha composite to use when rendering highlights with this
 * painter.
 *
 * @return The alpha composite.
 */
private AlphaComposite getAlphaComposite() {
	if (alphaComposite==null) {
		alphaComposite = AlphaComposite.getInstance(
								AlphaComposite.SRC_OVER, alpha);
	}
	return alphaComposite;
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:14,代码来源:ChangeableHighlightPainter.java

示例14: buildComposite

import java.awt.AlphaComposite; //导入方法依赖的package包/类
protected void buildComposite() {
  composite =
    AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity / 100.0f);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:5,代码来源:MapShader.java

示例15: buildBorderComposite

import java.awt.AlphaComposite; //导入方法依赖的package包/类
protected AlphaComposite buildBorderComposite() {
  return AlphaComposite.getInstance(
    AlphaComposite.SRC_OVER, borderOpacity / 100.0f);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:5,代码来源:MapShader.java


注:本文中的java.awt.AlphaComposite.getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。