행운을 빌어 내 문제에 대한 해결책을 찾기 위해 꽤 많이 검색했습니다. 나는 거기에 간단한 해결책이 있다고 생각했을 것이다. 나는 ArrayList에 저장된 여러 점을 찾고 ArrayList에 주어진 각 점에서 셰이프를 드레이프 (이 단계에서 어떤 점이 상관 없으며 사각형이 수행합니다.)하고 싶습니다. 다음 코드를 사용합니다. 코드는 다음과 같습니다 :JPanel의 알려진 좌표에서 모양을 그립니다.
public static void main(String[] args){
image = null;
try {
// Read from a file
File file = new File("box.jpg");
image = ImageIO.read(file);
} catch (IOException e) {
System.out.print("LAAAAMMME!!!!");
}
ImagePanel panel = new ImagePanel(image); //Custom JPanel to show a background image
panel.setPreferredSize(new Dimension(500, 500));
JFrame frame = new JFrame("Find the Squares");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
frame.setResizable(false);
frame.setLocationRelativeTo(null);
frame.getContentPane().add(panel);
frame.validate();
frame.setVisible(true);
frame.pack();
ArrayList<Point> points = getCenterPoint(floatarray);
for(int x = 0 ; x < points.size(); x++){
//Here I guess is where each point is created and drawn.
}
}
어떤 제안이 있습니까?
* "어떤 제안이 있습니까?"* 더 빨리 도움을 받으려면 해당 코드를 [SSCCE] (http://sscce.org/)로 업그레이드하십시오. –
* // 여기서 각 지점이 작성되고 그려지는 곳입니다. * 여기에서 [2D Graphics Trail] (http://download.oracle.com/javase/tutorial/2d/index)을 수행해야하는 곳이 여기 있습니다. html). –