本文整理了Java中java.awt.Graphics2D.getComposite()
方法的一些代码示例,展示了Graphics2D.getComposite()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Graphics2D.getComposite()
方法的具体详情如下:
包路径:java.awt.Graphics2D
类名称:Graphics2D
方法名:getComposite
[英]Returns the current Composite
in the Graphics2D
context.
[中]返回Graphics2D
上下文中的当前Composite
。
代码示例来源:origin: graphhopper/graphhopper
public void makeTransparent(Graphics2D g2) {
Color col = g2.getColor();
Composite comp = null;
// force transparence of this layer only. If no buffering we would clear layers below
if (buffering) {
comp = g2.getComposite();
g2.setComposite(AlphaComposite.Clear);
}
g2.setColor(new Color(0, 0, 0, 0));
g2.fillRect(0, 0, bounds.width, bounds.height);
g2.setColor(col);
if (comp != null) {
g2.setComposite(comp);
}
}
代码示例来源:origin: apache/geode
@Override
public void paint(Graphics g) {
super.paint(g);
if (zoomBoxStartX != -1 && zoomBoxStartY != -1 && zoomBoxWidth != -1 && zoomBoxHeight != -1) {
Graphics2D g2 = (Graphics2D) g.create();
Composite old = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
g2.setColor(Color.BLUE);
// g2.drawRect(zoomBoxStartX, zoomBoxStartY, zoomBoxWidth, zoomBoxHeight);
// g2.setBackground(Color.BLUE);
g2.fillRect(getBoxX(), getBoxY(), getBoxWidth(), getBoxHeight());
g2.setComposite(old);
}
}
}
代码示例来源:origin: marytts/marytts
Composite origC = g.getComposite();
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
g.setComposite(ac);
g.fillRect(positionCursor.getX(this), positionCursor.getYMin(this),
rangeCursor.getX(this) - positionCursor.getX(this),
rangeCursor.getYMax(this) - positionCursor.getYMin(this));
g.setComposite(origC);
代码示例来源:origin: libgdx/libgdx
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) {
g = (Graphics2D)g.create();
g.translate(xDistance, yDistance);
g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), Math.round(opacity * 255)));
g.fill(glyph.getShape());
// Also shadow the outline, if one exists.
for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();) {
Effect effect = (Effect)iter.next();
if (effect instanceof OutlineEffect) {
Composite composite = g.getComposite();
g.setComposite(AlphaComposite.Src); // Prevent shadow and outline shadow alpha from combining.
g.setStroke(((OutlineEffect)effect).getStroke());
g.draw(glyph.getShape());
g.setComposite(composite);
break;
}
}
g.dispose();
if (blurKernelSize > 1 && blurKernelSize < NUM_KERNELS && blurPasses > 0) blur(image);
}
代码示例来源:origin: marytts/marytts
Composite origC = g.getComposite();
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);
g.setComposite(ac);
g.fillRect(positionCursor.getX(this), positionCursor.getYMin(this),
rangeCursor.getX(this) - positionCursor.getX(this),
rangeCursor.getYMax(this) - positionCursor.getYMin(this));
g.setComposite(origC);
代码示例来源:origin: libgdx/libgdx
public void draw (BufferedImage image, Graphics2D g, UnicodeFont unicodeFont, Glyph glyph) {
g = (Graphics2D)g.create();
g.translate(xDistance, yDistance);
g.setColor(new Color(color.getRed(), color.getGreen(), color.getBlue(), Math.round(opacity * 255)));
g.fill(glyph.getShape());
// Also shadow the outline, if one exists.
for (Iterator iter = unicodeFont.getEffects().iterator(); iter.hasNext();) {
Effect effect = (Effect)iter.next();
if (effect instanceof OutlineEffect) {
Composite composite = g.getComposite();
g.setComposite(AlphaComposite.Src); // Prevent shadow and outline shadow alpha from combining.
g.setStroke(((OutlineEffect)effect).getStroke());
g.draw(glyph.getShape());
g.setComposite(composite);
break;
}
}
g.dispose();
if (blurKernelSize > 1 && blurKernelSize < NUM_KERNELS && blurPasses > 0) blur(image);
}
代码示例来源:origin: mapsforge/mapsforge
private void fillColor(java.awt.Color color) {
final Composite originalComposite = this.graphics2D.getComposite();
this.graphics2D.setComposite(AlphaComposite.getInstance(color.getAlpha() == 0 ? AlphaComposite.CLEAR : AlphaComposite.SRC_OVER));
this.graphics2D.setColor(color);
this.graphics2D.fillRect(0, 0, getWidth(), getHeight());
this.graphics2D.setComposite(originalComposite);
}
代码示例来源:origin: mapsforge/mapsforge
@Override
public void shadeBitmap(Bitmap bitmap, Rectangle shadeRect, Rectangle tileRect, float magnitude) {
Composite oldComposite = this.graphics2D.getComposite();
Composite composite = getHillshadingComposite(magnitude);
this.graphics2D.setComposite(composite);
this.graphics2D.setComposite(oldComposite);
this.graphics2D.setClip(null);
return;
this.graphics2D.setClip(null);
this.graphics2D.setComposite(oldComposite);
代码示例来源:origin: magefree/mage
float alpha = bgalpha;
Component c = (Component)o;
Composite composite = g2.getComposite();
if (composite instanceof AlphaComposite) {
alpha *= ((AlphaComposite) composite).getAlpha();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
g2.setColor(bgColor);
alpha *= ((AlphaComposite) composite).getAlpha();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
g2.setColor(new Color(1.0f, 1.0f, 1.0f));
g2.fill(area);
g2.setComposite(composite);
代码示例来源:origin: bobbylight/RSyntaxTextArea
Composite originalComposite = null;
if (getAlpha()<1.0f) {
originalComposite = g2d.getComposite();
g2d.setComposite(getAlphaComposite());
g2d.setComposite(originalComposite);
代码示例来源:origin: nodebox/nodebox
g2.drawImage(checkDisabledOff, 0, 0, null);
} else {
Composite oldComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
g2.drawImage(normalImage, 0, 0, null);
g2.setComposite(oldComposite);
代码示例来源:origin: bobbylight/RSyntaxTextArea
Composite originalComposite = null;
if (getAlpha()<1.0f) {
originalComposite = g2d.getComposite();
g2d.setComposite(getAlphaComposite());
g2d.setComposite(originalComposite);
g2d.setComposite(originalComposite);
代码示例来源:origin: magefree/mage
Composite composite = g2.getComposite();
if (composite instanceof AlphaComposite) {
alpha *= ((AlphaComposite) composite).getAlpha();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
g2.fill(casing);
g2.setComposite(composite);
Composite composite = g2.getComposite();
if (composite instanceof AlphaComposite) {
alpha *= ((AlphaComposite) composite).getAlpha();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
g2.fill(casing);
g2.setComposite(composite);
代码示例来源:origin: com.threerings/nenya
public void beforePaint (Graphics2D gfx)
{
_ocomp = gfx.getComposite();
gfx.setComposite(_comp);
}
代码示例来源:origin: nodebox/nodebox
public void draw(Graphics2D g) {
setupTransform(g);
// You can only position an image using an affine transformation.
// We use the transformation to translate the image to the specified
// position, and scale it according to the given width and height.
Transform imageTrans = new Transform();
// Move to the image position. Convert x, y, which are centered coordinates,
// to "real" coordinates.
double factor = getScaleFactor();
double finalWidth = image.getWidth() * factor;
double finalHeight = image.getHeight() * factor;
imageTrans.translate(x - finalWidth / 2, y - finalHeight / 2);
// Scaling only applies to image that have their desired width and/or height set.
// However, getScaleFactor return 1 if height/width are not set, in effect negating
// the effect of the scale.
imageTrans.scale(getScaleFactor());
double a = clamp(alpha);
Composite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, (float) a);
Composite oldComposite = g.getComposite();
g.setComposite(composite);
g.drawRenderedImage(image, imageTrans.getAffineTransform());
g.setComposite(oldComposite);
restoreTransform(g);
}
代码示例来源:origin: threerings/nenya
public void beforePaint (Graphics2D gfx)
{
_ocomp = gfx.getComposite();
gfx.setComposite(_comp);
}
代码示例来源:origin: magefree/mage
AlphaComposite comp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
Composite origc = g.getComposite();
g.setComposite(comp);
g.setBackground(new Color(155, 0, 0, 150));
contentWidth - 2, cardHeight - borderWidth * 3 - typeLineY - 1);
g.setComposite(origc);
代码示例来源:origin: stackoverflow.com
Graphics2D g2d = (Graphics2D)g; //Some graphics object
//Save the original
Composite original = g2d.getComposite();
//Set to semi translucent
Composite translucent = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f);
g2d.setComposite(translucent);
//Draw
//Set back to original
g2d.setComposite(original);
代码示例来源:origin: Multibit-Legacy/multibit-hd
/**
* <p>Apply the alpha composite to the given graphics context</p>
*
* @param g2 The graphics context
*/
private void applyAlphaComposite(Graphics2D g2) {
originalComposite = g2.getComposite();
int rule = AlphaComposite.SRC_OVER;
Composite alphaComposite = AlphaComposite.getInstance(rule, alpha);
g2.setComposite(alphaComposite);
}
代码示例来源:origin: com.samskivert/samskivert
public void paintIcon (Component c, Graphics g, int x, int y)
{
Graphics2D gfx = (Graphics2D) g;
Composite ocomp = gfx.getComposite();
gfx.setComposite(_alpha);
_icon.paintIcon(c, gfx, x, y);
gfx.setComposite(ocomp);
}
内容来源于网络,如有侵权,请联系作者删除!