Java Code Examples for java.awt.TexturePaint

The following are top voted examples for showing how to use java.awt.TexturePaint. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: trashjam2017   File: ImagePanel.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Project: rapidminer   File: PlotInstanceLegendCreator.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 3
Project: Progetto-C   File: ImagePanel.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 4
Project: OpenJSharp   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 5
Project: jdk8u-jdk   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 6
Project: jdk8u-jdk   File: TexturePaintPrintingTest.java   Source Code and License 6 votes vote down vote up
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);

}
 
Example 7
Project: openjdk-jdk10   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 8
Project: openjdk-jdk10   File: TexturePaintPrintingTest.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 9
Project: openjdk9   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 10
Project: pumpernickel   File: ColorSwatch.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 11
Project: pumpernickel   File: ColorWellUI.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 12
Project: pumpernickel   File: BrushedMetalDemo.java   Source Code and License 6 votes vote down vote up
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();
}
 
Example 13
Project: Push2Display   File: SVGPaint.java   Source Code and License 6 votes vote down vote up
/**
 * @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;
}
 
Example 14
Project: jdk8u_jdk   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 15
Project: jdk8u_jdk   File: TexturePaintPrintingTest.java   Source Code and License 6 votes vote down vote up
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);

}
 
Example 16
Project: amidst   File: Drawer.java   Source Code and License 6 votes vote down vote up
@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()));
}
 
Example 17
Project: lookaside_java-1.8.0-openjdk   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 18
Project: iSeleda   File: ColorSwatch.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 19
Project: SweetHome3D   File: ImportedTextureWizardStepsPanel.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
}
 
Example 20
Project: SweetHome3D   File: PlanComponent.java   Source Code and License 6 votes vote down vote up
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));
}
 
Example 21
Project: rapidminer-studio   File: PlotInstanceLegendCreator.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 22
Project: swingx   File: PaintUtils.java   Source Code and License 6 votes vote down vote up
/**
 * 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));
}
 
Example 23
Project: dsworkbench   File: WelcomePanel.java   Source Code and License 6 votes vote down vote up
/** 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))));
    }
}
 
Example 24
Project: MeteoInfoLib   File: Draw.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 25
Project: MeteoInfoLib   File: Draw.java   Source Code and License 6 votes vote down vote up
/**
 * Draw polygon symbol
 *
 * @param aP The point
 * @param width The width
 * @param height The height
 * @param aPGB The polygon break
 * @param g Graphics2D
 */
public static void drawPolygonSymbol(PointF aP, float width, float height, PolygonBreak aPGB,
        Graphics2D g) {
    aP.X = aP.X - width / 2;
    aP.Y = aP.Y - height / 2;
    if (aPGB.isDrawFill()) {
        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(new Rectangle.Float(aP.X, aP.Y, width, height));
        } else {
            g.setColor(aPGB.getColor());
            g.fill(new Rectangle.Float(aP.X, aP.Y, width, height));
        }
    }
    if (aPGB.isDrawOutline()) {
        g.setColor(aPGB.getOutlineColor());
        g.setStroke(new BasicStroke(aPGB.getOutlineSize()));
        g.draw(new Rectangle.Float(aP.X, aP.Y, width, height));
    }
}
 
Example 26
Project: MeteoInfoLib   File: Draw.java   Source Code and License 6 votes vote down vote up
/**
 * Draw rectangle
 *
 * @param aPoint Start point
 * @param width Width
 * @param height Height
 * @param aPGB Polygon break
 * @param g Graphics2D
 */
public static void drawRectangle(PointF aPoint, float width, float height, PolygonBreak aPGB, Graphics2D g) {
    Color aColor = aPGB.getColor();
    if (aPGB.isDrawFill()) {
        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(new Rectangle.Float(aPoint.X, aPoint.Y, width, height));
        } else {
            g.setColor(aColor);
            g.fill(new Rectangle.Float(aPoint.X, aPoint.Y, width, height));
        }
    }
    if (aPGB.isDrawOutline()) {
        g.setColor(aPGB.getOutlineColor());
        g.setStroke(new BasicStroke(aPGB.getOutlineSize()));
        g.draw(new Rectangle.Float(aPoint.X, aPoint.Y, width, height));
    }
}
 
