Java Code Examples for java.awt.Graphics

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project echo2, under directory /src/webcontainer/java/nextapp/echo2/webcontainer/image/.

Source file: ImageToBufferedImage.java

  19 
vote

/** 
 * Converts an <code>Image</code> to a <code>BufferedImage</code>. If the image is already a <code>BufferedImage</code>, the original is returned.
 * @param image the image to convert
 * @return the image as a <code>BufferedImage</code>
 */
static BufferedImage toBufferedImage(Image image){
  if (image instanceof BufferedImage) {
    return (BufferedImage)image;
  }
  image=new ImageIcon(image).getImage();
  int type=hasAlpha(image) ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
  BufferedImage bufferedImage=new BufferedImage(image.getWidth(null),image.getHeight(null),type);
  Graphics g=bufferedImage.createGraphics();
  g.drawImage(image,0,0,null);
  g.dispose();
  return bufferedImage;
}
 

Example 2

From project Agot-Java, under directory /src/main/java/got/utility/.

Source file: PolygonGrabber.java

  18 
vote

/** 
 * createImage(java.lang.String) We create the image of the map here and assure that it is loaded properly.
 * @param java .lang.String mapName the path of the image map
 */
private void createImage(final String mapName){
  m_image=Toolkit.getDefaultToolkit().createImage(mapName);
  try {
    Util.ensureImageLoaded(m_image);
  }
 catch (  final InterruptedException ex) {
    ex.printStackTrace();
  }
  m_bufferedImage=new BufferedImage(m_image.getWidth(null),m_image.getHeight(null),BufferedImage.TYPE_INT_ARGB);
  final Graphics g=m_bufferedImage.getGraphics();
  g.drawImage(m_image,0,0,this);
  g.dispose();
}
 

Example 3

From project arquillian-rusheye, under directory /rusheye-impl/src/main/java/org/jboss/rusheye/core/.

Source file: DefaultImageComparator.java

  18 
vote

private void drawRectangleAroundDifferentPixels(Point min,Point max,int width,int height,BufferedImage diffImage){
  int x1=Math.max(0,min.x - BOUNDARY_SIZE);
  int y1=Math.max(0,min.y - BOUNDARY_SIZE);
  int x2=Math.min(width - 1,max.x + BOUNDARY_SIZE);
  int y2=Math.min(height - 1,max.y + BOUNDARY_SIZE);
  Graphics g=diffImage.createGraphics();
  g.setColor(BOUNDARY_COLOR);
  g.drawRect(x1,y1,x2 - x1,y2 - y1);
  g.dispose();
}
 

Example 4

From project BioMAV, under directory /Vision/standin-module/.

Source file: Vision.java

  18 
vote

private void paintImageToFrame(byte[] image){
  int index=0;
  for (int i=0; i < im.length; i++, index+=3) {
    im[i]=image[index] << 16 | image[index + 1] << 8 | image[index + 2];
  }
  bi.setRGB(0,0,imWidth,imHeight,im,0,imWidth);
  Graphics g=displayFrame.getGraphics();
  g.drawImage(bi,0,0,null);
}
 

Example 5

From project BMach, under directory /src/jsyntaxpane/actions/gui/.

Source file: MemberCell.java

  18 
vote

@Override public Dimension getPreferredSize(){
  Font font=list.getFont();
  Graphics g=getGraphics();
  FontMetrics fm=g.getFontMetrics(font);
  String total=getMemberName() + getArguments() + getReturnType()+ "  ";
  return new Dimension(fm.stringWidth(total) + 20,Math.max(fm.getHeight(),16));
}
 

Example 6

From project Clotho-Core, under directory /ClothoProject/ClothoCore/src/org/clothocore/util/frames/.

Source file: GraphicFrame.java

  18 
vote

protected void coverButtonDragged(java.awt.event.MouseEvent evt){
  Point aPoint=evt.getPoint();
  int x=getX() + aPoint.x - mousePointer.x;
  int y=getY() + aPoint.y - mousePointer.y;
  setLocation(x,y);
  Graphics graphics=getGraphics();
  paint(graphics);
}
 

Example 7

From project Custom-Salem, under directory /src/haven/.

Source file: Alchemy.java

  18 
vote

public BufferedImage smallmeter(){
  int max=0;
  for (int i=0; i < 4; i++)   max=Math.max(a[i],max);
  BufferedImage buf=TexI.mkbuf(new Coord(max / 200,12));
  Graphics g=buf.getGraphics();
  for (int i=0; i < 4; i++) {
    g.setColor(colors[i]);
    g.fillRect(0,i * 3,a[i] / 200,3);
  }
  g.dispose();
  return (buf);
}
 

Example 8

From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/lf5/viewer/.

Source file: LogTable.java

  18 
vote

public void setFont(Font font){
  super.setFont(font);
  Graphics g=this.getGraphics();
  if (g != null) {
    FontMetrics fm=g.getFontMetrics(font);
    int height=fm.getHeight();
    _rowHeight=height + height / 3;
    setRowHeight(_rowHeight);
  }
}
 

Example 9

From project drools-planner, under directory /drools-planner-examples/src/main/java/org/drools/planner/examples/tsp/swingui/.

Source file: TspWorldPanel.java

  18 
vote

private Graphics createCanvas(double width,double height){
  int canvasWidth=(int)Math.ceil(width) + 1;
  int canvasHeight=(int)Math.ceil(height) + 1;
  canvas=new BufferedImage(canvasWidth,canvasHeight,BufferedImage.TYPE_INT_RGB);
  Graphics g=canvas.getGraphics();
  g.setColor(Color.WHITE);
  g.fillRect(0,0,canvasWidth,canvasHeight);
  return g;
}
 

