Package java.awt.geom

Examples of java.awt.geom.Point2D


        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++) {
                xa[i] = lowrange + i * (Math.abs(hirange - lowrange) / (double)AMOUNT);
                ya[i] = ChartUtilities.interpolate(x, y, xa[i]);
            }
           
            // Rendering xa[] and ya[]
            for(int i = 0; i < AMOUNT; i++) {
               
                val = new Point2D.Double(xa[i], ya[i]);
                   
                oldpaint = paint;
                if(yaxis1.transform(val, null) != null)
                    paint = yaxis1.transform(val, paint);
                else
                    continue;
               
                g.setColor(rcm.getColor(set));
               
               
                if(oldpaint != null) {
                   
                    g.drawLine((int)oldpaint.getX(), (int)oldpaint.getY(),
                               (int)paint.getX(), (int)paint.getY());
                }
            }
            oldpaint = null;
            paint = null;
View Full Code Here


        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);

                //System.out.println("** Rendered "+val);
                oldpaint = paint;
               
                if(yaxis1.transform(val, null) != null) {
                    paint = yaxis1.transform(val, null);
                    //System.out.println("** val = "+val+"  paint = "+paint);
                }
                else
                    continue;

                g.setColor(rcm.getColor(set));

                if(oldpaint != null) {
                    g.drawLine((int)oldpaint.getX(), (int)oldpaint.getY(),
                               (int)paint.getX(), (int)paint.getY());
                }
            }
            oldpaint = null;
            paint = null;
View Full Code Here

        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);
                   
               
                yaxis1.transform(val, paint);
                if(paint == null)
                    continue;
               
                g.setColor(rcm.getColor(set));
               
                shape = rcm.getShape(set);
                shape.setFrame(paint.getX() - shapeSize/2, paint.getY() - shapeSize/2, shapeSize, shapeSize);
               
        g.fill(shape);
            }
        }
   }   
View Full Code Here

        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()),
                                          (float)boxwidth,
                                          (float)Math.abs(pointzero.getY() - value.getY()));
                   
                g.setColor(rcm.getColor(i));
                g.fill(box);
                g.setColor(Color.black);
                g.draw(box);

                if (barTopFormat != null) {
                    //get value for zero'th set, index j
                    columnTop = barTopFormat.format(model.getValueAt(i,j).doubleValue());
                    fontRec = barTopFont.getStringBounds(columnTop, columnTopfrc);
                    lm = barTopFont.getLineMetrics(columnTop, columnTopfrc);
                    g.drawString(columnTop,
                        (float)(value.getX() + i*boxwidth +
                                (boxwidth - fontRec.getWidth())/2) - lm.getLeading(),
                        (float)(Math.min(value.getY(), pointzero.getY())-lm.getDescent()));
                }
            }
        }
   }//end render method   
View Full Code Here

       
        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;
                    yaxis1.transform(new Point2D.Float((float)j, (float)minvalue),
                                     value);
                  
                    box =
                        new Rectangle2D.Float((float)(value.getX()),
                                              (float)Math.min(value.getY(), oldminvalue.getY()),
                                              (float)boxwidth,
                                              (float)Math.abs(oldminvalue.getY() - value.getY()));
                    oldminvalue = (Point2D)value.clone();
                 }
                else {
                    maxvalue += currentvalue;
                    yaxis1.transform(new Point2D.Float((float)j, (float)maxvalue),
View Full Code Here

        ArrayList<WhiteboardPoint> pointsList = new ArrayList<WhiteboardPoint>();
        WhiteboardPoint p;
        for (int i = 0; i < m_points.size (); i++)
        {
            p = m_points.get (i);
            Point2D w = at.transform (
              new Point2D.Double (p.getX (), p.getY ()), null);
            pointsList.add (new WhiteboardPoint (w.getX (), w.getY ()));
        }

        this.initShape(t, c, pointsList, fill);
    }
View Full Code Here

          GeneralPath.WIND_EVEN_ODD, points.size ());
        if(points.size ()<=0)
            return polygon;
       
        WhiteboardPoint start = points.get (0);
        Point2D w = new Point2D.Double (start.getX (), start.getY ());
        Point2D v = w2v.transform (w, null);
        polygon.moveTo ((int) v.getX (), (int) v.getY ());
       
        WhiteboardPoint p;
        for (int i =0; i<points.size ();i++)
        {
            p = points.get (i);
            w = new Point2D.Double (p.getX (), p.getY ());
            v = w2v.transform (w, null);
            polygon.lineTo ((int) v.getX (), (int) v.getY ());
        }
       
        polygon.closePath ();
        return polygon;
    }
View Full Code Here

        WhiteboardPoint p;
        for (int i = 0; i<m_points.size ();i++)
        {
            p = m_points.get (i);
            Point2D w = at.transform (
              new Point2D.Double (p.getX (), p.getY ()), null);
            pointsList.add (new WhiteboardPoint (w.getX (), w.getY ()));
        }

        this.initShape(thickness, color, pointsList, fill);
    }
View Full Code Here

        GeneralPath polyline = new GeneralPath (
          GeneralPath.WIND_EVEN_ODD, points.size ());
        if(points.size ()<=0)
            return polyline;
        WhiteboardPoint start = points.get (0);
        Point2D w = new Point2D.Double (start.getX (), start.getY ());
        Point2D v = w2v.transform (w, null);
        polyline.moveTo ((int) v.getX (), (int) v.getY ());
        WhiteboardPoint p;
        for (int i =0; i<points.size ();i++)
        {
            p = points.get (i);
            w = new Point2D.Double (p.getX (), p.getY ());
            v = w2v.transform (w, null);
            polyline.lineTo ((int) v.getX (), (int) v.getY ());
        }
       
        return polyline;
    }
View Full Code Here

    double value = ChartThemesUtilities.getScaledValue(plot.getValue(this.getDatasetIndex()), scale);
    DialScale scale = plot.getScaleForDataset(this.getDatasetIndex());
    double angle = scale.valueToAngle(value);

    Arc2D arc1 = new Arc2D.Double(lengthRect, angle, 0, Arc2D.OPEN);
    Point2D pt1 = arc1.getEndPoint();
    Arc2D arc2 = new Arc2D.Double(widthRect, angle - 90.0, 180.0,
        Arc2D.OPEN);
    Point2D pt2 = arc2.getStartPoint();
    Point2D pt3 = arc2.getEndPoint();
    Arc2D arc3 = new Arc2D.Double(widthRect, angle - 180.0, 0.0,
        Arc2D.OPEN);
    Point2D pt4 = arc3.getStartPoint();

    GeneralPath gp = new GeneralPath();
    gp.moveTo((float) pt1.getX(), (float) pt1.getY());
    gp.lineTo((float) pt2.getX(), (float) pt2.getY());
    gp.lineTo((float) pt4.getX(), (float) pt4.getY());
    gp.lineTo((float) pt3.getX(), (float) pt3.getY());
    gp.closePath();
    g2.setPaint(this.fillPaint);
    g2.fill(gp);
View Full Code Here

TOP

Related Classes of java.awt.geom.Point2D

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.