Package java.awt.geom

Examples of java.awt.geom.Line2D$Double


    {
      // here comes the magic - we transform the line into the absolute space;
      // this should preserve the general appearance. Heck, and if not, then
      // it is part of the users reponsibility to resolve that. Magic does not
      // solve all problems, you know.
      final Line2D line = new Line2D.Float
          (Math.abs(x1), Math.abs(y1), Math.abs(x2), Math.abs(y2));
      final Rectangle2D shapeBounds = line.getBounds2D();
      final Shape transformedShape =
          ShapeTransform.translateShape(line, -shapeBounds.getX(), -shapeBounds.getY());
      // and use that shape with the user's bounds to create the element.
      final ContentElementFactory elementFactory = new ContentElementFactory();
      elementFactory.setName(name);
View Full Code Here


   */
  private static Line2D resizeLine(final Line2D line,
                                   final double width,
                                   final double height)
  {
    final Line2D newLine = getNormalizedLine(line);
    final Point2D p1 = newLine.getP1();
    final Point2D p2 = newLine.getP2();
    final double normPointX = (p1.getX() - p2.getX());
    final double normPointY = (p1.getY() - p2.getY());
    final double scaleX = (normPointX == 0) ? 1 : width / Math.abs(normPointX);
    final double scaleY = (normPointY == 0) ? 1 : height / Math.abs(normPointY);
    p2.setLocation((p2.getX() - p1.getX()) * scaleX + p1.getX(),
        (p2.getY() - p1.getY()) * scaleY + p1.getY());
    newLine.setLine(p1, p2);
    return newLine;
  }
View Full Code Here

   * @param line the original line
   * @return the normalized line
   */
  private static Line2D getNormalizedLine(final Line2D line)
  {
    final Line2D lineClone = (Line2D) line.clone();

    final Point2D p1 = line.getP1();
    final Point2D p2 = line.getP2();
    if (p1.getX() < p2.getX())
    {
      return lineClone;
    }
    if (p1.getX() > p2.getX())
    {
      lineClone.setLine(p2, p1);
      return lineClone;
    }
    if (p1.getY() < p2.getY())
    {
      return lineClone;
    }
    lineClone.setLine(p2, p1);
    return lineClone;
  }
View Full Code Here

   */
  public static Shape performCliping(final Shape s, final Rectangle2D bounds)
  {
    if (s instanceof Line2D)
    {
      final Line2D line = (Line2D) s;
      final Point2D[] clipped = getClipped
          (line.getX1(), line.getY1(), line.getX2(), line.getY2(),
              -DELTA, DELTA + bounds.getWidth(),
              -DELTA, DELTA + bounds.getHeight());
      if (clipped == null)
      {
        return new GeneralPath();
View Full Code Here

      retval.setFrame(retval.getX() + x, retval.getY() + y, retval.getWidth(), retval.getHeight());
      return retval;
    }
    if (s instanceof Line2D)
    {
      final Line2D line = (Line2D) s;
      final Line2D retval = (Line2D) line.clone();
      retval.setLine(retval.getX1() + x, retval.getY1() + y,
          retval.getX2() + x, retval.getY2() + y);
      return retval;
    }

    final AffineTransform af = AffineTransform.getTranslateInstance(x, y);
    return af.createTransformedShape(s);
View Full Code Here

    final StyleSheet styleSheet = node.getStyleSheet();
    final boolean draw = styleSheet.getBooleanStyleProperty(ElementStyleKeys.DRAW_SHAPE);
    if (draw && shape instanceof Line2D)
    {
      final Line2D line = (Line2D) shape;

      final boolean vertical = line.getX1() == line.getX2();
      final boolean horizontal = line.getY1() == line.getY2();
      if (vertical && horizontal)
      {
        // not a valid line ..
        return;
      }
      if (vertical == false && horizontal == false)
      {
        // not a valid line ..
        return;
      }
      if (retval == null)
      {
        retval = new CellBackground();
      }
      final BorderEdge edge = ProcessUtility.produceBorderEdge(styleSheet);
      if (vertical)
      {
        if (line.getX1() == 0)
        {
          if ((backgroundHint & BACKGROUND_LEFT) == BACKGROUND_LEFT)
          {
            retval.setLeft(edge);
          }
          else if ((backgroundHint & BACKGROUND_RIGHT) == BACKGROUND_RIGHT)
          {
            final RenderBox nodeParent = node.getParent();
            if (nodeParent != null && (nodeParent.getX() + nodeParent.getWidth()) == (nodeX + nodeWidth))
            {
              retval.setRight(edge);
            }
          }
        }
        else
        {
          if ((backgroundHint & BACKGROUND_RIGHT) == BACKGROUND_RIGHT)
          {
            retval.setRight(edge);
          }
        }
      }
      else
      {
        if (line.getY1() == 0)
        {
          if ((backgroundHint & BACKGROUND_TOP) == BACKGROUND_TOP)
          {
            retval.setTop(edge);
          }
View Full Code Here

    for (int i = getLowest(); i <= highest; i++)
    {
      for (int j = 0; j < 10; j++)
      {
        final double xx = valueToJava2D(i + j / 10.0, area);
        final Line2D mark = new Line2D.Double(xx, area.getCenterY() - 2.0, xx,
            area.getCenterY() + 2.0);
        g2.draw(mark);
      }
    }
    final double xx = valueToJava2D(highest, area);
    final Line2D mark = new Line2D.Double(xx, area.getCenterY() - 2.0, xx,
        area.getCenterY() + 2.0);
    g2.draw(mark);
  }
View Full Code Here

    Point2D one = new Point2D.Double(xx + 6, yy + hh / 2);
    // calculate point two
    Point2D two = new Point2D.Double(xx + ww - 6, yy + hh / 2);

    // draw a line connecting the points
    Line2D line = new Line2D.Double(one, two);
    if (stroke != null) {
      g2.setStroke(stroke);
    }
    else{
      g2.setStroke(new BasicStroke());
View Full Code Here

        // determine the end points
        double lX = center_x + (lLineValue * Math.sin(lRotation));
        double lY = center_y + (lLineValue * Math.cos(lRotation));

        // draw the line
        Line2D lLine = new Line2D.Double(center_x, center_y, lX, lY);
            g.setColor(Color.black);
            g.draw(lLine);

        // add to polygone
        if (lCol == 0) filledPolygon.moveTo((float)lX, (float)lY);
        else filledPolygon.lineTo((float)lX, (float)lY);           
      }
     
      // draw the polygone
      filledPolygon.closePath();
      g.setPaint( rcm.getColor(lRow) );
      g.draw(filledPolygon);
        }
       
        double lRotation;
        double lX;
        double lY;
        TextLayout lLabel;

    // draw the lines
    for (int lCol = 0; lCol < lNumberOfColumns; lCol++)
    {
      // determine rotation: there are 2PI/noOfCols vertexes, this is vertex no lCol   
      // -1 : we want to rotate clockwise
      // + PI: rotate 180 degree to get the first column pointing up
            // Math.PI ... - Math.PI
      lRotation = (-1 * (2 * Math.PI / lNumberOfColumns) * lCol) + Math.PI;

      // determine the end points
      lX = center_x + (lRadius * Math.sin(lRotation));
      lY = center_y + (lRadius * Math.cos(lRotation));

      // draw the line
      Line2D lLine = new Line2D.Double(center_x, center_y, lX, lY );
          g.setColor(Color.black);
          g.draw(lLine);

          // draw the label
          lLabel = new TextLayout("" + model.getColumnValueAt(lCol), new Font("Courier", Font.BOLD, 9), new FontRenderContext(null, true, false));
View Full Code Here

    gp.closePath();
    g2.setPaint(this.fillPaint);
    g2.fill(gp);

    g2.setPaint(this.getOutlinePaint());
    Line2D line = new Line2D.Double(frame.getCenterX(),
        frame.getCenterY(), pt1.getX(), pt1.getY());
//    g2.draw(line);

    line.setLine(pt2, pt3);
    g2.draw(line);

    line.setLine(pt3, pt1);
    g2.draw(line);

    line.setLine(pt2, pt1);
    g2.draw(line);

    line.setLine(pt2, pt4);
    g2.draw(line);

    line.setLine(pt3, pt4);
    g2.draw(line);
  }
View Full Code Here

TOP

Related Classes of java.awt.geom.Line2D$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.