74 lines
2.3 KiB
Java
74 lines
2.3 KiB
Java
import java.awt.print.Paper;
|
|
|
|
public class Metrique extends Paper {
|
|
public Metrique() {
|
|
super();
|
|
// WIDTH : 21*(1cm in inches)*72 HEIGHT : 29,7*(1cm en inches)*72
|
|
this.setSize(595.27584, 841.88952);
|
|
// MARGE : 1.5*(1cm in inches)*72 DECALAGE : 3cm = 85.0392 1/72inches
|
|
this.setImageableArea(42.519672, 42.519672, 510.23664, 756.85032);
|
|
}
|
|
|
|
public double getMetricHeight() {
|
|
return this.getHeight() / 72 * 25.4; // 1inch = 25.4mm
|
|
}
|
|
|
|
public double getMetricWidth() {
|
|
return this.getWidth() / 72 * 25.4; // 1inch = 25.4mm
|
|
}
|
|
|
|
public double getMetricImageableHeight() {
|
|
return this.getImageableHeight() / 72 * 25.4; // 1inch = 25.4mm
|
|
}
|
|
|
|
public double getMetricImageableWidth() {
|
|
return this.getImageableWidth() / 72 * 25.4; // 1inch = 25.4mm
|
|
}
|
|
|
|
public double getMetricImageableX() {
|
|
return this.getImageableX() / 72 * 25.4; // 1inch = 25.4mm
|
|
}
|
|
|
|
public double getMetricImageableY() {
|
|
return this.getImageableY() / 72 * 25.4; // 1inch = 25.4mm
|
|
}
|
|
|
|
public void setMetricImageableArea(double x, double y, double width, double height) {
|
|
this.setImageableArea(
|
|
x * 0.393701 * 72,
|
|
y * 0.393701 * 72,
|
|
width * 0.393701 * 72,
|
|
height * 0.393701 * 72
|
|
);
|
|
}
|
|
|
|
public void setMetricSize(double width, double height) {
|
|
this.setSize(
|
|
width * 0.393701 * 72,
|
|
height * 0.393701 * 72
|
|
);
|
|
}
|
|
|
|
public static void main(String[] args) {
|
|
Metrique papier = new Metrique();
|
|
System.out.println("TESTS DE DEPART : ");
|
|
System.out.println("" + papier.getMetricHeight());
|
|
System.out.println("" + papier.getMetricWidth());
|
|
System.out.println("" + papier.getMetricImageableHeight());
|
|
System.out.println("" + papier.getMetricImageableWidth());
|
|
System.out.println("" + papier.getMetricImageableX());
|
|
System.out.println("" + papier.getMetricImageableY());
|
|
|
|
System.out.println("MODIFICATION DES DIMENSIONS : ");
|
|
papier.setMetricSize(50,100);
|
|
System.out.println("" + papier.getMetricHeight());
|
|
System.out.println("" + papier.getMetricWidth());
|
|
|
|
System.out.println("MODIFICATION DE LA TAILLE IMAGEABLE: ");
|
|
papier.setMetricImageableArea(5,5,40,80);
|
|
System.out.println("" + papier.getMetricImageableX());
|
|
System.out.println("" + papier.getMetricImageableY());
|
|
System.out.println("" + papier.getMetricImageableHeight());
|
|
System.out.println("" + papier.getMetricImageableWidth());
|
|
}
|
|
} |