0
輸入: - 一個幾何形狀在Java中使用的JScrollBar進出面板縮放
的Point2D的ArrayList和transformin它爲:
private void SetScale1(Graphics2D gr, int gr_width , int gr_height, double left_x , double right_x , double top_y , double bottom_y){
Rectangle2D drawing_rect = new Rectangle2D.Double(left_x, top_y, right_x - left_x, bottom_y - top_y);
drawing_cx=(left_x+ right_x)/2;
drawing_cy =(top_y + bottom_y)/2;
at= AffineTransform.getTranslateInstance(-1* drawing_cx, -1*drawing_cy);
//gr.translate(-1 * drawing_cx, -1 * drawing_cy);
//gr.TranslateTransform(0, 0)
double scale_x=gr_width/drawing_rect.getWidth();
double scale_y=gr_height/Math.abs(drawing_rect.getHeight());
scale_x = Math.min(scale_x, scale_y);
scale_y = scale_x;
scale_x = Math.abs(scale_x);
// at = AffineTransform.getScaleInstance(scale_x, -1 * scale_y);
gr.scale(Math.round(scale_x), Math.round(scale_y));
//gr.scale(1.2, 1.2);
//gr.transform(tt);
gr.transform(at);
//' Translate to center over the drawing area.
graphics_cx =gr_width/2;
graphics_cy = gr_height/2;
gr.translate(graphics_cx, graphics_cy);
//
}
:======和displayin上的面板
我想zoomin找到一個perticular點和一些操作選擇它..
請幫我找到一個解決方案是如何放大了此JPanel .....
爲了更快提供更好的幫助,請發佈[SSCCE](http://sscce.org/)。 – 2013-04-29 09:04:36
看看[這個](http://stackoverflow.com/questions/12719085/how-to-zoom-in-to-jpanel-without-moving-the-center-math-or-swing/12719389#12719389 ) – MadProgrammer 2013-04-29 09:50:16