////////////////////////////////////////////////////////////////////////////
 // Paint
 //
 public synchronized void paint(Graphics g) {
   Graphics2D g2 = (Graphics2D) g;
   // Graphics2D buffGraphics2 = (Graphics2D) buffGraphics;
   //    g2.drawImage(bImage, 3, 3, getWidth() - 3, getHeight() - 3,
   //        0, 0, iWidth, iHeight, null);
   g2.drawImage(bImage, 0, 0, iWidth, iHeight, null);
   g2.drawString(String.valueOf(System.currentTimeMillis()), 10, 10);
 }
Пример #2
0
  @Override
  public void paintIcon(Component c, Graphics g, int x, int y) {
    if (image == null) {
      image = new BufferedImage(getIconWidth(), getIconHeight(), BufferedImage.TYPE_INT_ARGB);
      double coef = Math.min((double) width / (double) 68, (double) height / (double) 81);

      Graphics2D g2d = image.createGraphics();
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2d.scale(coef, coef);
      paint(g2d);
      g2d.dispose();
    }

    g.drawImage(image, x, y, null);
  }
Пример #3
0
 public void render(int w, int h, Graphics2D g2) {
   int mindim = Math.min(w, h);
   AffineTransform at = new AffineTransform();
   at.translate((w - mindim) / 2.0, (h - mindim) / 2.0);
   at.scale(mindim, mindim);
   at.translate(0.5, 0.5);
   at.scale(0.3, 0.3);
   at.translate(-(Twidth + Rwidth), FontHeight / 4.0);
   g2.transform(at);
   tree(g2, mindim * 0.3, 0);
 }
Пример #4
0
  /**
   * Paints the transcoded SVG image on the specified graphics context.
   *
   * @param g Graphics context.
   */
  private void paint(Graphics2D g) {
    Shape shape = null;

    float origAlpha = 1.0f;

    java.util.LinkedList<AffineTransform> transformations =
        new java.util.LinkedList<AffineTransform>();

    //
    transformations.offer(g.getTransform());
    g.transform(new AffineTransform(1.0666667f, 0, 0, 1.0666667f, 0, 0));

    // _0

    // _0_0

    // _0_0_0
    shape = new GeneralPath();
    ((GeneralPath) shape).moveTo(44.85476, 13.658783);
    ((GeneralPath) shape).lineTo(39.8797, 18.833183);
    ((GeneralPath) shape).lineTo(62.034473, 24.087093);
    ((GeneralPath) shape).lineTo(56.182423, 2.2196937);
    ((GeneralPath) shape).lineTo(51.25553, 7.156234);
    ((GeneralPath) shape).curveTo(23.11004, -15.968987, -18.852411, 21.698124, 9.346271, 53.566833);
    ((GeneralPath) shape).curveTo(34.37855, 75.45358, 62.938217, 55.468464, 62.84925, 31.573273);
    ((GeneralPath) shape).lineTo(53.94392, 31.646673);
    ((GeneralPath) shape).curveTo(53.04116, 50.485714, 32.096634, 60.792103, 16.790325, 48.184963);
    ((GeneralPath) shape)
        .curveTo(-3.4530144, 28.782303, 21.423546, -2.7391064, 44.85476, 13.658743);
    ((GeneralPath) shape).closePath();

    g.setPaint(color);
    g.fill(shape);

    g.setTransform(transformations.poll()); // _0
  }
Пример #5
0
    public void run() {

      Thread me = Thread.currentThread();

      while (thread == me && !isShowing() || getSize().width == 0) {
        try {
          thread.sleep(500);
        } catch (InterruptedException e) {
          return;
        }
      }

      while (thread == me && isShowing()) {
        Dimension d = getSize();
        if (d.width != w || d.height != h) {
          w = d.width;
          h = d.height;
          bimg = (BufferedImage) createImage(w, h);
          big = bimg.createGraphics();
          big.setFont(font);
          FontMetrics fm = big.getFontMetrics(font);
          ascent = (int) fm.getAscent();
          descent = (int) fm.getDescent();
        }
        repaint();
        try {
          thread.sleep(sleepAmount);
        } catch (InterruptedException e) {
          break;
        }
        if (MemoryMonitor.dateStampCB.isSelected()) {
          System.out.println(new Date().toString() + " " + usedStr);
        }
      }
      thread = null;
    }
Пример #6
0
  public void render(int w, int h, Graphics2D g2) {

    g2.translate(w * .2, h * .2);

    GeneralPath p = new GeneralPath(GeneralPath.WIND_NON_ZERO);
    p.moveTo(0.0f, 0.0f);
    p.lineTo(w * .5f, 0.0f);
    p.lineTo(w * .5f, h * .2f);
    p.lineTo(0.0f, h * .2f);
    p.closePath();

    p.moveTo(w * .05f, h * .05f);
    p.lineTo(w * .55f, h * .05f);
    p.lineTo(w * .55f, h * .25f);
    p.lineTo(w * .05f, h * .25f);
    p.closePath();

    g2.setColor(LIGHT_GRAY);
    g2.fill(p);
    g2.setColor(BLACK);
    g2.draw(p);
    g2.drawString("NON_ZERO rule", 0, -5);

    g2.translate(0.0f, h * .45);

    p.setWindingRule(GeneralPath.WIND_EVEN_ODD);
    g2.setColor(LIGHT_GRAY);
    g2.fill(p);
    g2.setColor(BLACK);
    g2.draw(p);
    g2.drawString("EVEN_ODD rule", 0, -5);
  }
