001package com.hfg.xml.msofficexml.docx.drawingml.theme;
002
003
004
005import com.hfg.graphics.units.EMUs;
006import com.hfg.xml.XMLTag;
007import com.hfg.xml.msofficexml.OfficeOpenXMLTag;
008import com.hfg.xml.msofficexml.OfficeOpenXmlDocument;
009import com.hfg.xml.msofficexml.docx.drawingml.DmlXML;
010import com.hfg.xml.msofficexml.docx.drawingml.color.DmlSchemeColor;
011import com.hfg.xml.msofficexml.docx.drawingml.color.DmlSchemeColorValue;
012import com.hfg.xml.msofficexml.docx.drawingml.effect.DmlEffectStyle;
013import com.hfg.xml.msofficexml.docx.drawingml.fill.DmlFill;
014import com.hfg.xml.msofficexml.docx.drawingml.fill.DmlSolidFill;
015import com.hfg.xml.msofficexml.docx.drawingml.line.DmlCompoundLineType;
016import com.hfg.xml.msofficexml.docx.drawingml.line.DmlLine;
017import com.hfg.xml.msofficexml.docx.drawingml.line.DmlLineEndCapType;
018import com.hfg.xml.msofficexml.docx.drawingml.line.DmlPenAlignmentType;
019import com.hfg.xml.msofficexml.docx.drawingml.line.dash.DmlPresetLineDashType;
020import com.hfg.xml.msofficexml.docx.drawingml.line.join.DmlMiterLineJoin;
021
022//------------------------------------------------------------------------------
023/**
024 Represents an Office Open XML drawingml format scheme (<a:fmtScheme>) tag.
025 <div>
026 @author J. Alex Taylor, hairyfatguy.com
027 </div>
028 */
029//------------------------------------------------------------------------------
030// com.hfg XML/HTML Coding Library
031//
032// This library is free software; you can redistribute it and/or
033// modify it under the terms of the GNU Lesser General Public
034// License as published by the Free Software Foundation; either
035// version 2.1 of the License, or (at your option) any later version.
036//
037// This library is distributed in the hope that it will be useful,
038// but WITHOUT ANY WARRANTY; without even the implied warranty of
039// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
040// Lesser General Public License for more details.
041//
042// You should have received a copy of the GNU Lesser General Public
043// License along with this library; if not, write to the Free Software
044// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
045//
046// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
047// jataylor@hairyfatguy.com
048//------------------------------------------------------------------------------
049
050public class DmlFormatScheme extends OfficeOpenXMLTag
051{
052   private XMLTag mFillStyleList;
053   private XMLTag mBackgroundFillStyleList;
054   private XMLTag mLineStyleList;
055   private XMLTag mEffectStyleList;
056
057   //###########################################################################
058   // CONSTRUCTORS
059   //###########################################################################
060
061   //---------------------------------------------------------------------------
062   public DmlFormatScheme(OfficeOpenXmlDocument inParentDoc)
063   {
064      super(DmlXML.FORMAT_SCHEME, inParentDoc);
065      init();
066   }
067
068   //---------------------------------------------------------------------------
069   private void init()
070   {
071      // Set default values
072
073      DmlLine defaultLine = new DmlLine(getParentDoc())
074            .setWidth(new EMUs(6350))
075            .setCapType(DmlLineEndCapType.flat)
076            .setCompoundLineType(DmlCompoundLineType.sng)
077            .setPenAlignmentType(DmlPenAlignmentType.ctr)
078            .setFill(new DmlSolidFill(new DmlSchemeColor(DmlSchemeColorValue.placeholderColor)))
079            .setDash(DmlPresetLineDashType.solid)
080            .setLineJoin(new DmlMiterLineJoin().setLimit(new EMUs(80000)));
081
082      addLineStyle(defaultLine);
083      addEffectStyle(new DmlEffectStyle(getParentDoc())); // Add an empty effect style
084
085      addFillStyle(new DmlSolidFill(new DmlSchemeColor(DmlSchemeColorValue.placeholderColor)));
086      addBackgroundFillStyle(new DmlSolidFill(new DmlSchemeColor(DmlSchemeColorValue.placeholderColor)));
087   }
088
089   //###########################################################################
090   // PUBLIC METHODS
091   //###########################################################################
092
093   //---------------------------------------------------------------------------
094   public DmlFormatScheme addFillStyle(DmlFill inValue)
095   {
096      if (null == mFillStyleList)
097      {
098         mFillStyleList = new XMLTag(DmlXML.FILL_STYLE_LIST);
099         addSubtag(mFillStyleList);
100      }
101
102      mFillStyleList.addSubtag(inValue);
103
104      return this;
105   }
106
107   //---------------------------------------------------------------------------
108   public DmlFormatScheme addBackgroundFillStyle(DmlFill inValue)
109   {
110      if (null == mBackgroundFillStyleList)
111      {
112         mBackgroundFillStyleList = new XMLTag(DmlXML.BKGRD_FILL_STYLE_LIST);
113         addSubtag(mBackgroundFillStyleList);
114      }
115
116      mBackgroundFillStyleList.addSubtag(inValue);
117
118      return this;
119   }
120
121   //---------------------------------------------------------------------------
122   public DmlFormatScheme addLineStyle(DmlLine inValue)
123   {
124      if (null == mLineStyleList)
125      {
126         mLineStyleList = new XMLTag(DmlXML.LINE_STYLE_LIST);
127         addSubtag(mLineStyleList);
128      }
129
130      mLineStyleList.addSubtag(inValue);
131
132      return this;
133   }
134
135   //---------------------------------------------------------------------------
136   public DmlFormatScheme addEffectStyle(DmlEffectStyle inValue)
137   {
138      if (null == mEffectStyleList)
139      {
140         mEffectStyleList = new XMLTag(DmlXML.EFFECT_STYLE_LIST);
141         addSubtag(mEffectStyleList);
142      }
143
144      mEffectStyleList.addSubtag(inValue);
145
146      return this;
147   }
148}