Java Code Examples for java.awt.Graphics2D.getRenderingHints()

The following are Jave code examples for showing how to use getRenderingHints() of the java.awt.Graphics2D class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: ListCompletionView.java   View Source Code Vote up 6 votes
public @Override void paint(Graphics g) {
    Object value = (Map)(Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
    Map renderingHints = (value instanceof Map) ? (java.util.Map)value : null;
    if (renderingHints != null && g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        RenderingHints oldHints = g2d.getRenderingHints();
        g2d.setRenderingHints(renderingHints);
        try {
            super.paint(g2d);
        } finally {
            g2d.setRenderingHints(oldHints);
        }
    } else {
        super.paint(g);
    }
}
 
Example 2
Project: incubator-netbeans   File: ResultBar.java   View Source Code Vote up 6 votes
public
@Override
void paint(Graphics g) {
    // Antialiasing if necessary
    Object value = (Map) (Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
    Map renderingHints = (value instanceof Map) ? (java.util.Map) value : null;
    if (renderingHints != null && g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        RenderingHints oldHints = g2d.getRenderingHints();
        g2d.setRenderingHints(renderingHints);
        try {
            super.paint(g2d);
        } finally {
            g2d.setRenderingHints(oldHints);
        }
    } else {
        super.paint(g);
    }
}
 
Example 3
Project: incubator-netbeans   File: ListCompletionView.java   View Source Code Vote up 6 votes
public @Override void paint(Graphics g) {
    Object value = Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints"); //NOI18N
    Map renderingHints = (value instanceof Map) ? (java.util.Map)value : null;
    if (renderingHints != null && g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        RenderingHints oldHints = g2d.getRenderingHints();
        g2d.setRenderingHints(renderingHints);
        try {
            super.paint(g2d);
        } finally {
            g2d.setRenderingHints(oldHints);
        }
    } else {
        super.paint(g);
    }
}
 
Example 4
Project: incubator-netbeans   File: CoverageBar.java   View Source Code Vote up 6 votes
public
@Override
void paint(Graphics g) {
    // Antialiasing if necessary
    Object value = (Map) (Toolkit.getDefaultToolkit().getDesktopProperty("awt.font.desktophints")); //NOI18N
    Map renderingHints = (value instanceof Map) ? (java.util.Map) value : null;
    if (renderingHints != null && g instanceof Graphics2D) {
        Graphics2D g2d = (Graphics2D) g;
        RenderingHints oldHints = g2d.getRenderingHints();
        g2d.setRenderingHints(renderingHints);
        try {
            super.paint(g2d);
        } finally {
            g2d.setRenderingHints(oldHints);
        }
    } else {
        super.paint(g);
    }
}
 
Example 5
Project: What-Happened-to-Station-7   File: TStack.java   View Source Code Vote up 5 votes
public gInfo(Graphics2D g)
{
	transform = g.getTransform();
	paint = g.getPaint();
	stroke = g.getStroke();
	font = g.getFont();
	composite = g.getComposite();
	bgrnd = g.getBackground();
	shape = g.getClip();
	hints = g.getRenderingHints();
}
 
Example 6
Project: Tarski   File: mxGraphComponent.java   View Source Code Vote up 5 votes
/**
 * 
 */
public void paintComponent(Graphics g) {
  super.paintComponent(g);

  // Draws the background
  paintBackground(g);

  // Creates or destroys the triple buffer as needed
  if (tripleBuffered) {
    checkTripleBuffer();
  } else if (tripleBuffer != null) {
    destroyTripleBuffer();
  }

  // Paints the buffer in the canvas onto the dirty region
  if (tripleBuffer != null) {
    mxUtils.drawImageClip(g, tripleBuffer, this);
  }

  // Paints the graph directly onto the graphics
  else {
    Graphics2D g2 = (Graphics2D) g;
    RenderingHints tmp = g2.getRenderingHints();

    // Sets the graphics in the canvas
    try {
      mxUtils.setAntiAlias(g2, antiAlias, textAntiAlias);
      drawGraph(g2, true);
    } finally {
      // Restores the graphics state
      g2.setRenderingHints(tmp);
    }
  }

  eventSource.fireEvent(new mxEventObject(mxEvent.PAINT, "g", g));
}
 
Example 7
Project: TrabalhoFinalEDA2   File: mxGraphComponent.java   View Source Code Vote up 4 votes
/**
 * 
 */
public void paintComponent(Graphics g)
{
	super.paintComponent(g);

	// Draws the background
	paintBackground(g);

	// Creates or destroys the triple buffer as needed
	if (tripleBuffered)
	{
		checkTripleBuffer();
	}
	else if (tripleBuffer != null)
	{
		destroyTripleBuffer();
	}

	// Paints the buffer in the canvas onto the dirty region
	if (tripleBuffer != null)
	{
		mxUtils.drawImageClip(g, tripleBuffer, this);
	}

	// Paints the graph directly onto the graphics
	else
	{
		Graphics2D g2 = (Graphics2D) g;
		RenderingHints tmp = g2.getRenderingHints();

		// Sets the graphics in the canvas
		try
		{
			mxUtils.setAntiAlias(g2, antiAlias, textAntiAlias);
			drawGraph(g2, true);
		}
		finally
		{
			// Restores the graphics state
			g2.setRenderingHints(tmp);
		}
	}

	eventSource.fireEvent(new mxEventObject(mxEvent.PAINT, "g", g));
}
 
Example 8
Project: geomapapp   File: D18oObservations.java   View Source Code Vote up 4 votes
public void draw(Graphics2D g) {
//	if(!display) return;
int yr1 = 1900;
int yr2 = 2005;
try {
	long[] interval = timeInterval();
	Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
	if( db.before.isSelected() ) {
			cal.setTimeInMillis(interval[0]);
			yr1 = cal.get(cal.YEAR);
	}
	if( db.after.isSelected() ) {
		cal.setTimeInMillis(interval[1]);
		yr2 = cal.get(cal.YEAR);
	}
} catch(Exception e) {
}
//	System.out.println( yr1 +"\t"+ yr2);
	float size = 2.0f + 6f/(float)map.getZoom();
	Arc2D.Float dot = new Arc2D.Float(-size/2f, -size/2f, size, size, 0f, 360f, Arc2D.CHORD);
	float size1 = 2.0f + 7f/(float)map.getZoom();
	GeneralPath triangle = new GeneralPath();
	triangle.moveTo(0f, size1/2f );
	triangle.lineTo(size1/2f, -size1/2f );
	triangle.lineTo(-size1/2f, -size1/2f );
	triangle.closePath();
//	Rectangle2D.Float square = new Rectangle2D.Float(-size1/2f, -size1/2f, size1, size1);
	AffineTransform at = g.getTransform();
	g.setStroke( new BasicStroke( .5f/(float)map.getZoom() ) );
	RenderingHints hints = g.getRenderingHints();
	g.setRenderingHint( RenderingHints.KEY_TEXT_ANTIALIASING,
			RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
	g.setRenderingHint( RenderingHints.KEY_ANTIALIASING,
			RenderingHints.VALUE_ANTIALIAS_ON);

	Shape shape = dot;
	for(int k=0 ; k<xyd.length ; k++) {
	//	Shape shape = triangle;
	//	if( xyd[k][5]<=1991f ) shape = dot;
		if( xyd[k][5]>yr2 )continue;
		if( xyd[k][5]<yr1 )continue;
		g.translate( (double)xyd[k][0], (double)xyd[k][1] );
	//	g.setColor( Color.black );
	//	g.draw(shape);
		g.setColor( color[k] );
		g.fill(shape);
		g.setColor( Color.black );
		g.draw(shape);
		g.setTransform( at );
	}
	g.setFont( (new Font("Serif", Font.BOLD, 1)).deriveFont( size1*1.5f));
	Rectangle2D rect = map.getClipRect2D();
	double s = (double) size1;
	double x = rect.getX() + s;
	double y = rect.getY() + 2.*s;
//	g.translate( x, y );
//	g.setColor( Color.white );
//	g.fill( dot );
//	g.setColor( Color.black );
//	g.draw( dot );
//	g.translate( s, s/2.);
//	String year = db.startF.getText();
//	String dateString = db.before.isSelected()
//		? "before 1/1/"+year
//		: "after 1/1/"+year;
//	g.drawString( dateString, 0, 0);
//	g.drawString( "before 1/1/1991", 0, 0);
//	g.setTransform(at);
//	g.translate( x, y+s*2.0 );
//	g.setColor( Color.white );
//	g.fill( triangle );
//	g.setColor( Color.black );
//	g.draw( triangle );
//	g.translate( s, s/2.);
//	g.drawString( "after 1/1/1991", 0, 0);
	g.setTransform(at);
	g.setRenderingHints( hints);
}