Java 类java.awt.RenderingHints 实例源码

项目:Neukoelln_SER316    文件:HTMLEditorPane.java   
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);
    }
}
项目:GIFKR    文件:ViewUtils.java   
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;
}
项目:Tarski    文件:OurAntiAlias.java   
/** 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;
}
项目:brModelo    文件:Editor.java   
@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);
}
项目:OpenJSharp    文件:Blit.java   
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();
}
项目:OpenJSharp    文件:AffineTransformOp.java   
/**
 * 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);
}
项目:VISNode    文件:JNodeBorder.java   
@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();
}
项目:jaer    文件:RNNfilter.java   
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;
}
项目:incubator-netbeans    文件:BalloonManager.java   
@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 );
}
项目:incubator-netbeans    文件:ProgressLabel.java   
@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);
    }
}
项目:jdk8u-jdk    文件:NonOpaqueDestLCDAATest.java   
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);
}
项目:OpenJSharp    文件:Font2DTest.java   
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;
}
项目:incubator-netbeans    文件:RemoteAWTService.java   
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;
}
项目:Tarski    文件:GraphViewer.java   
/** Export the current drawing as a PNG file with the given file name and image resolution. */
public void alloySaveAsPNG(String filename, double scale, double dpiX, double dpiY) throws IOException {
   try {
      int width = (int) (graph.getTotalWidth()*scale);   if (width<10) width=10;
      int height = (int) (graph.getTotalHeight()*scale); if (height<10) height=10;
      BufferedImage bf = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      Graphics2D gr = (Graphics2D) (bf.getGraphics());
      gr.setColor(WHITE);
      gr.fillRect(0, 0, width, height);
      gr.setColor(BLACK);
      gr.scale(scale,scale);
      gr.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      graph.draw(new Artist(gr), scale, null, false);
      OurPNGWriter.writePNG(bf, filename, dpiX, dpiY);
   } catch(Throwable ex) {
      if (ex instanceof IOException) throw (IOException)ex;
      throw new IOException("Failure writing the PNG file to " + filename + " (" + ex + ")");
   }
}
项目:Logisim    文件:Canvas.java   
protected void paintBackground(Graphics g) {
    if (AppPreferences.ANTI_ALIASING.getBoolean()) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }
    g.clearRect(0, 0, getWidth(), getHeight());
}
项目:hackrf-spectrum-analyzer    文件:WaterfallPlot.java   
@Override protected void paintComponent(Graphics arg0)
{
    Graphics2D g = (Graphics2D) arg0;
    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    int w = chartWidth;
    int h = getHeight();
    g.setColor(Color.black);
    g.fillRect(0, 0, getWidth(), getHeight());

    g.drawImage(bufferedImages[drawIndex], chartXOffset, 0, w, h, null);

    if (displayMarker){
        g.setColor(Color.gray);
        g.drawLine(displayMarkerX, 0, displayMarkerX, h);
        g.drawString(String.format("%.1fMHz", displayMarkerFrequency/1000000.0), displayMarkerX+5, h/2);
    }//finish marker 

    g.setColor(Color.white);
    int x   = chartXOffset + w - 250;
    int y   = h - 20;
    g.drawString(renderingInfo, x, y-20);
    g.drawString(statusMessage, x, y);
}
项目:defense-solutions-proofs-of-concept    文件:RoundedJPanel.java   
@Override
protected void paintComponent(Graphics g) {
    int borderWidth = 3;
    int x = borderWidth;
    int y = borderWidth;
    int w = getWidth() - (2 * borderWidth);
    int h = getHeight() - (2 * borderWidth);
    int arc = 30;

    Graphics2D g2 = (Graphics2D) g.create();
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);

    g2.setColor(Color.WHITE);
    g2.fillRoundRect(x, y, w, h, arc, arc);

    g2.setStroke(new BasicStroke(borderWidth));
    g2.setColor(new Color(40, 40, 40));
    g2.drawRoundRect(x, y, w, h, arc, arc);

    g2.dispose();
}
项目:hearthstone    文件:Animacao.java   
@Override
public void paintComponent(Graphics g) {
    SwingUtilities.invokeLater(() -> {
        Graphics2D g2 = (Graphics2D) getGraphics();
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND));
        g2.setColor(Color.red);
        g2.drawLine(origemEvento.x, origemEvento.y, destinoEvento.x, destinoEvento.y);
        g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND));
        g2.drawOval(destinoEvento.x - 25, destinoEvento.y - 25, 50, 50);
        g2.fillOval(destinoEvento.x - 10, destinoEvento.y - 10, 20, 20);
        g2.dispose();
    });
}
项目:incubator-netbeans    文件:BalloonManager.java   
@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 );
}
项目:freecol    文件:SimpleZippedAnimation.java   
/**
 * Create a scaled version of this image animation.
 *
 * @param scale The scale factor to apply.
 * @return The scaled {@code AnimationEvent}.
 */
