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

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值