Example 27
Project: SpreaD3   File: ColorSwatch.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 28
Project: Push2Display   File: SVGPaint.java   Source Code and License 6 votes vote down vote up
/**
 * @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;
}
 
Example 29
Project: amidst   File: Drawer.java   Source Code and License 6 votes vote down vote up
@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()));
}
 
Example 30
Project: PDFReporter-Studio   File: EmptyTexture.java   Source Code and License 6 votes vote down vote up
public static TexturePaint createTexture(Color c1, Color c2) {
	int gridSize = 10;
	BufferedImage img = new BufferedImage(gridSize * 2, gridSize * 2, BufferedImage.TYPE_INT_ARGB);
	Graphics2D g2 = img.createGraphics();

	AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f);
	g2.setComposite(ac);

	g2.setColor(c1 != null ? c1 : COLOR1);
	g2.fillRect(0, 0, 10, 10);
	g2.fillRect(10, 10, 10, 10);

	g2.setColor(c2 != null ? c2 : COLOR2);
	g2.fillRect(10, 0, 10, 10);
	g2.fillRect(0, 10, 10, 10);

	return new TexturePaint(img, new java.awt.Rectangle(0, 0, gridSize, gridSize));
}
 
Example 31
Project: infobip-open-jdk-8   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 32
Project: jdk8u-dev-jdk   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 33
Project: aibench-project   File: ColorUtil.java   Source Code and License 6 votes vote down vote up
public static Paint getCheckerPaint(Color c1, Color c2, int size) {
    BufferedImage img = new BufferedImage(size,size,BufferedImage.TYPE_INT_ARGB);
    Graphics g = img.getGraphics();
    
    try {
        g.setColor(c1);
        g.fillRect(0, 0, size, size);
        g.setColor(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));
}
 
Example 34
Project: feathers-sdk   File: SVGPaint.java   Source Code and License 6 votes vote down vote up
/**
 * @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;
}
 
Example 35
Project: jdk7-jdk   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 36
Project: BattleNationsAnimation   File: Bitmap.java   Source Code and License 6 votes vote down vote up
private void read() throws IOException {
	LittleEndianInputStream in = new LittleEndianInputStream(
			GameFiles.open(name + "_0.z2raw"));
	try {
		int ver = in.readInt();
		if (ver < 0 || ver > 1)
			throw new FileFormatException("Unrecognized version");
		width = in.readInt();
		height = in.readInt();
		bits = in.readInt();
		BufferedImage im = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
		if (ver == 0)
			readRaw(im, in);
		else
			readRLE(im, in);
		texture = new TexturePaint(im, new Rectangle2D.Double(0, 0, 0x8000, 0x8000));
		originalTexture = texture;
	}
	catch (ArrayIndexOutOfBoundsException e) {
		throw new FileFormatException("Invalid array index", e);
	}
	finally {
		in.close();
	}
}
 
Example 37
Project: jMCS   File: ImageUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Create a cross hatched texture
 * @param size internal image size (height = width)
 * @param backgroundColor background color
 * @param stripeColor line color
 * @param stroke line stroke
 * @return cross hatched texture paint
 */
public static Paint createHatchedTexturePaint(final int size, final Color backgroundColor, final Color stripeColor, final Stroke stroke) {

    // create buffered image (alpha):
    final BufferedImage bufferedImage = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);

    final Graphics2D g2d = bufferedImage.createGraphics();

    // LBO: use antialiasing:
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

    g2d.setColor(backgroundColor);
    g2d.fillRect(0, 0, size, size);

    g2d.setStroke(stroke);
    g2d.setColor(stripeColor);
    g2d.drawLine(0, 0, size, size);
    g2d.drawLine(0, size, size, 0);

    g2d.dispose();

    return new TexturePaint(bufferedImage, new Rectangle(0, 0, size, size));
}
 
Example 38
Project: openjdk-source-code-learn   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 39
Project: passage   File: DrawingAttributes.java   Source Code and License 6 votes vote down vote up
/**
 * Get the Paint for these attributes, and scale it for the scale compared to
 * the base scale set if the fill Paint is a TexturePattern. If the base
 * scale equals NONE, or if the Paint is not a TexturePaint, it's the same as
 * getFillPaint().
 * 
 * @param scale scale to compare to the base scale.
 * @return a Paint object to use for the fill, scaled if necessary.
 */
public Paint getFillPaintForScale(float scale) {
   if (fillPattern != null) {
      if (baseScale != NONE) {
         BufferedImage bi = fillPattern.getImage();
         float scaleFactor = scale / baseScale;
         Image image =
               bi.getScaledInstance((int) (bi.getWidth() * scaleFactor), (int) (bi.getHeight() * scaleFactor),
                                    Image.SCALE_SMOOTH);
         try {
            bi = BufferedImageHelper.getBufferedImage(image, 0, 0, -1, -1);

            return new TexturePaint(bi, new Rectangle(0, 0, bi.getWidth(), bi.getHeight()));
         } catch (InterruptedException ie) {
            if (logger.isLoggable(Level.FINE)) {
               logger.warning("DrawingAttributes: Interrupted Exception scaling texture paint");
            }
         }
      }
      return fillPattern;
   } else {
      return fillPaint;
   }
}
 
