@wcardinal/wcardinal-geditor
Version:
WebGL-based graphic editor, tester and viewer for supervisory systems
327 lines • 13.5 kB
JavaScript
import { createLine, DControllers, DThemes, EShapeBar, EShapeBarPosition, EShapeDefaults, EShapePointsStyle, EShapeRectangle, EShapeTextAlignHorizontal, EShapeTextAlignVertical, EShapeTextDirection } from "@wcardinal/wcardinal-ui";
import { ECommandChartAxisXPadding } from "./e-command-chart-axis-x-padding";
import { ECommandChartAxisYPadding } from "./e-command-chart-axis-y-padding";
import { ECommandChartTickXMajorCount } from "./e-command-chart-tick-x-major-count";
import { ECommandChartTickXMinorCount } from "./e-command-chart-tick-x-minor-count";
import { ECommandChartTickYMajorCount } from "./e-command-chart-tick-y-major-count";
import { ECommandChartTickYMinorCount } from "./e-command-chart-tick-y-minor-count";
import { EShapeChartLineIds } from "./e-shape-chart-line-ids";
import { UtilShapeSearch } from "../../util/util-shape-search";
var EShapeChartAxes = /** @class */ (function () {
function EShapeChartAxes() {
}
EShapeChartAxes.getTheme = function () {
return DThemes.get("EShapeChartLine");
};
EShapeChartAxes.getPlotArea = function (shape) {
return UtilShapeSearch.findChildById(shape, EShapeChartLineIds.PLOT_AREA_ID);
};
EShapeChartAxes.newPlotArea = function (shape) {
var result = new EShapeRectangle();
result.id = EShapeChartLineIds.PLOT_AREA_ID;
result.size.set(shape.size.x, shape.size.y);
result.stroke.enable = false;
result.fill.alpha = EShapeDefaults.FILL_ALPHA * 0.5;
result.text.value = this.getTheme().newPlotAreaLabel();
result.text.align.vertical = EShapeTextAlignVertical.OUTSIDE_TOP;
result.attach(shape);
return result;
};
EShapeChartAxes.getLine = function (shape) {
return UtilShapeSearch.findChildById(shape, EShapeChartLineIds.LINE_ID);
};
EShapeChartAxes.newLine = function (shape) {
var sx = 0.8 * shape.size.x;
var sy = 0.8 * shape.size.y;
var sxh = sx * 0.5;
var syh = sy * 0.5;
var result = createLine([-sxh, +syh, +sxh, -syh], [], EShapeDefaults.STROKE_WIDTH, EShapePointsStyle.NONE);
result.id = EShapeChartLineIds.LINE_ID;
result.attach(shape);
return result;
};
EShapeChartAxes.getXAxis = function (shape) {
return UtilShapeSearch.findChildById(shape, EShapeChartLineIds.X_AXIS_ID);
};
EShapeChartAxes.getXAxisTickMajor = function (shape) {
return UtilShapeSearch.findChildById(shape, EShapeChartLineIds.X_AXIS_TICK_MAJOR_ID);
};
EShapeChartAxes.getXAxisTickMinor = function (shape) {
return UtilShapeSearch.findChildById(shape, EShapeChartLineIds.X_AXIS_TICK_MINOR_ID);
};
EShapeChartAxes.newXAxis = function (shape) {
var result = new EShapeBar();
result.id = EShapeChartLineIds.X_AXIS_ID;
result.size.set(shape.size.x, 0);
result.transform.position.set(0, shape.size.y * 0.5);
result.points.position = EShapeBarPosition.LEFT;
result.points.size = -1;
result.stroke.width = EShapeDefaults.STROKE_WIDTH;
result.text.value = this.getTheme().newXAxisLabel();
result.text.align.vertical = EShapeTextAlignVertical.OUTSIDE_BOTTOM;
result.text.padding.set(50, 50);
result.attach(shape);
return result;
};
EShapeChartAxes.createXAxis = function (selection) {
selection.createChildren(function (shape) {
return [EShapeChartAxes.newXAxis(shape)];
});
};
EShapeChartAxes.deleteXAxis = function (selection) {
selection.deleteChildren(function (shape) {
var result = null;
var axis = EShapeChartAxes.getXAxis(shape);
if (axis != null) {
result = [axis];
}
var major = EShapeChartAxes.getXAxisTickMajor(shape);
if (major != null) {
if (result == null) {
result = [major];
}
else {
result.push(major);
}
}
var minor = EShapeChartAxes.getXAxisTickMinor(shape);
if (minor != null) {
if (result == null) {
result = [minor];
}
else {
result.push(minor);
}
}
return result;
});
};
EShapeChartAxes.setXAxisPadding = function (padding, selection) {
DControllers.getCommandController().push(new ECommandChartAxisXPadding(selection, padding));
};
EShapeChartAxes.newXAxisTickMajor = function (shape) {
var result = new EShapeBar();
result.id = EShapeChartLineIds.X_AXIS_TICK_MAJOR_ID;
result.size.set(0, 0);
result.transform.position.set(0, shape.size.y * 0.5);
result.points.position = EShapeBarPosition.TOP;
result.points.size = 10;
result.stroke.width = EShapeDefaults.STROKE_WIDTH;
result.text.value = "%YMD\n%Hms.%mi";
result.text.align.vertical = EShapeTextAlignVertical.TOP;
result.text.padding.set(12.5, 12.5);
result.attach(shape);
return result;
};
EShapeChartAxes.newXAxisTickMinor = function (shape, x, y) {
var result = new EShapeBar();
result.id = EShapeChartLineIds.X_AXIS_TICK_MINOR_ID;
result.size.set(0, 0);
result.transform.position.set(x, y);
result.points.position = EShapeBarPosition.TOP;
result.points.size = 5;
result.stroke.width = EShapeDefaults.STROKE_WIDTH * 0.5;
result.attach(shape);
return result;
};
EShapeChartAxes.createXAxisTickMajor = function (selection) {
var _this = this;
selection.createChildren(function (shape) {
var axis = EShapeChartAxes.getXAxis(shape);
if (axis != null) {
return [_this.newXAxisTickMajor(shape)];
}
return null;
});
};
EShapeChartAxes.deleteXAxisTickMajor = function (selection) {
selection.deleteChildren(function (shape) {
var result = null;
var major = EShapeChartAxes.getXAxisTickMajor(shape);
if (major != null) {
result = [major];
}
var minor = EShapeChartAxes.getXAxisTickMinor(shape);
if (minor != null) {
if (result == null) {
result = [minor];
}
else {
result.push(minor);
}
}
return result;
});
};
EShapeChartAxes.setXAxisTickMajorCount = function (count, selection) {
DControllers.getCommandController().push(new ECommandChartTickXMajorCount(selection, count));
};
EShapeChartAxes.createXAxisTickMinor = function (selection) {
var _this = this;
selection.createChildren(function (shape) {
var axis = EShapeChartAxes.getXAxis(shape);
if (axis != null) {
var sizeX = axis.size.x;
var position = axis.transform.position;
return [_this.newXAxisTickMinor(shape, position.x - sizeX * 0.25, position.y)];
}
return null;
});
};
EShapeChartAxes.deleteXAxisTickMinor = function (selection) {
selection.deleteChildren(function (shape) {
var minor = EShapeChartAxes.getXAxisTickMinor(shape);
if (minor != null) {
return [minor];
}
return null;
});
};
EShapeChartAxes.setXAxisTickMinorCount = function (count, selection) {
DControllers.getCommandController().push(new ECommandChartTickXMinorCount(selection, count));
};
EShapeChartAxes.getYAxis = function (shape) {
return UtilShapeSearch.findChildById(shape, EShapeChartLineIds.Y_AXIS_ID);
};
EShapeChartAxes.getYAxisTickMajor = function (shape) {
return UtilShapeSearch.findChildById(shape, EShapeChartLineIds.Y_AXIS_TICK_MAJOR_ID);
};
EShapeChartAxes.getYAxisTickMinor = function (shape) {
return UtilShapeSearch.findChildById(shape, EShapeChartLineIds.Y_AXIS_TICK_MINOR_ID);
};
EShapeChartAxes.newYAxis = function (shape) {
var result = new EShapeBar();
result.id = EShapeChartLineIds.Y_AXIS_ID;
result.size.set(0, shape.size.y);
result.transform.position.set(-shape.size.x * 0.5, 0);
result.points.position = EShapeBarPosition.TOP;
result.points.size = -1;
result.stroke.width = EShapeDefaults.STROKE_WIDTH;
result.text.value = this.getTheme().newYAxisLabel();
result.text.align.horizontal = EShapeTextAlignHorizontal.OUTSIDE_LEFT;
result.text.direction = EShapeTextDirection.BOTTOM_TO_TOP;
result.text.padding.set(50, 50);
result.attach(shape);
return result;
};
EShapeChartAxes.createYAxis = function (selection) {
selection.createChildren(function (shape) {
return [EShapeChartAxes.newYAxis(shape)];
});
};
EShapeChartAxes.deleteYAxis = function (selection) {
selection.deleteChildren(function (shape) {
var result = null;
var axis = EShapeChartAxes.getYAxis(shape);
if (axis != null) {
result = [axis];
}
var major = EShapeChartAxes.getYAxisTickMajor(shape);
if (major != null) {
if (result == null) {
result = [major];
}
else {
result.push(major);
}
}
var minor = EShapeChartAxes.getYAxisTickMinor(shape);
if (minor != null) {
if (result == null) {
result = [minor];
}
else {
result.push(minor);
}
}
return result;
});
};
EShapeChartAxes.setYAxisPadding = function (padding, selection) {
DControllers.getCommandController().push(new ECommandChartAxisYPadding(selection, padding));
};
EShapeChartAxes.newYAxisTickMajor = function (shape) {
var result = new EShapeBar();
result.id = EShapeChartLineIds.Y_AXIS_TICK_MAJOR_ID;
result.size.set(0, 0);
result.transform.position.set(-shape.size.x * 0.5, 0);
result.points.position = EShapeBarPosition.RIGHT;
result.points.size = 10;
result.stroke.width = EShapeDefaults.STROKE_WIDTH;
result.text.value = "%ssi";
result.text.align.horizontal = EShapeTextAlignHorizontal.RIGHT;
result.text.padding.set(12.5, 12.5);
result.attach(shape);
return result;
};
EShapeChartAxes.newYAxisTickMinor = function (shape, x, y) {
var result = new EShapeBar();
result.id = EShapeChartLineIds.Y_AXIS_TICK_MINOR_ID;
result.size.set(0, 0);
result.transform.position.set(x, y);
result.points.position = EShapeBarPosition.RIGHT;
result.points.size = 5;
result.stroke.width = EShapeDefaults.STROKE_WIDTH * 0.5;
result.attach(shape);
return result;
};
EShapeChartAxes.createYAxisTickMajor = function (selection) {
var _this = this;
selection.createChildren(function (shape) {
var axis = EShapeChartAxes.getYAxis(shape);
if (axis != null) {
return [_this.newYAxisTickMajor(shape)];
}
return null;
});
};
EShapeChartAxes.deleteYAxisTickMajor = function (selection) {
selection.deleteChildren(function (shape) {
var result = null;
var major = EShapeChartAxes.getYAxisTickMajor(shape);
if (major != null) {
result = [major];
}
var minor = EShapeChartAxes.getYAxisTickMinor(shape);
if (minor != null) {
if (result == null) {
result = [minor];
}
else {
result.push(minor);
}
}
return result;
});
};
EShapeChartAxes.setYAxisTickMajorCount = function (count, selection) {
DControllers.getCommandController().push(new ECommandChartTickYMajorCount(selection, count));
};
EShapeChartAxes.createYAxisTickMinor = function (selection) {
var _this = this;
selection.createChildren(function (shape) {
var axis = EShapeChartAxes.getYAxis(shape);
if (axis != null) {
var sizeY = axis.size.y;
var position = axis.transform.position;
return [_this.newYAxisTickMinor(shape, position.x, position.y + sizeY * 0.25)];
}
return null;
});
};
EShapeChartAxes.deleteYAxisTickMinor = function (selection) {
selection.deleteChildren(function (shape) {
var minor = EShapeChartAxes.getYAxisTickMinor(shape);
if (minor != null) {
return [minor];
}
return null;
});
};
EShapeChartAxes.setYAxisTickMinorCount = function (count, selection) {
DControllers.getCommandController().push(new ECommandChartTickYMinorCount(selection, count));
};
return EShapeChartAxes;
}());
export { EShapeChartAxes };
//# sourceMappingURL=e-shape-chart-axes.js.map