Package java.awt

Examples of java.awt.Graphics


    dummy.addNotify();
    Image image = dummy.createImage(100, 100);
    if (image == null) {
      System.err.println("getFontMetrics: image is null");
    }
    Graphics graphics = image.getGraphics();
    return graphics.getFontMetrics(font);

  }
View Full Code Here


    // Add the menubar
    menuBar = new TestMenuBar(this);
    setJMenuBar(menuBar);
      
    // Get the Graphics object for pdf writing
    Graphics pdfGraphics = null;
    job = new PDFJob(fileOutputStream);
    pdfGraphics = job.getGraphics();
    Dimension d = job.getPageDimension();
    documentDimension = d;
View Full Code Here

      System.out.println("Error!! - drawing image is null");
      System.exit(1);
    }

    drawingArea.setImage(img);
    Graphics javaGraphics = img.getGraphics();   

    // Now we have two Graphics objects - one for java Graphics to
    // draw to the screen , another to write
    // to the pdf file.  We'll use the same methods to act on both
    // objects, and (theoretically) the results should be identical.
    // If 'Print' is selected from the menu, the same methods wi
    // act on a Graphics object from the java.awt.PrintJob   

    doTest(javaGraphics, d);
    javaGraphics.dispose();

    // The whole pdf doc will be written when the program starts
    if ((!pdfDocumentAlreadyDone) && (pdfGraphics != null)) {
      doTest(pdfGraphics, d);
      pdfGraphics.dispose();
View Full Code Here

    PrintJob pjob = toolkit.getPrintJob(this,
                                        "PDF Test Print",
                                        jobAttributes, 
                                        null);
    if(pjob != null) { 
      Graphics printGraphics = pjob.getGraphics();
      if (currentPage == 1) {
        doTest(printGraphics, documentDimension);
        printGraphics.dispose();
        pjob.end();
      }
      else {
        doSecondPageTest(printGraphics);
        printGraphics.dispose();
        pjob.end();
      }
    }
    else {
      System.err.println("Can't print: printjob null");
View Full Code Here

      System.out.println("Error!! - drawing image is null");
      System.exit(1);
    }

    drawingArea.setImage(img);
    Graphics javaGraphics = img.getGraphics();   
  
    doSecondPageTest(javaGraphics);
    javaGraphics.dispose();

    currentPage = 2;
    drawingArea.repaint();
    drawingArea.revalidate();
  }
View Full Code Here

        int pwidth = 512;
        int pheight = 512;

        AcmeGifFormatter formatter = new AcmeGifFormatter();
        Graphics graphics = formatter.getGraphics(pwidth, pheight);

        Paint background;
        if (map == null) {
            background = MapBean.DEFAULT_BACKGROUND_COLOR;
        } else {
View Full Code Here

            if (drawingBuffer == null) {
                drawingBuffer = createImage(w, h);
            }

            // draw the old image
            Graphics gr = getMapBeanRepaintPolicy().modifyGraphicsForPainting(drawingBuffer.getGraphics());

            if (clip == null) {
                gr.setClip(0, 0, w, h);
            } else {
                gr.setClip(clip);
            }
            // gr.drawImage(drawingBuffer,0,0,null);
            if (Debug.debugging("mapbean")) {
                Debug.output("BufferedMapBean.rendering layers to buffer.");
            }

            paintChildrenWithBorder(gr, false);

            // reset the clip to full map
            // gr.setClip(0, 0, w, h);
            gr.dispose();
        } else if (Debug.debugging("mapbean")) {
            Debug.output("BufferedMapBean.rendering buffer.");
        }

        // Should be be clipping the graphics here? I'm not sure.
View Full Code Here

        if( newMetricsNeeded ) {
            calculateSize();
        }
       
        stringImage = createImage(stringWidth, stringHeight);
        Graphics graphics = stringImage.getGraphics();

        //  Draw shadow
        if( shadowEnabled ) {
            graphics.setColor(getShadow());
            graphics.drawString(message, shadowX, stringAscent + shadowY);
        }

        //  Draw foreground
        graphics.setColor(getForeground());
        graphics.drawString(message, 0, stringAscent);
    }
View Full Code Here

  /** 
  * Paint the ticks in the panel.
  */
    public void paint(Graphics g) {
  Graphics mygfx;

  if (labelFont != null) {
      mygfx = g.create();
      mygfx.setFont(labelFont);
  // Just in case, requested font unavailable
  else
      mygfx = g;

  FontMetrics fm = mygfx.getFontMetrics();

  int offset = 0;
  double w = (double) size.width;
  double ppu = w / (max - min);
  while (ppu * tickIncrement < 2) {
      tickIncrement += 10;
  }

  int pix_inc = (int)(tickIncrement * ppu);
  int labelSpan = labelIncrement * tickIncrement;

  for (int i = min, x = 0, j = 0;
    i <= max;
    i += tickIncrement, x += pix_inc) {
      if (i % labelSpan == 0) {
     String label = String.valueOf(min + (j * labelSpan));
    offset = 0;
    // Place leftmost label to right
    if (i != min)
        offset = fm.stringWidth(label) / 2;
          if (i >= max// Place rightmost label to left
        offset = fm.stringWidth(label);
   
    mygfx.drawString(label, x - offset, size.height/2);
          mygfx.drawLine(x, size.height/2, x, size.height);
    j++;
      } else
    mygfx.drawLine(x, 3 * size.height/4, x, size.height);
        }

  if (labelFont != null)
      mygfx.dispose();
    }
View Full Code Here

    VideoFormat vf = (VideoFormat) cbuffer.getFormat();
    bti = new BufferToImage(vf);
      }
      if (bti != null && component != null) {
    Image im = bti.createImage(cbuffer);
    Graphics g = component.getGraphics();
    Dimension size = component.getSize();
    if (g != null)
        g.drawImage(im, 0, 0, component);
      }
  }

  // Maybe synchronize this with setTransferHandler() ?
  if (transferHandler != null && cds.delStarted)
View Full Code Here

TOP

Related Classes of java.awt.Graphics

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.