All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.xml.msofficexml.xlsx.spreadsheetml.SsmlCfRule Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.xml.msofficexml.xlsx.spreadsheetml;




//------------------------------------------------------------------------------

import com.hfg.xml.XMLTag;
import com.hfg.xml.msofficexml.xlsx.spreadsheetml.style.SsmlDifferentialFormat;

/**
 Represents an Office Open XML conditional formatting rule (<ssml:cfRule>) tag.

 @author J. Alex Taylor, hairyfatguy.com
 */
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------

public class SsmlCfRule extends SsmlXMLTag
{
   private SsmlWorksheet mParentWorksheet;

   private static int sPrioritySrc = 1;

   //###########################################################################
   // CONSTRUCTORS
   //###########################################################################

   //---------------------------------------------------------------------------
   public SsmlCfRule(SsmlWorksheet inParentWorksheet, SsmlCfRuleType inType)
   {
      super(SsmlXML.CONDITIONAL_FORMATTING_RULE, inParentWorksheet.getParentDoc());
      mParentWorksheet = inParentWorksheet;
      setAttribute(SsmlXML.TYPE_ATT, inType.name());
      setPriority(sPrioritySrc++);
   }

   //###########################################################################
   // PUBLIC METHODS
   //###########################################################################

   //---------------------------------------------------------------------------
   public SsmlCfRule setPriority(int inValue)
   {
      setAttribute(SsmlXML.PRIORITY_ATT, inValue);

      if (inValue > sPrioritySrc)
      {
         sPrioritySrc = inValue + 1;
      }

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setFormat(SsmlDifferentialFormat inValue)
   {
      setAttribute(SsmlXML.DIFFERENTIAL_FORMAT_ID_ATT, inValue.getIndex());
      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setStopIfTrue(boolean inValue)
   {
      setAttribute(SsmlXML.STOP_IF_TRUE_ATT, inValue);

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setAboveAverage(boolean inValue)
   {
      setAttribute(SsmlXML.ABOVE_AVG_ATT, inValue);

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setTop10Percent(boolean inValue)
   {
      setAttribute(SsmlXML.PERCENT_ATT, inValue);

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setBottom(boolean inValue)
   {
      setAttribute(SsmlXML.BOTTOM_ATT, inValue);

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setEqualAverage(boolean inValue)
   {
      setAttribute(SsmlXML.EQUAL_AVG_ATT, inValue);

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setOperator(SsmlCfOperator inValue)
   {
      if (inValue !=  null)
      {
         setAttribute(SsmlXML.OPERATOR_ATT, inValue.name());
      }
      else
      {
         removeAttribute(SsmlXML.OPERATOR_ATT);
      }

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setText(String inValue)
   {
      if (inValue !=  null)
      {
         setAttribute(SsmlXML.TEXT_ATT, inValue);
      }
      else
      {
         removeAttribute(SsmlXML.TEXT_ATT);
      }

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setTimePeriod(SsmlCfTimePeriod inValue)
   {
      if (inValue !=  null)
      {
         setAttribute(SsmlXML.TIME_PERIOD_ATT, inValue.name());
      }
      else
      {
         removeAttribute(SsmlXML.TIME_PERIOD_ATT);
      }

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setRank(Integer inValue)
   {
      if (inValue !=  null)
      {
         setAttribute(SsmlXML.RANK_ATT, inValue);
      }
      else
      {
         removeAttribute(SsmlXML.RANK_ATT);
      }

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule setStdDev(Integer inValue)
   {
      if (inValue !=  null)
      {
         setAttribute(SsmlXML.STD_DEV_ATT, inValue);
      }
      else
      {
         removeAttribute(SsmlXML.STD_DEV_ATT);
      }

      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule addFormula(String inValue)
   {
      addSubtag(new XMLTag(SsmlXML.FORMULA).setContent(inValue));
      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule addFormula(int inValue)
   {
      addSubtag(new XMLTag(SsmlXML.FORMULA).setContent(inValue));
      return this;
   }

   //---------------------------------------------------------------------------
   public SsmlCfRule addFormula(float inValue)
   {
      addSubtag(new XMLTag(SsmlXML.FORMULA).setContent(inValue + ""));
      return this;
   }
}
/*

  
    ROW()=COLUMN()
  
  
    90
    100
  
  
    80
    90
  
  
    70
    80
  
  
    60
    70
  
  
    0
    60
  

 */




© 2015 - 2024 Weber Informatics LLC | Privacy Policy