Example 10

From project echo3, under directory /src/server-java/webcontainer/nextapp/echo/webcontainer/util/.

Source file: PngEncoder.java

  18 
vote

/** 
 * Converts an <code>Image</code> to a <code>BufferedImage</code>. If the image is already a <code>BufferedImage</code>, the original is returned.
 * @param image the image to convert
 * @return the image as a <code>BufferedImage</code>
 */
static BufferedImage toBufferedImage(Image image){
  if (image instanceof BufferedImage) {
    return (BufferedImage)image;
  }
  image=new ImageIcon(image).getImage();
  int type=hasAlpha(image) ? BufferedImage.TYPE_INT_RGB : BufferedImage.TYPE_INT_ARGB;
  BufferedImage bufferedImage=new BufferedImage(image.getWidth(null),image.getHeight(null),type);
  Graphics g=bufferedImage.createGraphics();
  g.drawImage(image,0,0,null);
  g.dispose();
  return bufferedImage;
}
 

Example 11

From project en4j, under directory /NBPlatformApp/Synchronization/src/main/java/com/rubenlaguna/en4j/sync/.

Source file: GraphicsUtilities.java

  18 
vote

/** 
 * <p>Return a new compatible image that contains a copy of the specified image. This method ensures an image is compatible with the hardware, and therefore optimized for fast blitting operations.</p>
 * @see #createCompatibleImage(java.awt.image.BufferedImage)
 * @see #createCompatibleImage(java.awt.image.BufferedImage,int,int)
 * @see #createCompatibleImage(int,int)
 * @see #createCompatibleTranslucentImage(int,int)
 * @see #loadCompatibleImage(java.net.URL)
 * @param image the image to copy into a new compatible image
 * @return a new compatible copy, with thesame width and height and transparency and content, of <code>image</code>
 */
public static BufferedImage toCompatibleImage(BufferedImage image){
  if (image.getColorModel().equals(getGraphicsConfiguration().getColorModel())) {
    return image;
  }
  BufferedImage compatibleImage=getGraphicsConfiguration().createCompatibleImage(image.getWidth(),image.getHeight(),image.getTransparency());
  Graphics g=compatibleImage.getGraphics();
  g.drawImage(image,0,0,null);
  g.dispose();
  return compatibleImage;
}
 

Example 12

From project fest-assert-1.x, under directory /src/test/java/org/fest/assertions/.

Source file: Images.java

  18 
vote

static BufferedImage image(int width,int height,Color color){
  BufferedImage image=new BufferedImage(width,height,TYPE_INT_ARGB);
  Graphics graphics=image.createGraphics();
  graphics.setColor(color);
  graphics.fillRect(0,0,width,height);
  return image;
}
 

Example 13

From project freemind, under directory /freemind/freemind/extensions/.

Source file: ExportHook.java

  18 
vote

public BufferedImage createBufferedImage(){
  view=getController().getView();
  if (view == null)   return null;
  view.preparePrinting();
  Rectangle innerBounds=view.getInnerBounds();
  BufferedImage myImage=(BufferedImage)view.createImage(view.getWidth(),view.getHeight());
  Graphics g=myImage.getGraphics();
  g.clipRect(innerBounds.x,innerBounds.y,innerBounds.width,innerBounds.height);
  view.print(g);
  myImage=myImage.getSubimage(innerBounds.x,innerBounds.y,innerBounds.width,innerBounds.height);
  view.endPrinting();
  return myImage;
}
 

Example 14

From project FScape, under directory /src/main/java/de/sciss/fscape/gui/.

Source file: OpIcon.java

  18 
vote

/** 
 * Zeichnet nur den run()-Fortschritt
 * @param g	darf null sein
 */
public void paintProgress(Graphics g){
  final int prog=(int)(op.getProgress() * 360);
  final Graphics g2=g != null ? g : getGraphics();
  if (g2 != null) {
    g2.setColor(progColor);
    g2.drawArc(1,1,ICON_WIDTH - 2,ICON_HEIGHT - 2,90,prog);
    g2.drawArc(2,2,ICON_WIDTH - 4,ICON_HEIGHT - 4,90,prog);
    if (g == null) {
      g2.dispose();
    }
  }
}
 

Example 15

From project Carolina-Digital-Repository, under directory /djatoka-cdr/src/gov/lanl/adore/djatoka/io/reader/.

Source file: ImageJReader.java

  17 
vote

/** 
 * Internal ImagePlus processing to populate BufferedIMage using Graphics objects
 * @param imp an ImageJ ImagePlus object
 * @return a BufferedImage of type BufferedImage.TYPE_3BYTE_BGR
 * @throws FormatIOException
 */
private BufferedImage open(ImagePlus imp) throws FormatIOException {
  if (imp == null) {
    logger.error("Null ImagePlus Object.");
    throw new FormatIOException("Null ImagePlus Object.");
  }
  ImageProcessor ip=imp.getProcessor();
  int width=ip.getWidth();
  int height=ip.getHeight();
  Image img=ip.createImage();
  imp.flush();
  imp=null;
  ip=null;
  BufferedImage bImg=new BufferedImage(width,height,BufferedImage.TYPE_3BYTE_BGR);
  Graphics g=bImg.getGraphics();
  g.drawImage(img,0,0,null);
  img.flush();
  img=null;
  g.dispose();
  g=null;
  return bImg;
}
 

Example 16

From project ceres, under directory /ceres-ui/src/main/java/com/bc/ceres/swing/.

Source file: TreeCellExtender.java

  17 
vote

