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


Java Graphics2D.setRenderingHints方法代码示例

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


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

示例1: filter

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Transforms source image using transform specified at the constructor.
 * The resulting transformed image is stored in the destination image if one
 * is provided; otherwise a new BufferedImage is created and returned. 
 *
 * @param src source image
 * @param dst destination image
 * @throws IllegalArgumentException if the source and destination image are
 *          the same
 * @return transformed source image.
 */
public final BufferedImage filter (BufferedImage src, BufferedImage dst)
{
  if (dst == src)
    throw new IllegalArgumentException("src image cannot be the same as "
                                     + "the dst image");

  // If the destination image is null, then use a compatible BufferedImage
  if (dst == null)
    dst = createCompatibleDestImage(src, null);

  Graphics2D gr = dst.createGraphics();
  gr.setRenderingHints(hints);
  gr.drawImage(src, transform, null);
  return dst;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:AffineTransformOp.java

示例2: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public @Override void paint(Graphics g) {
    Object value = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
    Map renderingHints = (value instanceof Map) ? (java.util.Map)value : null;
    if (renderingHints != null && g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        RenderingHints oldHints = g2d.getRenderingHints();
        g2d.setRenderingHints(renderingHints);
        try {
            super.paint(g2d);
        } finally {
            g2d.setRenderingHints(oldHints);
        }
    } else {
        super.paint(g);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ListCompletionView.java

示例3: paint

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

  RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING,
      RenderingHints.VALUE_ANTIALIAS_ON);

  rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);

  g2.setRenderingHints(rh);
  Dimension size = getSize();

  if (initialize) {
    reset(size.width, size.height);
    initialize = false;
  }
  this.step(size.width, size.height);
  render(size.width, size.height, g2);
}
 
开发者ID:kevingilboy,项目名称:COE1186,代码行数:20,代码来源:TimerBasedAnimation.java

