private void paintBars( Graphics2D g2d, float wb, int[] bottoms, int n, int[] x, int[] y, int s, int adj, boolean fill, Color[] colors) { if (_orientation==BarsView.Orientation.X1RIGHT_X2UP) paintBarsVertical(g2d,wb,bottoms,n,x,y,s,adj,fill,colors); else paintBarsHorizontal(g2d,wb,bottoms,n,x,y,s,adj,fill,colors); }
/** * Sets the orientation of (x1,x2) axes. * @param orientation the orientation. */ public void setOrientation(Orientation orientation) { if (_orientation!=orientation) { _orientation = orientation; updateBestProjectors(); repaint(); } }
/** * Constructs a view of bars for a sampled function x2(x1). * @param s1 the sampling of x1 coordinates. * @param x2 array of x2 values. */ public BarsView(Sampling s1, float[] x2) { set(s1,x2); }
RenderingHints.VALUE_ANTIALIAS_ON); Projector hp = getHorizontalProjector(); Projector vp = getVerticalProjector(); Transcaler ts = getTranscaler(); computeXY(hp,vp,ts,1,o1,o2,ox,oy); x2[i] += bottom[i]; computeXY(hp,vp,ts,n,x1,x2,x,y); paintBars(gbar,_barWidth,prevTop,n,x,y,shift,is,true,colors[is]); if (_lineColor[is]!=null) gbar.setColor(_lineColor[is]); else gbar.setColor(Color.BLACK); paintBars(gbar,_barWidth,prevTop,n,x,y,shift,is,false,null);
/** * Sets the line style. * The default style is solid. * @param style the line style. */ public void setLineStyle(Line style) { _lineStyle = style; repaint(); }
/** * Adds a view of bars x2 for a sampled function x2(x1). * @param irow the tile row index. * @param icol the tile column index. * @param s1 the sampling of the variable x1; must be uniform. * @param x2 array of x2 values. * @return the bars view. */ public BarsView addBars(int irow, int icol, Sampling s1, float[] x2) { BarsView bv = new BarsView(s1,x2); return addBarsView(irow,icol,bv); }
/** * Sets the line color for a set of bars. * The default line color is the tile foreground color. * That default is used if the specified line color is null. * @param ibar the index of the set of bars. * @param color the line color; null, for tile foreground color. */ public void setLineColor(int ibar, Color color) { _lineColor[ibar] = color; repaint(); } /**
/** * Adds a bars view of the array of arrays x2 of bar values and x2.length * plot segments. * @param irow the tile row index. * @param icol the tile column index. * @param x2 array of arrays of x2 values. * @return the bars view. */ public BarsView addBars(int irow, int icol, float[][] x2) { BarsView bv = new BarsView(x2); return addBarsView(irow,icol,bv); }
/** * Sets the alignment of the bars. * The default alignment is centered about the value's tick mark. * @param alignment the bar alignment. */ public void setAlignment(Alignment alignment) { if (_alignment!=alignment) { _alignment = alignment; updateBestProjectors(); repaint(); } }
/** * Constructs a view of bars for x2.length data sets. * @param x2 array of values containing x2.length separate sets. */ public BarsView(float[][] x2) { set(null,x2); }
/** * Sets the bar width. * The default width will be 1, or fully expanded bars. * @param width the bar width in range [0.0 - 1.0] */ public void setBarWidth(float width) { _barWidth = width; repaint(); }
/** * Adds a bars view of the array x2 of bar values. * @param irow the tile row index. * @param icol the tile column index. * @param x2 array of x2 values. * @return the bars view. */ public BarsView addBars(int irow, int icol, float[] x2) { BarsView bv = new BarsView(x2); return addBarsView(irow,icol,bv); }
/** * Sets the stacking behavior of the bars. * The default stacking behavior is to plot multiple bars adjacent. * @param stack true, if stacking bars; false, otherwise. */ public void setStackBars(boolean stack) { _stackingBars = stack; updateBestProjectors(); repaint(); }
/** * Constructs a view of bars with multiple plot segments. * @param x1 array of x1 coordinates. * @param x2 array of x2 coordinates. */ public BarsView(float[][] x1, float[][] x2) { set(x1,x2); }
/** * Sets a color map for a specific bar set. * @param i index of a bar set. * @param colorMap a color map. */ public void setColorMap(int i, ColorMap colorMap) { _colorMaps[i] = colorMap; repaint(); }
/** * Adds a bars view of the array of arrays x2 of bar values and x2.length * plot segments for a sample function x2(x1). * @param irow the tile row index. * @param icol the tile column index. * @param s1 the sampling of the variable x1; must be uniform. * @param x2 array of array of x2 values. * @return the bars view. */ public BarsView addBars(int irow, int icol, Sampling s1, float[][] x2) { BarsView bv = new BarsView(s1,x2); return addBarsView(irow,icol,bv); }
/** * Sets the line width. * The default width is zero, for the thinnest lines. * @param width the line width. */ public void setLineWidth(float width) { if (_lineWidth!=width) { _lineWidth = width; updateBestProjectors(); repaint(); } }
/** * Constructs a view of bars with a single plot segment. * The lengths of the specified arrays x1 and x2 must be equal. * @param x1 array of x1 coordinates. * @param x2 array of x2 coordinates. */ public BarsView(float[] x1, float[] x2) { set(x1,x2); }
/** * Sets the format used for text labels. * The default format is "%1.4G". * @param format the text format. */ public void setTextFormat(String format) { _textFormat = format; repaint(); }
/** * Sets array of (x1,x2) coordinates for a plot segment. * The lengths of x1 and x2 must be equal. * @param x1 array of x1 values. * @param x2 array of x2 coordinates. */ public void set(float[] x1, float[] x2) { Check.argument(x1.length==x2.length,"x1.length equals x2.length"); _ns = 1; _nx.clear(); _x1.clear(); _x2.clear(); _nxmax = x1.length; _nx.add(x1.length); _x1.add(copy(x1)); _x2.add(copy(x2)); _colorMaps = new ColorMap[_ns]; for (int i=0; i<_ns; ++i) _colorMaps[i] = new ColorMap(Color.CYAN); _lineColor = new Color[_ns]; updateBestProjectors(); repaint(); }