@Override protected void paintComponent(Graphics g){
  final int width=getWidth();
  final int height=getHeight();
  if (width <= 0 || height <= 0) {
    return;
  }
  Rectangle bounds=getBounds();
  Color color=g.getColor();
  g.setColor(getBackground());
  g.fillRect(bounds.x,bounds.y,bounds.width,bounds.height);
  g.setColor(color);
  TreePath path=tree.getPathForRow(row);
  TreeCellRenderer renderer=tree.getCellRenderer();
  Component rendererComponent=renderer.getTreeCellRendererComponent(tree,path.getLastPathComponent(),tree.isPathSelected(path),tree.isExpanded(path),true,row,false);
  rendererComponent.setSize(1024,height);
  Graphics g2=g.create(0,0,width,height);
  g2.translate(-offset,0);
  rendererComponent.paint(g2);
  g2.dispose();
}
 

Example 17

From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/hicc/.

Source file: ImageSlicer.java

  17 
vote

public BufferedImage subdivide(BufferedImage image,int level,XYData quadrant,XYData size,String prefix){
  if (image.getWidth() <= size.getX() * Math.pow(2,level)) {
    try {
      BufferedImage outputImage=tile(image,level,quadrant,size,true);
      write(outputImage,level,quadrant,prefix);
      return outputImage;
    }
 catch (    Exception e) {
      log.error(ExceptionUtil.getStackTrace(e));
    }
  }
  BufferedImage zoomed=new BufferedImage(size.getX() * 2,size.getY() * 2,BufferedImage.TYPE_INT_RGB);
  Graphics g=zoomed.getGraphics();
  XYData newQuadrant=new XYData(quadrant.getX() * 2 + 0,quadrant.getY() * 2 + 0);
  g.drawImage(subdivide(image,level + 1,newQuadrant,size,prefix),0,0,null);
  newQuadrant=new XYData(quadrant.getX() * 2 + 0,quadrant.getY() * 2 + 1);
  g.drawImage(subdivide(image,level + 1,newQuadrant,size,prefix),0,size.getY(),null);
  newQuadrant=new XYData(quadrant.getX() * 2 + 1,quadrant.getY() * 2 + 0);
  g.drawImage(subdivide(image,level + 1,newQuadrant,size,prefix),size.getX(),0,null);
  newQuadrant=new XYData(quadrant.getX() * 2 + 1,quadrant.getY() * 2 + 1);
  g.drawImage(subdivide(image,level + 1,newQuadrant,size,prefix),size.getX(),size.getY(),null);
  BufferedImage outputImage=new BufferedImage(size.getX(),size.getY(),BufferedImage.TYPE_INT_RGB);
  outputImage.getGraphics().drawImage(zoomed,0,0,size.getX(),size.getY(),null);
  write(outputImage,level,quadrant,prefix);
  return outputImage;
}
 

Example 18

From project dawn-common, under directory /org.dawb.hdf5/src/ncsa/hdf/view/.

Source file: DefaultImageView.java

  17 
vote

/** 
 * This method returns a buffered image with the contents of an image.
 * @param image the plain image object.
 * @return buffered image for the given image.
 */
private BufferedImage toBufferedImage(Image image){
  if (image == null) {
    return null;
  }
  if (image instanceof BufferedImage) {
    return (BufferedImage)image;
  }
  int w=image.getWidth(null);
  int h=image.getHeight(null);
  BufferedImage bimage=(BufferedImage)createImage(w,h);
  Graphics g=bimage.createGraphics();
  g.drawImage(image,0,0,null);
  g.dispose();
  return bimage;
}
 

Example 19

From project droolsjbpm-integration, under directory /droolsjbpm-integration-examples/src/main/java/org/drools/examples/conway/ui/.

Source file: CellGridCanvas.java

  17 
vote

/** 
 * Draw this generation.
 * @see java.awt.Component#paint(java.awt.Graphics)
 */
public void paint(final Graphics g){
  final int numberOfColumns=this.cellGrid.getNumberOfColumns();
  final int numberOfRows=this.cellGrid.getNumberOfRows();
  if (this.backgroundImage == null) {
    final Dimension d=getSize();
    this.backgroundImage=createImage(d.width,d.height);
    final Graphics backgroundImageGraphics=this.backgroundImage.getGraphics();
    backgroundImageGraphics.setColor(getBackground());
    backgroundImageGraphics.fillRect(0,0,d.width,d.height);
    backgroundImageGraphics.setColor(CellGridCanvas.BACKGROUND_COLOR);
    backgroundImageGraphics.fillRect(0,0,this.cellSize * numberOfColumns - 1,this.cellSize * numberOfRows - 1);
    backgroundImageGraphics.setColor(CellGridCanvas.GRID_COLOR);
    for (int x=1; x < numberOfColumns; x++) {
      backgroundImageGraphics.drawLine(x * this.cellSize - 1,0,x * this.cellSize - 1,this.cellSize * numberOfRows - 1);
    }
    for (int y=1; y < numberOfRows; y++) {
      backgroundImageGraphics.drawLine(0,y * this.cellSize - 1,this.cellSize * numberOfColumns - 1,y * this.cellSize - 1);
    }
  }
  g.drawImage(this.backgroundImage,0,0,null);
  for (int row=0; row < numberOfRows; row++) {
    for (int column=0; column < numberOfColumns; column++) {
      final Cell cell=this.cellGrid.getCellAt(row,column);
      if (cell.getCellState() == CellState.LIVE) {
        g.drawImage(this.liveCellImage,column * this.cellSize,row * this.cellSize,this);
      }
    }
  }
}
 

Example 20

From project encog-java-core, under directory /src/test/java/org/encog/neural/data/image/.

Source file: TestImageDataSet.java

  17 
vote