Пример #7
0
 public void tree(Graphics2D g2d, double size, int phase) {
   g2d.setColor(colors[phase % 3]);
   new TextLayout(theT.toString(), theFont, g2d.getFontRenderContext()).draw(g2d, 0.0f, 0.0f);
   if (size > 10.0) {
     AffineTransform at = new AffineTransform();
     at.setToTranslation(Twidth, -0.1);
     at.scale(0.6, 0.6);
     g2d.transform(at);
     size *= 0.6;
     new TextLayout(theR.toString(), theFont, g2d.getFontRenderContext()).draw(g2d, 0.0f, 0.0f);
     at.setToTranslation(Rwidth + 0.75, 0);
     g2d.transform(at);
     Graphics2D g2dt = (Graphics2D) g2d.create();
     at.setToRotation(-Math.PI / 2.0);
     g2dt.transform(at);
     tree(g2dt, size, phase + 1);
     g2dt.dispose();
     at.setToTranslation(.75, 0);
     at.rotate(-Math.PI / 2.0);
     at.scale(-1.0, 1.0);
     at.translate(-Twidth, 0);
     g2d.transform(at);
     tree(g2d, size, phase);
   }
   g2d.setTransform(new AffineTransform());
 }
Пример #8
0
    public void paint(Graphics g) {

      if (big == null) {
        return;
      }

      big.setBackground(getBackground());
      big.clearRect(0, 0, w, h);

      float freeMemory = (float) r.freeMemory();
      float totalMemory = (float) r.totalMemory();

      // .. Draw allocated and used strings ..
      big.setColor(GREEN);
      big.drawString(
          String.valueOf((int) totalMemory / 1024) + "K allocated", 4.0f, (float) ascent + 0.5f);
      usedStr = String.valueOf(((int) (totalMemory - freeMemory)) / 1024) + "K used";
      big.drawString(usedStr, 4, h - descent);

      // Calculate remaining size
      float ssH = ascent + descent;
      float remainingHeight = (float) (h - (ssH * 2) - 0.5f);
      float blockHeight = remainingHeight / 10;
      float blockWidth = 20.0f;
      float remainingWidth = (float) (w - blockWidth - 10);

      // .. Memory Free ..
      big.setColor(mfColor);
      int MemUsage = (int) ((freeMemory / totalMemory) * 10);
      int i = 0;
      for (; i < MemUsage; i++) {
        mfRect.setRect(5, (float) ssH + i * blockHeight, blockWidth, (float) blockHeight - 1);
        big.fill(mfRect);
      }

      // .. Memory Used ..
      big.setColor(GREEN);
      for (; i < 10; i++) {
        muRect.setRect(5, (float) ssH + i * blockHeight, blockWidth, (float) blockHeight - 1);
        big.fill(muRect);
      }

      // .. Draw History Graph ..
      big.setColor(graphColor);
      int graphX = 30;
      int graphY = (int) ssH;
      int graphW = w - graphX - 5;
      int graphH = (int) remainingHeight;
      graphOutlineRect.setRect(graphX, graphY, graphW, graphH);
      big.draw(graphOutlineRect);

      int graphRow = graphH / 10;

      // .. Draw row ..
      for (int j = graphY; j <= graphH + graphY; j += graphRow) {
        graphLine.setLine(graphX, j, graphX + graphW, j);
        big.draw(graphLine);
      }

      // .. Draw animated column movement ..
      int graphColumn = graphW / 15;

      if (columnInc == 0) {
        columnInc = graphColumn;
      }

      for (int j = graphX + columnInc; j < graphW + graphX; j += graphColumn) {
        graphLine.setLine(j, graphY, j, graphY + graphH);
        big.draw(graphLine);
      }

      --columnInc;

      if (pts == null) {
        pts = new int[graphW];
        ptNum = 0;
      } else if (pts.length != graphW) {
        int tmp[] = null;
        if (ptNum < graphW) {
          tmp = new int[ptNum];
          System.arraycopy(pts, 0, tmp, 0, tmp.length);
        } else {
          tmp = new int[graphW];
          System.arraycopy(pts, pts.length - tmp.length, tmp, 0, tmp.length);
          ptNum = tmp.length - 2;
        }
        pts = new int[graphW];
        System.arraycopy(tmp, 0, pts, 0, tmp.length);
      } else {
        big.setColor(YELLOW);
        pts[ptNum] = (int) (graphY + graphH * (freeMemory / totalMemory));
        for (int j = graphX + graphW - ptNum, k = 0; k < ptNum; k++, j++) {
          if (k != 0) {
            if (pts[k] != pts[k - 1]) {
              big.drawLine(j - 1, pts[k - 1], j, pts[k]);
            } else {
              big.fillRect(j, pts[k], 1, 1);
            }
          }
        }
        if (ptNum + 2 == pts.length) {
          // throw out oldest point
          for (int j = 1; j < ptNum; j++) {
            pts[j - 1] = pts[j];
          }
          --ptNum;
        } else {
          ptNum++;
        }
      }
      g.drawImage(bimg, 0, 0, this);
    }