From 6beb446925c967aca92f5513adf36c5db77c00d6 Mon Sep 17 00:00:00 2001 From: TATTAVARADA Date: Thu, 27 Apr 2017 07:53:18 -0400 Subject: [PORTAL-7] Rebase This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: Ia1efa4deacdc5701e6205104ac021a6c80ed60ba Signed-off-by: st782s --- .../portalsdk/analytics/view/HtmlFormatter.java | 205 +++++++++++++++++++++ 1 file changed, 205 insertions(+) create mode 100644 ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/view/HtmlFormatter.java (limited to 'ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/view/HtmlFormatter.java') diff --git a/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/view/HtmlFormatter.java b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/view/HtmlFormatter.java new file mode 100644 index 00000000..fa54a1d9 --- /dev/null +++ b/ecomp-sdk/epsdk-analytics/src/main/java/org/openecomp/portalsdk/analytics/view/HtmlFormatter.java @@ -0,0 +1,205 @@ +/*- + * ================================================================================ + * eCOMP Portal SDK + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property + * ================================================================================ + * Licensed 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.openecomp.portalsdk.analytics.view; + +import org.openecomp.portalsdk.analytics.RaptorObject; + +public class HtmlFormatter extends RaptorObject { + private boolean bold = false; + + private boolean italic = false; + + private boolean underline = false; + + private String bgColor = ""; + + private String fontColor = ""; + + private String fontFace = ""; + + private String fontSize = ""; + + private String alignment = ""; + + private String formatId = ""; + + public HtmlFormatter() { + super(); + } + + public HtmlFormatter(boolean bold, boolean italic, boolean underline, String bgColor, + String fontColor, String fontFace, String fontSize) { + this(); + + setBold(bold); + setItalic(italic); + setUnderline(underline); + setBgColor(bgColor); + setFontColor(fontColor); + setFontFace(fontFace); + setFontSize(fontSize); + } // HtmlFormatter + + public HtmlFormatter(boolean bold, boolean italic, boolean underline, String bgColor, + String fontColor, String fontFace, String fontSize, String alignment) { + this(bold, italic, underline, bgColor, fontColor, fontFace, fontSize); + setAlignment(alignment); + } // HtmlFormatter + + public boolean isBold() { + return bold; + } + + public boolean isItalic() { + return italic; + } + + public boolean isUnderline() { + return underline; + } + + public String getBgColor() { + return bgColor; + } + + public String getFontColor() { + return fontColor; + } + + public String getFontFace() { + return fontFace; + } + + public String getFontSize() { + return fontSize; + } + + public String getAlignment() { + return alignment; + } + + public void setBold(boolean bold) { + this.bold = bold; + } + + public void setItalic(boolean italic) { + this.italic = italic; + } + + public void setUnderline(boolean underline) { + this.underline = underline; + } + + public void setBgColor(String bgColor) { + this.bgColor = nvl(bgColor); + } + + public void setFontColor(String fontColor) { + this.fontColor = nvl(fontColor); + } + + public void setFontFace(String fontFace) { + this.fontFace = nvl(fontFace); + } + + public void setFontSize(String fontSize) { + this.fontSize = nvl(fontSize); + } + + public void setAlignment(String alignment) { + this.alignment = nvl(alignment); + } + + private String generateStyleHtml() { + StringBuffer sb = new StringBuffer(); + + if (isBold()) + sb.append("font-weight:bold;"); + if (isItalic()) + sb.append("font-style:italic;"); + if (isUnderline()) + sb.append("text-decoration:underline;"); + // if(getBgColor().length()>0) + // sb.append("background-color:"+getBgColor()+";"); + if (getFontColor().length() > 0) + sb.append("color:" + getFontColor() + ";"); + if (getFontFace().length() > 0) + sb.append("font-family:" + getFontFace() + ";"); + if (getFontSize().length() > 0) + sb.append("font-size:" + getFontSize() + "px;"); + if (getAlignment().length() > 0) + sb.append("text-align:" + getAlignment() + ";"); + + if (sb.length() > 0) { + sb.insert(0, " style=\""); + sb.append("\""); + } // if + + return sb.toString(); + } // generateStyleHtml + + public String generateStyleForZK() { + StringBuffer sb = new StringBuffer(); + + if (isBold()) + sb.append("font-weight:bold;"); + if (isItalic()) + sb.append("font-style:italic;"); + if (isUnderline()) + sb.append("text-decoration:underline;"); + // if(getBgColor().length()>0) + // sb.append("background-color:"+getBgColor()+";"); + if (getFontColor().length() > 0) + sb.append("color:" + getFontColor() + ";"); + if (getFontFace().length() > 0) + sb.append("font-family:" + getFontFace() + ";"); + if (getFontSize().length() > 0) + sb.append("font-size:" + getFontSize() + "px;"); + if (getAlignment().length() > 0) + sb.append("text-align:" + getAlignment() + ";"); + + return sb.toString(); + } // generateStyleHtml + + public String formatValue(String value) { + String style = generateStyleHtml(); + if (style.length() > 0) + return "" + value + ""; + else + return value; + } // formatValue + + public String formatLink(String value, String url, boolean drillDowninPoPUp) { + if(!drillDowninPoPUp) { + return "" + value + ""; + } else { + return "" + value + ""; + } + } // formatLink + + public String getFormatId() { + return formatId; + } + + public void setFormatId(String formatId) { + this.formatId = formatId; + } + +} // HtmlFormatter -- cgit 1.2.3-korg