001package com.hfg.math; 002 003import java.awt.Font; 004 005import com.hfg.graphics.units.GfxSize; 006import com.hfg.setting.StringSetting; 007import com.hfg.svg.SvgGenerationSettings; 008 009//------------------------------------------------------------------------------ 010/** 011 * Settings for use with generating histogram SVGs. 012 * 013 * @author J. Alex Taylor, hairyfatguy.com 014 */ 015//------------------------------------------------------------------------------ 016// com.hfg XML/HTML Coding Library 017// 018// This library is free software; you can redistribute it and/or 019// modify it under the terms of the GNU Lesser General Public 020// License as published by the Free Software Foundation; either 021// version 2.1 of the License, or (at your option) any later version. 022// 023// This library is distributed in the hope that it will be useful, 024// but WITHOUT ANY WARRANTY; without even the implied warranty of 025// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 026// Lesser General Public License for more details. 027// 028// You should have received a copy of the GNU Lesser General Public 029// License along with this library; if not, write to the Free Software 030// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 031// 032// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 033// jataylor@hairyfatguy.com 034//------------------------------------------------------------------------------ 035 036public class HistogramSvgSettings extends SvgGenerationSettings 037{ 038 private static final String BAR_STYLE_CLASS = "barStyleClass"; 039 private static final String RANGE_LABEL_FORMAT_STRING = "rangeLabelFormatString"; 040 041 private final String sDefaultRangeLabelFormatString = "%.1f"; 042 043 //########################################################################### 044 // CONSTRUCTORS 045 //########################################################################### 046 047 //--------------------------------------------------------------------------- 048 public HistogramSvgSettings() 049 { 050 super(); 051 } 052 053 //--------------------------------------------------------------------------- 054 @Override 055 protected void init() 056 { 057 super.init(); 058 059 add(new StringSetting(BAR_STYLE_CLASS)); 060 add(new StringSetting(RANGE_LABEL_FORMAT_STRING)); 061 062 setRangeLabelFormatString(sDefaultRangeLabelFormatString); 063 } 064 065 //########################################################################### 066 // PUBLIC METHODS 067 //########################################################################### 068 069 //--------------------------------------------------------------------------- 070 public HistogramSvgSettings setBarStyleClass(String inValue) 071 { 072 get(BAR_STYLE_CLASS).setValue(inValue); 073 return this; 074 } 075 076 //--------------------------------------------------------------------------- 077 public String getBarStyleClass() 078 { 079 return (String) get(BAR_STYLE_CLASS).getValue(); 080 } 081 082 083 //--------------------------------------------------------------------------- 084 public HistogramSvgSettings setRangeLabelFormatString(String inValue) 085 { 086 get(RANGE_LABEL_FORMAT_STRING).setValue(inValue != null ? inValue.toString() : null); 087 return this; 088 } 089 090 //--------------------------------------------------------------------------- 091 public String getRangeLabelFormatString() 092 { 093 return (String) get(RANGE_LABEL_FORMAT_STRING).getValue(); 094 } 095 096 //--------------------------------------------------------------------------- 097 @Override 098 public HistogramSvgSettings setHeight(GfxSize inValue) 099 { 100 return (HistogramSvgSettings) super.setHeight(inValue); 101 } 102 103 //--------------------------------------------------------------------------- 104 @Override 105 public HistogramSvgSettings setWidth(GfxSize inValue) 106 { 107 return (HistogramSvgSettings) super.setWidth(inValue); 108 } 109 110 111 //--------------------------------------------------------------------------- 112 @Override 113 public HistogramSvgSettings setFont(Font inValue) 114 { 115 return (HistogramSvgSettings) super.setFont(inValue); 116 } 117 118 119 //--------------------------------------------------------------------------- 120 @Override 121 public HistogramSvgSettings setPadding(GfxSize inValue) 122 { 123 return (HistogramSvgSettings) super.setPadding(inValue); 124 } 125 126}