本文整理汇总了Java中java.awt.Graphics2D.getPaint方法的典型用法代码示例。如果您正苦于以下问题:Java Graphics2D.getPaint方法的具体用法?Java Graphics2D.getPaint怎么用?Java Graphics2D.getPaint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Graphics2D
的用法示例。
在下文中一共展示了Graphics2D.getPaint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintTabBackground
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintTabBackground(Graphics g, int index, int x, int y,
int width, int height) {
Graphics2D g2d = (Graphics2D) g;
Paint p = g2d.getPaint();
if( isSelected(index) ) {
g2d.setPaint( ColorUtil.getGradientPaint(x, y, UIManager.getColor("NbTabControl.selectedTabBrighterBackground"),
x, y+height/2, UIManager.getColor("NbTabControl.selectedTabDarkerBackground")) );
} else if( isMouseOver(index) ) {
g2d.setPaint( ColorUtil.getGradientPaint(x, y, UIManager.getColor("NbTabControl.mouseoverTabBrighterBackground"),
x, y+height/2, UIManager.getColor("NbTabControl.mouseoverTabDarkerBackground")) );
} else {
g2d.setPaint( ColorUtil.getGradientPaint(x, y, UIManager.getColor("NbTabControl.inactiveTabBrighterBackground"),
x, y+height/2, UIManager.getColor("NbTabControl.inactiveTabDarkerBackground")) );
}
g2d.fillRect(x, y, width, height);
g2d.setPaint(p);
}
示例2: FillCampos
import java.awt.Graphics2D; //导入方法依赖的package包/类
private void FillCampos(Graphics2D g, Rectangle r, boolean normal) {
Composite originalComposite = g.getComposite();
float alfa = 1f - getAlfa();
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alfa));
Paint bkpp = g.getPaint();
g.setColor(getMaster().getBackground()); //# Não: isDisablePainted()? disabledColor :
if (!normal) {
if (isGradiente()) {
g.setColor(getGradienteStartColor());
} else {
g.setColor(getForeColor());
}
}
g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, getAlfa()));
g.fill(r);
g.setPaint(bkpp);
g.setComposite(originalComposite);
}
示例3: PaintAI
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* Mostra a área de impressão no diagrama
*
* @param g
* @param wdt largura
* @param ht altura
*/
public void PaintAI(Graphics2D g, int wdt, int ht) {
Paint bkppaint = g.getPaint();
g.setColor(new Color(221, 221, 221));
int w = wdt;
while (w < getWidth()) {
g.drawLine(w, 1, w, getHeight() - 1);
w += wdt;
}
int h = ht;
while (h < getHeight()) {
g.drawLine(1, h, getWidth() - 1, h);
h += ht;
}
g.setPaint(bkppaint);
}
示例4: DoPaint
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void DoPaint(Graphics2D g) {
Paint bkppaint = g.getPaint();
//super.DoPaint(g); //To change body of generated methods, choose Tools | Templates.
Graphics2D Canvas = g;
Stroke stroke = g.getStroke();
Canvas.setStroke(new BasicStroke(
1f,
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND,
2f,
new float[]{2f, 2f},
1f));
//Composite ori = g.getComposite();
//g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN, 1f));
Canvas.setPaint(Color.BLACK);
Canvas.drawRect(getLeft(), getTop(), getWidth() - 2, getHeight() - 2);
g.setStroke(stroke);
g.setPaint(bkppaint);//g.setComposite(ori);
}
示例5: DoPaintDoks
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void DoPaintDoks(Graphics2D g) {
Point[] pts = getPontosDoTriangulo();
Paint bkpP = g.getPaint();
g.setPaint(Color.orange);
for (Point pt : pts) {
g.fillRect(pt.x - 2, pt.y - 2, 4, 4);
}
g.setPaint(bkpP);
}
示例6: paintComponent
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g) {
if (isRoot && colorManager.isAqua() && node.isExpandable() && node.isRenderedWithGradient()) {
Graphics2D g2d = (Graphics2D) g;
Paint oldPaint = g2d.getPaint();
g2d.setPaint(new GradientPaint(0, 0, Color.white, 0, getHeight() / 2, getBackground()));
g2d.fillRect(0, 0, getWidth(), getHeight());
g2d.setPaint(oldPaint);
} else {
super.paintComponent(g);
}
}
示例7: draw
import java.awt.Graphics2D; //导入方法依赖的package包/类
public void draw(Graphics2D g2d, Shape s, double scale) {
if ((color != null && opacity > 0 ) || STYLE_IMAGE.equals(style)) {
final Stroke oldStroke = g2d.getStroke();
final Color oldColor = g2d.getColor();
final Composite oldComposite = g2d.getComposite();
final Paint oldPaint = g2d.getPaint();
if (!STYLE_PLAIN.equals(style)) {
g2d.setPaint(getPaint());
}
else {
g2d.setColor(color);
}
g2d.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER, opacity/100.0f));
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
if (COVERAGE_FULL.equals(coverage)) {
g2d.fill(s);
}
else {
final Stroke stroke = new BasicStroke((float)(width*scale),
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND);
g2d.setStroke(stroke);
g2d.draw(s);
}
g2d.setColor(oldColor);
g2d.setStroke(oldStroke);
g2d.setComposite(oldComposite);
g2d.setPaint(oldPaint);
}
}
示例8: paintGraph
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintGraph(Graphics2D g, int width, int height) {
g.setColor(keyframes.get(0).getValue());
g.fillRect(0, gradPadding, (int) (keyframes.get(0).getTime()*width), height-2*gradPadding);
g.setColor(keyframes.get(keyframes.size()-1).getValue());
g.fillRect((int) ((keyframes.get(keyframes.size()-1).getTime())*width), gradPadding, width - (int) ((keyframes.get(keyframes.size()-1).getTime())*width), height-2*gradPadding);
Paint origP = g.getPaint();
for(int i = 0; i < keyframes.size()-1; i++) {
Keyframe<Color> k0 = keyframes.get(i), k1 = keyframes.get(i+1);
g.setPaint(new GradientPaint(k0.getTime()*width, 0, k0.getValue(), k1.getTime()*width, 0, k1.getValue()));
g.fillRect((int) (k0.getTime()*width), gradPadding-3, (int) (k1.getTime()*width-k0.getTime()*width), height-2*(gradPadding-3));
}
g.setPaint(origP);
g.setStroke(new BasicStroke(3)); //Draw red bar at each keyframe
g.setColor(Color.BLACK);//new Color(255, 0, 0, 32));
for(int i = 0; i < keyframes.size(); i++)
g.drawLine((int) (keyframes.get(i).getTime() * width), 0, (int) (keyframes.get(i).getTime() * width), height);
g.setStroke(new BasicStroke(1)); //Draw red bar at each keyframe
g.setColor(Color.WHITE);//new Color(255, 0, 0, 32));
for(int i = 0; i < keyframes.size(); i++)
g.drawLine((int) (keyframes.get(i).getTime() * width), 0, (int) (keyframes.get(i).getTime() * width), height);
}
示例9: paintBackground
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* Paints the background, with a given shape.
*/
private void paintBackground(Graphics2D g, Shape shape) {
Paint oldPaint = g.getPaint();
Paint newPaint = JAttr.createPaint(shape.getBounds(), getBackground());
g.setPaint(newPaint);
g.fill(shape);
g.setPaint(oldPaint);
}
示例10: PinteNoArea
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* Pinta a área que não será impressa
*/
private void PinteNoArea(Graphics2D Canvas) {
if (getDiagrama() != null) {
Paint bkp = Canvas.getPaint();
Canvas.setColor(new Color(241, 241, 241));
int x = PaginasW * LarguraPagina;
Canvas.fillRect(x + 2, 2, getWidth() - (x + 4), getHeight() - 4);
int y = PaginasH * AlturaPagina;
Canvas.fillRect(2, y + 2, getWidth() - 4, getHeight() - (y + 4));
Canvas.setPaint(bkp);
}
}
示例11: DoPaintDoks
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void DoPaintDoks(Graphics2D g) {
Point[] pts = getPontosColaterais();
Paint bkpP = g.getPaint();
g.setPaint(Color.yellow);
for (int i = 0; i < pts.length; i++) {
if (shouldMove(i)) {
Point p = getReposicionePonto(i);
g.fillRect(pts[i].x - 2 + p.x, pts[i].y - 2 + p.y, 4, 4);
} else {
g.fillRect(pts[i].x - 2, pts[i].y - 2, 4, 4);
}
}
g.setPaint(bkpP);
}
示例12: draw
import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
* Draws the clip path.
*
* @param g2 current graphics2D.
* @param dataArea the dataArea that the plot is being draw in.
* @param horizontalAxis the horizontal axis.
* @param verticalAxis the vertical axis.
*
* @return The GeneralPath defining the outline
*/
public GeneralPath draw(Graphics2D g2,
Rectangle2D dataArea,
ValueAxis horizontalAxis, ValueAxis verticalAxis) {
GeneralPath generalPath = generateClipPath(
dataArea, horizontalAxis, verticalAxis
);
if (this.fillPath || this.drawPath) {
Composite saveComposite = g2.getComposite();
Paint savePaint = g2.getPaint();
Stroke saveStroke = g2.getStroke();
if (this.fillPaint != null) {
g2.setPaint(this.fillPaint);
}
if (this.composite != null) {
g2.setComposite(this.composite);
}
if (this.fillPath) {
g2.fill(generalPath);
}
if (this.drawStroke != null) {
g2.setStroke(this.drawStroke);
}
if (this.drawPath) {
g2.draw(generalPath);
}
g2.setPaint(savePaint);
g2.setComposite(saveComposite);
g2.setStroke(saveStroke);
}
return generalPath;
}
示例13: DoPaintDoks
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void DoPaintDoks(Graphics2D g) {
Point[] pts = getAllSubPoints();
Paint bkpP = g.getPaint();
g.setPaint(Color.orange);
for (Point pt : pts) {
g.fillRect(pt.x - 2, pt.y - 2, 4, 4);
}
g.setPaint(bkpP);
}
示例14: PaintGradiente
import java.awt.Graphics2D; //导入方法依赖的package包/类
protected void PaintGradiente(Graphics2D g) { //, boolean round) {
Paint bkp = g.getPaint();
int dist = distSelecao;
int W = getWidth() - dist;
int H = 2 * alturaTexto - 1 - dist;
boolean dv = getGDirecao() == VERTICAL;
Composite originalComposite = g.getComposite();
int type = AlphaComposite.SRC_OVER;
g.setComposite(AlphaComposite.getInstance(type, alfa));
Stroke bkps = g.getStroke();
if (isDashed()) {
g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{1, 2}, 0));
}
// GradientPaint GP = new GradientPaint(getLeft(), getTop(), Color.LIGHT_GRAY, dv ? getLeft() : getLeft() + W, dv ? getTop() + H : getTop(), Color.white, true);
// g.setPaint(GP);
int w = getWidth() - dist;
int h = getHeight() - dist;
int L = getLeft();
int T = getTop();
GradientPaint GP = new GradientPaint(L, T, getGradienteStartColor(), dv ? L : L + w, dv ? T + h : T, getGradienteEndColor(), true);
g.setPaint(GP);
g.fillRect(getLeft() + 1, getTop() + 1, W, H);
g.setComposite(originalComposite);
g.setPaint(bkp);
g.setStroke(bkps);
}
示例15: DoPaintDoks
import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void DoPaintDoks(Graphics2D g) {
Point[] pts = getPontosColaterais();
Paint bkpP = g.getPaint();
g.setPaint(Color.yellow);
for (int i = 0; i < pts.length; i ++) {
g.fillRect(pts[i].x -2, pts[i].y -2, 4, 4);
}
g.setPaint(bkpP);
}