當前位置: 首頁>>代碼示例>>Java>>正文


Java TexturePaint類代碼示例

本文整理匯總了Java中java.awt.TexturePaint的典型用法代碼示例。如果您正苦於以下問題:Java TexturePaint類的具體用法?Java TexturePaint怎麽用?Java TexturePaint使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TexturePaint類屬於java.awt包,在下文中一共展示了TexturePaint類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: ImagePanel

import java.awt.TexturePaint; //導入依賴的package包/類
/**
 * Create a new empty image panel
 */
public ImagePanel() {
	super();
	
	Color base = Color.gray;
	BufferedImage image = new BufferedImage(50, 50,
			BufferedImage.TYPE_INT_ARGB);
	Graphics2D g = (Graphics2D) image.getGraphics();
	g.setColor(base);
	g.fillRect(0, 0, image.getWidth(), image.getHeight());
	g.setColor(base.darker());
	g.fillRect(image.getWidth() / 2, 0, image.getWidth() / 2, image
			.getHeight() / 2);
	g.fillRect(0, image.getHeight() / 2, image.getWidth() / 2, image
			.getHeight() / 2);

	background = new TexturePaint(image, new Rectangle(0, 0, image
			.getWidth(), image.getHeight()));
	
   	setBackground(Color.black);
}
 
開發者ID:j-dong,項目名稱:trashjam2017,代碼行數:24,代碼來源:ImagePanel.java

示例2: createTransparentCheckeredPaint

import java.awt.TexturePaint; //導入依賴的package包/類
private static Paint createTransparentCheckeredPaint(Color color, int checkerSize) {
	int s = checkerSize;
	BufferedImage bufferedImage = new BufferedImage(2 * s, 2 * s, BufferedImage.TYPE_INT_ARGB);

	Graphics2D g2 = bufferedImage.createGraphics();
	g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias!
			RenderingHints.VALUE_ANTIALIAS_ON);

	Color c1 = DataStructureUtils.setColorAlpha(color, (int) (color.getAlpha() * .8));
	Color c2 = DataStructureUtils.setColorAlpha(color, (int) (color.getAlpha() * .2));
	g2.setStroke(new BasicStroke(0));
	g2.setPaint(c2);
	g2.setColor(c2);
	g2.fillRect(0, 0, s, s);
	g2.fillRect(s, s, s, s);
	g2.setPaint(c1);
	g2.setColor(c1);
	g2.fillRect(0, s, s, s);
	g2.fillRect(s, 0, s, s);

	// paint with the texturing brush
	Rectangle2D rect = new Rectangle2D.Double(0, 0, 2 * s, 2 * s);
	return new TexturePaint(bufferedImage, rect);
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:25,代碼來源:PlotInstanceLegendCreator.java

示例3: makeTexturePaint