private AnimationEvent createScaledVersion(float scale) {
    final int width = (int)(getWidth() * scale);
    final int height = (int)(getHeight() * scale);
    BufferedImage scaled = new BufferedImage(width, height,
        BufferedImage.TYPE_INT_ARGB);
    Graphics2D g = scaled.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
                       RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g.drawImage(this.image, 0, 0, width, height, null);
    g.dispose();

    return new ImageAnimationEventImpl(scaled, this.durationInMs);
}
项目:QN-ACTR-Release    文件:HtmlPanel.java   
@Override
protected void paintComponent(Graphics g) {
    if (antiAliasing) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        super.paintComponent(g2d);
    } else {
        super.paintComponent(g);
    }
}
项目:hearthstone    文件:DragAndDrop.java   
@Override
public void paintComponent(Graphics g) {
    SwingUtilities.invokeLater(() -> {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) getGraphics();
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND));
        g2.setColor(Color.red);
        g2.drawLine(pressed.x, pressed.y, released.x, released.y);
        g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND));
        g2.drawOval(released.x - 25, released.y - 25, 50, 50);
        g2.fillOval(released.x - 10, released.y - 10, 20, 20);
        g2.dispose();
    });
}
项目:AgentWorkbench    文件:BasicGraphGuiVisViewer.java   
/**
     * This Initializes the VisualizationViewer.
     */
    private void initialize() {

        this.setBackground(Color.WHITE);
        this.setDoubleBuffered(true);

        // --- Configure some rendering hints in order to accelerate the visualisation --
        this.renderingHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_SPEED);
        this.renderingHints.put(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED);
        this.renderingHints.put(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_SPEED);
        this.renderingHints.put(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);

        this.renderingHints.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_DEFAULT);
        this.renderingHints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF);

        this.renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);

        // --- useful and faster, but it makes the image quite unclear --------!!
//      this.renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); 

        // ------------------------------------------------------------------------------
        // --- Test area ----------------------------------------------------------------
        // ------------------------------------------------------------------------------
//      this.addPreRenderPaintable(new MapPreRenderer<V, E>(this));

    }
项目:BHBot    文件:MarvinImage.java   
/**
 * Resize and return the image passing the new height and width
 * @param height
 * @param width
 * @return
 */
public BufferedImage getBufferedImage(int width, int height)
{
    // using the new approach of Java 2D API 
    BufferedImage buf = new BufferedImage(width,height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = (Graphics2D) buf.getGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
    g2d.drawImage(image,0,0,width,height,null);
    g2d.dispose();
    return(buf);
}
项目:Logisim    文件:Canvas.java   
@Override
public void paintComponent(Graphics g) {
    if (AppPreferences.ANTI_ALIASING.getBoolean()) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }
    paintBackground(g);
    paintForeground(g);
}
项目:rapidminer    文件:ButtonUI.java   
@Override
protected void paintText(Graphics g, AbstractButton c, Rectangle textRect, String text) {
    // otherwise the tabs text would not have AA for some reason even though the rest of the
    // components has AA without this
    ((Graphics2D) g).setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    super.paintText(g, c, textRect, text);
}
项目:rapidminer    文件:TextFieldUI.java   
@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);
}
项目:rapidminer    文件:FormattedTextFieldUI.java   
@Override
protected void paintBackground(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

    if (getComponent().isEnabled()) {
        g2.setColor(Colors.TEXTFIELD_BACKGROUND);
    } else {
        g2.setColor(Colors.TEXTFIELD_BACKGROUND_DISABLED);
    }

    g2.fillRoundRect(0, 0, getComponent().getWidth(), getComponent().getHeight(),
            RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
}
项目:rapidminer    文件:TextAreaUI.java   
@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);
}
项目:jdk8u-jdk    文件:DrawRotatedString.java   
private static BufferedImage createBufferedImage(final boolean  aa) {
    final BufferedImage bi = new BufferedImage(SIZE, SIZE,
                                               BufferedImage.TYPE_INT_RGB);
    final Graphics2D bg = bi.createGraphics();
    bg.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                        aa ? RenderingHints.VALUE_ANTIALIAS_ON
                           : RenderingHints.VALUE_ANTIALIAS_OFF);
    bg.setColor(Color.RED);
    bg.fillRect(0, 0, SIZE, SIZE);
    bg.translate(100, 100);
    bg.rotate(Math.toRadians(90));
    bg.setColor(Color.BLACK);
    bg.setFont(bg.getFont().deriveFont(20.0f));
    bg.drawString("MMMMMMMMMMMMMMMM", 0, 0);
    bg.dispose();
    return bi;
}
项目:java-course    文件:Circle.java   
/**
 * {@inheritDoc}
 */
