📄 tojpg.java
字号:
package net.aetherial.gis.our;
import java.io.File;
import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
import net.aetherial.gis.surface.ItemValue;
import java.io.FileOutputStream;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import com.sun.image.codec.jpeg.JPEGCodec;
import java.awt.Color;
import org.w3c.dom.Node;
import com.sun.image.codec.jpeg.*;
import java.io.*;
import java.io.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ToJPG {
public ToJPG() {
super();
}
public void generateJPG(String inputDir, String fileName, String outPath) {
FrameOur fo = new FrameOur();
fo.openFile(new File(inputDir + "\\" + fileName));
generateJPG(ItemValue.getTracks(),
new File(outPath + "\\" + fileName + ".jpg"));
fo.reset();
}
public void generateJPG(File inputFile, String outPath) {
generateJPG(ItemValue.getTracks(),
new File(outPath + "\\" + inputFile.getName().toUpperCase().replaceAll(".GPS","") + ".jpg"));
}
public void generateJPG(Node[] track, File output) {
try {
output.getParentFile().mkdirs();
BufferedImage bffImg = new BufferedImage(612, 612,
BufferedImage.TYPE_INT_RGB);
Graphics2D gfx = bffImg.createGraphics();
gfx.setBackground(Color.white);
gfx.setColor(Color.white);
gfx.fillRect(0, 0, 612, 612);
ToMap tomap = new ToMap();
//Node[] tracks = ItemValue.getTracks();
//for(int i = 0; i < tracks.length; i++){
tomap.rollMemory();
//}
tomap.determinScale(500, 500);
tomap.setMove(10, 10);
tomap.drawAllTracks(gfx, track);
tomap.drawAllWaypoints(gfx,
ItemValue.getWaypointsWithTypes("|行政村|学校|自然村|起点|终点|乡镇府|乡政府|政府机关|隧道"));
//bffImg.flush();
FileOutputStream out = new FileOutputStream(output);
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
encoder.encode(bffImg); //近JPEG编码
//System.out.print(width+"*"+height);
out.close();
}
catch (ImageFormatException ex) {
}
catch (FileNotFoundException ex) {
}
catch (IOException ex) {
}
}
public static void main(String[] args) {
if (args.length < 2) {
System.out.println("参数太少,无法运算!请指明 [输入目录][文件名][输出目录]");
}
(new ToJPG()).generateJPG(args[0], args[1], args[2]);
System.exit(0);
// work.pathArray = ""; //this.fi.getTable().getPathArray();
// work.pathWanbi = ""; //this.fi.getTable().getPathWanbi();
// work.pathBubao = work.scan.getPathsBaobiaosString(); //this.scan.getPathsBaobiaosString();
// work.pathOut = ""; //this.fi.getTable().getPathOut();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -