Package java.awt.geom

Examples of java.awt.geom.Point2D$Double


    // work out the anchor point
    Rectangle2D f = DialPlot.rectangleByRadius(frame, getRadius(),
        this.getRadius());
    Arc2D arc = new Arc2D.Double(f, this.getAngle(), 0.0, Arc2D.OPEN);
    Point2D pt = arc.getStartPoint();

    // calculate the bounds of the template value
    FontMetrics fm = g2.getFontMetrics(this.getFont());
    String s = this.getNumberFormat().format(this.getTemplateValue());
    Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm);

    // align this rectangle to the frameAnchor
    Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(
        tb.getWidth(), tb.getHeight()), pt.getX(), pt.getY(),
        this.getFrameAnchor());

    // add the insets
    Rectangle2D fb = this.getInsets().createOutsetRectangle(bounds);

    // draw the background
    g2.setPaint(this.getBackgroundPaint());
    g2.fill(fb);

    // draw the border
    g2.setStroke(this.getOutlineStroke());
    g2.setPaint(this.getOutlinePaint());
    g2.draw(fb);


    // now find the text anchor point
    String valueStr = this.getNumberFormat().format(ChartThemesUtilities.getScaledValue(plot.getValue(this.getDatasetIndex()), scale));
    Point2D pt2 = RectangleAnchor.coordinates(bounds, this.getValueAnchor());
    g2.setPaint(this.getPaint());
    g2.setFont(this.getFont());
    TextUtilities.drawAlignedString(valueStr, g2, (float) pt2.getX(),
        (float) pt2.getY(), this.getTextAnchor());

  }
View Full Code Here


          - this.getStartAngle(), Arc2D.OPEN);
      g2.setPaint(this.getMajorTickPaint());
      g2.setStroke(arcStroke);
      g2.draw(arc);
     
      Point2D pt0 = arc.getEndPoint();
      arc.setArc(arcRectMajor, this.getStartAngle(), valueToAngle(v)
          - this.getStartAngle(), Arc2D.OPEN);
      Point2D pt1 = arc.getEndPoint();
      g2.setPaint(this.getMajorTickPaint());
      g2.setStroke(this.getMajorTickStroke());
      workingLine.setLine(pt0, pt1);
      g2.draw(workingLine);
      arc.setArc(arcRectForLabels, this.getStartAngle(), valueToAngle(v)
          - this.getStartAngle(), Arc2D.OPEN);
      Point2D pt2 = arc.getEndPoint();
     
      if (this.getTickLabelsVisible()) {
        if (!firstLabel || this.getFirstTickLabelVisible()) {
          g2.setFont(this.getTickLabelFont());
          TextUtilities.drawAlignedString(
              this.getTickLabelFormatter().format(v), g2,
              (float) pt2.getX(), (float) pt2.getY(),
              TextAnchor.CENTER);
        }
      }
      firstLabel = false;
     
      // now do the minor tick marks
      if (this.getMinorTickCount() > 0 && this.getMinorTickLength() > 0.0) {
        double minorTickIncrement = this.getMajorTickIncrement()
            / (this.getMinorTickCount() + 1);
        for (int i = 0; i < this.getMinorTickCount(); i++) {
          double vv = v + ((i + 1) * minorTickIncrement);
          if (vv >= this.getUpperBound()) {
            break;
          }
          double angle = valueToAngle(vv);

          arc.setArc(arcRect, this.getStartAngle(), angle
              - this.getStartAngle(), Arc2D.OPEN);
          pt0 = arc.getEndPoint();
          arc.setArc(arcRectMinor, this.getStartAngle(), angle
              - this.getStartAngle(), Arc2D.OPEN);
          Point2D pt3 = arc.getEndPoint();
          g2.setStroke(this.getMinorTickStroke());
          g2.setPaint(this.getMinorTickPaint());
          workingLine.setLine(pt0, pt3);
          g2.draw(workingLine);
        }
View Full Code Here

        if(constraints.getMinimumValue().doubleValue() > 0)
            ypt = constraints.getMinimumValue().doubleValue();
        else if(constraints.getMaximumValue().doubleValue() < 0)
            ypt = constraints.getMaximumValue().doubleValue();
       
        Point2D p = new Point2D.Double(0.0, 0.0);
        Point2D v;
        Line2D ticks = new Line2D.Double(0.0, 0.0, 0.0, 0.0);
       
    DecimalFormat df = c.getXDecimalFormat();
    FontRenderContext frc = c.getFontRenderContext();
        Font f = c.getFont();
       
    boolean paint = false;
   
        g.setFont(f);
        boolean paintLabels = c.isPaintLabels();
       
        for(double d = min; d <= max; d += tick) {
            p.setLocation(d, ypt);
            v = at.transform(p, null);
           
            ticks.setLine(v.getX(), v.getY() - marginOffset/2, v.getX(), v.getY() + marginOffset/2);
            g.draw(ticks);
            if(paint && paintLabels) {
                String sb = df.format(d);
                Rectangle2D r = f.getStringBounds(sb, frc);
               
                g.drawString(sb, (float)(v.getX() - r.getWidth() / 2),
              (float)(v.getY() + r.getHeight() + marginOffset));
            }
            paint = !paint;
        }
    }
