Package java.awt.geom

Examples of java.awt.geom.Line2D


        this.getTickRadius() - this.getTickLabelOffset());
   
    boolean firstLabel = true;
   
    Arc2D arc = new Arc2D.Double();
    Line2D workingLine = new Line2D.Double();
    Stroke arcStroke = new BasicStroke(0.75f);
   
    for (double v = this.getLowerBound(); v <= this.getUpperBound();
        v += this.getMajorTickIncrement()) {
      arc.setArc(arcRect, this.getStartAngle(), valueToAngle(v)
          - 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


        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);
               
View Full Code Here

       
        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
View Full Code Here

        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);
            }
           
View Full Code Here

     * @param g the <CODE>Graphics2D</CODE> object to paint in
     */
    public void paintDefault(Graphics2D g) {
        g.setColor(Color.black);
       
        Line2D x = c.getXAxisLine2D();
        Line2D y = c.getYAxisLine2D();
       
        g.draw(x);
        g.draw(y);
       
        // draw X-Axis Arrow
    if(shouldDrawArrows) {
      g.drawLine((int)x.getX2(), (int)x.getY2(), (int)x.getX2() + ARROWLENGTH, (int)x.getY2());
      g.fillPolygon(new int[] {(int)(x.getX2() + ARROWLENGTH / 3.0),
            (int)(x.getX2() + ARROWLENGTH / 3.0),
            (int)(x.getX2() + ARROWLENGTH)},
            new int[] {(int)x.getY2() - 3, (int)x.getY2() + 3, (int)x.getY2()},
            3);
    }
       
        // draw X-Axis label right below the Arrow ?!
        g.setColor(Color.black);
        TextLayout layoutX = new TextLayout(getXAxisUnit(), getFont(),
                                           new FontRenderContext(null, true, false));
    layoutX.draw(g, (float)x.getX2() + (float)ARROWLENGTH / 3(float)x.getY2() + (float)layoutX.getBounds().getHeight() + 5);
       
        // draw Y-Axis Arrow
    if(shouldDrawArrows) {
      g.drawLine((int)y.getX1(), (int)y.getY1(), (int)y.getX1(), (int)y.getY1() - ARROWLENGTH);
      g.fillPolygon(new int[] {(int)(y.getX1() - 3),
            (int)(y.getX1() + 3),
            (int)(y.getX1())},
            new int[] {(int)(y.getY1() - ARROWLENGTH / 3.0),
            (int)(y.getY1() - ARROWLENGTH / 3.0),
            (int)y.getY1() - ARROWLENGTH},
            3);
    }

        // draw Y-Axis label right below the Arrow ?!
        g.setColor(Color.black);
        TextLayout layoutY = new TextLayout(getYAxisUnit(), getFont(),
                                           new FontRenderContext(null, true, false));
        layoutY.draw(g, (float)y.getX1()-6-(float)layoutY.getBounds().getWidth(),
                        (float)y.getY1() - layoutX.getDescent() - 3);
       
        if(getSecondYAxis() != null) {
            Line2D y2 = c.getSecondYAxisLine2D();
            g.draw(y2);
        }
       
        if(model.isColumnNumeric())
            c.drawNumericalXAxisTicks(g);
View Full Code Here

    /* (non-Javadoc)
     * @see org.jpox.store.mapping.JavaTypeMapping#setObject(org.jpox.ObjectManager, java.lang.Object, int[], java.lang.Object)
     */
    public void setObject(ObjectManager om, Object preparedStatement, int[] exprIndex, Object value)
    {
      Line2D line = (Line2D)value;
        if (line == null)
        {
        for (int i = 0; i < exprIndex.length; i++)
        {
          getDataStoreMapping(i).setObject(preparedStatement, exprIndex[i], null);         
      }
        }
        else
        {
            getDataStoreMapping(0).setDouble(preparedStatement,exprIndex[0],line.getX1());
            getDataStoreMapping(1).setDouble(preparedStatement,exprIndex[1],line.getY1());
            getDataStoreMapping(2).setDouble(preparedStatement,exprIndex[2],line.getX2());
            getDataStoreMapping(3).setDouble(preparedStatement,exprIndex[3],line.getY2());
        }
    }
View Full Code Here

   * the point at (<code>x</code>, <code>y</code>)
   * with a given <code>margin</code> around the wall start line.
   */
  public boolean containsWallStartAt(float x, float y, float margin) {
    float [][] wallPoints = getPoints();
    Line2D startLine = new Line2D.Float(wallPoints [0][0], wallPoints [0][1],
        wallPoints [wallPoints.length - 1][0], wallPoints [wallPoints.length - 1][1]);
    return containsShapeAtWithMargin(startLine, x, y, margin);
  }
View Full Code Here

   * the point at (<code>x</code>, <code>y</code>)
   * with a given <code>margin</code> around the wall end line.
   */
  public boolean containsWallEndAt(float x, float y, float margin) {
    float [][] wallPoints = getPoints();
    Line2D endLine = new Line2D.Float(wallPoints [wallPoints.length / 2 - 1][0], wallPoints [wallPoints.length / 2 - 1][1],
        wallPoints [wallPoints.length / 2][0], wallPoints [wallPoints.length / 2][1]);
    return containsShapeAtWithMargin(endLine, x, y, margin);
  }
View Full Code Here

   * contains the point at (<code>x</code>, <code>y</code>)
   * with a given <code>margin</code> around the extension line.
   */
  public boolean containsStartExtensionLinetAt(float x, float y, float margin) {
    double angle = Math.atan2(this.yEnd - this.yStart, this.xEnd - this.xStart);
    Line2D startExtensionLine = new Line2D.Float(this.xStart, this.yStart,
        this.xStart + (float)-Math.sin(angle) * this.offset,
        this.yStart + (float)Math.cos(angle) * this.offset);
    return containsShapeAtWithMargin(startExtensionLine, x, y, margin);
  }
View Full Code Here

   * contains the point at (<code>x</code>, <code>y</code>)
   * with a given <code>margin</code> around the extension line.
   */
  public boolean containsEndExtensionLineAt(float x, float y, float margin) {
    double angle = Math.atan2(this.yEnd - this.yStart, this.xEnd - this.xStart);
    Line2D endExtensionLine = new Line2D.Float(this.xEnd, this.yEnd,
        this.xEnd + (float)-Math.sin(angle) * this.offset,
        this.yEnd + (float)Math.cos(angle) * this.offset);
    return containsShapeAtWithMargin(endExtensionLine, x, y, margin);
  }
View Full Code Here

TOP

Related Classes of java.awt.geom.Line2D

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.