Package java.awt.geom

Examples of java.awt.geom.Point2D


    if (totalHeight < width) totalHeight = width;
   
    GeneralPath path = computeShield(width, totalHeight);
    for (int i = 0; i < inputs; i++) {
      Location loci = OrGate.FACTORY.getInputOffset(attrs, i);
      Point2D p = new Point2D.Float(loci.getX() + 1, loci.getY());
      int iters = 0;
      while (path.contains(p) && iters < 15) {
        iters++;
        p.setLocation(p.getX() + 1, p.getY());
      }
      if (iters >= 15) iters = 0;
      lengths[i] = iters;
    }
   
View Full Code Here


            String string, JustificationInfo info, GlyphVector vector) {
        float adjust = 0.0f;
        for (int i = 0; i < string.length(); i++) {
            char c = string.charAt(i);
            if (i != 0) {
                Point2D point = vector.getGlyphPosition(i);
                vector.setGlyphPosition(
                        i, new Point2D.Double(point.getX() + adjust, point.getY()));
            }
            if (c == ' ' || c == '\u00a0' || c == '\u3000') {
                adjust += info.getSpaceAdjust();
            } else {
                adjust += info.getNonSpaceAdjust();
View Full Code Here

            bounds = box.getPaintingInfo().getAggregateBounds();
        } else {
            bounds = box.getContentAreaEdge(box.getAbsX(), box.getAbsY(), c);
        }

        Point2D docCorner = new Point2D.Double(bounds.x, bounds.y + bounds.height);
        Point2D pdfCorner = new Point.Double();
        _transform.transform(docCorner, pdfCorner);
        pdfCorner.setLocation(pdfCorner.getX(), normalizeY((float) pdfCorner.getY()));

        com.lowagie.text.Rectangle result = new com.lowagie.text.Rectangle(
                (float) pdfCorner.getX(), (float) pdfCorner.getY(),
                (float) pdfCorner.getX() + getDeviceLength(bounds.width),
                (float) pdfCorner.getY() + getDeviceLength(bounds.height));
        return result;
    }
View Full Code Here

    }

    final String positionText = result1.getProperty("position");
    if (positionText != null)
    {
      final Point2D pos = (Point2D) new Point2DConverter().convertFromString(positionText, getLocator());
      getStyle().setStyleProperty(ElementStyleKeys.POS_X, new Float(pos.getX()));
      getStyle().setStyleProperty(ElementStyleKeys.POS_Y, new Float(pos.getY()));
    }

    final String minSizeText = result1.getProperty("minimumSize");
    if (minSizeText != null)
    {
View Full Code Here

   *
   * @return The object.
   */
  public Object createObject()
  {
    final Point2D point = new Point2D.Float();

    final float x = getFloatParameter("x");
    final float y = getFloatParameter("y");
    point.setLocation(x, y);
    return point;
  }
View Full Code Here

    if (!(o instanceof Point2D))
    {
      throw new ObjectFactoryException("The given object is no java.awt.geom.Point2D.");
    }

    final Point2D point = (Point2D) o;
    final float x = (float) point.getX();
    final float y = (float) point.getY();

    setParameter("x", new Float(x));
    setParameter("y", new Float(y));
  }
View Full Code Here

      }
    }
    else if (paint instanceof GradientPaint)
    {
      final GradientPaint gp = (GradientPaint) paint;
      final Point2D p1 = gp.getPoint1();
      transform.transform(p1, p1);
      final Point2D p2 = gp.getPoint2();
      transform.transform(p2, p2);
      final Color c1 = gp.getColor1();
      final Color c2 = gp.getColor2();
      final PdfShading shading = PdfShading.simpleAxial(cb.getPdfWriter(), (float) p1.getX(), normalizeY(
          (float) p1.getY()), (float) p2.getX(), normalizeY((float) p2.getY()), c1, c2);
      final PdfShadingPattern pat = new PdfShadingPattern(shading);
      if (fill)
      {
        cb.setShadingFill(pat);
      }
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

   */
  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

                                      final double x2, final double y2, final int mask2,
                                      final double xmin, final double xmax,
                                      final double ymin, final double ymax)
  {
    final int mask = mask1 ^ mask2;
    Point2D p1 = null;

    if (mask1 == INSIDE)
    {
      // point 1 is internal
      p1 = new Point2D.Double(x1, y1);
      if (mask == 0)
      {
        // both masks are the same, so the second point is inside, too
        final Point2D[] ret = new Point2D[2];
        ret[0] = p1;
        ret[1] = new Point2D.Double(x2, y2);
        return ret;
      }
    }
    else if (mask2 == INSIDE)
    {
      // point 2 is internal
      p1 = new Point2D.Double(x2, y2);
    }

    if ((mask & LEFT) != 0)
    {
      //      System.out.println("Trying left");
      // try to calculate intersection with left line
      final Point2D p = intersect(x1, y1, x2, y2, xmin, ymin, xmin, ymax);
      if (p != null)
      {
        if (p1 == null)
        {
          p1 = p;
        }
        else
        {
          final Point2D[] ret = new Point2D[2];
          ret[0] = p1;
          ret[1] = p;
          return ret;
        }
      }
    }
    if ((mask & RIGHT) != 0)
    {
      //      System.out.println("Trying right");
      // try to calculate intersection with left line
      final Point2D p = intersect(x1, y1, x2, y2, xmax, ymin, xmax, ymax);
      if (p != null)
      {
        if (p1 == null)
        {
          p1 = p;
        }
        else
        {
          final Point2D[] ret = new Point2D[2];
          ret[0] = p1;
          ret[1] = p;
          return ret;
        }
      }
    }
    if (mask1 == (LEFT | BELOW) || mask1 == (RIGHT | BELOW))
    {
      // for exactly these two special cases use different sequence!

      if ((mask & ABOVE) != 0)
      {
        //      System.out.println("Trying top");
        // try to calculate intersection with lower line
        final Point2D p = intersect(x1, y1, x2, y2, xmin, ymax, xmax, ymax);
        if (p != null)
        {
          if (p1 == null)
          {
            p1 = p;
          }
          else
          {
            final Point2D[] ret = new Point2D[2];
            ret[0] = p1;
            ret[1] = p;
            return ret;
          }
        }
      }
      if ((mask & BELOW) != 0)
      {
        //      System.out.println("Trying bottom");
        // try to calculate intersection with lower line
        final Point2D p = intersect(x1, y1, x2, y2, xmin, ymin, xmax, ymin);
        if (p != null && p1 != null)
        {
          final Point2D[] ret = new Point2D[2];
          ret[0] = p1;
          ret[1] = p;
          return ret;
        }
      }
    }
    else
    {
      if ((mask & BELOW) != 0)
      {
        //      System.out.println("Trying bottom");
        // try to calculate intersection with lower line
        final Point2D p = intersect(x1, y1, x2, y2, xmin, ymin, xmax, ymin);
        if (p != null)
        {
          if (p1 == null)
          {
            p1 = p;
          }
          else
          {
            final Point2D[] ret = new Point2D[2];
            ret[0] = p1;
            ret[1] = p;
            return ret;
          }
        }
      }
      if ((mask & ABOVE) != 0)
      {
        //      System.out.println("Trying top");
        // try to calculate intersection with lower line
        final Point2D p = intersect(x1, y1, x2, y2, xmin, ymax, xmax, ymax);
        if (p != null && p1 != null)
        {
          final Point2D[] ret = new Point2D[2];
          ret[0] = p1;
          ret[1] = p;
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.