View Full Code Here

        if(constraints.getMinimumValue().doubleValue() > 0)
            ypt = constraints.getMinimumValue().doubleValue();
        else if(constraints.getMaximumValue().doubleValue() < 0)
            ypt = constraints.getMaximumValue().doubleValue();
       
        Point2D p = new Point2D.Double(0.0, 0.0);
        Point2D v = null;
        Point2D oldv = null;
       
        Line2D ticks = new Line2D.Double(0.0, 0.0, 0.0, 0.0);
       
    DecimalFormat df = c.getXDecimalFormat();
    FontRenderContext frc = c.getFontRenderContext();
        Font f = c.getFont();
       
        boolean paint = false;
        boolean paintLabels = c.isPaintLabels();
        g.setFont(f);
       
        for(int i = min - 1; i < max; i++) {
            p.setLocation(i + 1, ypt);
           
            v = at.transform(p, null);
           
            ticks.setLine(v.getX(), v.getY() - marginOffset/2, v.getX(), v.getY() + marginOffset/2);
           
            if(i + 1 < max)
                g.draw(ticks);
           
            // Draw Strings between ticks
            if(oldv != null && paintLabels) {
                String sb = (String)model.getColumnValueAt(i);
                Rectangle2D r = f.getStringBounds(sb, frc);
               
                g.drawString(sb, (float)(oldv.getX()+(v.getX() - oldv.getX()) / 2 - r.getWidth() / 2),
                                (float)(v.getY() + r.getHeight() + marginOffset));
            }
           
            oldv = v;
        }
View Full Code Here

        if(constraints.getMinimumColumnValue() > 0)
            xpt = constraints.getMinimumColumnValue();
        else if(constraints.getMaximumColumnValue() < 0 && c.getSecondYAxis() != null)
            xpt = constraints.getMaximumColumnValue();
       
        Point2D p = new Point2D.Double(0.0, 0.0);
        Point2D v;
        Line2D ticks = new Line2D.Double(0.0, 0.0, 0.0, 0.0);
        boolean paint = false;
       
        DecimalFormat df = c.getYDecimalFormat();
    FontRenderContext frc = c.getFontRenderContext();
        Font f = c.getFont();
   
    Color backupColor = g.getColor();
        g.setFont(f);
        boolean paintLabels = c.isPaintLabels();
       
        for(double d = min; d <= max; d += tick) {
            p.setLocation(xpt, d);
            v = at.transform(p, null);
           
            ticks.setLine(v.getX() - marginOffset/2, v.getY(), v.getX() + marginOffset/2, v.getY());
           
      g.draw(ticks);
     
      if (d != min && !c.isPaintOnlyTick()) {
                Line2D xax = getXAxisLine2D();
                ticks.setLine(v.getX() + marginOffset/2, v.getY(), xax.getX2(), v.getY());
                g.setColor(Color.lightGray);
                g.draw(ticks);
                g.setColor(backupColor);
            }
           
            if(paintLabels && (paint || !c.isPaintAltTick())) {
                String sb = df.format(d);
                Rectangle2D r = f.getStringBounds(sb, frc);
               
                g.drawString(sb, (float)(v.getX() - r.getWidth() - marginOffset),
                            (float)(v.getY() + r.getHeight() / 2));
            }
            paint = !paint;
        }
    }
View Full Code Here

        else if(constraints.getMaximumValue().doubleValue() < 0)
            ypt = constraints.getMaximumValue().doubleValue();
       
        AffineTransform at = c.getTransform(CoordSystem.FIRST_YAXIS);
       
        Point2D l = at.transform(new Point2D.Double(constraints.getMinimumColumnValue(), ypt), null);
        Point2D r = at.transform(new Point2D.Double(constraints.getMaximumColumnValue(), ypt), null);
       
        return new Line2D.Double(l, r);
    }
View Full Code Here

        else if(constraints.getMaximumColumnValue() < 0 && c.getSecondYAxis() != null)
            xpt = constraints.getMaximumColumnValue();
       
        AffineTransform at = c.getTransform(CoordSystem.FIRST_YAXIS);
       
        Point2D o = at.transform(new Point2D.Double(xpt, constraints.getMaximumValue().doubleValue()), null);
        Point2D u = at.transform(new Point2D.Double(xpt, constraints.getMinimumValue().doubleValue()), null);
        //System.out.println("** Y-Axis ("+o+", "+u+")");
        return new Line2D.Double(o, u);
    }
View Full Code Here

    public Line2D getSecondYAxisLine2D() {
        double xpt = constraints2.getMaximumColumnValue();
       
        AffineTransform at = c.getTransform(CoordSystem.SECOND_YAXIS);
       
        Point2D o = at.transform(new Point2D.Double(xpt, constraints2.getMaximumValue().doubleValue()), null);
        Point2D u = at.transform(new Point2D.Double(xpt, constraints2.getMinimumValue().doubleValue()), null);
       
        return new Line2D.Double(o, u);
    }
View Full Code Here

                x0 = getBounds().getX()+getLeftMargin()+
                x.getPixelForValue(pt.getX());
               
                y0 = getBounds().getY()+getBounds().getHeight() - getBottomMargin() -
                y.getPixelForValue(pt.getY());
                Point2D p = new Point2D.Double(x0, y0);
               
                if(getInnerBounds().contains(p))
                    return p;
                else
                    return null;
View Full Code Here

        ))
      {
        // Get the fitting text!
        String textChunk = textFitter.getFittedText();
        float textChunkWidth = textFitter.getFittedWidth();
        Point2D textChunkLocation = new Point2D.Double(
          currentRow.width,
          currentRow.y
          );

        // Render the fitting text:
View Full Code Here

TOP

Related Classes of java.awt.geom.Point2D$Double

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.