Example 40
Project: OLD-OpenJDK8   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 41
Project: jpexs-decompiler   File: BitmapExporter.java   Source Code and License 6 votes vote down vote up
@Override
public void beginBitmapFill(int bitmapId, Matrix matrix, boolean repeat, boolean smooth, ColorTransform colorTransform) {
    finalizePath();
    ImageTag imageTag = swf.getImage(bitmapId);
    if (imageTag != null) {
        SerializableImage img = imageTag.getImageCached();
        if (img != null) {
            if (colorTransform != null) {
                img = colorTransform.apply(img);
            }

            fillPaint = new TexturePaint(img.getBufferedImage(), new java.awt.Rectangle(img.getWidth(), img.getHeight()));
            fillTransform = matrix.toTransform();
            return;
        }
    }

    // fill with red in case any error
    fillPaint = Color.RED;
    fillTransform = matrix.toTransform();
}
 
Example 42
Project: PyramidShader   File: ColorSwatch.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 43
Project: UiL-OTS-Video-Coding-System   File: PanelTimeframe.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a layout for the panel
 */
private void createLayout()
{
	this.slate = new TexturePaint(getTexture(), new Rectangle(0,0,10,10));
	
	this.labelbl = new JLabel();
	this.commentLbl = new JLabel();
	this.commentLbl.setForeground(Color.DARK_GRAY);
	
	this.contextMenu = new ContextMenu(g, tf);
	
	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
			setBorder(new EmptyBorder(margin, margin, 0, 0));
			add(labelbl);
			add(commentLbl);
			setComponentPopupMenu(contextMenu);
			pane.add(panel);
		}
	});
}
 
Example 44
Project: r2cat   File: AbstractVectorGraphicsIO.java   Source Code and License 6 votes vote down vote up
/**
 * Sets the current paint. Dispatches to writePaint(Color),
 * writePaint(GradientPaint), writePaint(TexturePaint paint) or
 * writePaint(Paint). In the case paint is a Color the current color is also
 * changed.
 *
 * @param paint to be set
 */
public void setPaint(Paint paint) {
	if (paint == null) return;
	
    if (paint.equals(getPaint()))
        return;

    try {
        if (paint instanceof Color) {
            setColor((Color) paint);
        } else if (paint instanceof GradientPaint) {
            super.setPaint(paint);
            writePaint((GradientPaint) paint);
        } else if (paint instanceof TexturePaint) {
            super.setPaint(paint);
            writePaint((TexturePaint) paint);
        } else {
            super.setPaint(paint);
            writePaint(paint);
        }
    } catch (IOException e) {
        handleException(e);
    }
}
 
Example 45
Project: r2cat   File: PDFPaintDelayQueue.java   Source Code and License 6 votes vote down vote up
/** Creates a stream for every delayed image. */
public void processAll() throws IOException {
    ListIterator i = paintList.listIterator();
    while (i.hasNext()) {
        Entry e = (Entry) i.next();

        if (!e.written) {
            e.written = true;
            if (e.paint instanceof GradientPaint) {
                addGradientPaint(e);
            } else if (e.paint instanceof TexturePaint) {
                addTexturePaint(e);
            } else {
                System.err.println("PDFWriter: Paint of class '"
                        + e.paint.getClass() + "' not supported.");
                // FIXME, we could write a color here, to keep the file
                // valid.
            }
        }
    }
}
 
Example 46
Project: TerrainViewer   File: ColorSwatch.java   Source Code and License 6 votes vote down vote up
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);
	PaintUtils.drawBevel(g, r);
}
 
Example 47
Project: openjdk-jdk7u-jdk   File: RenderTests.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 48
Project: BfROpenLab   File: JungUtils.java   Source Code and License 6 votes vote down vote up
private static Paint mixWith(Paint paint, Color mix) {
	if (paint instanceof Color) {
		Color c = (Color) paint;

		return new Color((c.getRed() + mix.getRed()) / 2, (c.getGreen() + mix.getGreen()) / 2,
				(c.getBlue() + mix.getBlue()) / 2, (c.getAlpha() + mix.getAlpha()) / 2);
	} else if (paint instanceof TexturePaint) {
		BufferedImage texture = ((TexturePaint) paint).getImage();
		BufferedImage mixed = new BufferedImage(texture.getWidth(), texture.getHeight(), texture.getType());

		for (int x = 0; x < texture.getWidth(); x++) {
			for (int y = 0; y < texture.getHeight(); y++) {
				mixed.setRGB(x, y, ((Color) mixWith(new Color(texture.getRGB(x, y)), mix)).getRGB());
			}
		}

		return new TexturePaint(mixed, new Rectangle(mixed.getWidth(), mixed.getHeight()));
	} else {
		return paint;
	}
}
 