@Override
public void draw(Graphics g, RectBounds rect) {
    Graphics2D g2 = (Graphics2D) g;
    g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    g2.setRenderingHint(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
    g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
            RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
            RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    g2.setColor(color);
    g2.drawOval(center.x - radius - rect.getMinX(), center.y - radius
            - rect.getMinY(), 2 * radius, 2 * radius);
}
项目:ramus    文件:PIDEF0painter.java   
private void writeImage(final OutputStream stream, final String format)
        throws IOException {
    final int y1 = movingArea.getIntOrdinate(movingArea.TOP_PART_A);

    final int y2 = movingArea.getIntOrdinate(movingArea.CLIENT_HEIGHT);
    final int y3 = movingArea.getIntOrdinate(movingArea.BOTTOM_PART_A);

    int height = y1 + y2 + y3 + 1;
    final BufferedImage bi = new BufferedImage(size.width, height,
            BufferedImage.TYPE_INT_RGB);
    final Graphics2D g = (Graphics2D) bi.getGraphics();
    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
    g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
            RenderingHints.VALUE_STROKE_PURE);
    g.setColor(Color.white);
    g.fillRect(0, 0, size.width, size.height);
    g.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
            RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
    g.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
            RenderingHints.VALUE_COLOR_RENDER_QUALITY);
    g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
            RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
            RenderingHints.VALUE_INTERPOLATION_BICUBIC);
    g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
            RenderingHints.VALUE_STROKE_NORMALIZE);
    g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

    paint(g, 0, 0);
    ImageIO.write(bi, format, stream);
}
项目:Logisim    文件:ZoomControl.java   
@Override
protected void paintComponent(Graphics g) {
    if (AppPreferences.ANTI_ALIASING.getBoolean()) {
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }
    int width = getWidth();
    int height = getHeight();
    g.setColor(state ? Color.black : getBackground().darker());
    int dim = (Math.min(width, height) - 4) / 3 * 3 + 1;
    int xoff = (width - dim) / 2;
    int yoff = (height - dim) / 2;
    for (int x = 0; x < dim; x += 3) {
        for (int y = 0; y < dim; y += 3) {
            g.drawLine(x + xoff, y + yoff, x + xoff, y + yoff);
        }
    }
}
项目:rapidminer    文件:ColorRGBComboBoxCellRenderer.java   
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);
}
项目:rapidminer    文件:AbstractConfigurationPanel.java   
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);
}
项目:brModelo    文件:InspectorItemBase.java   
@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);
}
项目:org.alloytools.alloy    文件:OurAntiAlias.java   
/**
 * 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;
}
项目:parabuild-ci    文件:JFreeChart.java   
/**
 * Sets a flag that indicates whether or not anti-aliasing is used when the
 * chart is drawn.
 * <P>
 * Anti-aliasing usually improves the appearance of charts, but is slower.
 *
 * @param flag  the new value of the flag.
 * 
 * @see #getAntiAlias()
 */
public void setAntiAlias(boolean flag) {

    Object val = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING);
    if (val == null) {
        val = RenderingHints.VALUE_ANTIALIAS_DEFAULT;
    }
    if (!flag && RenderingHints.VALUE_ANTIALIAS_OFF.equals(val) 
        || flag && RenderingHints.VALUE_ANTIALIAS_ON.equals(val)) {
        // no change, do nothing
        return;
    }
    if (flag) {
        this.renderingHints.put(RenderingHints.KEY_ANTIALIASING, 
                                RenderingHints.VALUE_ANTIALIAS_ON);
    }
    else {
        this.renderingHints.put(RenderingHints.KEY_ANTIALIASING, 
                                RenderingHints.VALUE_ANTIALIAS_OFF);
    }
    fireChartChanged();

}
项目:parabuild-ci    文件:JFreeChart.java   
/**
 * Sets a flag that indicates whether or not anti-aliasing is used when the
 * chart is drawn.
 * <P>
 * Anti-aliasing usually improves the appearance of charts, but is slower.
 *
 * @param flag  the new value of the flag.
 */
public void setAntiAlias(boolean flag) {

    Object o = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING);
    if (o == null) {
        o = RenderingHints.VALUE_ANTIALIAS_DEFAULT;
    }
    if (!flag && RenderingHints.VALUE_ANTIALIAS_OFF.equals(o) 
        || flag && RenderingHints.VALUE_ANTIALIAS_ON.equals(o)) {
        // no change, do nothing
        return;
    }
    if (flag) {
        this.renderingHints.put(RenderingHints.KEY_ANTIALIASING, 
                                RenderingHints.VALUE_ANTIALIAS_ON);
    }
    else {
        this.renderingHints.put(RenderingHints.KEY_ANTIALIASING, 
                                RenderingHints.VALUE_ANTIALIAS_OFF);
    }
    fireChartChanged();

}
项目:GIFKR    文件:ImageTools.java   
public static BufferedImage fitHeight(BufferedImage img, int width, int height, boolean fast){
    img=resize(img, (int)(img.getWidth()*(height/(double)img.getHeight())), height, fast);
    if(img.getHeight()>height){
        img=img.getSubimage((img.getWidth()-width)/2, 0, width, img.getHeight());
    }

    BufferedImage fullImage=new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g=(Graphics2D)fullImage.getGraphics();
    if(!fast){
        g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
    }
    g.drawImage(img, (width-img.getWidth())/2, 0, null);

    g.dispose();

    return fullImage;   
}