本文整理匯總了Java中java.awt.RenderingHints類的典型用法代碼示例。如果您正苦於以下問題:Java RenderingHints類的具體用法?Java RenderingHints怎麽用?Java RenderingHints使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
RenderingHints類屬於java.awt包,在下文中一共展示了RenderingHints類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: paintBackground
import java.awt.RenderingHints; //導入依賴的package包/類
@Override
protected void paintBackground(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(getComponent().getBackground());
g2.fillRoundRect(0, 0, getComponent().getWidth(), getComponent().getHeight(),
RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
}
示例2: paint
import java.awt.RenderingHints; //導入依賴的package包/類
public void paint(Graphics g) {
if (antiAlias) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
/*g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);*/
super.paint(g2);
} else {
super.paint(g);
}
}
示例3: createColoredRectangleIcon
import java.awt.RenderingHints; //導入依賴的package包/類
protected Icon createColoredRectangleIcon(Color color) {
// create buffered image for colored icon
BufferedImage bufferedImage = new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = bufferedImage.createGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, // Anti-alias!
RenderingHints.VALUE_ANTIALIAS_ON);
if (color != null) {
// fill image with item color
Color newColor = new Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
g2.setColor(newColor);
} else {
g2.setColor(Color.gray);
}
g2.fillRect(0, 0, 10, 10);
return new ImageIcon(bufferedImage);
}
示例4: wrapMacFancy
import java.awt.RenderingHints; //導入依賴的package包/類
public static JPanel wrapMacFancy(JPanel content) {
JPanel panel = new JPanel(new BorderLayout()) {
private static final long serialVersionUID = 941275105778632480L;
@Override
public void paintComponent(Graphics g) {
Color border = new Color(64, 64, 64, 64);
Color bg = new Color(128, 128, 128, 64);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setColor(bg);
g2.fillRoundRect(1, 1, this.getWidth()-2, this.getHeight()-2, 10, 10);
g2.setColor(border);
g2.drawRoundRect(0, 0, this.getWidth()-1, this.getHeight()-1, 10, 10);
}
};
panel.setOpaque(false);
content.setOpaque(false);
panel.add(content, BorderLayout.CENTER);
return panel;
}
示例5: pane
import java.awt.RenderingHints; //導入依賴的package包/類
/** Constructs an antialias-capable JTextPane with a DefaultHighlighter associated with it.
* @param attributes - see {@link edu.mit.csail.sdg.alloy4.OurUtil#make OurUtil.make(component, attributes...)}
*/
public static JTextPane pane(Object... attributes) {
JTextPane ans = new JTextPane() {
static final long serialVersionUID = 0;
@Override public void paint(Graphics gr) {
if (antiAlias && gr instanceof Graphics2D) {
((Graphics2D)gr).setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
}
super.paint(gr);
}
};
OurUtil.make(ans, attributes);
ans.setHighlighter(new DefaultHighlighter());
map.put(ans, Boolean.TRUE);
return ans;
}
示例6: paintComponent
import java.awt.RenderingHints; //導入依賴的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);
}
示例7: Blit
import java.awt.RenderingHints; //導入依賴的package包/類
public void Blit(SurfaceData srcData,
SurfaceData dstData,
Composite comp,
Region clip,
int srcx, int srcy,
int dstx, int dsty,
int width, int height)
{
ColorModel srcCM = srcData.getColorModel();
ColorModel dstCM = dstData.getColorModel();
// REMIND: Should get RenderingHints from sg2d
CompositeContext ctx = comp.createContext(srcCM, dstCM,
new RenderingHints(null));
Raster srcRas = srcData.getRaster(srcx, srcy, width, height);
WritableRaster dstRas =
(WritableRaster) dstData.getRaster(dstx, dsty, width, height);
if (clip == null) {
clip = Region.getInstanceXYWH(dstx, dsty, width, height);
}
int span[] = {dstx, dsty, dstx+width, dsty+height};
SpanIterator si = clip.getSpanIterator(span);
srcx -= dstx;
srcy -= dsty;
while (si.nextSpan(span)) {
int w = span[2] - span[0];
int h = span[3] - span[1];
Raster tmpSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
w, h, 0, 0, null);
WritableRaster tmpDstRas = dstRas.createWritableChild(span[0], span[1],
w, h, 0, 0, null);
ctx.compose(tmpSrcRas, tmpDstRas, tmpDstRas);
}
ctx.dispose();
}
示例8: AffineTransformOp
import java.awt.RenderingHints; //導入依賴的package包/類
/**
* Construct AffineTransformOp with the given xform and rendering hints.
*
* @param xform AffineTransform that will applied to the source image
* @param hints rendering hints that will be used during transformation
* @throws ImagingOpException if the transform matrix is noninvertible
*/
public AffineTransformOp (AffineTransform xform, RenderingHints hints)
{
this.transform = xform;
this.hints = hints;
if (xform.getDeterminant() == 0)
throw new ImagingOpException(null);
}
示例9: paintBorder
import java.awt.RenderingHints; //導入依賴的package包/類
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(new Color(0x666666));
g2d.fillRect(x + 5, y + 5, width - 11, height - 11);
paintHeader(g2d, x, y, width, height);
if (node.getParentNodeContainer().getSelection().contains(node)) {
g2d.setColor(UIHelper.getColor("Node.border:selected"));
} else {
g2d.setColor(UIHelper.getColor("Node.border"));
}
g2d.drawRect(x + 5, y + 5, width - 11, height - 11);
g2d.setColor(UIHelper.getColor("Node.Header.title"));
g2d.drawString(title, 19, 22);
g2d.dispose();
}
示例10: getScaledImage
import java.awt.RenderingHints; //導入依賴的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;
}
示例11: paintComponent
import java.awt.RenderingHints; //導入依賴的package包/類
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D)g;
g2d.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
Composite oldC = g2d.getComposite();
Shape s = getMask( getWidth(), getHeight() );
g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, 0.25f*currentAlpha ) );
g2d.setColor( Color.black );
g2d.fill( getShadowMask(s) );
g2d.setColor( UIManager.getColor( "ToolTip.background" ) ); //NOI18N
g2d.setComposite( AlphaComposite.getInstance( AlphaComposite.SRC_OVER, currentAlpha ) );
Point2D p1 = s.getBounds().getLocation();
Point2D p2 = new Point2D.Double(p1.getX(), p1.getY()+s.getBounds().getHeight());
if( isMouseOverEffect )
g2d.setPaint( new GradientPaint( p2, getMouseOverGradientStartColor(), p1, getMouseOverGradientFinishColor() ) );
else
g2d.setPaint( new GradientPaint( p2, getDefaultGradientStartColor(), p1, getDefaultGradientFinishColor() ) );
g2d.fill(s);
g2d.setColor( Color.black );
g2d.draw(s);
g2d.setComposite( oldC );
}
示例12: paintIcon
import java.awt.RenderingHints; //導入依賴的package包/類
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
if( g instanceof Graphics2D ) {
Graphics2D g2d = (Graphics2D) g;
//turn on high quality bitmap rendering
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC);
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g2d.translate(x, y);
g2d.drawImage(img, at, null);
g2d.translate(-x, -y);
}
}
示例13: render
import java.awt.RenderingHints; //導入依賴的package包/類
private void render(Image im, int type, String s) {
Graphics2D g2d = (Graphics2D) im.getGraphics();
clear(g2d, type, im.getWidth(null), im.getHeight(null));
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
Font f = new Font("Dialog", Font.BOLD, 40);// g2d.getFont().deriveFont(32.0f);
g2d.setColor(Color.white);
g2d.setFont(g2d.getFont().deriveFont(36.0f));
g2d.drawString(s, 10, im.getHeight(null) / 2);
}
示例14: ChoiceV2Renderer
import java.awt.RenderingHints; //導入依賴的package包/類
public ChoiceV2Renderer(ChoiceV2 choice) {
BufferedImage yes =
new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = yes.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.BLUE);
g.drawLine(0, 5, 3, 10);
g.drawLine(1, 5, 4, 10);
g.drawLine(3, 10, 10, 0);
g.drawLine(4, 9, 9, 0);
g.dispose();
BufferedImage blank =
new BufferedImage(10, 10, BufferedImage.TYPE_INT_ARGB);
yesImage = new ImageIcon(yes);
blankImage = new ImageIcon(blank);
this.choice = choice;
}
示例15: getGUISnapshots
import java.awt.RenderingHints; //導入依賴的package包/類
static Snapshot[] getGUISnapshots() {
List snapshots = new ArrayList(); //System.err.println("gGUI: thread = "+Thread.currentThread());
Window[] windows = Window.getWindows(); //System.err.println("gGUI: windows = "+windows.length);
for (int wi = 0; wi < windows.length; wi++) {
Window w = windows[wi]; //System.err.println("gGUI: w["+wi+"] = "+w+", is visible = "+w.isVisible());
if (!w.isVisible()) {
continue;
}
Dimension d = w.getSize(); //System.err.println("gGUI: size = "+d);
if (d.width == 0 || d.height == 0) {
continue;
}
BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = bi.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_DEFAULT);
w.paint(g);
Raster raster = bi.getData();
Object data = raster.getDataElements(0, 0, d.width, d.height, null);
int[] dataArr; //System.err.println("gGUI: data = "+data);
if (data instanceof int[]) {
dataArr = (int[]) data;
} else {
continue;
}
String title = null;
if (w instanceof Frame) {
title = ((Frame) w).getTitle();
} else if (w instanceof Dialog) {
title = ((Dialog) w).getTitle();
} //System.err.println("gGUI: title = "+title);
snapshots.add(new Snapshot(w, title, d.width, d.height, dataArr));
}
Snapshot[] snapshotArr = (Snapshot[]) snapshots.toArray(new Snapshot[] {});
lastGUISnapshots = snapshotArr;
return snapshotArr;
}