Java Code Examples for java.awt.RenderingHints#KEY_RENDERING

The following examples show how to use java.awt.RenderingHints#KEY_RENDERING . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProgressPanel.java    From wpcleaner with Apache License 2.0 6 votes vote down vote up
/**
 * Constructor.
 * 
 * @param application Application name.
 * @param text Displayed text.
 * @param shield Transparency.
 */
public ProgressPanel(String application, String text, float shield) {
  this.application = application;
  this.text = text;
  this.shield = shield;

  this.hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
  this.hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
  this.hints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);

  this.background = new Color(255, 255, 255, (int) (alphaLevel * this.shield));
  this.textBackground = new Color(0, 255, 255, (int) (alphaLevel * this.shield));

  setOpaque(false);
  setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
 
Example 2
Source File: ColorTools.java    From commons-imaging with Apache License 2.0 6 votes vote down vote up
public BufferedImage convertToColorSpace(final BufferedImage bi, final ColorSpace to) {
    final ColorSpace from = bi.getColorModel().getColorSpace();

    final RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
    hints.put(RenderingHints.KEY_COLOR_RENDERING,
            RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    hints.put(RenderingHints.KEY_DITHERING,
            RenderingHints.VALUE_DITHER_ENABLE);

    final ColorConvertOp op = new ColorConvertOp(from, to, hints);

    BufferedImage result = op.filter(bi, null);

    result = relabelColorSpace(result, to);

    return result;
}
 
Example 3
Source File: ColorTools.java    From commons-imaging with Apache License 2.0 6 votes vote down vote up
public BufferedImage convertBetweenColorSpaces(BufferedImage bi,
        final ColorSpace from, final ColorSpace to) {
    final RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
    hints.put(RenderingHints.KEY_COLOR_RENDERING,
            RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    hints.put(RenderingHints.KEY_DITHERING,
            RenderingHints.VALUE_DITHER_ENABLE);

    final ColorConvertOp op = new ColorConvertOp(from, to, hints);

    bi = relabelColorSpace(bi, from);

    BufferedImage result = op.filter(bi, null);

    result = relabelColorSpace(result, to);

    return result;
}
 
Example 4
Source File: InfiniteProgressPanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
public InfiniteProgressPanel( String text, int barsCount, float shield, int fps, int rampDelay ) {
    setText( text );
    this.fadeDelay = rampDelay >= 0 ? rampDelay : 0;
    this.shield = shield >= 0.0f ? shield : 0.0f;
    this.fps = fps > 0 ? fps : 15;
    this.barsCount = barsCount > 0 ? barsCount : 14;
    
    this.hints = new RenderingHints( RenderingHints.KEY_RENDERING,
        RenderingHints.VALUE_RENDER_QUALITY );
    this.hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    this.hints.put( RenderingHints.KEY_FRACTIONALMETRICS,
        RenderingHints.VALUE_FRACTIONALMETRICS_ON );        
}
 
Example 5
Source File: AnimatedPanel.java    From qmcflactomp3 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Modifie la luminosit茅 de l'image.
 *
 * @param multiple Le taux de luminosit茅
 */
private void setBrightness(float multiple) {
    float[] brightKernel = { multiple };
    RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    BufferedImageOp bright = new ConvolveOp(new Kernel(1, 1, brightKernel), ConvolveOp.EDGE_NO_OP, hints);
    bright.filter(originalImage, convolvedImage);
    repaint();
}
 
Example 6
Source File: InfiniteProgressPanel.java    From qmcflactomp3 with GNU General Public License v3.0 5 votes vote down vote up
public InfiniteProgressPanel(String text, int barsCount, float shield, float fps, int rampDelay) {
    this.text = text;
    this.rampDelay = rampDelay >= 0 ? rampDelay : 0;
    this.shield = shield >= 0.0f ? shield : 0.0f;
    this.fps = fps > 0.0f ? fps : 15.0f;
    this.barsCount = barsCount > 0 ? barsCount : 14;

    this.hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    this.hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    this.hints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
}
 
Example 7
Source File: Sparkle.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
public BufferedImage renderAsBufferedImage(SparkDimension xdim, SparkDimension ydim) {
	BufferedImage im = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB);
	
	Graphics2D g = (Graphics2D) im.getGraphics();
	
	RenderingHints rh = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
	rh.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHints(rh);
	
    g.setColor(Color.white);
    g.fillRect(0, 0, imgWidth, imgHeight);

    Color c = new Color(0, 115, 180);
    g.setColor(c);
    BasicStroke stroke = new BasicStroke(2);
    g.setStroke(stroke);
    
    // Draw lines
    int prevX = xdim.get(0);
    int prevY = imgHeight - ydim.get(0);
    
    for (int i = 1; i< xdim.size(); i++) {
    	int x = xdim.get(i);
    	int y = imgHeight - ydim.get(i);
    	
    	g.drawLine(prevX, prevY, x, y);
    	prevX = x;
    	prevY = y;
    }
    
    // Draw high and low
    Color orange = new Color(255, 148, 0);
    g.setColor(orange);
    
    g.fillOval(xdim.get(ydim.indexOf(ydim.getMinValue()))-5, imgHeight - ydim.scale(ydim.getMinValue())-5, 10, 10);
    g.fillOval(xdim.get(ydim.indexOf(ydim.getMaxValue()))-5, imgHeight - ydim.scale(ydim.getMaxValue())-5, 10, 10);
    g.dispose();
	
    return im;
}
 
Example 8
Source File: AbstractGraphics2D.java    From pumpernickel with MIT License 5 votes vote down vote up
public void reset() {
	hints = new RenderingHints(RenderingHints.KEY_RENDERING,
			RenderingHints.VALUE_RENDER_DEFAULT);
	composite = AlphaComposite.SrcOver;
	paint = Color.white;
	background = Color.white;
	stroke = new BasicStroke(1);
	transform = new AffineTransform();
	font = UIManager.getFont("Label.font") == null ? new Font("Default", 0,
			12) : UIManager.getFont("Label.font");
	clipping = null;
}
 
Example 9
Source File: AbstractGraphics2D.java    From pumpernickel with MIT License 5 votes vote down vote up
/** Clones the properties of the <code>AbstractGraphics2D</code> argument. */
public AbstractGraphics2D(AbstractGraphics2D g) {
	hints = new RenderingHints(RenderingHints.KEY_RENDERING,
			RenderingHints.VALUE_RENDER_DEFAULT);
	hints.remove(RenderingHints.KEY_RENDERING);
	hints.putAll(g.hints);
	composite = g.composite;
	paint = g.paint;
	background = g.background;
	stroke = g.stroke;
	transform = new AffineTransform();
	setClip(g.clipping); // set *before* transform
	transform.setTransform(g.transform);
	font = g.font;

	int i = g.name.lastIndexOf(' ');
	if (i == -1) {
		name = g.name + " " + 2;
	} else {
		String end = g.name.substring(i + 1);
		try {
			int ctr = Integer.parseInt(end);
			ctr++;
			name = g.name.substring(0, i) + " " + ctr;
		} catch (NumberFormatException e) {
			name = g.name + " " + 2;
		}
	}
}
 
Example 10
Source File: ApplicationPDFPanel.java    From wandora with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void paintComponent(Graphics g) {
    int w = getWidth();
    int h = getHeight();
    
    if(g instanceof Graphics2D) {
        RenderingHints qualityHints = new RenderingHints(
            RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
        RenderingHints antialiasHints = new RenderingHints(
            RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);

        ((Graphics2D) g).addRenderingHints(qualityHints);
        ((Graphics2D) g).addRenderingHints(antialiasHints);
    }
    
    if(currentBufferedImage == null) {
        g.setColor(getBackground());
        g.fillRect(0, 0, w, h);
        g.setColor(Color.black);
        g.drawString("No page selected",
                     getWidth() / 2 - 30,
                     getHeight() / 2);
    }
    else {
        g.setColor(getBackground());
        g.fillRect(0, 0, w, h);
        g.drawImage(currentBufferedImage,
                    0,
                    0, 
                    currentBufferedImage.getWidth(), 
                    currentBufferedImage.getHeight(),
                    null);
    }
}
 
Example 11
Source File: ColorTools.java    From commons-imaging with Apache License 2.0 5 votes vote down vote up
public BufferedImage convertBetweenColorSpacesX2(BufferedImage bi,
        final ColorSpace from, final ColorSpace to) {
    final RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
    hints.put(RenderingHints.KEY_COLOR_RENDERING,
            RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    hints.put(RenderingHints.KEY_DITHERING,
            RenderingHints.VALUE_DITHER_ENABLE);

    // bi = relabelColorSpace(bi, cs);
    // dumpColorSpace("\tcs_sRGB", cs_sRGB);
    // dumpColorSpace("\tColorModel.getRGBdefaultc",
    // ColorModel.getRGBdefault().getColorSpace());

    bi = relabelColorSpace(bi, from);
    final ColorConvertOp op = new ColorConvertOp(from, to, hints);
    bi = op.filter(bi, null);

    bi = relabelColorSpace(bi, from);

    bi = op.filter(bi, null);

    bi = relabelColorSpace(bi, to);

    return bi;

}
 
Example 12
Source File: ShadowEffect.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Apply blurring to the generate image
 * 
 * @param image The image to be blurred
 */
private void blur(BufferedImage image) {
	float[] matrix = GAUSSIAN_BLUR_KERNELS[blurKernelSize - 1];
	Kernel gaussianBlur1 = new Kernel(matrix.length, 1, matrix);
	Kernel gaussianBlur2 = new Kernel(1, matrix.length, matrix);
	RenderingHints hints = new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
	ConvolveOp gaussianOp1 = new ConvolveOp(gaussianBlur1, ConvolveOp.EDGE_NO_OP, hints);
	ConvolveOp gaussianOp2 = new ConvolveOp(gaussianBlur2, ConvolveOp.EDGE_NO_OP, hints);
	BufferedImage scratchImage = EffectUtil.getScratchImage();
	for (int i = 0; i < blurPasses; i++) {
		gaussianOp1.filter(image, scratchImage);
		gaussianOp2.filter(scratchImage, image);
	}
}