Examples of Graphics2D


Examples of java.awt.Graphics2D

    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

Examples of java.awt.Graphics2D

  }

  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

Examples of java.awt.Graphics2D

  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

Examples of java.awt.Graphics2D

  public ProgramEditorPane() {
    super();
  }
 
  protected void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D)g;
   
    if (ProgramInfo.getInstance().getSettings().getAntialiasing()) {
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
        RenderingHints.VALUE_ANTIALIAS_ON);
   
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    }
  
    super.paintComponent(g2d);
  }
View Full Code Here

Examples of java.awt.Graphics2D

              m_mode = SELECTING;
              m_oldX = me.getX();
              m_oldY = me.getY();
              m_startX = m_oldX;
              m_startY = m_oldY;
              Graphics2D gx = (Graphics2D)layout.getGraphics();
              gx.setXORMode(java.awt.Color.white);
              //                gx.drawRect(m_oldX, m_oldY, m_oldX, m_oldY);
              //                gx.drawLine(m_startX, m_startY, m_startX, m_startY);
              gx.dispose();
              m_mode = SELECTING;
            }
          }
        }
      }
View Full Code Here

Examples of java.awt.Graphics2D

        m_startX = (int)closest.getX();
        m_startY = (int)closest.getY();
        m_oldX = m_startX;
        m_oldY = m_startY;

        Graphics2D gx = (Graphics2D)m_beanLayout.getGraphics();
        gx.setXORMode(java.awt.Color.white);
        gx.drawLine(m_startX, m_startY, m_startX, m_startY);
        gx.dispose();
        m_mode = CONNECTING;
      }
    }
  }
View Full Code Here

Examples of java.awt.Graphics2D

  throws IOException {
    boolean opaqueValue = component.isOpaque();
    component.setOpaque( true );
    BufferedImage image = new BufferedImage(region.width,
        region.height, BufferedImage.TYPE_INT_RGB);
    Graphics2D g2d = image.createGraphics();
    g2d.translate(-region.getX(), -region.getY());
    //g2d.setClip( region );
    component.paint( g2d );
    g2d.dispose();
    component.setOpaque( opaqueValue );

    return image;
  }
View Full Code Here

Examples of java.awt.Graphics2D

            }

            @Override
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                final Graphics2D g2d = (Graphics2D) g;

                // get viewport clip
                //Shape oldClip = g2d.getClip();
                // get the whole area
                //Rectangle oldBounds = getBounds();

                g2d.setColor(gridColor);
                // vertical lines
                for (int x = 1; x < visibleDays + 1; x++) {
                    g2d.drawLine(x * dayWidth, 0, x * dayWidth, getHoursPerDay() * hourWidth);
                }

                // horizontal lines
                int xEnd = visibleDays * dayWidth;
                for (int y = 1; y < getHoursPerDay() + 1; y++) {
                    g2d.drawLine(0, y * hourWidth, xEnd, y * hourWidth);
                }

                RoundBox selectedBox = null;
                DateTime startDate = settings.getStartDate();
                // paint events
                for (IntervalLong interval : getCurrentIntervals()) {
                    long startMillisOffset = interval.getStart() - startDate.getMillis()
                            + startDate.getMillisOfDay();
                    int day = (int) (startMillisOffset / ICalendarSettings.DAY);

                    int duration_hourWidth = (int) (interval.getDuration() / settings.getMillisPerTimeslot()
                            * getHourFactor() * hourWidth);

                    int start_hourWidth = (int) ((startMillisOffset % CalendarSettings.DAY
                            - startDate.getMillisOfDay()) / ICalendarSettings.HOUR * hourWidth)
                            + (hourWidth * interval.getStartDateTime().getMinuteOfHour() / 60);

                    int numberOfConflicts = stepFunction.getMaxAssignments(interval);
                    int position = stepFunction.getOffset(interval);
                    int thickness = dayWidth / numberOfConflicts;
                    int offset = position * thickness;

                    Rectangle2D paintingRect = new Rectangle2D.Double(
                            day * dayWidth + offset, start_hourWidth,
                            thickness, duration_hourWidth);

                    String text = interval.getDescription();
                    if (text == null || text.length() == 0)
                        text = interval.getName();
                    RoundBox box = new RoundBox(text, numberOfConflicts);
                    box.setRect(paintingRect);

                    if (paintingRect.intersects(mousePositionX, mousePositionY, 1, 1)) {
                        selectedBox = box;
                        continue;
                    }

                    box.paintComponent(g2d);
                }

                // now paint a selected interval a bit larger *and* on the top of the other
                if (selectedBox != null) {
                    selectedBox.setTransparent(false);
                    selectedBox.zoom(g2d.getClip());
                    selectedBox.paintComponent(g2d);
                }
            }
        };

View Full Code Here

Examples of java.awt.Graphics2D

   * Paints the component
   */
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    Graphics2D g2d = (Graphics2D)g;

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

    // Create the gradient paint
    GradientPaint paint =
        new GradientPaint((float)width / 3, 0, getBackground(), width, height, UIManager.getColor("List.selectionBackground"), false);

    g2d.setPaint(paint);
    g2d.fillRect(0, 0, width, height);
  }
View Full Code Here

Examples of java.awt.Graphics2D

      }

      //paint the cross
      protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g.create();
        //shift the image for pressed buttons
        if (getModel().isPressed()) {
          g2.translate(1, 1);
        }
        g2.setStroke(new BasicStroke(2));
        g2.setColor(Color.BLACK);
        if (!isEnabled()) {
          g2.setColor(Color.GRAY);
        }
        if (getModel().isRollover()) {
          g2.setColor(Color.MAGENTA);
        }
        int delta = 6;
        g2.drawLine(delta, delta, getWidth() - delta - 1, getHeight() - delta - 1);
        g2.drawLine(getWidth() - delta - 1, delta, delta, getHeight() - delta - 1);
        g2.dispose();
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.