List of usage examples for java.awt RenderingHints KEY_ANTIALIASING
Key KEY_ANTIALIASING
To view the source code for java.awt RenderingHints KEY_ANTIALIASING.
Click Source Link
From source file:Main.java
@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D twoD = (Graphics2D) g; RenderingHints rh = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); rh.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); twoD.setRenderingHints(rh);/*w ww.j a va2s . c o m*/ twoD.setColor(Color.BLACK); twoD.drawString(raised, 5, 90); }
From source file:org.evors.rs.ui.sandpit.WorldViewer.java
@Override public void draw() { Graphics2D g2 = (Graphics2D) getGraphics(); camera.setWindowSize(new Vector2D(this.getWidth(), this.getHeight())); g2.setColor(Color.WHITE);/*w w w.j a va 2 s . c o m*/ g2.fillRect(0, 0, getWidth(), getHeight()); AffineTransform prevTrans = g2.getTransform(); g2.setTransform(camera.getTransform()); g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); grid.draw(g2); if (world != null) { SandpitRenderer.drawWorld(g2, world); } g2.setTransform(prevTrans); }
From source file:GuiUtil.java
public static final void setAntiAliasing(Graphics g, boolean yesno) { Object obj = yesno ? RenderingHints.VALUE_ANTIALIAS_ON : RenderingHints.VALUE_ANTIALIAS_OFF; ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_ANTIALIASING, obj); }
From source file:Main.java
ThreeDimensionalBorder(Color color, int transparency, int shadowWidth) { this.color = color; shadowPad = shadowWidth;//from w w w . j av a 2 s. c o m stroke = new BasicStroke(thickness); strokePad = thickness / 2; hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int pad = radius + strokePad; int bottomPad = pad + strokePad + shadowPad; int rightPad = pad + strokePad + shadowPad; insets = new Insets(pad, pad, bottomPad + shadowPad, rightPad); }
From source file:FontRenderContextRenderingHints.java
public void paint(Graphics g) { Graphics2D g2D = (Graphics2D) g; int w = getSize().width; int h = getSize().height; RenderingHints qualityHints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); qualityHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); g2D.setRenderingHints(qualityHints); AffineTransform at = new AffineTransform(); at.setToTranslation(-300, -400);/*from www . j a v a2s . co m*/ at.shear(-0.5, 0.0); FontRenderContext frc = new FontRenderContext(at, false, false); TextLayout tl = new TextLayout("World!", font, frc); Shape outline = tl.getOutline(null); g2D.setColor(Color.blue); BasicStroke wideStroke = new BasicStroke(2.0f); g2D.setStroke(wideStroke); g2D.draw(outline); }
From source file:Main.java
public void drawImage() { Graphics2D g = img.createGraphics(); RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHints(hints);/*from w w w. j a v a2 s . co m*/ g.setColor(Color.RED); int x = (int) mouse.getX(); int y = (int) mouse.getY(); g.setStroke(new BasicStroke(2)); int s = 3; g.drawLine(x - s, y, x + s, y); g.drawLine(x, y - s, x, y + s); l.setIcon(new ImageIcon(img)); g.dispose(); }
From source file:Main.java
public void drawImage() { Graphics2D g = img.createGraphics(); RenderingHints hints = new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.setRenderingHints(hints);/*from w w w. ja v a 2s .co m*/ g.setStroke(new BasicStroke(4)); for (Ellipse2D shape : shapes) { g.setColor(Color.blue); g.fill(shape); if (shape.contains(mouse)) { g.setColor(Color.RED); } else { g.setColor(Color.YELLOW); } g.draw(shape); } l.setIcon(new ImageIcon(img)); g.dispose(); }
From source file:MyCanvas.java
public Graphics2D createDemoGraphics2D(Graphics g) { Graphics2D g2 = null;/*from www . j av a 2s . com*/ if (offImg == null || offImg.getWidth() != getSize().width || offImg.getHeight() != getSize().height) { offImg = (BufferedImage) createImage(getSize().width, getSize().height); } if (offImg != null) { g2 = offImg.createGraphics(); g2.setBackground(getBackground()); } // .. set attributes .. g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // .. clear canvas .. g2.clearRect(0, 0, getSize().width, getSize().height); return g2; }
From source file:MainClass.java
public void paint(Graphics g) { Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); String s = "www.java2s.com"; Font font = new Font("Serif", Font.PLAIN, 32); if (mTextLayout == null) { FontRenderContext frc = g2.getFontRenderContext(); mTextLayout = new TextLayout(s, font, frc); }//from ww w . j a v a 2 s .c o m mTextLayout.draw(g2, mX, mY); }
From source file:dataminning2.KmeanGraphplot.java
protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); int w = getWidth(); int h = getHeight(); // Draw ordinate. g2.draw(new Line2D.Double(PAD, PAD, PAD, h - PAD)); // Draw abcissa. g2.draw(new Line2D.Double(PAD, h - PAD, w - PAD, h - PAD)); double xInc = (double) (w - 2 * PAD) / (data.length - 1); double scale = (double) (h - 2 * PAD) / 88; // Mark data points. g2.setPaint(Color.red);// ww w. j a v a 2 s .c o m for (int i = 0; i < cluster0.length; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); } g2.setPaint(Color.BLUE); for (int i = 0; i < cluster1.length; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); } g2.setPaint(Color.YELLOW); for (int i = 0; i < cluster2.length; i++) { double x = PAD + i * dataX[i]; double y = h - PAD - scale * dataY[i]; g2.fill(new Ellipse2D.Double(x - 2, y - 2, 4, 4)); } }