94 lines
2.1 KiB
Vala
94 lines
2.1 KiB
Vala
namespace LAview {
|
|
|
|
/**
|
|
* Graphics in the LaTeX document.
|
|
*
|
|
* Specified by '\includegraphics' tag in the LaTeX code.
|
|
*/
|
|
public class Graphics : ADoc {
|
|
|
|
/**
|
|
* All unknown parameters.
|
|
*/
|
|
public string rest_params { get; set; default = ""; }
|
|
|
|
/**
|
|
* Path to the image on the disk.
|
|
*/
|
|
public string path { get; set; default = ""; }
|
|
|
|
/**
|
|
* Width of the image.
|
|
*
|
|
* For ex: 3.22, 128
|
|
*/
|
|
public double width { get; set; }
|
|
|
|
/**
|
|
* Width units of the image.
|
|
*
|
|
* For ex: bp, cc, cm, dd, em, ex, in, mm, pc, pt, sp <<BR>>
|
|
* or \textwidth, \columnwidth, \pagewidth,
|
|
* \linewidth, \textwidth, \paperwidth
|
|
*/
|
|
public string width_unit { get; set; default = ""; }
|
|
|
|
/**
|
|
* Height of the image.
|
|
*
|
|
* For ex: 3.22, 128
|
|
*/
|
|
public double height { get; set; }
|
|
|
|
/**
|
|
* Height units of the image.
|
|
*
|
|
* For ex: bp, cc, cm, dd, em, ex, in, mm, pc, pt, sp <<BR>>
|
|
* or \textwidth, \columnwidth, \pagewidth,
|
|
* \linewidth, \textwidth, \paperwidth
|
|
*/
|
|
public string height_unit { get; set; default = ""; }
|
|
|
|
/**
|
|
* Constructs a new ``Graphics`` by it's properties.
|
|
*
|
|
* @param path path to the image on the disk.
|
|
*/
|
|
public Graphics.with_params (string path = "") {
|
|
this.path = path;
|
|
}
|
|
|
|
private Graphics () {}
|
|
|
|
/**
|
|
* Gets a copy of the ``Graphics``.
|
|
*/
|
|
public override IDoc copy () {
|
|
var clone = new Graphics.with_params (path);
|
|
clone.width = width;
|
|
clone.height = height;
|
|
clone.width_unit = width_unit;
|
|
clone.height_unit = height_unit;
|
|
clone.rest_params = rest_params;
|
|
return clone;
|
|
}
|
|
|
|
/**
|
|
* Generates LaTeX string for the ``Graphics``.
|
|
*/
|
|
public override string generate () {
|
|
var str = new StringBuilder ("\\includegraphics[");
|
|
if (width != 0)
|
|
str.append_printf ("width=%f%s,", width, width_unit);
|
|
if (height != 0)
|
|
str.append_printf ("height=%f%s,", height, height_unit);
|
|
if (rest_params != "")
|
|
str.append_printf ("%s,", rest_params);
|
|
if (str.str[str.len - 1] == ',')
|
|
str.len -= 1;
|
|
str.append_printf ("]{%s}", path);
|
|
return str.str;
|
|
}
|
|
}
|
|
}
|