import java.awt.TexturePaint; //導入依賴的package包/類
private TexturePaint makeTexturePaint(int size, boolean alpha) {
    int s2 = size / 2;
    int type =
        alpha ? BufferedImage.TYPE_INT_ARGB : BufferedImage.TYPE_INT_RGB;
    BufferedImage img = new BufferedImage(size, size, type);
    Color[] colors = makeGradientColors(4, alpha);
    Graphics2D g2d = img.createGraphics();
    g2d.setComposite(AlphaComposite.Src);
    g2d.setColor(colors[0]);
    g2d.fillRect(0, 0, s2, s2);
    g2d.setColor(colors[1]);
    g2d.fillRect(s2, 0, s2, s2);
    g2d.setColor(colors[3]);
    g2d.fillRect(0, s2, s2, s2);
    g2d.setColor(colors[2]);
    g2d.fillRect(s2, s2, s2, s2);
    g2d.dispose();
    Rectangle2D bounds = new Rectangle2D.Float(0, 0, size, size);
    return new TexturePaint(img, bounds);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:21,代碼來源:RenderTests.java

示例4: doPaint

import java.awt.TexturePaint; //導入依賴的package包/類
public void doPaint(Graphics2D g2d) {
    BufferedImage patternImage = new BufferedImage(2,2,BufferedImage.TYPE_INT_ARGB);
            Graphics gImage = patternImage.getGraphics();
            gImage.setColor(Color.WHITE);
            gImage.drawLine(0,1,1,0);
            gImage.setColor(Color.BLACK);
            gImage.drawLine(0,0,1,1);
            gImage.dispose();

            Rectangle2D.Double shape = new Rectangle2D.Double(0,0,DIM*6/5, DIM*8/5);
            g2d.setPaint(new TexturePaint(patternImage, new Rectangle2D.Double(0,0,
                    DIM*6/50, DIM*8/50)));
            g2d.fill(shape);
            g2d.setPaint(Color.BLACK);
            g2d.draw(shape);

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:18,代碼來源:TexturePaintPrintingTest.java

示例5: doPaint

import java.awt.TexturePaint; //導入依賴的package包/類
public void doPaint(Graphics2D g2d) {
    BufferedImage patternImage = new BufferedImage(2,2,BufferedImage.TYPE_INT_ARGB);
    Graphics gImage = patternImage.getGraphics();
    gImage.setColor(Color.WHITE);
    gImage.drawLine(0,1,1,0);
    gImage.setColor(Color.BLACK);
    gImage.drawLine(0,0,1,1);
    gImage.dispose();

    Rectangle2D.Double shape = new Rectangle2D.Double(0,0,DIM*6/5, DIM*8/5);
    g2d.setPaint(new TexturePaint(patternImage, new Rectangle2D.Double(0,0,
                 DIM*6/50, DIM*8/50)));
    g2d.fill(shape);
    g2d.setPaint(Color.BLACK);
    g2d.draw(shape);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:17,代碼來源:TexturePaintPrintingTest.java

示例6: paint

import java.awt.TexturePaint; //導入依賴的package包/類
@Override
public void paint(Graphics g0) {
	super.paint(g0); //may be necessary for some look-and-feels?
	
	Graphics2D g = (Graphics2D)g0;
	
	Color c = getForeground();
	int w2 = Math.min(getWidth(), w);
	int h2 = Math.min(getHeight(), w);
	Rectangle r = new Rectangle(getWidth()/2-w2/2,getHeight()/2-h2/2, w2, h2);
	
	if(c.getAlpha()<255) {
		TexturePaint checkers = getCheckerPaint();
		g.setPaint(checkers);
		g.fillRect(r.x, r.y, r.width, r.height);
	}
	g.setColor(c);
	g.fillRect(r.x, r.y, r.width, r.height);
	PlafPaintUtils.drawBevel(g, r);
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:21,代碼來源:ColorSwatch.java

示例7: paint

import java.awt.TexturePaint; //導入依賴的package包/類
@Override
public void paint(Graphics g0, JComponent c) {
	Graphics2D g = (Graphics2D)g0;
	ColorWell well = (ColorWell)c;
	Color color = well.getColor();
	Border border = c.getBorder();
	Insets borderInsets = border.getBorderInsets(c);
	if(color.getAlpha()<255) {
		TexturePaint checkers = PlafPaintUtils.getCheckerBoard(8);
		g.setPaint(checkers);
		g.fillRect(borderInsets.left, borderInsets.top, 
				c.getWidth()-borderInsets.left-borderInsets.right, 
				c.getHeight()-borderInsets.top-borderInsets.bottom);
	}
	g.setColor(color);
	g.fillRect(borderInsets.left, borderInsets.top, 
			c.getWidth()-borderInsets.left-borderInsets.right, 
			c.getHeight()-borderInsets.top-borderInsets.bottom);
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:20,代碼來源:ColorWellUI.java

示例8: setMetalColor

import java.awt.TexturePaint; //導入依賴的package包/類
protected void setMetalColor(Color c) {
	BufferedImage image = BrushedMetalLook.getImage(c);
	texturePaint = new TexturePaint(image, new Rectangle(0,0,image.getWidth(),image.getHeight()));
	
	Shape shape = new Ellipse2D.Float(100,100,400,400);
	image = BrushedMetalLook.paint(shape, 20, null, c, true);
	Icon icon1 = new ImageIcon(image);
	label1.setIcon(icon1);
	
	shape = new Line2D.Float(100,100,500,500);
	image = BrushedMetalLook.paint(shape, 20, null, c, true);
	ImageIcon icon2 = new ImageIcon(image);
	label2.setIcon(icon2);

	shape = new Line2D.Float(100,500,500,100);
	image = BrushedMetalLook.paint(shape, 20, null, c, true);
	ImageIcon icon3 = new ImageIcon(image);
	label3.setIcon(icon3);
	
	tabs.repaint();
}
 
開發者ID:mickleness,項目名稱:pumpernickel,代碼行數:22,代碼來源:BrushedMetalDemo.java

示例9: toSVG

import java.awt.TexturePaint; //導入依賴的package包/類
/**
 * @param paint Paint to be converted to SVG
 * @return a descriptor of the corresponding SVG paint
 */
public SVGPaintDescriptor toSVG(Paint paint){
    // we first try the extension handler because we may
    // want to override the way a Paint is managed!
    SVGPaintDescriptor paintDesc = svgCustomPaint.toSVG(paint);

    if (paintDesc == null) {
        if (paint instanceof Color)
            paintDesc = SVGColor.toSVG((Color)paint, generatorContext);
        else if (paint instanceof GradientPaint)
            paintDesc = svgLinearGradient.toSVG((GradientPaint)paint);
        else if (paint instanceof TexturePaint)
            paintDesc = svgTexturePaint.toSVG((TexturePaint)paint);
    }

    return paintDesc;
}
 
開發者ID:git-moss,項目名稱:Push2Display,代碼行數:21,代碼來源:SVGPaint.java

示例10: Drawer

import java.awt.TexturePaint; //導入依賴的package包/類
@CalledOnlyBy(AmidstThread.EDT)
public Drawer(
		FragmentGraph graph,
		FragmentGraphToScreenTranslator translator,
		Zoom zoom,
		Movement movement,
		List<Widget> widgets,
		Iterable<FragmentDrawer> drawers,
		Setting<Dimension> dimensionSetting,
		Graphics2DAccelerationCounter accelerationCounter) {
	this.graph = graph;
	this.translator = translator;
	this.zoom = zoom;
	this.movement = movement;
	this.widgets = widgets;
	this.drawers = drawers;
	this.dimensionSetting = dimensionSetting;
	this.accelerationCounter = accelerationCounter;
	this.voidTexturePaint = new TexturePaint(
			VOID_TEXTURE,
			new Rectangle(0, 0, VOID_TEXTURE.getWidth(), VOID_TEXTURE.getHeight()));
}
 
開發者ID:toolbox4minecraft,項目名稱:amidst,代碼行數:23,代碼來源:Drawer.java

示例11: updateAttributesPreviewImage

import java.awt.TexturePaint; //導入依賴的package包/類
/**
 * Updates the image shown in attributes panel.
 */
private void updateAttributesPreviewImage()
{
	BufferedImage attributesPreviewImage = this.attributesPreviewComponent.getImage();
	if (attributesPreviewImage == null || attributesPreviewImage == this.imageChoicePreviewComponent.getImage())
	{
		attributesPreviewImage = new BufferedImage(IMAGE_PREFERRED_SIZE, IMAGE_PREFERRED_SIZE,
				BufferedImage.TYPE_INT_RGB);
		this.attributesPreviewComponent.setImage(attributesPreviewImage);
	}
	// Fill image with a white background
	Graphics2D g2D = (Graphics2D) attributesPreviewImage.getGraphics();
	g2D.setPaint(Color.WHITE);
	g2D.fillRect(0, 0, IMAGE_PREFERRED_SIZE, IMAGE_PREFERRED_SIZE);
	BufferedImage textureImage = this.imageChoicePreviewComponent.getImage();
	if (textureImage != null)
	{
		// Draw the texture image as if it will be shown on a 250 x 250 cm wall
		g2D.setPaint(new TexturePaint(textureImage,
				new Rectangle2D.Float(0, 0, this.controller.getWidth() / 250 * IMAGE_PREFERRED_SIZE,
						this.controller.getHeight() / 250 * IMAGE_PREFERRED_SIZE)));
		g2D.fillRect(0, 0, IMAGE_PREFERRED_SIZE, IMAGE_PREFERRED_SIZE);
	}
	g2D.dispose();
	this.attributesPreviewComponent.repaint();
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:29,代碼來源:ImportedTextureWizardStepsPanel.java

示例12: setTexturedIcon

import java.awt.TexturePaint; //導入依賴的package包/類
private void setTexturedIcon(Component c, BufferedImage textureImage, float angle)
{
	// Paint plan icon in an image
	BufferedImage image = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB);
	final Graphics2D imageGraphics = (Graphics2D) image.getGraphics();
	imageGraphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
	PieceOfFurniturePlanIcon.super.paintIcon(c, imageGraphics, 0, 0);
	
	// Fill the pixels of plan icon with texture image
	imageGraphics
			.setPaint(new TexturePaint(textureImage,
					new Rectangle2D.Float(0, 0,
							-getIconWidth() / this.pieceWidth * this.pieceTexture.getWidth(),
							-getIconHeight() / this.pieceDepth * this.pieceTexture.getHeight())));
	imageGraphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_IN));
	imageGraphics.rotate(angle);
	float maxDimension = Math.max(image.getWidth(), image.getHeight());
	imageGraphics.fill(new Rectangle2D.Float(-maxDimension, -maxDimension, 3 * maxDimension, 3 * maxDimension));
	imageGraphics.fillRect(0, 0, getIconWidth(), getIconHeight());
	imageGraphics.dispose();
	
	setIcon(new ImageIcon(image));
}
 
開發者ID:valsr,項目名稱:SweetHome3D,代碼行數:24,代碼來源:PlanComponent.java

示例13: getCheckerPaint

import java.awt.TexturePaint; //導入依賴的package包/類
/**
 * Creates a new {@code Paint} that is a checkered effect using the specified colors.
 * <p>
 * While this method supports transparent colors, this implementation performs painting
 * operations using the second color after it performs operations using the first color. This
 * means that to create a checkered paint with a fully-transparent color, you MUST specify that
 * color first.
 * 
 * @param c1
 *            the first color
 * @param c2
 *            the second color
 * @param size
 *            the size of the paint
 * @return a new {@code Paint} checkering the supplied colors
 */
public static Paint getCheckerPaint(Paint c1, Paint c2, int size) {
    BufferedImage img = GraphicsUtilities.createCompatibleTranslucentImage(size, size);
    Graphics2D g = img.createGraphics();
    
    try {
        g.setPaint(c1);
        g.fillRect(0, 0, size, size);
        g.setPaint(c2);
        g.fillRect(0, 0, size / 2, size / 2);
        g.fillRect(size / 2, size / 2, size / 2, size / 2);
    } finally {
        g.dispose();
    }
    
    return new TexturePaint(img,new Rectangle(0,0,size,size));
}
 
開發者ID:RockManJoe64,項目名稱:swingx,代碼行數:33,代碼來源:PaintUtils.java

示例14: WelcomePanel

import java.awt.TexturePaint; //導入依賴的package包/類
/** Creates new form WelcomePanel */
public WelcomePanel() {
    initComponents();
    setOpaque(true);
    welcomeTooltipMap.put(jxHelpLabel, "<html> <h2 style='color:#953333; font-weight: bold;'>Integrierte Hilfe</h2> DS Workbench bietet eine umfangreiche Hilfe, die du im Programm jederzeit &uuml;ber <strong>F1</strong> aufrufen kannst. Dabei wird versucht, das passende Hilfethema f&uuml;r die Ansicht, in der du dich gerade befindest, auszuw&auml;hlen. Es schadet aber auch nicht, einfach mal so in der Hilfe zu st&ouml;bern um neue Funktionen zu entdecken. Einsteiger sollten in jedem Fall die ersten drei Kapitel der Wichtigen Grundlagen gelesen haben.</html>");
    welcomeTooltipMap.put(jxCommunityLabel, "<html> <h2 style='color:#953333; font-weight: bold;'>Die DS Workbench Community</h2> Nat&uuml;rlich gibt es neben dir noch eine Vielzahl anderer Spieler, die DS Workbench regelm&auml;&szlig;ig und intensiv benutzen. Einen perfekten Anlaufpunkt f&uuml;r alle Benutzer bietet das DS Workbench Forum, wo man immer jemanden trifft mit dem man Erfahrungen austauschen und wo man Fragen stellen kann.</html>");
    welcomeTooltipMap.put(jxIdeaLabel, "<html> <h2 style='color:#953333; font-weight: bold;'>Verbesserungen und Ideen </h2> Gibt es irgendwas wo du meinst, dass es in DS Workbench fehlt und was anderen Benutzern auch helfen k&ouml;nnte? Hast du eine Idee, wie man DS Workbench verbessern oder die Handhabung vereinfachen k&ouml;nnte? Dann bietet dieser Bereich im DS Workbench Forum die perfekte Anlaufstelle f&uuml;r dich. Trau dich und hilf mit, DS Workbench  zu verbessern. </html>");
    welcomeTooltipMap.put(jxFacebookLabel, "<html> <h2 style='color:#953333; font-weight: bold;'>DS Workbench @ Facebook</h2> Nat&uuml;rlich geh&ouml;rt es heutzutage fast zum guten Ton, bei Facebook in irgendeiner Art und Weise vertreten zu sein. Auch DS Workbench hat eine eigene Facebook Seite, mit deren Hilfe ihr euch jederzeit &uuml;ber aktuelle News oder Geschehnisse im Zusammenhang mit DS Workbench informieren k&ouml;nnt.</html>");
    welcomeTooltipMap.put(jContentLabel, "<html> <h2 style='color:#953333'>Willkommen bei DS Workbench</h2> Wenn du diese Seite siehst, dann hast du DS Workbench erfolgreich installiert und die ersten Schritte ebenso erfolgreich gemeistert. Eigentlich steht nun einer unbeschwerten Angriffsplanung und -durchf&uuml;hrung nichts mehr im Wege. Erlaube mir trotzdem kurz auf einige Dinge hinzuweisen, die dir m&ouml;glicherweise beim <b>Umgang mit DS Workbench helfen</b> oder aber dir die M&ouml;glichkeit geben, einen wichtigen Teil zur <b>Weiterentwicklung und stetigen Verbesserung</b> dieses Programms beizutragen. Fahre einfach mit der Maus &uuml;ber eins der vier Symbole in den Ecken, um hilfreiche und interessante Informationen rund um DS Workbench zu erfahren. Klicke auf ein Symbol, um direkt zum entsprechenden Ziel zu gelangen. Die Eintr&auml;ge findest du sp&auml;ter auch im Hauptmen&uuml; unter 'Sonstiges'. <br> <h3 style='color:#953333'> Nun aber viel Spa&szlig; mit DS Workbench.</h3> </html>");
    try {
        back = ImageIO.read(WelcomePanel.class.getResource("/images/c.gif"));
    } catch (Exception ignored) {
    }
    if (back != null) {
        setBackgroundPainter(new MattePainter(new TexturePaint(back, new Rectangle2D.Float(0, 0, 200, 20))));
    }
}
 
開發者ID:Torridity,項目名稱:dsworkbench,代碼行數:18,代碼來源:WelcomePanel.java

示例15: fillPolygon

import java.awt.TexturePaint; //導入依賴的package包/類
/**
 * Fill polygon
 *
 * @param points The points array
 * @param g Graphics2D
 * @param aPGB Polygon break
 */
public static void fillPolygon(PointF[] points, Graphics2D g, PolygonBreak aPGB) {
    GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, points.length);
    for (int i = 0; i < points.length; i++) {
        if (i == 0) {
            path.moveTo(points[i].X, points[i].Y);
        } else {
            path.lineTo(points[i].X, points[i].Y);
        }
    }
    path.closePath();

    if (aPGB != null) {
        if (aPGB.isUsingHatchStyle()) {
            int size = aPGB.getStyleSize();
            BufferedImage bi = getHatchImage(aPGB.getStyle(), size, aPGB.getColor(), aPGB.getBackColor());
            Rectangle2D rect = new Rectangle2D.Double(0, 0, size, size);
            g.setPaint(new TexturePaint(bi, rect));
            g.fill(path);
        } else {
            g.fill(path);
        }
    } else {
        g.fill(path);
    }
}
 
開發者ID:meteoinfo,項目名稱:MeteoInfoLib,代碼行數:33,代碼來源:Draw.java


注:本文中的java.awt.TexturePaint類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。