Skip to content

ScaleJob.js

Jason von Nieda edited this page Nov 11, 2018 · 1 revision

Prompts the user for an X and Y scaling factor and then multiplies each placement in the job by the scaling factors. Can be used to correct boards that are fabricated incorrectly from the board house.

var xField = new javax.swing.JTextField("1.0");
var yField = new javax.swing.JTextField("1.0");
var fields = [
    "X Scale:", xField,
    "Y Scale:", yField
];

var option = javax.swing.JOptionPane.showConfirmDialog(
	null, 
	Java.to(fields, "java.lang.Object[]"), 
	"Scale Job", 
	javax.swing.JOptionPane.OK_CANCEL_OPTION);

if (option == javax.swing.JOptionPane.OK_OPTION) {
	var xScale = java.lang.Double.valueOf(xField.text);
	var yScale = java.lang.Double.valueOf(yField.text);

	var boards = new java.util.HashSet();
	for each (var boardLocation in gui.jobTab.job.boardLocations) {
		if (boards.contains(boardLocation.board)) {
			continue;
		}
		for each (var placement in boardLocation.board.placements) {
			placement.location =  placement.location.multiply(xScale, yScale, 1, 1);
		}
		boards.add(boardLocation.board);
	}
        gui.jobTab.jobPlacementsPanel.refresh();
}
Clone this wiki locally