Example 49
Project: birt   File: SVGGraphics2D.java   Source Code and License 6 votes vote down vote up
protected Element createTexturePaint( TexturePaint paint, String imgId,
		boolean highlight )
{
	Element elem = dom.createElement( "pattern" ); //$NON-NLS-1$
	if ( highlight )
		elem.setAttribute( "id", getTextureId( paint ) + "h" ); //$NON-NLS-1$ //$NON-NLS-2$
	else
		elem.setAttribute( "id", getTextureId( paint ) ); //$NON-NLS-1$
	
	BufferedImage img = paint.getImage( );
	int width = img.getWidth( );
	int height = img.getHeight( );
	elem.setAttribute( "patternUnits", "userSpaceOnUse" );  //$NON-NLS-1$//$NON-NLS-2$
	elem.setAttribute( "width", Integer.toString( width ) ); //$NON-NLS-1$
	elem.setAttribute( "height", Integer.toString( height ) ); //$NON-NLS-1$

	Element elemUse = dom.createElement( "use" ); //$NON-NLS-1$
	elemUse.setAttribute( "x", "0" );  //$NON-NLS-1$//$NON-NLS-2$
	elemUse.setAttribute( "y", "0" );  //$NON-NLS-1$//$NON-NLS-2$
	elemUse.setAttribute( "xlink:href", "#" + imgId );  //$NON-NLS-1$//$NON-NLS-2$
	
	elem.appendChild( elemUse );
	return elem;
}
 
Example 50
Project: Disparity-RHE   File: ImagePanel.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 51
Project: OOGASalad   File: MapCreationView.java   Source Code and License 6 votes vote down vote up
/**
 * Paints a tile in the view at the given x-
 * and y-coordinates. Called by the mouse listener
 * which handles the point-and-click painting of
 * tiles on the part of the user.
 * 
 * @param g
 * @param x
 * @param y
 */
public void paintTile (Graphics2D g, int x, int y) {
	if (isValueSelected()) {
		TexturePaint tp =
				new TexturePaint(myCurrentTile.getImage(),
						new Rectangle(0,
								0,
								(int) myTileManager.getTileWidth(),
								(int) myTileManager.getTileHeight()));

		g.setPaint(tp);
		g.fillRect((int) myTileManager.getTileAnchorX(x),
				(int) myTileManager.getTileAnchorY(y),
				(int) myTileManager.getTileWidth(),
				(int) myTileManager.getTileHeight());
	}

}
 
Example 52
Project: rapidminer-5   File: PlotInstanceLegendCreator.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 53
Project: jClipCorn   File: CoverCropDialog.java   Source Code and License 6 votes vote down vote up
private void imageChanged() {
	imgheight = img.getHeight();
	imgwidth = img.getWidth();
	crop_tl = new Point(0, 0);
	crop_br = new Point(imgwidth, imgheight);
	
	BufferedImage pattern = new BufferedImage(16, 16, BufferedImage.TYPE_4BYTE_ABGR);
	Graphics gpat = pattern.getGraphics();
	gpat.setColor(Color.LIGHT_GRAY);
	gpat.fillRect(0, 0, 16, 16);
	gpat.setColor(Color.WHITE);
	gpat.fillRect(0, 0, 8, 8);
	gpat.fillRect(8, 8, 16, 16);
	transparencyPattern = new TexturePaint(pattern, new Rectangle(0, 0, 16, 16));
	
	updateCropInfoLabel();
}
 
Example 54
Project: fop   File: AFPGraphics2D.java   Source Code and License 6 votes vote down vote up
/**
     * Apply the java paint to the AFP.
     * This takes the java paint sets up the appropriate AFP commands
     * for the drawing with that paint.
     * Currently this supports the gradients and patterns from batik.
     *
     * @param paint the paint to convert to AFP
     * @param fill true if the paint should be set for filling
     * @return true if the paint is handled natively, false if the paint should be rasterized
     */
    private boolean applyPaint(Paint paint, boolean fill) {
        if (paint instanceof Color) {
            return true;
        }
        LOG.debug("NYI: applyPaint() " + paint + " fill=" + fill);
        if (paint instanceof TexturePaint) {
//            TexturePaint texturePaint = (TexturePaint)paint;
//            BufferedImage bufferedImage = texturePaint.getImage();
//            AffineTransform at = paintingState.getTransform();
//            int x = (int)Math.round(at.getTranslateX());
//            int y = (int)Math.round(at.getTranslateY());
//            drawImage(bufferedImage, x, y, null);
        }
        return false;
    }
 
