Пример #1
0
        /**
         * Does the same as {@link #line(String, java.awt.Color, String)},
         * but the graph gets stacked on top of the
         * previous LINE, AREA or STACK graph. Depending on the type of the
         * previous graph, the STACK will be either a LINE or an AREA.  This
         * obviously implies that the first STACK must be preceded by an AREA
         * or LINE.
         * <p/>
         * Note, that when you STACK onto *UNKNOWN* data, Rrd4n will not
         * draw any graphics ... *UNKNOWN* is not zero.
         *
         * @param srcName Virtual source name
         * @param color   Stacked graph color
         * @param legend  Legend text
         * @throws ArgumentException Thrown if this STACK has no previously defined AREA, STACK or LINE
         *                      graph bellow it.
         */
        public void stack(String srcName, Color color, String legend)
        {
            // find parent AREA or LINE
            SourcedPlotElement parent = null;

            for (int i = plotElements.Count - 1; i >= 0; i--)
            {
                PlotElement plotElement = plotElements[i];
                if (plotElement.GetType() == typeof(SourcedPlotElement) ||
                    plotElement.GetType() == typeof(Area) ||
                    plotElement.GetType() == typeof(Line))
                {
                    parent = (SourcedPlotElement)plotElement;
                    break;
                }
            }
            if (parent == null)
            {
                throw new ArgumentException("You have to stack graph onto something (line or area)");
            }
            else
            {
                LegendText legendText = new LegendText(color, legend);
                comments.Add(legendText);
                plotElements.Add(new Stack(parent, srcName, color));
            }
        }
Пример #2
0
        private void drawData()
        {
            worker.setAntiAliasing(gdef.antiAliasing);
            worker.clip(im.xorigin + 1, im.yorigin - gdef.height - 1, gdef.width - 1, gdef.height + 2);
            double areazero = mapper.ytr((im.minval > 0.0) ? im.minval : (im.maxval < 0.0) ? im.maxval : 0.0);

            double[] x = xtr(dproc.getTimestamps()), lastY = null;
            // draw line, area and stack
            foreach (PlotElement plotElement in gdef.plotElements)
            {
                if (plotElement.GetType() == typeof(Line) ||
                    plotElement.GetType() == typeof(Area) ||
                    plotElement.GetType() == typeof(Stack))
                {
                    SourcedPlotElement source = (SourcedPlotElement)plotElement;
                    double[]           y      = ytr(source.getValues());
                    if (source.GetType() == typeof(Line))
                    {
                        worker.drawPolyline(x, y, source.color, ((Line)source).width);
                    }
                    else if (source.GetType() == typeof(Area))
                    {
                        worker.fillPolygon(x, areazero, y, source.color);
                    }
                    else if (source.GetType() == typeof(Stack))
                    {
                        Stack stack = (Stack)source;
                        float width = stack.getParentLineWidth();
                        if (width >= 0F)
                        {
                            // line
                            worker.drawPolyline(x, y, stack.color, width);
                        }
                        else
                        {
                            // area
                            worker.fillPolygon(x, lastY, y, stack.color);
                            worker.drawPolyline(x, lastY, stack.getParentColor(), 0);
                        }
                    }
                    else
                    {
                        // should not be here
                        throw new ApplicationException("Unknown plot source: " + source.GetType());
                    }
                    lastY = y;
                }
            }
            worker.reset();
            worker.setAntiAliasing(false);
        }
Пример #3
0
   internal Stack(SourcedPlotElement parent, String srcName, Color color) 
   : base(srcName, color)
   {
		
		this.parent = parent;
	}
Пример #4
0
 internal Stack(SourcedPlotElement parent, String srcName, Color color)
     : base(srcName, color)
 {
     this.parent = parent;
 }