public void testImageDataSet(){
  try {
    JFrame frame=new JFrame();
    frame.setVisible(true);
    Image image=frame.createImage(10,10);
    Graphics g=image.getGraphics();
    g.setColor(Color.BLACK);
    g.fillRect(0,0,10,10);
    g.setColor(Color.WHITE);
    g.fillRect(0,0,5,5);
    g.dispose();
    Downsample downsample=new SimpleIntensityDownsample();
    ImageMLDataSet set=new ImageMLDataSet(downsample,true,-1,1);
    BasicMLData ideal=new BasicMLData(1);
    ImageMLData input=new ImageMLData(image);
    set.add(input,ideal);
    set.downsample(2,2);
    Iterator<MLDataPair> itr=set.iterator();
    MLDataPair pair=(MLDataPair)itr.next();
    MLData data=pair.getInput();
    double[] d=data.getData();
    input.toString();
    input.setImage(input.getImage());
  }
 catch (  HeadlessException ex) {
  }
}
 

Example 21

From project entando-core-engine, under directory /src/main/java/com/agiletec/plugins/jacms/aps/system/services/resource/model/imageresizer/.

Source file: PNGImageResizer.java

  17 
vote

protected BufferedImage toBufferedImage(Image image) throws ApsSystemException {
  if (image instanceof BufferedImage) {
    return (BufferedImage)image;
  }
  image=new ImageIcon(image).getImage();
  boolean hasAlpha=this.hasAlpha(image);
  BufferedImage bimage=null;
  GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
  try {
    int transparency=Transparency.OPAQUE;
    if (hasAlpha) {
      transparency=Transparency.BITMASK;
    }
    GraphicsDevice gs=ge.getDefaultScreenDevice();
    GraphicsConfiguration gc=gs.getDefaultConfiguration();
    bimage=gc.createCompatibleImage(image.getWidth(null),image.getHeight(null),transparency);
  }
 catch (  HeadlessException e) {
    throw new ApsSystemException("The system does not have a screen",e);
  }
  if (bimage == null) {
    int type=BufferedImage.TYPE_INT_RGB;
    if (hasAlpha) {
      type=BufferedImage.TYPE_INT_ARGB;
    }
    bimage=new BufferedImage(image.getWidth(null),image.getHeight(null),type);
  }
  Graphics graphics=bimage.createGraphics();
  graphics.drawImage(image,0,0,null);
  graphics.dispose();
  return bimage;
}
 

Example 22

From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/swing/.

Source file: BasicPanel.java

  17 
vote

protected void doRender(RenderingContext c,Layer root){
  try {
    Graphics g=((Java2DOutputDevice)c.getOutputDevice()).getGraphics();
    paintDefaultBackground(g);
    if (enclosingScrollPane == null) {
      Insets insets=getInsets();
      g.translate(insets.left,insets.top);
    }
    long start=System.currentTimeMillis();
    if (!c.isPrint()) {
      root.paint(c);
    }
 else {
      paintPagedView(c,root);
    }
    long after=System.currentTimeMillis();
    if (Configuration.isTrue("xr.incremental.repaint.print-timing",false)) {
      Uu.p("repaint took ms: " + (after - start));
    }
  }
 catch (  ThreadDeath t) {
    throw t;
  }
catch (  Throwable t) {
    if (documentListeners.size() > 0) {
      fireOnRenderException(t);
    }
 else {
      if (t instanceof Error) {
        throw (Error)t;
      }
      if (t instanceof RuntimeException) {
        throw (RuntimeException)t;
      }
      XRLog.exception(t.getMessage(),t);
    }
  }
}
 

Example 23

From project Game_3, under directory /java/src/playn/java/.

Source file: JavaGLContext.java

  17 
vote

private ByteBuffer convertImageData(BufferedImage img){
  Asserts.checkNotNull(img);
  ByteBuffer imageBuffer;
  ColorModel glAlphaColorModel=new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_sRGB),new int[]{8,8,8,8},true,false,Transparency.TRANSLUCENT,DataBuffer.TYPE_BYTE);
  WritableRaster raster=Raster.createInterleavedRaster(DataBuffer.TYPE_BYTE,img.getWidth(),img.getHeight(),4,null);
  BufferedImage texImage=new BufferedImage(glAlphaColorModel,raster,true,null);
  Graphics g=texImage.getGraphics();
  g.setColor(new Color(0f,0f,0f,0f));
  g.fillRect(0,0,256,256);
  g.drawImage(img,0,0,null);
  DataBufferByte dbuf=(DataBufferByte)texImage.getRaster().getDataBuffer();
  imageBuffer=ByteBuffer.allocateDirect(dbuf.getSize());
  imageBuffer.order(ByteOrder.nativeOrder());
  imageBuffer.put(dbuf.getData());
  imageBuffer.flip();
  return imageBuffer;
}
 

Example 24

From project Gmote, under directory /gmoteserver/src/org/gmote/server/media/itunes/.

Source file: ItunesCommandHandler.java

  17 
vote

