⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 savefileasimg.java

📁 用JAVA编写的绘图程序 功能简介: 支持存储
💻 JAVA
字号:
package drawsmart.itsv.image;

import java.io.File;
import drawsmart.itsv.framework.JDSDesktopface;
import drawsmart.itsv.FrameSwing;
import drawsmart.itsv.framework.JDSComponentface;
import drawsmart.itsv.framework.JDSLineface;
import java.awt.Font;
import drawsmart.itsv.tool.GetResource;
import drawsmart.itsv.swing.*;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2003</p>
 * <p>Company: </p>
 * @author not attributable
 * @version 1.0
 */

public class SaveFileAsImg {
  public SaveFileAsImg() {
  }

  public boolean saveFile(JDSDesktopface jDSDesktopface, File file) {
    return saveFile(jDSDesktopface, file, "jpg", null);
  }
  public boolean saveFile(JDSDesktopface jDSDesktopface, File file,String ext,FrameSwing mainFrame) {
    boolean bl = true;

    //开始绘制图形
    try
    {
      int w = Integer.parseInt(GetResource.getXMLResource("imagew"));
      int h = Integer.parseInt(GetResource.getXMLResource("imageh"));
      ExportToImg exportToImg1 = new ExportToImg(w, h, file, ext, mainFrame);
      //绘制线条

      JDSLineface[] jDSLinefaces = jDSDesktopface.getJDSAllLineface();
      for (int i = 0; i < jDSLinefaces.length; i++) {
        exportToImg1.drawLine( (int) (jDSLinefaces[i].getStartPoint().getX()),
                              (int) (jDSLinefaces[i].getStartPoint().getY()),
                              (int) (jDSLinefaces[i].getEndPoint().getX()),
                              (int) (jDSLinefaces[i].getEndPoint().getY()),3);
      }
      //绘制方形
      JDSComponentface[] jDSComponentfaces = jDSDesktopface.getJDSAllComponent();
      for (int i = 0; i < jDSComponentfaces.length; i++) {
        if (!jDSComponentfaces[i].getTextInfo().equals(""))
        {
          exportToImg1.draw(jDSComponentfaces[i].getShape(),
                                jDSComponentfaces[i].getFrameColor(),
                                jDSComponentfaces[i].getFillColor(),
                                jDSComponentfaces[i].getTextInfo(),
                                new Font("Dialog", 14, 14),4);
        }
        else
        {
          exportToImg1.draw(jDSComponentfaces[i].getShape(),
                              jDSComponentfaces[i].getFrameColor(),
                              jDSComponentfaces[i].getFillColor(),4);

        }

      }
      exportToImg1.close();

    }
    catch(Exception e)
    {
      bl=false;
      e.printStackTrace();
    }

    return bl;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -