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


Java Graphics2D.getComposite方法代码示例

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


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

示例1: 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

示例2: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g;
    
    g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    
    Composite oldC = g2d.getComposite();
    Shape s = getMask( getWidth(), getHeight() );

    g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.25f*currentAlpha ) );
    g2d.setColor( Color.black );
    g2d.fill( getShadowMask(s) );
    
    g2d.setColor( UIManager.getColor( "ToolTip.background" ) ); //NOI18N
    g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, currentAlpha ) );
    Point2D p1 = s.getBounds().getLocation();
    Point2D p2 = new Point2D.Double(p1.getX(), p1.getY()+s.getBounds().getHeight());
    if( isMouseOverEffect )
        g2d.setPaint( new GradientPaint( p2, getMouseOverGradientStartColor(), p1, getMouseOverGradientFinishColor() ) );
    else
        g2d.setPaint( new GradientPaint( p2, getDefaultGradientStartColor(), p1, getDefaultGradientFinishColor() ) );
    g2d.fill(s);
    g2d.setColor( Color.black );
    g2d.draw(s);
    g2d.setComposite( oldC );
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:BalloonManager.java

示例3: drawFMSImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
private BufferedImage drawFMSImage() {
	BufferedImage fms = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);

	Graphics2D g = fms.createGraphics();
	Composite c = g.getComposite();

	g.setComposite(AlphaComposite.getInstance(
					AlphaComposite.CLEAR, 0));
	g.fillRect(0, 0, size, size);
	g.setComposite(c);

	g.translate(size / 2, size / 2);
	FMSDraw.drawFMS(g, size / 2,
			eq.strike1,
			eq.dip1, 
			eq.rake1, 
			eq.strike2, 
			eq.dip2, 
			eq.rake2);
	return fms;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:22,代码来源:FocalMechanismSolutionDB.java

示例4: paintMenuItem

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Paints a menu item
 * @param g The graphics to use
 * @param menuItem The menu item to paint
 * @param hasCursor Whether or not the cursor is over the component
 * @param defaultTextIconGap The gap between the text and the icon
 */
private static final void paintMenuItem(Graphics2D g, JMenuItem menuItem, boolean hasCursor, int defaultTextIconGap){
	g.setColor(Main.config.customColors ? Main.config.background : Color.BLACK);
	g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
	if(menuItem instanceof JCheckBoxMenuItem && menuItem.isSelected()){
		g.drawImage(ColorManager.checkmark, 0, 0, 22, 22, 0, 0, 100, 100, menuItem);
	}else if(menuItem instanceof JMenu){
		g.drawImage(ColorManager.arrow, menuItem.getWidth() - 12, 5, menuItem.getWidth(), 17, 0, 0, 128, 128, menuItem);
	}
	g.setColor(Main.config.customColors ? Main.config.foreground : Color.CYAN);
	if(hasCursor){
		g.drawLine(0, 0, menuItem.getWidth(), 0);
		g.drawLine(0, menuItem.getHeight() - 1, menuItem.getWidth(), menuItem.getHeight() - 1);
		Composite prev = g.getComposite();
		g.setComposite(MenuItemUI.mode);
		g.fillRect(0, 0, menuItem.getWidth(), menuItem.getHeight());
		g.setComposite(prev);
	}
	FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
	int mnemIndex = menuItem.getDisplayedMnemonicIndex();
	int y = (22 - fm.getHeight()) / 2;
	SwingUtilities2.drawStringUnderlineCharAt(menuItem, g, menuItem.getText(), mnemIndex, 22 + defaultTextIconGap, y + fm.getAscent());
}
 
开发者ID:RoanH,项目名称:KeysPerSecond,代码行数:30,代码来源:Menu.java

示例5: drawBackgroundImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Draws the background image (if there is one) aligned within the specified area.
 * 
 * @param g2  the graphics device.
 * @param area  the area.
 */
protected void drawBackgroundImage(Graphics2D g2, Rectangle2D area) {
    if (this.backgroundImage != null) {
        Composite originalComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC, this.backgroundAlpha));
        Rectangle2D dest = new Rectangle2D.Double(
            0.0, 0.0,
            this.backgroundImage.getWidth(null), this.backgroundImage.getHeight(null)
        );
        Align.align(dest, area, this.backgroundImageAlignment);
        g2.drawImage(
            this.backgroundImage,
            (int) dest.getX(), (int) dest.getY(),
            (int) dest.getWidth() + 1, (int) dest.getHeight() + 1, null
        );
        g2.setComposite(originalComposite);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:Plot.java

示例6: render

import java.awt.Graphics2D; //导入方法依赖的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

