lizhizuoyongzhe 2015-06-03 10:19 采纳率: 20%
浏览 1671

怎么将java swing中画的曲线缩小啊

public class PGraph extends javax.swing.JPanel {

/** Creates new form PGraph */
public PGraph() {
    initComponents();
}
public PGraph(double[] a,double[] b){
    initComponents();
}
private double[] c;
private double[] d;
private AffineTransform at = new AffineTransform();   

/** This method is called from within the constructor to
 * initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
//GEN-BEGIN:initComponents
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(
            javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400,
            Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(
            javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300,
            Short.MAX_VALUE));
}// </editor-fold>
//GEN-END:initComponents

//GEN-BEGIN:variables
// Variables declaration - do not modify
// End of variables declaration//GEN-END:variables
public void paint(java.awt.Graphics g){
    super.paint(g);
    Graphics2D g2 = (Graphics2D) g;
    g2.setBackground(Color.white);
    g2.setColor(Color.red);

// this.setBounds(250, 250, 200, 300);
double maxx=this.getHeight();
double maxy=this.getWidth();
double xx=this.getX();
double yy=this.getY();
System.out.println(maxx+"能不能");
System.out.println(this.getX()+"能不能2");
g2.translate(0, maxx-20);
g2.setBackground(Color.white);
g2.setColor(Color.green);
g.drawLine(0, 0, 0, -(int)maxx);
g.drawLine(0, 0, (int)maxy, 0);
g2.setColor(Color.BLACK);
g.drawLine(20, 0, 20, 10);
for(int i=0;i<101;i++){

g.drawString(i+"", i*30, 20);
g.drawString(i+"", 10, -i*30);
}
g.drawLine(0, -20, 10, -20);
g.setColor(Color.red);
double[] lea=new double[100];
double[] leak=new double[100];
for(int f=0;f<100;f++){
leak[f]=f*30;
}
SPBPXiShu spb=new SPBPXiShu();
double u=0;
for(int i=0;i<100;i++){
lea[i]=u*30;
u+=3.4;
}
c=leak;
d=lea;
for(int i=1;i<c.length;i++){

g.drawLine((int)c[i-1], (int)-d[i-1], (int)c[i], (int)-d[i]);
}

g2.rotate(Math.toRadians(90));
// g2.scale(1/10, 1/10);
at=g2.getTransform();
at.scale(1/2.0, 1/2.0);
}

}

为什么这么写曲线不会缩小 求大神给个缩小曲线的代码

  • 写回答

1条回答

  • 大树底下的苹果 2015-06-26 08:03
    关注

    只能修改关键参数重绘啊

    评论

报告相同问题?

悬赏问题

  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集