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


Java Graphics2D.getPaint方法代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:AquaViewTabDisplayerUI.java

示例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);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:20,代码来源:Tabela.java

示例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);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:23,代码来源:Diagrama.java

示例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);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:23,代码来源:Selecionador.java

示例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);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:11,代码来源:FormaTriangular.java

示例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);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:RendererPanel.java

示例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);
    }
  }
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:37,代码来源:ZoneHighlight.java

示例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);
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:28,代码来源:ColorInterpolator.java

示例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);
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:11,代码来源:JVertexView.java

示例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);
    }
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:17,代码来源:Impressor.java

示例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);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:16,代码来源:FormaNaoRetangularDisformeBase.java

示例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;

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:46,代码来源:ClipPath.java

示例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);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:11,代码来源:FormaLosangular.java

示例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);
    }
 
开发者ID:chcandido,项目名称:brModelo,代码行数:34,代码来源:FormaArea.java

示例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);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:11,代码来源:FormaNaoRetangularBase.java


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