use of org.eclipse.rap.json.JsonArray in project hop by apache.
the class CanvasFacadeImpl method setDataPipeline.
private void setDataPipeline(Canvas canvas, float magnification, AbstractMeta meta) {
final int iconSize = HopGui.getInstance().getProps().getIconSize();
PipelineMeta pipelineMeta = (PipelineMeta) meta;
JsonObject jsonNodes = new JsonObject();
pipelineMeta.getTransforms().forEach(transformMeta -> {
JsonObject jsonNode = new JsonObject();
jsonNode.add("x", transformMeta.getLocation().x);
jsonNode.add("y", transformMeta.getLocation().y);
jsonNode.add("selected", transformMeta.isSelected());
// Translated from org.apache.hop.ui.hopgui.shared.SwtGc.drawTransformIcon(int, int,
// TransformMeta, float)
SwtUniversalImage swtImage = null;
if (transformMeta.isMissing()) {
swtImage = GuiResource.getInstance().getSwtImageMissing();
} else if (transformMeta.isDeprecated()) {
swtImage = GuiResource.getInstance().getSwtImageDeprecated();
} else {
String pluginId = transformMeta.getPluginId();
if (pluginId != null) {
swtImage = GuiResource.getInstance().getImagesTransforms().get(pluginId);
}
}
if (swtImage == null) {
return;
}
int w = Math.round(iconSize * magnification);
int h = Math.round(iconSize * magnification);
Image image = swtImage.getAsBitmapForSize(Display.getCurrent(), w, h);
// Translated
jsonNode.add("img", image.internalImage.getResourceName());
jsonNodes.add(transformMeta.getName(), jsonNode);
});
canvas.setData("nodes", jsonNodes);
JsonArray jsonHops = new JsonArray();
for (int i = 0; i < pipelineMeta.nrPipelineHops(); i++) {
JsonObject jsonHop = new JsonObject();
PipelineHopMeta hop = pipelineMeta.getPipelineHop(i);
if (hop.getFromTransform() != null && hop.getToTransform() != null) {
jsonHop.add("from", hop.getFromTransform().getName());
jsonHop.add("to", hop.getToTransform().getName());
jsonHops.add(jsonHop);
}
}
canvas.setData("hops", jsonHops);
}
use of org.eclipse.rap.json.JsonArray in project org.eclipse.rap by eclipse-rap.
the class MeasurementUtil method createItemParamObject.
static JsonArray createItemParamObject(MeasurementItem item) {
FontData fontData = item.getFontData();
JsonArray result = new JsonArray().add(getId(item)).add(item.getTextToMeasure()).add(createJsonArray(ProtocolUtil.parseFontName(fontData.getName()))).add(fontData.getHeight()).add((fontData.getStyle() & SWT.BOLD) != 0).add((fontData.getStyle() & SWT.ITALIC) != 0).add(item.getWrapWidth()).add(isMarkup(item.getMode()));
return result;
}
use of org.eclipse.rap.json.JsonArray in project org.eclipse.rap by eclipse-rap.
the class MeasurementUtil method appendStartupTextSizeProbe.
public static void appendStartupTextSizeProbe(ProtocolMessageWriter writer) {
JsonArray startupProbes = getStartupProbes();
if (!startupProbes.isEmpty()) {
JsonObject parameters = new JsonObject().add(PARAM_ITEMS, startupProbes);
writer.appendCall(TYPE, METHOD_MEASURE_ITEMS, parameters);
}
}
use of org.eclipse.rap.json.JsonArray in project org.eclipse.rap by eclipse-rap.
the class MeasurementUtil method createProbeParamObject.
static JsonArray createProbeParamObject(Probe probe) {
FontData fontData = probe.getFontData();
JsonArray result = new JsonArray().add(getId(probe)).add(probe.getText()).add(createJsonArray(ProtocolUtil.parseFontName(fontData.getName()))).add(fontData.getHeight()).add((fontData.getStyle() & SWT.BOLD) != 0).add((fontData.getStyle() & SWT.ITALIC) != 0).add(-1).add(true);
return result;
}
use of org.eclipse.rap.json.JsonArray in project org.eclipse.rap by eclipse-rap.
the class TreeLCA method renderItemMetrics.
private static void renderItemMetrics(Tree tree) {
ItemMetrics[] itemMetrics = getItemMetrics(tree);
if (hasChanged(tree, PROP_ITEM_METRICS, itemMetrics)) {
JsonArray metrics = new JsonArray();
for (int i = 0; i < itemMetrics.length; i++) {
metrics.add(new JsonArray().add(i).add(itemMetrics[i].left).add(itemMetrics[i].width).add(itemMetrics[i].imageLeft).add(itemMetrics[i].imageWidth).add(itemMetrics[i].textLeft).add(itemMetrics[i].textWidth));
}
getRemoteObject(tree).set(PROP_ITEM_METRICS, metrics);
}
}
Aggregations