Example 55
Project: proyecto-teoria-control-utn-frro   File: PaintAlpha.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new <code>TexturePaint</code> with its colours darkened.
 * <p>
 * This entails cloning the underlying <code>BufferedImage</code>,
 * then darkening each colour-pixel individually!
 *
 * @param paint a <code>TexturePaint</code>
 *
 * @param ignoreThisDummyArgument which is just to guarantee a unique
 *        method signature
 *
 * @return a darker version of the <code>TexturePaint</code>
 */
private static TexturePaint darker(TexturePaint paint,
        boolean ignoreThisDummyArgument) {
    try {
        return darker(paint);
    }
    catch (Exception e) {
        /*
         * Lots can go wrong while fiddling with Images, Colour Models
         * & such!  If anything at all goes awry, just return the original
         * TexturePaint.  (TexturePaint's are immutable anyway, so no harm
         * done)
         */
        return paint;
    }
}
 
Example 56
Project: IDDEA   File: InteractiveDrawingView.java   Source Code and License 6 votes vote down vote up
/**
 * Returns a paint for drawing the background of the drawing area.
 * @return Paint.
 */
protected Paint getBackgroundPaint(
        int x, int y) {
    if (backgroundTile == null) {
        backgroundTile = new BufferedImage(16, 16, BufferedImage.TYPE_INT_RGB);
        Graphics2D g = backgroundTile.createGraphics();
        g.setColor(Color.white);
        g.fillRect(0, 0, 16, 16);
        g.setColor(new Color(0xdfdfdf));
        g.fillRect(0, 0, 8, 8);
        g.fillRect(8, 8, 8, 8);
        g.dispose();
    }

    return new TexturePaint(backgroundTile,
            new Rectangle(x, y, backgroundTile.getWidth(), backgroundTile.getHeight()));
}
 
Example 57
Project: Memetic-Algorithm-for-TSP   File: PaintAlpha.java   Source Code and License 6 votes vote down vote up
/**
 * Create a new <code>TexturePaint</code> with its colours darkened.
 * <p>
 * This entails cloning the underlying <code>BufferedImage</code>,
 * then darkening each colour-pixel individually!
 *
 * @param paint a <code>TexturePaint</code>
 *
 * @param ignoreThisDummyArgument which is just to guarantee a unique
 *        method signature
 *
 * @return a darker version of the <code>TexturePaint</code>
 */
private static TexturePaint darker(TexturePaint paint,
        boolean ignoreThisDummyArgument) {
    try {
        return darker(paint);
    }
    catch (Exception e) {
        /*
         * Lots can go wrong while fiddling with Images, Colour Models
         * & such!  If anything at all goes awry, just return the original
         * TexturePaint.  (TexturePaint's are immutable anyway, so no harm
         * done)
         */
        return paint;
    }
}
 
Example 58
Project: slick2d-maven   File: ImagePanel.java   Source Code and License 6 votes vote down vote up
/**
 * 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);
}
 
Example 59
Project: freedomotic   File: Renderer.java   Source Code and License 6 votes vote down vote up
/**
 *
 * @param textureFile
 * @param shape
 */
protected void paintTexture(String textureFile, Shape shape) {
    BufferedImage img = null;
    Graphics2D g2 = (Graphics2D) getContext();

    if (textureFile != null) {
        img = ResourcesManager.getResource(textureFile);

        if (img != null) {
            Rectangle2D replicationPath = new Rectangle2D.Double(0,
                    0,
                    img.getWidth(),
                    img.getHeight());
            TexturePaint texture = new TexturePaint(img, replicationPath);
            g2.setPaint(texture);
            g2.fill(shape);
        }
    }
}
 
Example 60
Project: trashjam2017   File: SheetPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Create a panel showing a sprite sheet
 * 
 * @param p The GUI tool this panel is part of
 */
public SheetPanel(Packer p) {
	this.packer = p;
	
	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()));
	
	addMouseListener(new MouseAdapter() {
		public void mousePressed(MouseEvent e) {
			Sprite sprite = packer.getSpriteAt(e.getX(), e.getY());
			
			if (sprite != null) {
				ArrayList selection = new ArrayList();
				if ((e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0) {
					selection.addAll(selected);
				}
				selection.add(sprite);
				
				packer.select(selection);
			}
		}
	});
}