private void getArtwork(){
  NSAppleEventDescriptor result;
  try {
    int myPool=NSAutoreleasePool.push();
    result=tellItunesTo("get data of artwork 1 of current track",1);
    NSData data=result.data();
    byte[] pictbytes=data.bytes(0,data.length());
    byte[] newpictbytes=new byte[512 + pictbytes.length];
    System.arraycopy(pictbytes,0,newpictbytes,512,pictbytes.length);
    if (QTSession.isInitialized() == false) {
      QTSession.open();
    }
    QTHandle qt=new QTHandle(newpictbytes);
    GraphicsImporter gc=new GraphicsImporter(QTUtils.toOSType("PICT"));
    gc.setDataHandle(qt);
    QDRect qdRect=gc.getNaturalBounds();
    GraphicsImporterDrawer myDrawer=new quicktime.app.view.GraphicsImporterDrawer(gc);
    QTImageProducer qtProducer=new QTImageProducer(myDrawer,new Dimension(qdRect.getWidth(),qdRect.getHeight()));
    Image img=Toolkit.getDefaultToolkit().createImage(qtProducer);
    BufferedImage bu=new BufferedImage(img.getWidth(null),img.getHeight(null),BufferedImage.TYPE_INT_RGB);
    Graphics g=bu.getGraphics();
    g.drawImage(img,0,0,null);
    g.dispose();
    ByteArrayOutputStream bas=new ByteArrayOutputStream();
    ImageIO.write(bu,"PNG",bas);
    byte[] image=bas.toByteArray();
    media.setImage(image);
    NSAutoreleasePool.pop(myPool);
  }
 catch (  java.lang.NullPointerException e) {
  }
catch (  Exception e) {
    LOGGER.log(Level.INFO,e.getMessage(),e);
  }
 finally {
    QTSession.close();
  }
}
 

Example 25

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/rendering/.

Source file: Engine.java

  15 
vote

public void updateGraphics(Graphics g){
  if (backBuffer != null && window != null) {
    g.drawImage(backBuffer,0,0,(int)window.getSize().getWidth(),(int)window.getSize().getHeight(),window);
    window.showStatus("StatusText");
  }
 else {
    Utils.log("No backbuffer created yet",System.err);
  }
}
 

Example 26

From project addis, under directory /application/src/main/java/org/drugis/addis/forestplot/.

Source file: ForestPlot.java

  15 
vote

@Override public void paint(Graphics g){
  d_g2d=(Graphics2D)g;
  d_g2d.translate(PADDING,PADDING);
  d_g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
  drawVerticalCenterString(d_g2d,"Study",1,Align.LEFT,FULLROW * 0);
  drawVerticalCenterString(d_g2d,"Relative Effect (95% CI)",FULLWIDTH,Align.RIGHT,FULLROW * 0);
  d_g2d.drawRect(1,ROWHEIGHT,FULLWIDTH,1);
  for (int i=0; i < d_pm.getNumRelativeEffects(); ++i) {
    drawVerticalCenterString(d_g2d,d_pm.getStudyLabelAt(i),1,Align.LEFT,FULLROW * (i + 1));
    drawVerticalCenterString(d_g2d,d_pm.getCIlabelAt(i),FULLWIDTH,Align.RIGHT,FULLROW * (i + 1));
  }
  d_g2d.translate(STUDYWIDTH,FULLROW);
  for (int i=0; i < d_bars.size(); ++i) {
    if (d_pm.getRelativeEffectAt(i).isDefined())     d_bars.get(i).paint(d_g2d);
  }
  paintAxis(d_g2d);
}
 

Example 27

From project alg-vis, under directory /src/algvis/gui/.

Source file: Screen.java

  15 
vote

@Override public void paintComponent(Graphics g){
  check_size();
  clear();
  if (D != null) {
    V.startDrawing();
    D.draw(V);
    V.endDrawing();
  }
 else {
    System.err.println("[DS null !]");
  }
  g.drawImage(I,0,0,null);
}
 

Example 28

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/ingest/.

Source file: IngestDialogPanel.java

  15 
vote

@Override public void paint(Graphics g){
  super.paint(g);
  if (manager.isIngestRunning()) {
    setProcessUnallocSpaceEnabled(false);
  }
 else {
    setProcessUnallocSpaceEnabled(true);
  }
}
 

Example 29

From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/event/.

Source file: EventViewVieport.java

  15 
vote

@Override public void paintChildren(final Graphics g){
  final Graphics2D g2d=(Graphics2D)g;
  final Composite alphaComp=AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.15f);
  final Composite noAlphaComp=AlphaComposite.getInstance(AlphaComposite.SRC_OVER,1f);
  g2d.setComposite(alphaComp);
  if ((ev != null) && (ev.getLogo() != null)) {
    g2d.drawImage(ev.getLogo(),getWidth() - ev.getLogo().getWidth(null),getHeight() - ev.getLogo().getHeight(null),this);
  }
  g2d.setComposite(noAlphaComp);
  super.paintChildren(g);
}
 

Example 30

From project bioclipse.speclipse, under directory /plugins/net.bioclipse.spectrum/src/net/bioclipse/spectrum/graph2d/.

Source file: Markers.java

  15 
vote

/** 
 * draw the marker
 * @param g Graphics context
 * @param m Index of the marker to draw
 * @param scale scale factor. All coordinates are multiplied by this factor.
 * @param x Coordinate where to draw the marker
 * @param y Coordinate where to draw the marker
 */
public void draw(Graphics g,int m,double scale,int x,int y){
  int i;
  MarkerVertex mv;
  int x0=x, x1=x, y0=y, y1=y;
  Vector v;
  if (m < 1 || m > max)   return;
  if (scale <= 0)   return;
  v=vert[m - 1];
  if (v == null)   return;
  for (i=0; i < v.size(); i++) {
    mv=(MarkerVertex)v.elementAt(i);
    if (mv.draw) {
      x1=x + (int)(mv.x * scale);
      y1=y + (int)(mv.y * scale);
      g.drawLine(x0,y0,x1,y1);
      x0=x1;
      y0=y1;
    }
 else {
      x0=x + (int)(mv.x * scale);
      y0=y + (int)(mv.y * scale);
    }
  }
}
 

Example 31

From project Briss, under directory /src/main/java/at/laborg/briss/gui/.

Source file: MergedPanel.java

  15 
vote

