嗨,我正在繪製一個圖像的形狀。該形狀基本上包含幾條連接線。我現在需要旋轉繪製的形狀,但不是背景圖像。我到目前爲止的代碼是:在圖像上畫一個形狀,並在java中旋轉它
public void drawTrack(){
try {
File input = new File(mapPath);
md.image = ImageIO.read(input);
} catch (IOException ie) {
System.out.println("Error:"+ie.getMessage());
}
Graphics2D g2d = md.image.createGraphics();
g2d.setColor(Color.RED);
BasicStroke bs = new BasicStroke(2);
g2d.setStroke(bs);
int currentX = Integer.parseInt(ts.xcord.getText());
int currentY = Integer.parseInt(ts.ycord.getText());
int scale = Integer.parseInt(ts.size.getText());
td.computeTracksMotion(currentX, currentY, scale);
for(TracksMotion currentTm: td.tm){
// drawing the lines g2d.drawLine(currentTm.oldX,currentTm.oldY,currentTm.newX,currentTm.newY);
}
md.repaint();
}
你能讓我知道我該怎麼做。
重新格式化的代碼;如果不正確請回復。 – trashgod 2011-02-02 01:29:03