示例7: DrawImagem

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void DrawImagem(Graphics2D g) {
    BufferedImage imgB = getImagem();
    if (imgB == null) {
        return;
    }
    Rectangle rec = getBounds();
    rec.grow(-2, -2);
    if (imgres == null) {
        imgres = imgB.getScaledInstance(rec.width, rec.height, Image.SCALE_SMOOTH);
    }

    Composite originalComposite = g.getComposite();
    if (alfa != 1f) {
        int type = AlphaComposite.SRC_OVER;
        g.setComposite(AlphaComposite.getInstance(type, alfa));
    }
    Image img = imgres;
    if (isDisablePainted()) {
        img = util.Utilidades.dye(new ImageIcon(imgres), disabledColor);
    }
    
    g.drawImage(img, rec.x, rec.y, null);
    g.setComposite(originalComposite);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:25,代码来源:Desenhador.java

示例8: drawShadowPoint

import java.awt.Graphics2D; //导入方法依赖的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

示例9: drawShadowPoint

import java.awt.Graphics2D; //导入方法依赖的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

示例10: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
	super.paintComponent(g);

	Graphics2D g2d = (Graphics2D) g;
	Composite originalComposite = g2d.getComposite();

	boolean cond = this.getText().equals("")
			&& (!this.isFocusOwner() || !this.isEditable());

	if (!isEditable())
		g2d.setComposite(alphaComposite);

	// hack: assuming insets on all sites
	// are the same, because on mac margins are
	// not accepted...
	int mg = getInsets().top;
	// draw icons
	if (cond)
		g.drawImage(searchIcon, this.getWidth() - 18 - mg, 1 + mg, 16, 16,
				null);
	else
		g.drawImage(clearIcon, this.getWidth() - 18 - mg, 1 + mg, 16, 16,
				null);

	if (!isEditable())
		g2d.setComposite(originalComposite);

	// draw instruction
	if (cond) {
		g.setColor(Color.GRAY);
		g.drawString("Search for sites / edges...", 4 + mg, 14 + mg);
	}
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:35,代码来源:AbstractSearchField.java

示例11: drawSeries

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Plots the data for a given series.
 * 
 * @param g2  the drawing surface.
 * @param dataArea  the data area.
 * @param info  collects plot rendering info.
 * @param plot  the plot.
 * @param dataset  the dataset.
 * @param seriesIndex  the series index.
 */
public void drawSeries(Graphics2D g2, 
                       Rectangle2D dataArea, 
                       PlotRenderingInfo info,
                       PolarPlot plot,
                       XYDataset dataset,
                       int seriesIndex) {
    
    Polygon poly = new Polygon();
    int numPoints = dataset.getItemCount(seriesIndex);
    for (int i = 0; i < numPoints; i++) {
        double theta = dataset.getXValue(seriesIndex, i);
        double radius = dataset.getYValue(seriesIndex, i);
        Point p = plot.translateValueThetaRadiusToJava2D(theta, radius, 
                dataArea);
        poly.addPoint(p.x, p.y);
    }
    g2.setPaint(getSeriesPaint(seriesIndex));
    g2.setStroke(getSeriesStroke(seriesIndex));
    if (isSeriesFilled(seriesIndex)) {
        Composite savedComposite = g2.getComposite();
        g2.setComposite(AlphaComposite.getInstance(
                AlphaComposite.SRC_OVER, 0.5f));
        g2.fill(poly);
        g2.setComposite(savedComposite);
    }
    else {
        g2.draw(poly);
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:40,代码来源:DefaultPolarItemRenderer.java

示例12: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g) {
    if (isTransparent()) {
        Graphics2D g2 = (Graphics2D) g;
        final Composite oldComposite = g2.getComposite();
        g2.setComposite(TRANSPARENT_COMPOSITE);
        super.paintComponent(g);
        g2.setComposite(oldComposite);
    } else {
        super.paintComponent(g);
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:13,代码来源:DisplayTreeCellRenderer.java

示例13: PinteRegiao

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void PinteRegiao(Graphics2D g) {
    Composite originalComposite = g.getComposite();
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alfa));
    g.setPaint(this.getForeColor());

    if (isGradiente()) {
        int dist = 0;
        int w = getWidth() - dist;
        int h = getHeight() - dist;
        int L = getLeft();
        int T = getTop();
        boolean dv = getGDirecao() == VERTICAL;

        GradientPaint GP = new GradientPaint(L, T, getGradienteStartColor(), dv ? L : L + w, dv ? T + h : T, getGradienteEndColor(), true);
        g.setPaint(GP);
    }

    if (getTipoDesenho() != TipoDraw.tpTexto) {
        Stroke bkp = g.getStroke();
        if (isDashed()) {
            g.setStroke(new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{1, 2}, 0));
        }
        if (isGradiente()) {
            g.fill(getRegiao());
        }
        g.draw(getRegiao()); //Pinta as eventuais linhas internas do dezenho. Ex. LivreVariosDocumemtos 

        g.setStroke(bkp);
    }
    g.setComposite(originalComposite);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:33,代码来源:LivreBase.java

示例14: paint

import java.awt.Graphics2D; //导入方法依赖的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

示例15: 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


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