@Override public void update(Graphics g){
  if (!isEnabled())   return;
  Graphics2D g2=(Graphics2D)g;
  g2.drawImage(img,null,0,0);
  int cropCnt=0;
  for (  DrawableCropRect crop : crops) {
    drawNormalCropRectangle(g2,cropCnt,crop);
    if (crop.isSelected()) {
      drawSelectionOverlay(g2,crop);
    }
    cropCnt++;
  }
  g2.dispose();
}
 

Example 32

From project Calendar-Application, under directory /calendar/.

Source file: CalendarPanel.java

  15 
vote

/** 
 * Constructor for CalendarPanel, the main Panel of the application
 * @param parent The parent frame
 */
public CalendarPanel(Calindrom parent){
  m_parent=parent;
  m_view=CalendarPanel.MONTH_VIEW;
  setLayout(new BoxLayout(this,BoxLayout.X_AXIS));
  m_left_panel=new JPanel(){
    @Override protected void paintComponent(    Graphics grphcs){
      Graphics2D g2d=(Graphics2D)grphcs;
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
      GradientPaint gp=new GradientPaint(0,0,Calindrom.gray_yellow,0,getHeight(),Calindrom.gray);
      g2d.setPaint(gp);
      g2d.fillRect(0,0,getWidth(),getHeight());
      super.paintComponent(grphcs);
    }
  }
;
  m_left_panel.setOpaque(false);
  m_left_panel.setPreferredSize(new Dimension(CalendarPanel.LEFT_WIDTH,Integer.MAX_VALUE));
  m_left_panel.setMaximumSize(new Dimension(CalendarPanel.LEFT_WIDTH,Integer.MAX_VALUE));
  InitLeftPanel();
  m_right_panel=new MonthView(this);
  m_left_panel.setBorder(new MatteBorder(0,0,0,2,Color.black));
  m_right_panel.setBorder(new MatteBorder(0,1,0,0,Color.gray));
  add(m_left_panel);
  add(m_right_panel);
}
 

Example 33

From project Chess_1, under directory /src/chess/gui/.

Source file: ColorEditor.java

  15 
vote

public void paintIcon(Component c,Graphics g,int x,int y){
  Rectangle r=new Rectangle(x,y,WIDTH - 1,HEIGHT - 1);
  Graphics2D g2=(Graphics2D)g;
  Color oldColor=g2.getColor();
  g2.setColor(color);
  g2.fill(r);
  g2.setColor(Color.BLACK);
  g2.draw(r);
  g2.setColor(oldColor);
}
 

Example 34

From project Cinch, under directory /example/com/palantir/ptoss/cinch/example/demo/.

Source file: DrawingCanvas.java

  15 
vote

@Override protected void paintComponent(Graphics g){
  Graphics2D g2=(Graphics2D)g;
  g2.setColor(Color.WHITE);
  g2.fillRect(0,0,getWidth(),getHeight());
  g2.setColor(Color.BLACK);
  for (  Line2D line : model.getLines()) {
    g2.draw(line);
  }
  for (  Point2D point : model.getPoints()) {
    g2.fillOval((int)point.getX(),(int)point.getY(),5,5);
  }
}
 

Example 35

From project codjo-standalone-common, under directory /src/main/java/net/codjo/utils/sql/.

Source file: PrintAction.java

  15 
vote

/** 
 * Lance l'impression d'une page si elle exisre.
 * @param g Le Graphics de l'impression.
 * @param pf Le PageFormat (portrait ou paysage).
 * @param idx Le num?o de la page.
 * @return Si la page doit ?re imprimer ou non.
 * @exception PrinterException Pb d'impression ?
 */
public int print(Graphics g,PageFormat pf,int idx) throws PrinterException {
  if (curPageFormat != pf) {
    curPageFormat=pf;
    pages=repaginate(pf);
  }
  if (idx >= pages.size()) {
    return Printable.NO_SUCH_PAGE;
  }
  g.setFont(font);
  g.setColor(Color.black);
  renderPage(g,pf,idx);
  return Printable.PAGE_EXISTS;
}
 

Example 36

From project dawn-isencia, under directory /com.isencia.passerelle.engine/src/main/java/com/isencia/passerelle/actor/gui/graph/.

Source file: ModelGraphPanel.java

  15 
vote

/** 
 * Print the visible portion of the graph to a printer, which is represented by the specified graphics object.
 * @param graphics The context into which the page is drawn.
 * @param format The size and orientation of the page being drawn.
 * @param index The zero based index of the page to be drawn.
 * @return PAGE_EXISTS if the page is rendered successfully, or NO_SUCH_PAGEif pageIndex specifies a non-existent page.
 * @exception PrinterException If the print job is terminated.
 */
public int print(Graphics graphics,PageFormat format,int index) throws PrinterException {
  if (getJGraph() != null) {
    Rectangle2D view=getVisibleRectangle();
    return getJGraph().print(graphics,format,index,view);
  }
 else {
    return NO_SUCH_PAGE;
  }
}
 

Example 37

From project encog-java-examples, under directory /src/main/java/org/encog/examples/gui/elementary/.

Source file: DisplayPanel.java

  15 
vote

public void paint(Graphics g){
  super.paint(g);
  if (this.currentImage != null) {
    g.drawImage(this.currentImage,0,0,null);
  }
}
 

Example 38

From project encog-java-workbench, under directory /src/main/java/org/encog/workbench/dialogs/splash/.

Source file: EncogWorkbenchSplash.java

  15 
vote

