use of java.awt.Composite in project Portugol-Studio by UNIVALI-LITE.
the class DesenhoImagem method desenhar.
@Override
public void desenhar(Graphics2D graficos) {
if (opacidade == 255) {
graficos.drawImage(imagem, x, y, null);
} else {
Composite original = graficos.getComposite();
Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, nivelTransparencia);
graficos.setComposite(alpha);
graficos.drawImage(imagem, x, y, null);
graficos.setComposite(original);
}
}
use of java.awt.Composite in project LoboEvolution by LoboEvolution.
the class SVGSVGElementImpl method draw.
/**
* {@inheritDoc}
*/
@Override
public void draw(final Graphics2D graphics) {
recalculateViewboxToViewportTransform();
boolean display = getDisplay();
float opacity = getOpacity();
if (display && opacity > 0) {
AffineTransform oldGraphicsTransform = graphics.getTransform();
Shape oldClip = graphics.getClip();
graphics.translate(viewport.getX(), viewport.getY());
if (opacity < 1) {
SVGSVGElement root = this;
float currentScale = root.getCurrentScale();
// create buffer to draw on
Shape shape = createShape(null);
AffineTransform screenCTM = getScreenCTM().getAffineTransform();
Shape transformedShape = screenCTM.createTransformedShape(shape);
Rectangle2D bounds = transformedShape.getBounds2D();
double xInc = bounds.getWidth() / 5;
double yInc = bounds.getHeight() / 5;
bounds.setRect(bounds.getX() - xInc, bounds.getY() - yInc, bounds.getWidth() + 2 * xInc, bounds.getHeight() + 2 * yInc);
int imageWidth = (int) (bounds.getWidth() * currentScale);
int imageHeight = (int) (bounds.getHeight() * currentScale);
if (imageWidth > 0 && imageHeight > 0) {
BufferedImage image = new BufferedImage(imageWidth, imageHeight, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D offGraphics = (Graphics2D) image.getGraphics();
RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
offGraphics.setRenderingHints(hints);
if (currentScale != 1) {
offGraphics.scale(currentScale, currentScale);
}
offGraphics.translate(-bounds.getX(), -bounds.getY());
offGraphics.transform(screenCTM);
drawChildren(offGraphics);
Composite oldComposite = graphics.getComposite();
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, opacity);
graphics.setComposite(ac);
AffineTransform imageTransform = AffineTransform.getTranslateInstance(bounds.getX(), bounds.getY());
imageTransform.scale(1 / currentScale, 1 / currentScale);
try {
imageTransform.preConcatenate(screenCTM.createInverse());
} catch (NoninvertibleTransformException e) {
}
graphics.drawImage(image, imageTransform, null);
graphics.setComposite(oldComposite);
image.flush();
}
} else {
drawChildren(graphics);
}
graphics.setTransform(oldGraphicsTransform);
graphics.setClip(oldClip);
}
}
use of java.awt.Composite in project LoboEvolution by LoboEvolution.
the class BaseTabbedPaneUI method paintLeftTabBorder.
/**
* <p>paintLeftTabBorder.</p>
*
* @param tabIndex a int.
* @param g a {@link java.awt.Graphics} object.
* @param x1 a int.
* @param y1 a int.
* @param x2 a int.
* @param y2 a int.
* @param isSelected a boolean.
*/
protected void paintLeftTabBorder(int tabIndex, Graphics g, int x1, int y1, int x2, int y2, boolean isSelected) {
Graphics2D g2D = (Graphics2D) g;
int tc = tabPane.getTabCount();
int currentRun = getRunForTab(tc, tabIndex);
int lastIndex = lastTabInRun(tc, currentRun);
int firstIndex = tabRuns[currentRun];
Color loColor = getLoBorderColor(tabIndex);
Color hiColor = getHiBorderColor(tabIndex);
g.setColor(hiColor);
Composite savedComposite = g2D.getComposite();
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.4f);
g2D.setComposite(alpha);
g.drawLine(x1 + GAP + 1, y1 + 1, x2 - 1, y1 + 1);
g.drawLine(x1 + GAP, y1 + 1, x1 + 1, y1 + GAP);
g.drawLine(x1 + 1, y1 + GAP + 1, x1 + 1, y2 - 1);
g2D.setComposite(savedComposite);
g.setColor(loColor);
g.drawLine(x1 + GAP, y1, x2 - 1, y1);
g.drawLine(x1 + GAP, y1, x1, y1 + GAP);
g.drawLine(x1, y1 + GAP, x1, y2);
g.drawLine(x1 + GAP, y2, x2 - 1, y2);
if (tabIndex == lastIndex) {
g.drawLine(x1, y2, x1 + GAP, y2);
}
// paint gap
int gapTabIndex = getTabAtLocation(x1 + 2, y1 - 2);
Color gapColor = getGapColor(gapTabIndex);
g.setColor(gapColor);
for (int i = 0; i < GAP; i++) {
g.drawLine(x1, y1 + i, x1 + GAP - i - 1, y1 + i);
}
if (tabIndex != firstIndex || currentRun != runCount - 1) {
loColor = getLoBorderColor(gapTabIndex);
g.setColor(loColor);
g.drawLine(x1, y1, x1, y1 + GAP - 1);
if (tabIndex != firstIndex) {
g2D.setComposite(alpha);
hiColor = getHiBorderColor(gapTabIndex);
g.setColor(hiColor);
g.drawLine(x1 + 1, y1, x1 + 1, y1 + GAP - 2);
g2D.setComposite(savedComposite);
}
}
}
use of java.awt.Composite in project LoboEvolution by LoboEvolution.
the class BaseTitleButton method paint.
/**
* {@inheritDoc}
*/
@Override
public void paint(final Graphics g) {
if (JTattooUtilities.isActive(this) || alpha >= 1.0) {
super.paint(g);
} else {
Graphics2D g2D = (Graphics2D) g;
Composite savedComposite = g2D.getComposite();
AlphaComposite alphaComposite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha);
g2D.setComposite(alphaComposite);
super.paint(g);
g2D.setComposite(savedComposite);
}
}
use of java.awt.Composite in project LoboEvolution by LoboEvolution.
the class BaseScrollButton method paint.
/**
* {@inheritDoc}
*/
@Override
public void paint(final Graphics g) {
boolean isPressed = getModel().isPressed();
boolean isRollover = getModel().isRollover();
int width = getWidth();
int height = getHeight();
Color[] colors;
if (isPressed) {
colors = AbstractLookAndFeel.getTheme().getPressedColors();
} else if (isRollover) {
colors = AbstractLookAndFeel.getTheme().getRolloverColors();
} else {
colors = AbstractLookAndFeel.getTheme().getButtonColors();
}
boolean inverse = ColorHelper.getGrayValue(colors) < 128;
Color frameColorHi = ColorHelper.brighter(colors[0], 20);
Color frameColorLo = ColorHelper.darker(colors[colors.length - 1], 20);
Graphics2D g2D = (Graphics2D) g;
Composite savedComposite = g2D.getComposite();
if (getDirection() == NORTH || getDirection() == SOUTH) {
JTattooUtilities.fillVerGradient(g2D, colors, 0, 0, width, height);
} else {
JTattooUtilities.fillHorGradient(g2D, colors, 0, 0, width, height);
}
g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
switch(getDirection()) {
case NORTH:
{
Icon upArrow = inverse ? BaseIcons.getUpArrowInverseIcon() : BaseIcons.getUpArrowIcon();
int x = width / 2 - upArrow.getIconWidth() / 2;
int y = height / 2 - upArrow.getIconHeight() / 2 - 1;
upArrow.paintIcon(this, g2D, x, y);
break;
}
case SOUTH:
{
Icon downArrow = inverse ? BaseIcons.getDownArrowInverseIcon() : BaseIcons.getDownArrowIcon();
int x = width / 2 - downArrow.getIconWidth() / 2;
int y = height / 2 - downArrow.getIconHeight() / 2;
downArrow.paintIcon(this, g2D, x, y);
break;
}
case WEST:
{
Icon leftArrow = inverse ? BaseIcons.getLeftArrowInverseIcon() : BaseIcons.getLeftArrowIcon();
int x = width / 2 - leftArrow.getIconWidth() / 2 - 1;
int y = height / 2 - leftArrow.getIconHeight() / 2;
leftArrow.paintIcon(this, g2D, x, y);
break;
}
default:
{
Icon rightArrow = inverse ? BaseIcons.getRightArrowInverseIcon() : BaseIcons.getRightArrowIcon();
int x = width / 2 - rightArrow.getIconWidth() / 2;
int y = height / 2 - rightArrow.getIconHeight() / 2;
rightArrow.paintIcon(this, g2D, x, y);
break;
}
}
JTattooUtilities.draw3DBorder(g2D, frameColorLo, ColorHelper.darker(frameColorLo, 10), 0, 0, width, height);
g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f));
g2D.setColor(frameColorHi);
g2D.drawLine(1, 1, width - 2, 1);
g2D.drawLine(1, 1, 1, height - 2);
g2D.setComposite(savedComposite);
}
Aggregations