Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / setup / BuildSplashVersion.groovy @ 479

History | View | Annotate | Download (1.8 kB)

1
package org.txm.setup;
2

    
3
import java.awt.*;
4
import java.awt.image.*;
5
import java.io.File;
6
import java.text.DateFormat;
7
import java.text.SimpleDateFormat;
8
import javax.imageio.ImageIO;
9
import org.txm.importer.XPathResult;
10

    
11
// Update splash screen using the RCP project version set in the product file
12
// The BMP image must be 32bit encoded
13

    
14
int img_width = 316;
15

    
16
File rcpDir = new File(System.getProperty("user.home"), "workspace442/org.txm.rcp")
17
File product = new File(rcpDir, "rcpapplication.product");
18
File imgFile = new File(rcpDir, "splash_sansversion.bmp");
19
File imgFile2 = new File(rcpDir,"splash.bmp");
20

    
21
String modifier = ""
22

    
23
//String version =  org.txm.rcpapplication.Activator.getDefault().getBundle().getVersion().toString(); // "0.7.7.201412160925";
24
String version = XPathResult.getXpathResponse(product, "//product/@version")
25
//def date = " ("+new SimpleDateFormat("yyyy-MM-dd").format(new Date())+")"
26
def date = ""
27
version = "TXM "+version.replaceAll(".qualifier", date);
28

    
29
if (modifier.length() > 0 ) version = version + " - "+modifier
30

    
31
println "VERSION: '$version'"
32

    
33
BufferedImage img = null;
34
img = ImageIO.read(imgFile);
35
Graphics g = img.getGraphics();
36
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
37

    
38
File imgMascot = new File(System.getProperty("user.home"),"Images/splashs/"+version+".png");
39
println imgMascot
40
if (imgMascot.exists()) {
41
        println "write mascot"
42
        g.drawImage(ImageIO.read(imgMascot), 0, 0, img_width, 360, null, null);
43
}
44

    
45
Font font = new Font("Arial", Font.BOLD, 20);
46
g.setColor(new Color(109,139,0)); //
47
g.setFont(font);
48
FontMetrics fontMetrics = g.getFontMetrics();
49
int width = fontMetrics.stringWidth(version);
50
g.drawString(version, img_width - width - 20, 300);
51

    
52
ImageIO.write(img, "BMP", imgFile2);
53

    
54
println "Done: "+imgFile2.getAbsoluteFile()