public void paint(final Graphics g){
  super.paint(g);
  final FontMetrics fm=g.getFontMetrics();
  g.setFont(EncogFonts.getInstance().getTitleFont());
  int y=fm.getHeight() + 30;
  g.setFont(EncogFonts.getInstance().getTitleFont());
  g.drawString("Encog Workbench v" + EncogWorkBench.VERSION,10,y);
  y+=g.getFontMetrics().getHeight();
  g.setFont(EncogFonts.getInstance().getBodyFont());
  g.drawString(EncogWorkBench.COPYRIGHT,10,y);
  y+=g.getFontMetrics().getHeight();
  g.drawString("Released under the LGPL license",10,y);
  y+=g.getFontMetrics().getHeight();
  y+=g.getFontMetrics().getHeight();
  g.setFont(EncogFonts.getInstance().getHeadFont());
  g.drawString("Java Version:",10,y);
  g.setFont(EncogFonts.getInstance().getBodyFont());
  g.drawString(System.getProperty("java.version"),150,y);
  y+=g.getFontMetrics().getHeight();
  g.setFont(EncogFonts.getInstance().getHeadFont());
  g.drawString("Java 64/32-Bit:",10,y);
  g.setFont(EncogFonts.getInstance().getBodyFont());
  g.drawString(System.getProperty("sun.arch.data.model"),150,y);
  y+=g.getFontMetrics().getHeight();
  g.setFont(EncogFonts.getInstance().getHeadFont());
  g.drawString("Processor Count:",10,y);
  g.setFont(EncogFonts.getInstance().getBodyFont());
  g.drawString("" + Runtime.getRuntime().availableProcessors(),150,y);
  y+=g.getFontMetrics().getHeight();
}
 

Example 39

From project engine, under directory /main/com/midtro/platform/.

Source file: Engine.java

  15 
vote

/** 
 * Executes the render on the state and any injectors.
 * @param graphics The graphics reference.
 */
private void draw(final Graphics graphics){
  final AppGraphics appGraphics=new AppGraphics((Graphics2D)graphics,app.getSettings().isTextAntiAliasing());
  app.getCurrentState().draw(appGraphics,app);
  for (  final DrawInjector injector : app.getDrawInjectors()) {
    injector.draw(appGraphics,app);
  }
}
 

Example 40

From project erjang, under directory /src/main/java/erjang/console/.

Source file: ERLConsole.java

  15 
vote

protected void paintComponent(Graphics g){
  super.paintComponent(g);
  int y=0;
  g.setColor(new Color(156,154,140));
  g.drawLine(0,y,getWidth(),y);
  y++;
  g.setColor(new Color(196,194,183));
  g.drawLine(0,y,getWidth(),y);
  y++;
  g.setColor(new Color(218,215,201));
  g.drawLine(0,y,getWidth(),y);
  y++;
  g.setColor(new Color(233,231,217));
  g.drawLine(0,y,getWidth(),y);
  y=getHeight() - 3;
  g.setColor(new Color(233,232,218));
  g.drawLine(0,y,getWidth(),y);
  y++;
  g.setColor(new Color(233,231,216));
  g.drawLine(0,y,getWidth(),y);
  y=getHeight() - 1;
  g.setColor(new Color(221,221,220));
  g.drawLine(0,y,getWidth(),y);
}
 

Example 41

From project Euclidean-Pattern-Generator, under directory /src/com/hisschemoller/sequencer/view/components/.

Source file: JPanelRoundedCorners.java

  15 
vote

public void paintComponent(Graphics graphics){
  super.paintComponent(graphics);
  Graphics2D graphics2=(Graphics2D)graphics;
  graphics2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  int radius=8;
  Color color=new Color(0xFFFFFFFF);
  graphics2.setColor(new Color(color.getRed(),color.getGreen(),color.getBlue(),255));
  graphics2.fillRoundRect(0,0,getWidth(),getHeight(),radius,radius);
}
 

Example 42

From project extension_libero_manufacturing, under directory /extension/eevolution/libero/src/main/java/org/eevolution/form/crp/.

Source file: DiagramTreeCellRenderer.java

  15 
vote

@Override public Component getTreeCellRendererComponent(JTree tree,Object value,boolean sel,boolean expanded,boolean leaf,int row,boolean hasFocus){
  Component c=super.getTreeCellRendererComponent(tree,value,sel,expanded,leaf,row,hasFocus);
  String name=(String)getMapping(value);
  ImageIcon icon=getIcon(value);
  if (isNotAvailable(name)) {
    final int x1=getFontMetrics(getFont()).stringWidth(name) + icon.getIconWidth();
    JLabel l=new JLabel(name.substring(1,name.length() - 1),icon,JLabel.LEFT){
      private static final long serialVersionUID=1L;
      public void paint(      Graphics g){
        super.paint(g);
        int y=getFont().getSize() / 2;
        g.drawLine(0,y,x1,y);
      }
    }
;
    l.setFont(getFont());
    return l;
  }
  return c;
}
 

Example 43

From project FBReaderJ, under directory /obsolete/swing/src/org/geometerplus/zlibrary/ui/swing/dialogs/.

Source file: ZLBoolean3OptionView.java

  15 
vote

public void paintIcon(Component c,Graphics g,int x,int y){
  JCheckBox cb=(JCheckBox)c;
  TristateModel model=(TristateModel)cb.getModel();
  int controlSize=getControlSize();
  boolean drawCheck=model.getState() == SELECTED;
  boolean drawCross=model.getState() == DONT_CARE;
  if (model.isEnabled()) {
    if (model.isPressed() && model.isArmed()) {
      g.setColor(MetalLookAndFeel.getControlShadow());
      g.fillRect(x,y,controlSize - 1,controlSize - 1);
      drawPressed3DBorder(g,x,y,controlSize,controlSize);
    }
 else {
      drawFlush3DBorder(g,x,y,controlSize,controlSize);
    }
    g.setColor(MetalLookAndFeel.getControlInfo());
  }
 else {
    g.setColor(MetalLookAndFeel.getControlShadow());
    g.drawRect(x,y,controlSize - 1,controlSize - 1);
  }
  if (drawCross) {
    drawCross(c,g,x,y);
  }
  if (drawCheck) {
    if (cb.isBorderPaintedFlat()) {
      x++;
    }
    drawCheck(c,g,x,y);
  }
}
 

