public class BarGroup extends ChartObject{ private ArrayList bars; private color m_color; private int gap; /****************************************** Constructors ******************************************/ public BarGroup(color barColor){ m_color = barColor; bars = new ArrayList(); } public BarGroup(color barColor, String label){ m_color = barColor; m_label = label; tickSize = DEFAULT_TICK_SIZE; x_tick = true; bars = new ArrayList(); } public BarGroup(color barColor, ArrayList aList){ bars = aList; m_color = barColor; } public BarGroup(color barColor,String label, ArrayList aList){ m_label = label; tickSize = DEFAULT_TICK_SIZE; bars = aList; } public void addBar(float mean,float margin,int n){ bars.add(new Bar(mean,m_color,margin,n)); }//end addBar public void addBar(float mean,float margin,int n,String label){ bars.add(new Bar(mean,m_color,margin,n,label)); }//end addBar public void addBar(Bar aBar){ bars.add(aBar); } public void addGradient(float mean,float margin,int n){ bars.add(new Gradient(mean,m_color,margin,n)); }//end addBar public void addGradient(float mean,float margin,int n,String label){ bars.add(new Gradient(mean,m_color,margin,n,label)); }//end addBar public void addGradient(Gradient aBar){ bars.add(aBar); } public void addViolin(float mean,float margin,int n){ bars.add(new Violin(mean,m_color,margin,n)); }//end addBar public void addViolin(float mean,float margin,int n,String label){ bars.add(new Violin(mean,m_color,margin,n,label)); }//end addBar public void addViolin(Violin aBar){ bars.add(aBar); } public void addDot(float mean,float margin,int n){ bars.add(new Dot(mean,m_color,margin,n)); }//end addBar public void addDot(float mean,float margin,int n,String label){ bars.add(new Dot(mean,m_color,margin,n,label)); }//end addBar public void addDot(Dot aBar){ bars.add(aBar); } public void addBox(float mean,float margin,int n){ bars.add(new Box(mean,m_color,margin,n)); }//end addBar public void addBox(float mean,float margin,int n,String label){ bars.add(new Box(mean,m_color,margin,n,label)); }//end addBar public void addBox(Box aBar){ bars.add(aBar); } public void setGap(int newGap){ gap = newGap; } /****************************************** Draw Method ******************************************/ public void draw(int curX,int objWidth,float startY,float endY,float dataMin,float dataMax){ int curBarX = curX; if(m_label !=null){ stroke(0); line(curX,startY+tickSize+textAscent(),curX,startY+tickSize+(textAscent())+5); line(curX+objWidth,startY+tickSize+textAscent(),curX+objWidth,startY+tickSize+(textAscent())+5); line(curX,startY+tickSize+textAscent()+5,curX+objWidth,startY+tickSize+(textAscent())+5); stroke(0,64); line(curX,startY,curX,endY); line(curX+objWidth,startY,curX+objWidth,endY); text(m_label,curX+(objWidth/2.0)-(textWidth(m_label)/2.0),startY+tickSize+(2*textAscent())+10); } if(bars.size()>0){ curBarX+=2*gap; int perBar = floor((objWidth-(2*gap))/bars.size()); int barWidth = perBar - (2*gap); for(ChartObject aBar:bars){ aBar.draw(curBarX,barWidth,startY,endY,dataMin,dataMax); curBarX+=perBar; }//end for }//end if }//end draw }//end class