コード例 #1
0
    public void paint(java.awt.Graphics g) {

      int w = m_bi.getWidth(this);

      int h = m_bi.getHeight(this);

      // int ww= (int)(w*(percentSize/100));

      // int hh=(int)(h*(percentSize/100));

      g.setColor(java.awt.Color.white);

      g.fillRect(0, 0, this.getWidth(), this.getHeight());

      java.awt.Graphics2D g2d = (java.awt.Graphics2D) g;

      g2d.scale(percentSize / 100.0, percentSize / 100.0);

      int ml = (this.getWidth() / 2) - (w / 2);

      int mh = (this.getHeight() / 2) - (h / 2);

      if (m_bi != null) {
        g2d.drawImage(m_bi, ml, mh, this);
      }
    }
コード例 #2
0
  public void paint(java.awt.Graphics g) {
    if (element != null) {
      Rectangle bounds = element.jGetBounds();
      Graphics2D g2 = (Graphics2D) g;

      g2.setFont(font);

      int mitteX = bounds.x + (bounds.width) / 2;
      int mitteY = bounds.y + (bounds.height) / 2;

      int distanceY = 10;

      g2.setColor(new Color(204, 204, 255));
      g2.fillRect(bounds.x, mitteY - distanceY, bounds.width, 2 * distanceY);
      g2.setColor(Color.BLACK);
      g2.drawRect(bounds.x, mitteY - distanceY, bounds.width, 2 * distanceY);

      String caption = "dec(" + variable.getValue() + ")";

      FontMetrics fm = g2.getFontMetrics();
      Rectangle2D r = fm.getStringBounds(caption, g2);

      g2.setColor(Color.BLACK);
      g.drawString(
          caption, mitteX - (int) (r.getWidth() / 2), (int) (mitteY + fm.getHeight() / 2) - 3);
    }
    super.paint(g);
  }
コード例 #3
0
  /** LinesPanel constructor comment. */
  public void paintBuffer(java.awt.Graphics g) {
    //	Color c = g.getColor();
    //	g.setColor(Color.black);
    boxes.paint(g);
    //	g.setColor(Color.darkGray);
    connections.paint(g);
    //	g.setColor(c);
    Item.highlighted.paint(g);

    if (connecting) g.drawLine(x1, y1, x2, y2);
  }
コード例 #4
0
    public int print(java.awt.Graphics pg, java.awt.print.PageFormat pageFormat, int pageIndex)
        throws java.awt.print.PrinterException {

      if (pageIndex >= m_maxNumPage || m_bi == null) {
        return NO_SUCH_PAGE;
      }

      pg.translate((int) pageFormat.getImageableX() + 1, (int) pageFormat.getImageableY() + 1);

      int wPage = (int) pageFormat.getImageableWidth() + 1;

      int hPage = (int) pageFormat.getImageableHeight() + 1;

      double scale = percentSize / 100.0;

      wPage = (int) (wPage / scale);

      hPage = (int) (hPage / scale);

      /*

      int wPage = (int)pageFormat.getImageableWidth();

      int hPage = (int)pageFormat.getImageableHeight();



      int w = m_bi.getWidth(this);

      int h = m_bi.getHeight(this);

      if (w == 0 || h == 0)

      return NO_SUCH_PAGE;

      int nCol = Math.max((int)Math.ceil((double)w/wPage), 1);

      int nRow = Math.max((int)Math.ceil((double)h/hPage), 1);

      m_maxNumPage = nCol*nRow;



      int iCol = pageIndex % nCol;

      int iRow = pageIndex / nCol;

      int x = iCol*wPage;

      int y = iRow*hPage;

      int wImage = Math.min(wPage, w-x);

      int hImage = Math.min(hPage, h-y);

      */

      int w = m_bi.getWidth(this);

      int h = m_bi.getHeight(this);

      // int resizedw = (int)(w*(percentSize/100.0));

      // int resizedh = (int)(h*(percentSize/100.0));

      java.awt.Graphics2D g2d = (java.awt.Graphics2D) pg;

      g2d.scale(percentSize / 100.0, percentSize / 100.0);

      if (w == 0 || h == 0) {
        return NO_SUCH_PAGE;
      }

      int nCol = Math.max((int) Math.ceil((double) w / wPage), 1);

      int nRow = Math.max((int) Math.ceil((double) h / hPage), 1);

      m_maxNumPage = nCol * nRow;

      int iCol = pageIndex % nCol;

      int iRow = pageIndex / nCol;

      int x = iCol * wPage;

      int y = iRow * hPage;

      int wImage = Math.min(wPage, w - x);

      int hImage = Math.min(hPage, h - y);

      g2d.drawImage(m_bi, 0, 0, wImage, hImage, x, y, x + wImage, y + hImage, this);

      // pg.drawImage(m_bi, 0, 0, 40, 40,  x, y, x+wImage, y+hImage, this);

      System.gc();

      return PAGE_EXISTS;
    }