示例4: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public
@Override
void paint(Graphics g) {
    // Antialiasing if necessary
    Object value = (Map) (Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
    Map renderingHints = (value instanceof Map) ? (java.util.Map) value : null;
    if (renderingHints != null && g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        RenderingHints oldHints = g2d.getRenderingHints();
        g2d.setRenderingHints(renderingHints);
        try {
            super.paint(g2d);
        } finally {
            g2d.setRenderingHints(oldHints);
        }
    } else {
        super.paint(g);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ResultBar.java

示例5: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public @Override void paint(Graphics g) {
    Object value = Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); //NOI18N
    Map renderingHints = (value instanceof Map) ? (java.util.Map)value : null;
    if (renderingHints != null && g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        RenderingHints oldHints = g2d.getRenderingHints();
        g2d.setRenderingHints(renderingHints);
        try {
            super.paint(g2d);
        } finally {
            g2d.setRenderingHints(oldHints);
        }
    } else {
        super.paint(g);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ListCompletionView.java

示例6: cacheAnnotationImage

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Creates an image of the given annotation and caches it with the specified cache id.
 *
 * @param anno
 *            the annotation to cache
 * @param cacheId
 *            the cache id for the given annotation
 * @return the cached image
 */
private Image cacheAnnotationImage(final WorkflowAnnotation anno, final int cacheId) {
	Rectangle2D loc = anno.getLocation();
	// paint each annotation with the same JEditorPane
	Dimension size = new Dimension((int) loc.getWidth(), (int) loc.getHeight());
	pane.setSize(size);
	pane.setText(AnnotationDrawUtils.createStyledCommentString(anno));
	pane.setCaretPosition(0);
	// draw annotation area to image and then to graphics
	// otherwise heavyweight JEdiorPane draws over everything and outside of panel
	BufferedImage img = new BufferedImage((int) loc.getWidth(), (int) loc.getHeight(), BufferedImage.TYPE_INT_ARGB);
	Graphics2D gImg = img.createGraphics();
	gImg.setRenderingHints(ProcessDrawer.HI_QUALITY_HINTS);
	// without this, the text is pixelated on half opaque backgrounds
	gImg.setComposite(AlphaComposite.SrcOver);
	// paint JEditorPane to image
	pane.paint(gImg);
	displayCache.put(anno.getId(), new SoftReference<Image>(img));
	cachedID.put(anno.getId(), cacheId);

	return img;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:31,代码来源:AnnotationDrawer.java

示例7: getResizedIcon

import java.awt.Graphics2D; //导入方法依赖的package包/类
protected Icon getResizedIcon(Icon originalIcon) {
    if(originalIcon == null) {
        return null;
    } else {
        int width = originalIcon.getIconWidth();
        int height = originalIcon.getIconHeight();
        if(width != 48) {
            double scale = 48.0D / (double)width;
            BufferedImage bi = new BufferedImage((int)(scale * (double)width), (int)(scale * (double)height), 2);
            Graphics2D g = bi.createGraphics();
            g.setRenderingHints(HI_QUALITY_HINTS);
            g.scale(scale, scale);
            originalIcon.paintIcon((Component)null, g, 0, 0);
            g.dispose();
            return new ImageIcon(bi);
        } else {
            return originalIcon;
        }
    }
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:21,代码来源:AbstractPackageDescriptorListCellRenderer.java

示例8: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintComponent(Graphics g)
{
    Graphics2D g2 = (Graphics2D)g;
    RenderingHints rh = new RenderingHints(
             RenderingHints.KEY_TEXT_ANTIALIASING,
             RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g2.setRenderingHints(rh);

    g.setColor(BloxsColors.$BACKGROUND);
    g.fillRect(0, 0, getWidth(), getHeight());
    
    for (int i = 0; i < elements.size(); i++) {
        Element get = elements.get(i);
        get.draw((Graphics2D) g);
    }
}
 
开发者ID:fesch,项目名称:Moenagade,代码行数:18,代码来源:LibraryPanel.java

示例9: paint

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void paint(Graphics g) {
    if (selectedValues.isEmpty()) return;

    Graphics2D g2 = (Graphics2D)g;
    g2.setRenderingHints(chart.getRenderingHints());

    Iterator<Point> it = selectedValues.iterator();
    boolean linePainted = false;

    while (it.hasNext()) {
        Point p = it.next();

        if (!linePainted) {
            g2.setPaint(evenPerfPaint);
            g2.setStroke(evenPerfStroke);
            g2.drawLine(p.x, 0, p.x, getHeight());
            g2.setPaint(oddPerfPaint);
            g2.setStroke(oddPerfStroke);
            g2.drawLine(p.x, 0, p.x, getHeight());

            g2.setPaint(markPaint);
            g2.setStroke(markStroke);

            linePainted = true;
        }

        g2.fillOval(p.x - selectionExtent + 1, p.y - selectionExtent + 1,
                    selectionExtent * 2 - 1, selectionExtent * 2 - 1);
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:ProfilerXYSelectionOverlay.java

示例10: paintBorder

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
	Graphics2D g2d = (Graphics2D) g.create();
	g2d.setRenderingHints(ProcessDrawer.HI_QUALITY_HINTS);
	g2d.setStroke(new BasicStroke(2f));

	// clear edges, otherwise they will be in the color of the component background
	if (drawRoundFrame && !c.getBackground().equals(c.getParent().getBackground())) {
		Shape frame = new Rectangle2D.Float(x + 2, y + 2, width - 4, height - 4);
		g2d.setPaint(c.getParent().getBackground());
		g2d.draw(frame);
	}

	g2d.setPaint(paint);
	g2d.setFont(new Font("Dialog", Font.BOLD, 21));

	if (drawRoundFrame) {
		Shape roundFrame = new RoundRectangle2D.Float(x + 2, y + 2, width - 4, height - 4, 10, 10);
		g2d.draw(roundFrame);
	}

	if (number > 0) {
		Shape circle = new Ellipse2D.Float(20, 20, 34, 34);
		g2d.fill(circle);
		g2d.setPaint(Color.WHITE);
		g2d.drawString(String.valueOf(number), 29, 44);
	}

	if (key != null) {
		g2d.setPaint(paint);
		g2d.drawString(key, 60, 44);
	}

	g2d.dispose();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:36,代码来源:RoundTitledBorder.java

示例11: paintComponent

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics graphics) {
	super.paintComponent(graphics);
	double scaleX = (double) getWidth() / (double) processRenderer.getWidth();
	double scaleY = (double) getHeight() / (double) processRenderer.getHeight();
	scale = Math.min(scaleX, scaleY);
	double scaledW = processRenderer.getWidth() * scale;
	double scaledH = processRenderer.getHeight() * scale;

	Graphics2D g = (Graphics2D) graphics.create();
	g.translate((getWidth() - scaledW) / 2d, (getHeight() - scaledH) / 2d);
	g.scale(scale, scale);

	g.setRenderingHints(ProcessDrawer.LOW_QUALITY_HINTS);
	processRenderer.getOverviewPanelDrawer().draw(g, true);

	g.setStroke(new BasicStroke((int) (1d / scale)));

	Rectangle visibleRect = processRenderer.getVisibleRect();
	Rectangle drawRect = new Rectangle((int) visibleRect.getX(), (int) visibleRect.getY(),
			(int) visibleRect.getWidth() - 1, (int) visibleRect.getHeight() - 1);

	g.setColor(FILL_COLOR);
	g.fill(drawRect);

	g.setColor(DRAW_COLOR);
	g.draw(drawRect);

	g.dispose();
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:31,代码来源:OverviewPanel.java

示例12: render

import java.awt.Graphics2D; //导入方法依赖的package包/类
@Override
public BufferedImage render(final BufferedImage baseImage) {

    int width = baseImage.getWidth();
    int height = baseImage.getHeight();

    // create an opaque image
    RenderingHints hints = new RenderingHints(
            RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_OFF);

    hints.add(new RenderingHints(RenderingHints.KEY_COLOR_RENDERING,
            RenderingHints.VALUE_COLOR_RENDER_QUALITY));
    hints.add(new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION,
            RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY));

    hints.add(new RenderingHints(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY));

    BufferedImage imageWithBackground = new BufferedImage(width, height,
            BufferedImage.TYPE_INT_RGB);

    Graphics2D graph = (Graphics2D) imageWithBackground.getGraphics();
    graph.setRenderingHints(hints);
    graph.setPaint(new GradientPaint(0, 0, colorFrom, width, height, colorTo));
    graph.fill(new Rectangle2D.Double(0, 0, width, height));
    graph.drawImage(baseImage, 0, 0, null);
    graph.dispose();

    return imageWithBackground;
}
 
开发者ID:febit,项目名称:febit,代码行数:32,代码来源:GradientBackgroundFilter.java

示例13: apply

import java.awt.Graphics2D; //导入方法依赖的package包/类
public void apply(Graphics2D g)
{
	g.setTransform(transform);
	g.setPaint(paint);
	g.setStroke(stroke);
	g.setFont(font);
	g.setComposite(composite);
	g.setBackground(bgrnd);
	g.setClip(shape);
	g.setRenderingHints(hints);
}
 
开发者ID:Chroniaro,项目名称:What-Happened-to-Station-7,代码行数:12,代码来源:TStack.java

示例14: copyimage

import java.awt.Graphics2D; //导入方法依赖的package包/类
/**
 * Copy a source image to a destination image, respecting their colorspaces 
 * and performing colorspace conversions if necessary.  
 * 
 * @param src The source image.
 * @param dst The destination image.
 */
private void copyimage(BufferedImage src, BufferedImage dst)
{
  // This is done using Graphics2D in order to respect the rendering hints.
  Graphics2D gg = dst.createGraphics();
  
  // If no hints are set there is no need to call
  // setRenderingHints on the Graphics2D object.
  if (hints != null)
    gg.setRenderingHints(hints);
  
  gg.drawImage(src, 0, 0, null);
  gg.dispose();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:ColorConvertOp.java

示例15: paintComponent

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

  // Draws the background
  paintBackground(g);

  // Creates or destroys the triple buffer as needed
  if (tripleBuffered) {
    checkTripleBuffer();
  } else if (tripleBuffer != null) {
    destroyTripleBuffer();
  }

  // Paints the buffer in the canvas onto the dirty region
  if (tripleBuffer != null) {
    mxUtils.drawImageClip(g, tripleBuffer, this);
  }

  // Paints the graph directly onto the graphics
  else {
    Graphics2D g2 = (Graphics2D) g;
    RenderingHints tmp = g2.getRenderingHints();

    // Sets the graphics in the canvas
    try {
      mxUtils.setAntiAlias(g2, antiAlias, textAntiAlias);
      drawGraph(g2, true);
    } finally {
      // Restores the graphics state
      g2.setRenderingHints(tmp);
    }
  }

  eventSource.fireEvent(new mxEventObject(mxEvent.PAINT, "g", g));
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:39,代码来源:mxGraphComponent.java


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