Package java.awt

Examples of java.awt.Graphics2D


  }


  public void paintComponent(Graphics grp) {
    if (Settings.propEnableAntialiasing.getBoolean()) {
      final Graphics2D g2d = (Graphics2D) grp;
      if (null != g2d) {
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
      }
    }

    // Using the information of the clip bounds, we can speed up painting
View Full Code Here


           rect = new Rectangle(0,y-1,getWidth(),2);
          }
          mCueLine.setRect(rect);
        }

        Graphics2D g2 = (Graphics2D) getGraphics();
        Color c = new Color(255, 0, 0, mCueLine.getHeight() > 2 ? 40 : 180);
        g2.setColor(c);
        g2.fill(mCueLine);
      }

      return true;
    }
View Full Code Here

    }
  }

  protected void paintText(Graphics g, JMenuItem menuItem, Rectangle textRect, String text) {
    if (g instanceof Graphics2D && Settings.propTrayIsAntialiasing.getBoolean()) {
      Graphics2D g2d = (Graphics2D) g;
      g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    }

    if (menuItem.isArmed()) {
      g.setColor(selectionForeground);
    } else {
View Full Code Here

           // create a BufferedImage of only 1 pixel height for fetching the rows
           // of the image in the correct format (ARGB)
           // This speeds up things by more than factor 2, compared to the standard
           // BufferedImage.getRGB solution
           BufferedImage row = new BufferedImage(width, 1, BufferedImage.TYPE_INT_ARGB);
           Graphics2D g2d = row.createGraphics();
           int pixels[] = ((DataBufferInt) row.getRaster().getDataBuffer()).getData();
           // make sure alpha values do not add up for each row:
           g2d.setComposite(AlphaComposite.Src);
           // calculate scanline by scanline in order to safe memory.
           // It also seems to run faster like that
           for (y = 0; y < height; y++) {
               g2d.drawImage(image, null, 0, -y);
               // now pixels contains the rgb values of the row y!
               if (numNodes > MAX_NODES) {
                   // Prune one level if the color tree is too large.
                   root.pruneLevel();
                   depth--;
View Full Code Here

               // create a BufferedImage of only 1 pixel height for fetching
               // the rows of the image in the correct format (ARGB)
               // This speeds up things by more than factor 2, compared to the
               // standard BufferedImage.getRGB solution
               BufferedImage row = new BufferedImage(width, 1, BufferedImage.TYPE_INT_ARGB);
               Graphics2D g2d = row.createGraphics();
               int pixels[] = ((DataBufferInt) row.getRaster().getDataBuffer()).getData();
               // make sure alpha values do not add up for each row:
               g2d.setComposite(AlphaComposite.Src);
               // calculate scanline by scanline in order to safe memory.
               // It also seems to run faster like that
               Node node;
               int x, y, i, id;
               int pixel, red, green, blue, alpha;
               int pos = 0;
               for (y = 0; y < height; y++) {
                   g2d.drawImage(image, null, 0, -y);
                   // now pixels contains the rgb values of the row y!
                   // filter this row now:
                   for (x = 0; x < width;) {
                       pixel = pixels[x];
                       red = (pixel >> 16) & 0xff;
View Full Code Here

    InputStream inImg = saver.read(ctx, imgURL);
    BufferedImage old_img = (BufferedImage)ImageIO.read(inImg)
    int width = old_img.getWidth();
    int height = old_img.getHeight();
    BufferedImage new_img = new BufferedImage(height,width,BufferedImage.TYPE_INT_RGB);       
        Graphics2D g2d =new_img.createGraphics();
       
        AffineTransform origXform = g2d.getTransform();
        AffineTransform newXform = (AffineTransform)(origXform.clone());
        // center of rotation is center of the panel
    double radian = 0;
        double xRot = 0;
        double yRot = 0;
    switch(orient){
    case 3:
      radian = 180.0;
      xRot = width/2.0;
      yRot = height/2.0;
    case 6:
      radian = 90.0;
          xRot = height/2.0;
          yRot = xRot;
      break;
    case 8:
      radian = 270.0;
          xRot = width/2.0;
          yRot = xRot;
          break;
        default:
          return false;
    }
        newXform.rotate(Math.toRadians(radian), xRot, yRot);

        g2d.setTransform(newXform);  
        // draw image centered in panel
        g2d.drawImage(old_img, 0, 0, null);
        // Reset to Original
        g2d.setTransform(origXform);
        OutputStream out = saver.write(ctx, imgURL);
        try{
          ImageIO.write(new_img, "JPG", out);
        }finally{
          out.close();
View Full Code Here

              : (location.x + c.getWidth() - p.x ), 1, 2,
              toolBarPanel.getHeight() - 1);
        }

        if (!oldCueLineBounds.equals(mCueLine.getBounds())) {
          Graphics2D g2d = (Graphics2D) toolBarPanel.getGraphics();
          toolBarPanel.paintImmediately(oldCueLineBounds);

          Color color = new Color(255, 0, 0, 180);
          g2d.setColor(color);
          g2d.fill(mCueLine);

          g2d.dispose();
        }
      }
    }
  }
View Full Code Here

    BufferedImage old_img = (BufferedImage)ImageIO.read(img)
    int width = old_img.getWidth();
    int height = old_img.getHeight();
   
    BufferedImage new_img = new BufferedImage(height,width,BufferedImage.TYPE_INT_BGR);       
        Graphics2D g2d =new_img.createGraphics();
       
        AffineTransform origXform = g2d.getTransform();
        AffineTransform newXform = (AffineTransform)(origXform.clone());
        // center of rotation is center of the panel
        double xRot = width/2.0;
        newXform.rotate(Math.toRadians(270.0), xRot, xRot);

        g2d.setTransform(newXform);  
        // draw image centered in panel
        g2d.drawImage(old_img, 0, 0, null);
        // Reset to Original
        g2d.setTransform(origXform);

        FileOutputStream out = new FileOutputStream("D:\\test.jpg");
        try{
          ImageIO.write(new_img, "JPG", out);
        }finally{
View Full Code Here

  }

  private Icon createIcon() {
    BufferedImage img = new BufferedImage(25, 15, BufferedImage.TYPE_INT_RGB);

    Graphics2D g = GraphicsEnvironment.getLocalGraphicsEnvironment().createGraphics(img);

    g.setColor(Color.WHITE);
    g.fillRect(1, 1, 23, 13);
    g.setColor(mColor);
    g.fillRect(1, 1, 23, 13);
    g.setColor(Color.BLACK);
    g.drawRect(0, 0, 24, 14);
   
    ImageIcon icon = new ImageIcon(img);

    return icon;
  }
View Full Code Here

  public LineButton() {
    super();
   
    BufferedImage image = new BufferedImage(22, 22, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2 = image.createGraphics();
    g2.setColor(new Color(255,0,0,0));
    g2.fillRect(0, 0, 22, 22);
   
    g2.setColor(getForeground());
    g2.drawLine(0, 11, 22, 11);
    setIcon(new ImageIcon(image));
  }
View Full Code Here

TOP

Related Classes of java.awt.Graphics2D

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.