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


Java Graphics2D.addRenderingHints方法代码示例

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


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

示例1: getScaledImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
private BufferedImage getScaledImage() {
    BufferedImage image = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = image.createGraphics();
    g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
    g2d.drawImage(this.image.getImage(), 0, 0, getWidth(), getHeight(), null);
    return image;
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:8,代码来源:RNNfilter.java

示例2: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {
    super.paint(g);
    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    Graphics2D Canvas = (Graphics2D) g;

    Canvas.addRenderingHints(renderHints);

    Canvas.setStroke(new BasicStroke(
            1f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND));

    Canvas.setPaint(Color.BLACK);

    paint2D(Canvas);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:25,代码来源:InspectorItemBase.java

示例3: paintComponent

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

    if (diagramaAtual == null) {
        return;
    }

    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    Graphics2D Canvas = (Graphics2D) g;
    Canvas.addRenderingHints(renderHints);

    Canvas.setPaint(Color.BLACK);
    Stroke stroke = new BasicStroke(2.f,
            BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
    Canvas.setStroke(stroke);

    Canvas.drawRect(box.getLocation().x, box.getLocation().y, box.getWidth(), box.getHeight());
    Canvas.setPaint(Color.GRAY);
    Canvas.drawRect(box.getLocation().x + 1, box.getLocation().y + 1, box.getWidth(), box.getHeight());
    //Canvas.setPaint(Color.BLACK);
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:28,代码来源:Editor.java

示例4: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paint(Graphics g) {
    RenderingHints renderHints =
            new RenderingHints(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    Graphics2D Canvas = (Graphics2D) g;
    Canvas.addRenderingHints(renderHints);

    super.paint(g);
    for (IObjetoPintavel p: pintaveis) {
        p.setOutroPintor(true);
        p.DoPaint(Canvas);
        p.setOutroPintor(false);
    }
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:19,代码来源:PainelPintador.java

示例5: prepareGraphics

import java.awt.Graphics2D; //导入方法依赖的package包/类
private static Graphics2D prepareGraphics(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Map rhints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
    if( rhints == null && Boolean.getBoolean("swing.aatext") ) { //NOI18N
         g2.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
    } else if( rhints != null ) {
        g2.addRenderingHints( rhints );
    }
    return g2;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:LinkButton.java

示例6: prepareGraphics

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static Graphics2D prepareGraphics(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    Map rhints = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
    if( rhints == null && Boolean.getBoolean("swing.aatext") ) { //NOI18N
         g2.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
    } else if( rhints != null ) {
        g2.addRenderingHints( rhints );
    }
    return g2;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Utils.java

示例7: drawArrow

import java.awt.Graphics2D; //导入方法依赖的package包/类
private void drawArrow(Graphics2D g, int x1, int y1, int x2, int y2) {

        RenderingHints renderHints
                = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
        renderHints.put(RenderingHints.KEY_RENDERING,
                RenderingHints.VALUE_RENDER_QUALITY);

        renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        g.addRenderingHints(renderHints);

        g.setStroke(new BasicStroke(
                getSetaLargura(),
                BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND));

        //g.setPaint(Color.BLACK);
        int ARR_SIZE = 3 + getSetaLargura();
        double dx = x2 - x1, dy = y2 - y1;
        double angle = Math.atan2(dy, dx);
        int len = (int) Math.sqrt(dx * dx + dy * dy);
        AffineTransform at = AffineTransform.getTranslateInstance(x1, y1);
        at.concatenate(AffineTransform.getRotateInstance(angle));
        //AffineTransform bkp = g.getTransform();
        g.setTransform(at);

        // Draw horizontal arrow starting in (0, 0)
        g.drawLine(ARR_SIZE, 0, len - ARR_SIZE, 0);

        if (isSetaPontaEsquerda()) {
            g.fillPolygon(new int[]{len, len - ARR_SIZE, len - ARR_SIZE, len},
                    new int[]{0, -ARR_SIZE, ARR_SIZE, 0}, 4);
        }
        if (isSetaPontaDireita()) {
            g.fillPolygon(new int[]{0, ARR_SIZE, ARR_SIZE, 0},
                    new int[]{0, -ARR_SIZE, ARR_SIZE, 0}, 4);
        }
    }
 
开发者ID:chcandido,项目名称:brModelo,代码行数:40,代码来源:Desenhador.java

示例8: paintBackground

import java.awt.Graphics2D; //导入方法依赖的package包/类
private void paintBackground (final Graphics g, final JComponent c) {
  Dimension size = c.getSize();
  Graphics2D g2 = (Graphics2D) g;
  
  g2.addRenderingHints (new RenderingHints (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
  
  g.setColor (c.getBackground ());
  g.fillRoundRect (0, 0, size.width, size.height, 7, 7);//button
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:10,代码来源:MaterialButtonUI.java

示例9: rescaleImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Rescales the displayed image to be the specified size.
 *
 * @param width The new width of the image.
 * @param height The new height of the image.
 * @param hint The scaling hint to use.
 */
@Override
protected void rescaleImage(int width, int height, int hint) {

	Image master = getMasterImage();
	if (master!=null) {

		Map<RenderingHints.Key, Object> hints =
				new HashMap<RenderingHints.Key, Object>();
		switch (hint) {
			default:
			case Image.SCALE_AREA_AVERAGING:
			case Image.SCALE_SMOOTH:
				hints.put(RenderingHints.KEY_INTERPOLATION,
						RenderingHints.VALUE_INTERPOLATION_BICUBIC);
				hints.put(RenderingHints.KEY_RENDERING,
						RenderingHints.VALUE_RENDER_QUALITY);
				hints.put(RenderingHints.KEY_ANTIALIASING,
						RenderingHints.VALUE_ANTIALIAS_ON);
		}

		bgImage = createAcceleratedImage(width, height);
		Graphics2D g = bgImage.createGraphics();
		g.addRenderingHints(hints);
		g.drawImage(master, 0,0, width,height, null);
		g.dispose();

	}
	else {
		bgImage = null;
	}
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:39,代码来源:BufferedImageBackgroundPainterStrategy.java

示例10: getGraphics2D

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Returns a <code>Graphics2D</code> version of the specified graphics
 * that has been initialized with the proper rendering hints.
 *
 * @param g The graphics context for which to get a
 *        <code>Graphics2D</code>.
 * @return The <code>Graphics2D</code>.
 */
private Graphics2D getGraphics2D(Graphics g) {
	Graphics2D g2d = (Graphics2D)g;
	if (aaHints!=null) {
		g2d.addRenderingHints(aaHints);
	}
	if (fractionalFontMetricsEnabled) {
		g2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
						RenderingHints.VALUE_FRACTIONALMETRICS_ON);
	}
	return g2d;
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:20,代码来源:RSyntaxTextArea.java

示例11: ExternalPaint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void ExternalPaint(Graphics g) {
    RenderingHints renderHints
            = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);

    renderHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    Graphics2D Canvas = (Graphics2D) g;

    Canvas.addRenderingHints(renderHints);

    Canvas.setStroke(new BasicStroke(
            1f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND));

    Canvas.setPaint(Color.BLACK);

    for (int i = subItens.size() - 1; i > -1; i--) {
        Elementar e = subItens.get(i);
        if (e.CanPaint()) {
            e.DoPaint(Canvas);
        }
    }
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:28,代码来源:Diagrama.java

示例12: getListCellRendererComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public Component getListCellRendererComponent(JList list, Object value,
        int index, boolean isSelected, boolean cellHasFocus) {
    Legenda.ItemDeLegenda entry = (Legenda.ItemDeLegenda) value;
    setText(entry.getTexto());

    BufferedImage off_Image = new BufferedImage(ehLina ? 32 : 16, 16, BufferedImage.TYPE_INT_ARGB);

    Graphics2D g = off_Image.createGraphics();
    
    RenderingHints renderHints =
            new RenderingHints(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    renderHints.put(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
    
    g.addRenderingHints(renderHints);
    g.setColor(entry.getCor());
    if (ehLina) {
        g.fillRect(1, 6, 30, 4);
    } else {
        g.fillRect(1, 1, 14, 14);
    }
    ImageIcon img = new ImageIcon(off_Image);

    setIcon(img);

    if (isSelected) {
        setBackground(HIGHLIGHT_COLOR);
        setForeground(Color.white);
    } else {
        setBackground(Color.white);
        setForeground(Color.black);
    }
    
    return this;
}
 
开发者ID:chcandido,项目名称:brModelo,代码行数:38,代码来源:JListItemParaItemLegenda.java

示例13: paintIcon

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Paints the icon. The image is reduced or magnified to fit the component to which it is painted.
 * <P>
 * If the proportion has not been specified, or has been specified as <code>true</code>, the aspect ratio of the image will be preserved
 * by padding and centering the image horizontally or vertically. Otherwise the image may be distorted to fill the component it is
 * painted to.
 * <P>
 * If this icon has no image observer,this method uses the <code>c</code> component as the observer.
 *
 * @param c the component to which the Icon is painted. This is used as the observer if this icon has no image observer
 * @param g the graphics context
 * @param x not used.
 * @param y not used.
 *
 * @see ImageIcon#paintIcon(java.awt.Component, java.awt.Graphics, int, int)
 */
@Override
public synchronized void paintIcon(Component c, Graphics g, int x, int y)
{
    Image image = getImage();
    if (image == null)
    {
        return;
    }
    Insets insets = ((Container) c).getInsets();
    x = insets.left;
    y = insets.top;
    int w = c.getWidth() - x - insets.right;
    int h = c.getHeight() - y - insets.bottom;
    this.glitchArt.lblImageRender.setSize(w, h);

    if (proportionate && w >=510)
    {
        int iw = image.getWidth(c);
        int ih = image.getHeight(c);

        if ((iw * h) < (ih * w))
        {
            iw = (h * iw) / ih;
            x += (w - iw) / 2;
            w = iw;
        }
        else
        {
            ih = (w * ih) / iw;
            y += (h - ih) / 2;
            h = ih;
        }
    }
    ImageObserver io = getImageObserver();

    /*
     * Added this code to generate nicer looking results when scaling. - bspkrs
     * BEGIN CHANGES
     */
    this.glitchArt.resizedHeight = h;
    this.glitchArt.resizedWidth = w;
    this.glitchArt.lblImageRender.setSize(w, h);
    BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_4BYTE_ABGR);
    Graphics2D g2d = bi.createGraphics();
    g2d.addRenderingHints(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
    g2d.drawImage(image, 0, 0, w, h, io == null ? c : io);
    g2d.dispose();
    /*
     * END CHANGES
     */

    g.drawImage(bi, x, y, w, h, io == null ? c : io);
}
 
开发者ID:scriptkittie,项目名称:GlitchKernel,代码行数:70,代码来源:StretchIcon.java

示例14: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paint(Graphics gcomp) {
    // System.out.println("PlotCanvas.paint");

    Graphics2D gcomp2D = (Graphics2D) gcomp;

    // anti-aliasing methods
    gcomp2D.addRenderingHints(AALIAS);
    gcomp2D.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

    gcomp2D.setColor(getBackground());
    gcomp2D.fillRect(0, 0, getSize().width, getSize().height);

    draw.initGraphics(gcomp2D);

    // draw plot
    grid.plot(draw);

    for (int i = 0; i < plots.size(); i++) {
        getPlot(i).plot(draw);
        if (linkedLegendPanel != null) {
            linkedLegendPanel.nonote(i);
        }
    }

    for (int i = 0; i < objects.size(); i++) {
        getPlotable(i).plot(draw);
    }

    if (drawRect != null) {
        gcomp2D.setColor(Color.black);
        gcomp2D.setStroke(rectStroke);
        gcomp2D.drawRect(drawRect[0], drawRect[1], drawRect[2], drawRect[3]);
    }

    // draw note
    if (allowNote) {
        /*if (allowNoteCoord && coordNoted != null) {
        draw.setColor(NOTE_COLOR);
        draw.drawCoordinate(coordNoted);
        draw.drawText(Array.cat(reverseMapedData(coordNoted)), coordNoted);
        }*/
        for (int i = 0; i < plots.size(); i++) {
            if (getPlot(i).noted) {
                if (linkedLegendPanel != null) {
                    linkedLegendPanel.note(i);
                }
                getPlot(i).note(draw);
                //return;
            }
            if (allowNoteCoord && getPlot(i).coordNoted != null) {
                getPlot(i).noteCoord(draw, getPlot(i).coordNoted);
            }
        }
    }
}
 
开发者ID:Cvarier,项目名称:2D-Elliptic-Mesh-Generator,代码行数:56,代码来源:PlotCanvas.java

示例15: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g); //paint background
        RenderingHints renderHints
                = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
                        RenderingHints.VALUE_ANTIALIAS_ON);
        renderHints.put(RenderingHints.KEY_RENDERING,
                RenderingHints.VALUE_RENDER_QUALITY);

        Graphics2D Canvas = (Graphics2D) g;
        Canvas.addRenderingHints(renderHints);

//        Canvas.setPaint(Color.BLACK);
//        Canvas.draw3DRect(0, 0, getWidth() - 4, getHeight() - 4, true);
        Canvas.setPaint(Color.BLACK);
        Stroke stroke = new BasicStroke(1.f,
                BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER);
        Canvas.setStroke(stroke);

        Canvas.drawRect(0, 0, getWidth() - 1, getHeight() - 1);
        Canvas.setPaint(Color.GRAY);
        Canvas.drawRect(0, 0, getWidth() - 2, getHeight() - 2);

        if (pgatual == 0) {
            return;
        }
        float[] dash4 = {2f, 2f, 2f};

        BasicStroke bs4 = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_ROUND, 1.0f, dash4,
                2f);
        Canvas.setStroke(bs4);

        Canvas.drawLine(l - 1, 1, l - 1, getHeight() - 1);
        Canvas.drawLine(l + w + 1, 1, l + w + 1, getHeight() - 1);
        Canvas.drawLine(1, t - 1, getWidth() - 1, t - 1);
        Canvas.drawLine(1, t + h + 1, getWidth() - 1, t + h + 1);

        Canvas.setStroke(new BasicStroke(
                1f,
                BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND));
        Canvas.setPaint(Color.BLACK);
        DrawPagina(Canvas);
    }
 
开发者ID:chcandido,项目名称:brModelo,代码行数:45,代码来源:ImpressorPreview.java


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