Example 44

From project formic, under directory /src/java/net/java/swingfx/waitwithstyle/.

Source file: SingleComponentInfiniteProgress.java

  15 
vote

protected double paintBars(final Graphics g,final boolean paintBackground){
  Rectangle oClip=g.getClipBounds();
  if (paintBackground) {
    if (imageBuf != null) {
      g.drawImage(imageBuf,oClip.x,oClip.y,oClip.x + oClip.width,oClip.y + oClip.height,oClip.x,oClip.y,oClip.x + oClip.width,oClip.y + oClip.height,null);
      g.drawImage(imageBuf,0,0,null);
    }
 else {
      Color color=getBackground();
      g.setColor(new Color(color.getRed(),color.getGreen(),color.getBlue(),200));
      g.fillRect(oClip.x,oClip.y,oClip.width,oClip.height);
    }
  }
  Graphics2D g2=(Graphics2D)g.create();
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  g2.transform(centerAndScaleTransform);
  if (colors[0] == null) {
    for (int i=0; i < bars.length; i++) {
      int re=Math.abs(getBackground().getRed() - 128 / (i + 1));
      int gr=Math.abs(getBackground().getGreen() - 128 / (i + 1));
      int bl=Math.abs(getBackground().getBlue() - 128 / (i + 1));
      colors[i]=new Color(re,gr,bl);
      colors[numBars + i]=colors[i];
    }
  }
  for (int i=0; i < bars.length; i++) {
    g2.setColor(colors[i + colorOffset]);
    g2.fill(bars[i]);
  }
  double maxY=drawTextAt(text,getFont(),(Graphics2D)g,getWidth(),barsScreenBounds.getMaxY(),getForeground());
  return maxY;
}
 

Example 45

From project GAIL, under directory /src/gail/utils/.

Source file: PresentationScreen.java

  15 
vote

@Override protected void paintComponent(Graphics g){
  Graphics2D g2=(Graphics2D)g;
  g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  g2.setRenderingHint(RenderingHints.KEY_RENDERING,RenderingHints.VALUE_RENDER_QUALITY);
  g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,opacity));
  g2.setColor(getBackground());
  g2.fillRect(0,0,getWidth(),getHeight());
  g2.drawImage(logo,(attachedFrame.getWidth() / 2) - (logo.getWidth() / 2),topMargin,null);
}
 

Example 46

From project gitblit, under directory /src/com/gitblit/client/.

Source file: ClosableTabComponent.java

  15 
vote

@Override protected void paintComponent(Graphics g){
  super.paintComponent(g);
  Graphics2D g2=(Graphics2D)g;
  Stroke stroke=g2.getStroke();
  g2.setStroke(new BasicStroke(2));
  g.setColor(Color.BLACK);
  if (getModel().isRollover()) {
    Color highlight=new Color(0,51,153);
    g.setColor(highlight);
  }
  int delta=5;
  g.drawLine(delta,delta,getWidth() - delta - 1,getHeight() - delta - 1);
  g.drawLine(getWidth() - delta - 1,delta,delta,getHeight() - delta - 1);
  g2.setStroke(stroke);
  int i=pane.indexOfTabComponent(ClosableTabComponent.this);
  pane.setTitleAt(i,label.getText());
}
 

Example 47

From project glg2d, under directory /src/main/java/glg2d/.

Source file: G2DGLCanvas.java

  15 
vote

@Override public void paint(Graphics g){
  if (isGLDrawing() && drawableComponent != null && canvas != null) {
    canvas.display();
  }
 else {
    super.paint(g);
  }
}
 

Example 48

From project gridland, under directory /src/org/grid/agent/sample/.

Source file: HumanAgent.java

  15 
vote

@Override public void paint(Graphics g){
  super.paint(g);
  if (hasFlag) {
    g.fillPolygon(flag);
  }
  g.drawString(direction.toString(),10,70);
}
 

Example 49

From project groovejaar, under directory /src/groovejaar/.

Source file: ClosableTabbedPane.java

  15 
vote

public void paint(Graphics g){
  int tabCount=tabbedPane.getTabCount();
  for (int j=0; j < tabCount; j++)   if (tabbedPane.getComponent(j).isShowing()) {
    int x=tabbedPane.getBoundsAt(j).x + tabbedPane.getBoundsAt(j).width - width - 5;
    int y=tabbedPane.getBoundsAt(j).y + 5;
    drawClose(g,x,y);
    break;
  }
  if (mouseOverTab(meX,meY)) {
    drawClose(g,closeX,closeY);
  }
}
 

Example 50

From project gs-core, under directory /src/org/graphstream/ui/swingViewer/.

Source file: DefaultView.java

  15 
vote

@Override public void paintComponent(Graphics g){
  super.paintComponent(g);
  checkTitle();
  Graphics2D g2=(Graphics2D)g;
  render(g2);
}
 

Example 51

From project gs-tool, under directory /src/org/graphstream/tool/gui/.

Source file: EnumComboBox.java

  15 
vote

protected void paintComponent(Graphics g){
  g.setColor(background);
  g.fillRoundRect(0,0,getWidth() - 1,getHeight() - 1,10,10);
  g.setColor(border);
  g.drawRoundRect(0,0,getWidth() - 1,getHeight() - 1,10,10);
}