Ma77Ball commented on code in PR #4193: URL: https://github.com/apache/texera/pull/4193#discussion_r2825234483
########## common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/visualization/ternaryContour/TernaryContourOpDesc.scala: ########## @@ -0,0 +1,153 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.texera.amber.operator.visualization.ternaryContour + +import com.fasterxml.jackson.annotation.{JsonProperty, JsonPropertyDescription} +import com.kjetland.jackson.jsonSchema.annotations.JsonSchemaTitle +import org.apache.texera.amber.core.tuple.{AttributeType, Schema} +import org.apache.texera.amber.core.workflow.OutputPort.OutputMode +import org.apache.texera.amber.pybuilder.PythonTemplateBuilder.PythonTemplateBuilderStringContext +import org.apache.texera.amber.pybuilder.PyStringTypes.EncodableString +import org.apache.texera.amber.core.workflow.{InputPort, OutputPort, PortIdentity} +import org.apache.texera.amber.operator.PythonOperatorDescriptor +import org.apache.texera.amber.operator.metadata.annotations.AutofillAttributeName +import org.apache.texera.amber.operator.metadata.{OperatorGroupConstants, OperatorInfo} +import org.apache.texera.amber.pybuilder.PythonTemplateBuilder + +/** + * Visualization Operator for Ternary Plots. + * + * This operator uses three data fields to construct a ternary plot. + * The points can optionally be color coded using a data field. + */ + +class TernaryContourOpDesc extends PythonOperatorDescriptor { + + // Add annotations for the first variable + @JsonProperty(value = "firstVariable", required = true) + @JsonSchemaTitle("Variable 1") + @JsonPropertyDescription("First variable data field") + @AutofillAttributeName var firstVariable: EncodableString = "" + + // Add annotations for the second variable + @JsonProperty(value = "secondVariable", required = true) + @JsonSchemaTitle("Variable 2") + @JsonPropertyDescription("Second variable data field") + @AutofillAttributeName var secondVariable: EncodableString = "" + + // Add annotations for the third variable + @JsonProperty(value = "thirdVariable", required = true) + @JsonSchemaTitle("Variable 3") + @JsonPropertyDescription("Third variable data field") + @AutofillAttributeName var thirdVariable: EncodableString = "" + + // Add annotations for the fourth variable + @JsonProperty(value = "fourthVariable", required = true) + @JsonSchemaTitle("Measured Value") + @JsonPropertyDescription("Measured value data field") + @AutofillAttributeName var fourthVariable: EncodableString = "" + + // OperatorInfo instance describing ternary plot + override def operatorInfo: OperatorInfo = + OperatorInfo( + userFriendlyName = "Ternary Contour", + operatorDescription = + "A ternary contour plot shows how a measured value changes across all mixtures of three components that always sum to a constant (usually 100%).", + operatorGroupName = OperatorGroupConstants.VISUALIZATION_SCIENTIFIC_GROUP, + inputPorts = List(InputPort()), + outputPorts = List(OutputPort(mode = OutputMode.SINGLE_SNAPSHOT)) + ) + + override def getOutputSchemas( + inputSchemas: Map[PortIdentity, Schema] + ): Map[PortIdentity, Schema] = { + val outputSchema = Schema() + .add("html-content", AttributeType.STRING) + Map(operatorInfo.outputPorts.head.id -> outputSchema) + Map(operatorInfo.outputPorts.head.id -> outputSchema) Review Comment: @ELin2025 removed duplicate line: "Map(operatorInfo.outputPorts.head.id -> outputSchema)" -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
