我是靠谱客的博主 悲凉马里奥,最近开发中收集的这篇文章主要介绍java graphics2d renderinghints_Java Graphics2D.getRenderingHints方法代码示例,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

import java.awt.Graphics2D; //导入方法依赖的package包/类

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

//Shape shape = triangle;

//if( xyd[k][5]<=1991f ) shape = dot;

if( xyd[k][5]>yr2 )continue;

if( xyd[k][5]

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);

}

最后

以上就是悲凉马里奥为你收集整理的java graphics2d renderinghints_Java Graphics2D.getRenderingHints方法代码示例的全部内容,希望文章能够帮你解决java graphics2d renderinghints_Java Graphics2D.getRenderingHints方法代码示例所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(34)

评论列表共有 0 条评论

立即
投稿
返回
顶部