Package de.progra.charting.model

Examples of de.progra.charting.model.ChartDataModel


   
    /** Finally renders the Object in the Graphics object.
     * @param g the Graphics2D object in which to render
     */
    public void renderChart(Graphics2D g) {
        ChartDataModel m = getChartDataModel();
        RowColorModel rcm = getRowColorModel();
        AffineTransform yaxis1 = getTransform(CoordSystem.FIRST_YAXIS);
       
        int datasetcount = m.getDataSetNumber();
        Point2D val;
        Point2D paint = null;
        Point2D oldpaint = null;
        if(! m.isColumnNumeric())
            return;
       
        for(int set = 0; set < datasetcount; set++) {
            // Creating Interpolated Function Data
            /*
             "for i in range(AMOUNT) :\n"+
             "   x = lowrange + i * (float(abs(highrange - lowrange)) / AMOUNT)\n"+
             "   columns.append(x)\n"+
             "   model.append("+function+")\n";
            */
           
            double[] x = new double[m.getDataSetLength(set)];
            double[] y = new double[x.length];
           
            for(int i = 0; i < m.getDataSetLength(set);  i++) {
                x[i] = ((Number)m.getColumnValueAt(set, i)).doubleValue();
               
                // Catch x[i] == Not A Number
                if(x[i] != x[i]) x[i] = 0.0;
               
                y[i] = m.getValueAt(set, i).doubleValue();
            }       
                       
            int AMOUNT = 2000;
            double lowrange = m.getChartDataModelConstraints(CoordSystem.FIRST_YAXIS).getMinimumColumnValue();
            double hirange = m.getChartDataModelConstraints(CoordSystem.FIRST_YAXIS).getMaximumColumnValue();

            double xa[] = new double[AMOUNT];
            double ya[] = new double[AMOUNT];
           
            for(int i = 0; i < AMOUNT; i++) {
View Full Code Here


     * @param g the Graphics2D object in which to render
     */
    public void renderChart(Graphics2D g) {
        Object rh = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        ChartDataModel m = getChartDataModel();
        RowColorModel rcm = getRowColorModel();
       
        double height = this.getBounds().getHeight();
        double width = this.getBounds().getWidth();

        int datenreihen = m.getDataSetNumber();
        // determine shortest dataset length
        int min_length = Integer.MAX_VALUE;
       
        for(int i = 0; i < datenreihen; i++)
            min_length = Math.min(min_length, m.getDataSetLength(i));
       
        double center_y = getBounds().getCenterY();
        double center_x = getBounds().getCenterX();
       
        double rad = Math.min(width * 0.9, height * 0.9);
        double modelVal = 0.0;
        for(int reihe = min_length; reihe >= 1; reihe--) {
           
            double kreis = (double)rad / min_length * reihe;
            Ellipse2D.Double circle = new Ellipse2D.Double((double)center_x-kreis/2,
                                                           (double)center_y-kreis/2,
                                                           kreis, kreis);
                       
            double sum = 0;
            double start = 0.0;
           
            // Paint data
            for(int i = 0; i < datenreihen; i++) {
                modelVal = m.getValueAt(i, reihe - 1).doubleValue();
               
                // Catch modelVal == Not A Number
                if(modelVal != modelVal)
                    continue;
                sum += modelVal;
            }
           
            for(int i = 0; i < datenreihen; i++) {
                double value = m.getValueAt(i, reihe - 1).doubleValue();
               
                // Catch value == Not A Number
                if(value != value) value = 0.0;
               
                Arc2D.Double arc = new Arc2D.Double(circle.getBounds2D(),
View Full Code Here

   
    /** Finally renders the Object in the Graphics object.
     * @param g the Graphics2D object in which to render
     */
    public void renderChart(Graphics2D g) {
        ChartDataModel m = getChartDataModel();
        RowColorModel rcm = getRowColorModel();
        AffineTransform yaxis1 = getTransform(CoordSystem.FIRST_YAXIS);
       
        int datasetcount = m.getDataSetNumber();
        Point2D val;
        Point2D paint = null;
        Point2D oldpaint = null;
        boolean numericalcolumns = m.isColumnNumeric();
        float modelVal = 0f;
        //System.out.println("** Render LineChart.-");
        for(int set = 0; set < datasetcount; set++) {
            for(int value = 0; value < m.getDataSetLength(set);  value++) {
                modelVal = m.getValueAt(set, value).floatValue();
               
                if(modelVal != modelVal || modelVal == Float.NEGATIVE_INFINITY || modelVal == Float.POSITIVE_INFINITY) {
                    //System.out.print(".");
                    oldpaint = null;
                    continue;
                }
               
                if(numericalcolumns)
                    val = new Point2D.Float(((Number)m.getColumnValueAt(set, value)).floatValue(),
                                            modelVal);
                else
                    val = new Point2D.Float((float)value,
                                            modelVal);

View Full Code Here

      // then activate it
        Object rh = g.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
       
        // get the models
        ChartDataModel m = getChartDataModel();
        RowColorModel rcm = getRowColorModel();

    // get the available drawing space       
        double height = this.getBounds().getHeight();
        double width = this.getBounds().getWidth();

    // the number of dataset
        int lNumberOfRows = m.getDataSetNumber();
       
        // determine shortest dataset length, this is the number of axis that we need to draw
        int lNumberOfColumns = Integer.MAX_VALUE;       
        for(int i = 0; i < lNumberOfRows; i++)
            lNumberOfColumns = Math.min(lNumberOfColumns, m.getDataSetLength(i));
       
        double[] maxvalues = new double[lNumberOfColumns];
       
        // get center
        double center_y = getBounds().getCenterY();
        double center_x = getBounds().getCenterX();

    // determine the radius
        double lRadius = Math.min(width * 0.9, height * 0.9) / 2;

    // scan through the datasets
        for(int lRow = 0; lRow < lNumberOfRows; lRow++)
        {
      // scan through the values in the dataset
      GeneralPath filledPolygon = new GeneralPath(GeneralPath.WIND_EVEN_ODD, lNumberOfColumns);
      for (int lCol = 0; lCol < lNumberOfColumns; lCol++)
      {
        // get the value
                double lValue = m.getValueAt(lRow, lCol).doubleValue();
       
            // determine the scale
            double lMaxValue = maxvalues[lCol];
               
                if(lMaxValue == 0.0) {
                    for(int row = 0; row < lNumberOfRows; row++)
                        lMaxValue = Math.max(lMaxValue, m.getValueAt(row, lCol).doubleValue() * 1.1);
                   
                    maxvalues[lCol] = lMaxValue;
                }
               
            double lScaledValue = lValue / lMaxValue;
View Full Code Here

    /** Finally renders the Object in the Graphics object.
     * @param g the Graphics2D object in which to render
     */
    public void renderChart(Graphics2D g) {
        ChartDataModel m = getChartDataModel();
        RowColorModel rcm = getRowColorModel();
        AffineTransform yaxis1 = getTransform(CoordSystem.FIRST_YAXIS);
       
        int datasetcount = m.getDataSetNumber();
        Point2D val;
        Point2D paint = new Point2D.Float(0f, 0f);
        boolean numericalcolumns = m.isColumnNumeric();
 
        float modelVal = 0f;
       
        RectangularShape shape;
       
        for(int set = 0; set < datasetcount; set++) {
            for(int value = 0; value < m.getDataSetLength(set);  value++) {
                modelVal = m.getValueAt(set, value).floatValue();
               
                // Catch modelVal == Not A Number
                if(modelVal != modelVal)
                    continue;
               
                if(numericalcolumns)
                    val = new Point2D.Float(((Number)m.getColumnValueAt(set, value)).floatValue(),
                                            modelVal);
                else
                    val = new Point2D.Float((float)value,
                                            modelVal);
                   
View Full Code Here

    /** Finally renders the Object in the Graphics object.
     * @param g the Graphics2D object in which to render
     */
    public void renderChart(Graphics2D g) {
        ChartDataModel m = getChartDataModel();
        ChartDataModelConstraints con = m.getChartDataModelConstraints(CoordSystem.FIRST_YAXIS);
       
        if(m.isColumnNumeric())
            return;
       
        RowColorModel rcm = getRowColorModel();
        AffineTransform yaxis1 = getTransform(CoordSystem.FIRST_YAXIS);       
        AffineTransform yaxis2 = getTransform(CoordSystem.SECOND_YAXIS);
       
        int datasetcount = m.getDataSetNumber();
           
        Point2D point1 = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
                                                           con.getMaximumValue().floatValue()),
                                          null);
        Point2D point2 = yaxis1.transform(new Point2D.Float((float)con.getMaximumColumnValue(),
                                                             con.getMaximumValue().floatValue()),
                                          null);
        Point2D value = point1;
       
        int dataunitwidth = (int)((point2.getX() - point1.getX()) / con.getMaximumColumnValue());
        int boxwidth = (int)(dataunitwidth * boxWidth / datasetcount);
        float margin = (float)(dataunitwidth * ((1.0 - boxWidth)/2f));
       
        Point2D pointzero;
        if(con.getMinimumValue().floatValue() > 0)
           pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
                                                         con.getMinimumValue().floatValue()),
                                        null);
        else if(con.getMaximumValue().floatValue() < 0)
           pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
                                                         con.getMaximumValue().floatValue()),
                                        null);
        else
           pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
                                                         0f),
                                        null);
        
        FontRenderContext columnTopfrc = null;
        LineMetrics lm = null;
        DecimalFormat df = null;
        Rectangle2D fontRec = null;
        String columnTop = null;
        if (barTopFormat != null) {
            g.setFont(barTopFont);
            columnTopfrc = new FontRenderContext(null, false, false);
        }
        /* We paint the values starting at x-value "0".
         * As we only render BarCharts for ChartDataModels with
         * non-numeric x-axis values we don't have to read those
         * values from the data model. You can look in
         * ObjectChartDataModel to see, how the x-axis bounds
         * are defined: the minimum value is always 0, the maximum
         * value is the amount of non-numeric x-axis values.
         */
        for(int i = 0; i < datasetcount; i++) {
            //System.out.println("** DataSet "+i);
           
            for(int j = 0; j < m.getDataSetLength(i); j++) {
                yaxis1.transform(new Point2D.Float((float)j, m.getValueAt(i, j).floatValue()),
                                 value);
               
                Rectangle2D box =
                    new Rectangle2D.Float((float)(value.getX() + margin + i*boxwidth),
                                          (float)Math.min(value.getY(), pointzero.getY()),
View Full Code Here

    /** Finally renders the Object in the Graphics object.
     * @param g the Graphics2D object in which to render
     */
    public void renderChart(Graphics2D g) {
        ChartDataModel m = getChartDataModel();
        ChartDataModelConstraints con = m.getChartDataModelConstraints(CoordSystem.FIRST_YAXIS);
       
        System.out.println("** Maximum: "+con.getMaximumValue()+" Minimum: "+con.getMinimumValue());
       
        if(m.isColumnNumeric())
            return;
       
        RowColorModel rcm = getRowColorModel();
        AffineTransform yaxis1 = getTransform(CoordSystem.FIRST_YAXIS);
       
        int datasetcount = m.getDataSetNumber();
       
        int maximumDataSetLength = Integer.MIN_VALUE;
       
        for(int i = 0; i < model.getDataSetNumber(); i++) {
            maximumDataSetLength = Math.max(maximumDataSetLength, model.getDataSetLength(i));
        }
       
        Point2D pointzero;
        if(con.getMinimumValue().floatValue() > 0)
           pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
                                                         con.getMinimumValue().floatValue()),
                                        null);
        else if(con.getMaximumValue().floatValue() < 0)
           pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
                                                         con.getMaximumValue().floatValue()),
                                        null);
        else
           pointzero = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
                                                         0f),
                                        null);
       
        Point2D point1 = yaxis1.transform(new Point2D.Float((float)con.getMinimumColumnValue(),
                                                           con.getMaximumValue().floatValue()),
                                          null);
        Point2D point2 = yaxis1.transform(new Point2D.Float((float)con.getMaximumColumnValue(),
                                                             con.getMaximumValue().floatValue()),
                                          null);
        Point2D value = point1;
       
        int dataunitwidth = (int)((point2.getX() - point1.getX()) / con.getMaximumColumnValue());
        int boxwidth = (int)(dataunitwidth * boxWidth);
        float margin = (float)(dataunitwidth * ((1.0 - boxWidth)/2f));
       
        /* We paint the values starting at x-value "0".
         * As we only render BarCharts for ChartDataModels with
         * non-numeric x-axis values we don't have to read those
         * values from the data model. You can look in
         * ObjectChartDataModel to see, how the x-axis bounds
         * are defined: the minimum value is always 0, the maximum
         * value is the amount of non-numeric x-axis values.
         */
        double currentvalue = 0.0;
        Rectangle2D box = null;
        Point2D oldmaxvalue;
        Point2D oldminvalue;
       
        for(int j = 0; j < maximumDataSetLength; j++) {
            double minvalue = 0.0;
            double maxvalue = 0.0;
           
            oldmaxvalue = pointzero;
            oldminvalue = pointzero;
           
            for(int i = 0; i < m.getDataSetNumber(); i++) {
               
                if(j < m.getDataSetLength(i))
                    currentvalue = m.getValueAt(i, j).doubleValue();
                else
                    currentvalue = 0.0;
               
                if(currentvalue < 0.0) {
                    minvalue += currentvalue;
View Full Code Here

TOP

Related Classes of de.progra.charting.model.ChartDataModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.