001/* 002 * Copyright 2023 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.workflow.readers; 017 018import org.apache.commons.lang3.StringUtils; 019 020/** 021 * Abstract class for reading plantUML mindmaps 022 */ 023public abstract class AbstractPlantUMLMindmapSVGReader extends AbstractPlantUMLSVGReader 024{ 025 @Override 026 protected String _getPlantUMLType() 027 { 028 return "mindmap"; 029 } 030 031 /** 032 * Create a node in a plantUML mindmap 033 * @param positionPrefix can be '+', '++' or '--' depending on the relative position of this node toward the central node 034 * @param label the label of the node 035 * @param iconPath the encoded icon path of the step/action 036 * @param color the background color for the node 037 * @param jsFunction the function to insert in a link 038 * @param linkTooltip the link tooltip 039 * @param isBoxless true if the node doesn't have a border 040 * @return the node graph as string 041 */ 042 protected String _getMindMapNodeContent(String positionPrefix, String label, String iconPath, String color, String jsFunction, String linkTooltip, boolean isBoxless) 043 { 044 StringBuilder nodeContent = new StringBuilder(positionPrefix); 045 046 if (isBoxless) 047 { 048 nodeContent.append("_"); 049 } 050 051 if (StringUtils.isNotBlank(color)) 052 { 053 nodeContent.append("[" + color + "]"); 054 } 055 056 if (StringUtils.isNotBlank(jsFunction)) 057 { 058 nodeContent.append(" [[javascript:parent." + jsFunction + " "); 059 if (StringUtils.isNotBlank(linkTooltip)) 060 { 061 nodeContent.append("{" + linkTooltip + "}"); 062 } 063 } 064 065 if (StringUtils.isNotBlank(iconPath)) 066 { 067 nodeContent.append(" <img:" + iconPath + ">"); 068 } 069 070 nodeContent.append(" " + label); 071 072 if (StringUtils.isNotBlank(jsFunction)) 073 { 074 nodeContent.append("]] "); 075 } 076 077 nodeContent.append(" \n"); 078 return nodeContent.toString(); 079 } 080}