View unanswered posts | View active topics It is currently 2022-07-06 8:16



This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
 请教一个swing绘制性能问题 
Author Message
新手上路

Joined: 2012-07-25 11:46
Posts: 9
Post 请教一个swing绘制性能问题
在一个panel上要绘制大约10万个点,而且这些点的位置是实时变化的,现在画出来的效果很卡,请求大家帮忙。。。


2015-12-17 19:42
Profile
TWaver开发组
User avatar

Joined: 2009-04-20 18:37
Posts: 3115
Post Re: 请教一个swing绘制性能问题
数据量太大了,界面也没法看清,建议分层。


2015-12-18 12:35
Profile
新手上路

Joined: 2012-07-25 11:46
Posts: 9
Post Re: 请教一个swing绘制性能问题
感谢你的回答,其实我这样的,我用swing开发的地图,现在在地图上要显示全世界的飞机,也就加了一个飞机图层,这些飞机每隔一秒就变位置,该图层的绘制方法如下:
/**
* 绘制飞机
*/
private void doFlightPaint(Graphics2D g2, MapViewer mapViewer) {

Rectangle viewportBounds = mapViewer.getViewportBounds();

for (FlightWayPoint flightWayPoint : getFlightWayPoints()) {//飞机列表,实时更新坐标点,大概有5000+架飞机,getFlightWayPoints().size<=5000

Point2D point = flightWayPoint.getPoint();

if (!viewportBounds.contains(point)) return;

//绘制拖尾点,每个飞机有300+个拖尾点
for (Point2D tailPoint : flightWayPoint.getTailPoints()) {
...
//绘制点
g2.fillOval(tailPoint.getX(), tailPoint.getY(), 2, 2);
...
}

...
//绘制飞机
g2.drawImage(flightImage, tailPoint.getX(), tailPoint.getY(), null);
...
//绘制飞机信息
g2.drawString(flihtInfo, tailPoint.getX() + 30, 0);
...
}
}

这样性能很差,地图放大的话性能就好,如果地图缩小到显示全部飞机时,就有5000*300个点要绘制,界面非常卡,也偿试缩小时减少拖尾点的绘制,但效果还是不太好,有什么好的办法吗?


2016-03-01 16:39
Profile
TWaver开发组
User avatar

Joined: 2009-04-20 18:37
Posts: 3115
Post Re: 请教一个swing绘制性能问题
您的问题和
viewtopic.php?f=4&t=5478
重复了。


2016-03-03 10:38
Profile
Display posts from previous:  Sort by  
This topic is locked, you cannot edit posts or make further replies.   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 40 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron