Exemplo n.º 1
0
  /** Constructor for objects of class CoffeeCup */
  public HouseWithWindows(double x, double y, double width, double height) {
    // construct the basic house shell
    super(x, y, width, height);

    // get the GeneralPath that we are going to append stuff to
    GeneralPath gp = this.get();

    // Make three windows, spaced like this, where w=width/10.0;
    // | +--+ +--+ +--+ |
    // | |  | |  | |  | |
    // | +--+ +--+ +--+ |
    // |w 2w w 2w w w2 w|
    //
    // The top of window will be at y + 0.5*height and the
    // height of the window is 0.25height;

    double w = 0.10 * width;
    double winTop = y + 0.5 * height;
    double winHt = 0.25 * height;

    Rectangle2D.Double win1 = new Rectangle2D.Double(x + w, winTop, 2.0 * w, winHt);
    Rectangle2D.Double win2 = new Rectangle2D.Double(x + 4.0 * w, winTop, 2.0 * w, winHt);
    Rectangle2D.Double win3 = new Rectangle2D.Double(x + 7.0 * w, winTop, 2.0 * w, winHt);

    // add the windows to the house
    // Look up the meaning of the second parameter of append
    // (Hint--is a method of "GeneralPath")

    GeneralPath wholeHouse = this.get();
    wholeHouse.append(win1, false);
    wholeHouse.append(win2, false);
    wholeHouse.append(win3, false);
  }
Exemplo n.º 2
0
  /**
   * Constructor
   *
   * @param x x coord of top left corner of the rectangle surrounding the person
   * @param y y coord of top left corner of the rectangle surrounding the person
   * @param width width of the rectangle surrounding the person
   * @param height of the rectangle surrounding the person
   */
  public Person(double x, double y, double width, double height) {
    // The head takes up 25% of the
    double headWidth = width * .25;
    double headHeight = height * .20;
    double headTop = 0f;
    double headBottom = height * .25;
    double armTop = height * .30;
    double armBottom = height * .45;
    double legTop = height * .70;
    double legBottom = height;
    double center = width / 2;
    double armWidth = width / 3;
    double legWidth = width / 4;
    Ellipse2D head =
        new Ellipse2D.Double(
            x + center - headWidth / 2, y + headBottom - headHeight, headWidth, headHeight);

    Line2D.Double body = new Line2D.Double(center + x, headBottom + y, center + x, legTop + y);
    Line2D.Double leftArm =
        new Line2D.Double(center + x, armTop + y, center + x - armWidth, armBottom + y);
    Line2D.Double rightArm =
        new Line2D.Double(center + x, armTop + y, center + x + armWidth, armBottom + y);
    Line2D.Double leftLeg =
        new Line2D.Double(center + x, legTop + y, center + x - legWidth, legBottom + y);
    Line2D.Double rightLeg =
        new Line2D.Double(center + x, legTop + y, center + x + legWidth, legBottom + y);

    GeneralPath wholePerson = this.get();
    wholePerson.append(head, false);
    wholePerson.append(body, false);
    wholePerson.append(leftArm, false);
    wholePerson.append(rightArm, false);
    wholePerson.append(leftLeg, false);
    wholePerson.append(rightLeg, false);
  }
Exemplo n.º 3
0
  public void drawPage(Graphics2D g2) {
    FontRenderContext context = g2.getFontRenderContext();
    Font f = new Font("Serif", Font.PLAIN, 72);
    GeneralPath clipShape = new GeneralPath();

    TextLayout layout = new TextLayout("2426打印指南", f, context);
    AffineTransform transform = AffineTransform.getTranslateInstance(0, 72);
    Shape outline = layout.getOutline(transform);
    clipShape.append(outline, false);

    layout = new TextLayout("thank you", f, context);
    transform = AffineTransform.getTranslateInstance(0, 144);
    outline = layout.getOutline(transform);
    clipShape.append(outline, false);

    g2.draw(clipShape);
    g2.clip(clipShape);

    final int NLINES = 50;
    Point2D p = new Point2D.Double(0, 0);
    for (int i = 0; i < NLINES; i++) {
      double x = (2 * getWidth() * i) / NLINES;
      double y = (2 * getHeight() * (NLINES - 1 - i)) / NLINES;
      Point2D q = new Point2D.Double(x, y);
      g2.draw(new Line2D.Double(p, q));
    }
  }
Exemplo n.º 4
0
  @Override
  public void draw(Graphics2D g2d) {
    final Dimension2D dimTotal = getDimension(StringBounderUtils.asStringBounder(g2d));

    // Shape ellipse = new Ellipse2D.Double(0, 0, dimTotal.getWidth(),
    // dimTotal.getHeight());
    final GeneralPath ellipse = new GeneralPath();
    final double h = dimTotal.getHeight();
    final double w = dimTotal.getWidth();
    ellipse.append(new QuadCurve2D.Double(0, h / 2, 0, 0, w / 2, 0), true);
    ellipse.append(new QuadCurve2D.Double(w / 2, 0, w, 0, w, h / 2), true);
    ellipse.append(new QuadCurve2D.Double(w, h / 2, w, h, w / 2, h), true);
    ellipse.append(new QuadCurve2D.Double(w / 2, h, 0, h, 0, h / 2), true);
    g2d.setColor(getYellow());
    g2d.fill(ellipse);

    g2d.setColor(getRed());
    g2d.draw(ellipse);

    final Dimension2D nameDim = name.calculateDimension(StringBounderUtils.asStringBounder(g2d));
    final double posx = (w - nameDim.getWidth()) / 2;
    final double posy = (h - nameDim.getHeight()) / 2;
    final Shape rect = new Rectangle2D.Double(posx, posy, nameDim.getWidth(), nameDim.getHeight());
    // g2d.draw(rect);

    g2d.setColor(Color.BLACK);
    name.drawTOBEREMOVED(g2d, posx, posy);
  }
Exemplo n.º 5
0
  /**
   * Constructor
   *
   * @param x x coord of lower left corner of house
   * @param y y coord of lower left corner of house
   * @param width width of the house
   * @param height of house (including first story and second story)
   */
  public House(double x, double y, double width, double height) {

    // Rather than having to scale at the end, we can just
    // draw things the right way to begin with, using the
    // x, y, width and height.   If you haven't already
    // hard coded a particular drawing, this may be an easier
    // way.

    double firstStoryHeight = .75 * height;
    double roofHeight = height - firstStoryHeight;

    double firstStoryUpperLeftY = y + roofHeight;

    // Make the first story

    Rectangle2D.Double firstStory =
        new Rectangle2D.Double(x, firstStoryUpperLeftY, width, firstStoryHeight);

    // make the roof.   Remember that y goes DOWN the page,
    // so we ADD to y to get a "lower" value on the screen

    Line2D.Double leftRoof = new Line2D.Double(x, y + roofHeight, x + width / 2.0, y);

    Line2D.Double rightRoof = new Line2D.Double(x + width / 2.0, y, x + width, y + roofHeight);

    // put the whole house together

    GeneralPath wholeHouse = this.get();
    wholeHouse.append(firstStory, false);
    wholeHouse.append(leftRoof, false);
    wholeHouse.append(rightRoof, false);
  }
  public static GeneralPath filter(GeneralPath in) {
    GeneralPath out = new GeneralPath();
    PathIterator it = in.getPathIterator(null);
    float[] seg = new float[6];
    float px = 0, py = 0;

    int n = 0;
    GeneralPath next = new GeneralPath();

    while (!it.isDone()) {
      int l = it.currentSegment(seg);

      double d = Math.sqrt((px - seg[0]) * (px - seg[0]) + (py - seg[1]) * (py - seg[1]));
      if (d > 20) {
        l = PathIterator.SEG_MOVETO;
      }

      if (l == PathIterator.SEG_MOVETO) {
        if (n > 50) out.append(next.getPathIterator(null), false);
        next = new GeneralPath();
        next.moveTo(seg[0], seg[1]);
        n = 0;
      } else {
        next.lineTo(seg[0], seg[1]);
        n++;
      }
      px = seg[0];
      py = seg[1];
      it.next();
    }
    if (n > 50) out.append(next.getPathIterator(null), false);
    return out;
  }
Exemplo n.º 7
0
  /**
   * Build a shape for the entire subtree by joining together the shapes for each of its edges.
   * Vertices included since needed for FullTextPanel.
   */
  public Shape constructInternalShape(DiagramBase diagram, boolean includeVertices) {
    GeneralPath shape = new GeneralPath();
    Enumeration edges = m_edgeList.elements();
    while (edges.hasMoreElements()) {
      TreeEdge edge = (TreeEdge) edges.nextElement();
      Shape edgeShape = edge.getSchemeShape(diagram);
      PathIterator path = edgeShape.getPathIterator(null);
      shape.append(path, false);

      if (includeVertices) {
        Shape vertexShape;
        if (!edge.getSourceVertex().isVirtual()) {
          vertexShape = edge.getSourceVertex().getShape(diagram);
          path = vertexShape.getPathIterator(null);
          shape.append(path, false);
        }
        if (!edge.getDestVertex().isVirtual()) {
          vertexShape = edge.getDestVertex().getShape(diagram);
          path = vertexShape.getPathIterator(null);
          shape.append(path, false);
        }
      }
    }
    BasicStroke stroke =
        new BasicStroke(
            diagram.getSubtreeLineWidth() - DiagramBase.EDGE_OUTLINE_WIDTH + 1,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_MITER);
    internalShapeTable.put(diagram, stroke.createStrokedShape(shape));
    return (Shape) internalShapeTable.get(diagram);
  }
Exemplo n.º 8
0
  /** Constructor for objects of class CoffeeCup */
  public CoffeeCup(double x, double y, double width, double height) {

    // Specify the upper left corner, and the
    //  width and height of the original points used to
    //  plot the *hard-coded* coffee cup

    final double ORIG_ULX = 100.0;
    final double ORIG_ULY = 100.0;
    final double ORIG_HEIGHT = 300.0;
    final double ORIG_WIDTH = 400.0;

    GeneralPath leftSide = new GeneralPath();

    // left side of cup

    leftSide.moveTo(200, 400);
    leftSide.lineTo(160, 360);
    leftSide.lineTo(130, 300);
    leftSide.lineTo(100, 200);
    leftSide.lineTo(100, 100);

    GeneralPath topAndBottom = new GeneralPath();

    topAndBottom.moveTo(100, 100);
    topAndBottom.lineTo(500, 100); // top of cup

    topAndBottom.moveTo(200, 400);
    topAndBottom.lineTo(400, 400); // bottom of cup

    Shape rightSide = ShapeTransforms.horizontallyFlippedCopyOf(leftSide);

    // after flipping around the upper left hand corner of the
    // bounding box, we move this over to the right by 400 pixels

    rightSide = ShapeTransforms.translatedCopyOf(rightSide, 400.0, 0.0);

    // now we put the whole thing together ino a single path.

    GeneralPath wholeCup = new GeneralPath();
    wholeCup.append(topAndBottom, false);
    wholeCup.append(leftSide, false);
    wholeCup.append(rightSide, false);

    // translate to the origin by subtracting the original upper left x and y
    // then translate to (x,y) by adding x and y

    Shape s = ShapeTransforms.translatedCopyOf(wholeCup, -ORIG_ULX + x, -ORIG_ULY + y);

    // scale to correct height and width
    s = ShapeTransforms.scaledCopyOf(s, width / ORIG_WIDTH, height / ORIG_HEIGHT);

    // Use the GeneralPath constructor that takes a shape and returns
    // it as a general path to set our instance variable cup

    this.set(new GeneralPath(s));
  }
Exemplo n.º 9
0
  /**
   * Constructor
   *
   * @param x x coord of tip of mountain
   * @param y y coord of tip of mountain
   * @param width width of mountain
   * @param height height of mountain
   */
  public Mountain(double x, double y, double width, double height) {

    Line2D.Double leftSlope = new Line2D.Double(x - width / 2.0, y + height, x, y);

    Line2D.Double rightSlope = new Line2D.Double(x, y, x + width / 2.0, y + height);

    GeneralPath wholeMountain = this.get();
    wholeMountain.append(leftSlope, false);
    wholeMountain.append(rightSlope, false);
  }
Exemplo n.º 10
0
  /**
   * Constructor
   *
   * @param x x coord of lower left corner of car (exluding wheels)
   * @param y y coord of lower left corner of car (excluding wheels)
   * @param width width of the car
   * @param height height of car
   * @param wheelRadius radius of the wheels
   */
  public Car(double x, double y, double width, double height) {
    double wheelDiameter = 2 * width * .125;
    // Rather than having to scale at the end, we can just
    Rectangle2D.Double carBody = new Rectangle2D.Double(x, y, width, height);
    Ellipse2D.Double leftWheel =
        new Ellipse2D.Double(x + .125 * width, y + height, wheelDiameter, wheelDiameter);
    Ellipse2D.Double rightWheel =
        new Ellipse2D.Double(x + .625 * width, y + height, wheelDiameter, wheelDiameter);
    // put the whole car together

    GeneralPath wholeCar = this.get();
    wholeCar.append(carBody, false);
    wholeCar.append(leftWheel, false);
    wholeCar.append(rightWheel, false);
  }
Exemplo n.º 11
0
    public void draw(Graphics p_graphics) {

      if (!location_initialized) {
        return;
      }
      Graphics2D g2 = (Graphics2D) p_graphics;
      init_graphics(g2);
      GeneralPath draw_path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
      draw_path.append(VERTICAL_LINE, false);
      draw_path.append(HORIZONTAL_LINE, false);
      draw_path.append(RIGHT_DIAGONAL_LINE, false);
      draw_path.append(LEFT_DIAGONAL_LINE, false);
      g2.translate(this.x_coor, this.y_coor);
      g2.draw(draw_path);
    }
Exemplo n.º 12
0
  /**
   * Constructor
   *
   * @param x x coord of lower left corner of egg carton
   * @param y y coord of lower left corner of egg carton
   * @param width width of the egg carton
   * @param height of egg carton
   */
  public EggCarton(double x, double y, double width, double height) {

    Rectangle2D.Double carton = new Rectangle2D.Double(x, y, width, 0.45 * width);

    GeneralPath wholeCarton = this.get();
    wholeCarton.append(carton, false);
  }
Exemplo n.º 13
0
 /**
  * Returns the outline of this glyph. This will be positioned correctly and any glyph transforms
  * will have been applied.
  *
  * @return the outline of this glyph.
  */
 public Shape getOutline() {
   if (outline == null) {
     AffineTransform tr = AffineTransform.getTranslateInstance(position.getX(), position.getY());
     if (transform != null) {
       tr.concatenate(transform);
     }
     Shape glyphChildrenOutline = null;
     if (glyphChildrenNode != null) {
       glyphChildrenOutline = glyphChildrenNode.getOutline();
     }
     GeneralPath glyphOutline = null;
     if (dShape != null && glyphChildrenOutline != null) {
       glyphOutline = new GeneralPath(dShape);
       glyphOutline.append(glyphChildrenOutline, false);
     } else if (dShape != null && glyphChildrenOutline == null) {
       glyphOutline = new GeneralPath(dShape);
     } else if (dShape == null && glyphChildrenOutline != null) {
       glyphOutline = new GeneralPath(glyphChildrenOutline);
     } else {
       // must be a whitespace glyph, return an empty shape
       glyphOutline = new GeneralPath();
     }
     outline = tr.createTransformedShape(glyphOutline);
   }
   return outline;
 }
Exemplo n.º 14
0
  /**
   * Constructor for objects of class ShipwithFunnels this one asks you to input numoffunnels which
   * is the number of funnels you want the ship to have
   */
  public ShipwithFunnels(double x, double y, double width, double height, int numoffunnels) {
    // construct the basic ship shell
    super(x, y, width, height);

    // get the GeneralPath that we are going to append stuff to
    GeneralPath gp = this.get();

    // Make a funnel;
    // | 	+--+ +--+	|
    // | 	|  | |  |	|
    // |	+--+ +--+ 	|
    // |5w	 w 	w  w 5w |
    //
    // The width of funnel will be 1/11 of ship's width and the
    // height of the funnel is 1*height;

    double w = width / 13;
    double funnelTop = y - height;
    double funnelHt = height;
    int margin = (13 - (numoffunnels * 2 - 1)) / 2;

    GeneralPath wholeShip = this.get();
    for (int i = 0; i < numoffunnels; i++) {
      Rectangle2D.Double funnel1 =
          new Rectangle2D.Double(x + margin * w + i * 2 * w, funnelTop, w, funnelHt);

      wholeShip.append(funnel1, false);
    }
  }
Exemplo n.º 15
0
  /** Render a compound glyf */
  protected GeneralPath renderCompoundGlyph(GlyfTable glyf, GlyfCompound g) {
    GeneralPath gp = new GeneralPath();

    for (int i = 0; i < g.getNumComponents(); i++) {
      // find and render the component glyf
      Glyf gl = glyf.getGlyph(g.getGlyphIndex(i));
      GeneralPath path = null;
      if (gl instanceof GlyfSimple) {
        path = renderSimpleGlyph((GlyfSimple) gl);
      } else if (gl instanceof GlyfCompound) {
        path = renderCompoundGlyph(glyf, (GlyfCompound) gl);
      } else {
        throw new RuntimeException("Unsupported glyph type " + gl.getClass().getCanonicalName());
      }

      // multiply the translations by units per em
      double[] matrix = g.getTransform(i);

      // transform the path
      path.transform(new AffineTransform(matrix));

      // add it to the global path
      gp.append(path, false);
    }

    return gp;
  }
Exemplo n.º 16
0
  /**
   * Default Constructor for objects of class ShipwithFunnels this one gives one funnel on the ship
   */
  public ShipwithFunnels(double x, double y, double width, double height) {
    // construct the basic ship shell
    super(x, y, width, height);

    // get the GeneralPath that we are going to append stuff to
    GeneralPath gp = this.get();

    // Make a funnel;
    // | 	+--+ 	|
    // | 	|  |	|
    // |	+--+ 	|
    // |6w	 w 	  6w|
    //
    // The width of funnel will be 1/11 of ship's width and the
    // height of the funnel is 1*height;

    double w = width / 13;
    double funnelTop = y - height;
    double funnelHt = height;

    Rectangle2D.Double funnel1 = new Rectangle2D.Double(x + 6 * w, funnelTop, w, funnelHt);

    // add the funnel to the ship

    GeneralPath wholeShip = this.get();
    wholeShip.append(funnel1, false);
  }
  /**
   * displays the tag using the renderer
   *
   * @param renderer EMFRenderer storing the drawing session data
   * @param closePath if true the path is closed and filled
   */
  protected void render(EMFRenderer renderer, boolean closePath) {
    // create a GeneralPath containing GeneralPathes
    GeneralPath path = new GeneralPath(renderer.getWindingRule());

    // iterate the polgons
    Point p;
    for (int polygon = 0; polygon < numberOfPoints.length; polygon++) {

      // create a new member of path
      GeneralPath gp = new GeneralPath(renderer.getWindingRule());
      for (int point = 0; point < numberOfPoints[polygon]; point++) {
        // add a point to gp
        p = points[polygon][point];
        if (point > 0) {
          gp.lineTo((float) p.getX(), (float) p.getY());
        } else {
          gp.moveTo((float) p.getX(), (float) p.getY());
        }
      }

      // close the member, add it to path
      if (closePath) {
        gp.closePath();
      }

      path.append(gp, false);
    }

    // draw the complete path
    if (closePath) {
      renderer.fillAndDrawOrAppend(path);
    } else {
      renderer.drawOrAppend(path);
    }
  }
Exemplo n.º 18
0
  /**
   * Constructor
   *
   * @param x - x coord of the center of the cookie
   * @param y - y coord of the center of the cookie
   * @param radius - radius of cookie
   */
  public Cookie(double x, double y, double r) {

    // Rather than having to scale at the end, we can just
    // draw things the right way to begin with, using the
    // x, y, and radius.   If you haven't already
    // hard coded a particular drawing, this may be an easier
    // way.
    GeneralPath cookie = this.get();
    cookie.append(new Circle(x, y, r), false);
  }
Exemplo n.º 19
0
 public void ellipse(double x, double y, double w, double h) {
   currentPath = new GeneralPath();
   currentPath.append(
       new Ellipse2D.Double(
           (state.dx + x) * state.scale,
           (state.dy + y) * state.scale,
           w * state.scale,
           h * state.scale),
       false);
 }
Exemplo n.º 20
0
  private GeneralPath subdivide(Point b0, Point b1, Point b2, Point b3) {
    double cutDistance = getTargetAnchorShape().getCutDistance();
    double minDistance = cutDistance - ENDPOINT_DEVIATION;
    /**
     * if the cutDistance is valid the last segment of the curve gets reduced by subdivision until
     * the distance of the endpoint(epDistance) satisfys the condition (cutDistance > epDistance >
     * (cutDistance - ENDPOINT-DEVIATION)
     */
    if (cutDistance > minDistance && minDistance > 0) {
      GeneralPath path = new GeneralPath();

      path.moveTo(b0.x, b0.y);

      CubicCurve2D.Double left =
          new CubicCurve2D.Double(
              b0.x, b0.y,
              b1.x, b1.y,
              b2.x, b2.y,
              b3.x, b3.y);

      CubicCurve2D right = new CubicCurve2D.Double();
      left.subdivide(left, right);
      double distance = b3.distance(left.getP2());
      // if the distance is bigger as the cutDistance the left segment is added
      // and the right segment is divided again
      while (distance > cutDistance) {
        path.append(left, true);
        right.subdivide(left, right);
        distance = b3.distance(left.getP2());
        // if the devision removed to much the left segment is divided
        while (distance < minDistance) {
          // changes the distance to ~ (distance+distance/2)
          left.subdivide(left, right);
          distance = b3.distance(left.getP2());
        }
      }
      // append the last segment with (minDistance < distance < cutDistance)
      // actually we should check if the a division happend, but this is very unlikly
      path.append(left, true);
      return path;
    }
    return null;
  }
Exemplo n.º 21
0
  /**
   * Constructor for objects of class Balloon
   *
   * @param x x coordinate of center of Balloon
   * @param y y coordinate of center of Balloon
   * @param r radius of Balloon
   */
  public Balloon(double x, double y, double r) {

    double upperLeftX = x - r;
    double upperLeftY = y - r;
    double width = 2 * r;
    double height = 3 * r;

    Ellipse2D.Double b = new Ellipse2D.Double(upperLeftX, upperLeftY, width, height);
    GeneralPath balloon = this.get();
    balloon.append(b, false);
  }
Exemplo n.º 22
0
  public GeneralPath getPath(double x, double y, double width, double height) {

    // Width and height have correct ratio;
    GeneralPath path = new GeneralPath();
    double[] points = new double[] {x, y, x + width, y, x + width, y + height, x, y + height};
    double[] midpts =
        new double[] {
          x + width, y + height / 2., x + width / 2., y, x, y + height / 2., x + width / 2., y
        };

    int d = direction;
    path.moveTo(points[d % 8], points[d % 8]);

    //		path.curveTo(points[d++ % 8], points[d++ % 8], points[d++ % 8], points[d++ % 8], points[d++
    // % 8],
    //				points[d++ % 8]);

    QuadCurve2D curve =
        new QuadCurve2D.Double(
            points[d++ % 8],
            points[d++ % 8],
            points[d++ % 8],
            points[d++ % 8],
            midpts[direction],
            midpts[direction + 1]);
    path.append(curve, true);

    curve =
        new QuadCurve2D.Double(
            midpts[direction],
            midpts[direction + 1],
            points[d++ % 8],
            points[d++ % 8],
            points[d++ % 8],
            points[d++ % 8]);
    path.append(curve, true);

    path.lineTo(points[d++ % 8], points[d++ % 8]);

    return path;
  }
Exemplo n.º 23
0
  /** Constructor for objects of class Stopsign, sticks a hexagon on top of pole */
  public Stopsign(double x, double y, double width, double height) {
    // construct the pole
    super(x, y, width, height);

    // get the GeneralPath that we are going to append stuff to
    GeneralPath gp = this.get();

    //  side 3   _
    // side 2   / \ side 4
    // side 1   \_/ side 5   No need to draw the bottomside because it will be attached to the top
    // of the pole
    //

    Line2D.Double side =
        new Line2D.Double(x, y, x - width * Math.sin(120), y - width * Math.sin(120));
    Line2D.Double side2 =
        new Line2D.Double(
            x - width * Math.sin(120), y - width * Math.sin(120), x, y - 2 * width * Math.sin(120));
    Line2D.Double side3 =
        new Line2D.Double(
            x, y - 2 * width * Math.sin(120), x + width, y - 2 * width * Math.sin(120));
    Line2D.Double side4 =
        new Line2D.Double(
            x + width,
            y - 2 * width * Math.sin(120),
            x + width + width * Math.sin(120),
            y - width * Math.sin(120));
    Line2D.Double side5 =
        new Line2D.Double(
            x + width + width * Math.sin(120), y - width * Math.sin(120), x + width, y);

    // add the lines to the pole

    GeneralPath completeStopSign = this.get();
    completeStopSign.append(side, false);
    completeStopSign.append(side2, false);
    completeStopSign.append(side3, false);
    completeStopSign.append(side4, false);
    completeStopSign.append(side5, false);
  }
Exemplo n.º 24
0
 public void appendShape(GeneralPath gp, DrawAreaInterface da, UserFunction own)
     throws MathException {
   AffPoint s, e;
   s = (AffPoint) ((UserFunction) startPoint).eval();
   e = (AffPoint) ((UserFunction) endPoint).eval();
   gp.append(
       new Line2D.Double(
           da.xCoordToPix(s.evalX()),
           da.yCoordToPix(s.evalY()),
           da.xCoordToPix(e.evalX()),
           da.yCoordToPix(e.evalY())),
       true);
 }
  /**
   * Returns a shape that can be draw.
   *
   * <p>It is recommended to call getShape() every time a draw is needed because the shape does not
   * update if the EditGeom is updated between draws. getShape is guaranteed to get a shape that is
   * representative of the current state of geom.
   *
   * @return
   */
  public Shape toShape() {
    prepareToPath();

    if (geom.getShell().getNumPoints() == 1) {
      Shape createPoint = createPoint();
      if (createPoint != null) return createPoint;
    }
    GeneralPath path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);

    path.append(this, false);

    return path;
  }
Exemplo n.º 26
0
 public void addTextSprite(TextSprite nextSprite) {
   Area area = nextSprite.getGlyphOutline();
   // When TJ/Tj and Other text operators are called on a font using
   // modes 5-7 we don't actually craw anything but we still need to
   // transform the glyph to the correct coordinate, so each
   // outline is place correctly with in the total outline shape.
   Area tmp = area.createTransformedArea(nextSprite.getGraphicStateTransform());
   if (path == null) {
     path = new GeneralPath(tmp);
   } else {
     path.append(tmp, false);
   }
 }
Exemplo n.º 27
0
 /** Build a shape for the entire subtree by joining together the shapes for each of its edges. */
 public Shape constructFullTextShape(DiagramBase diagram) {
   GeneralPath shape = new GeneralPath();
   Enumeration edges = m_edgeList.elements();
   while (edges.hasMoreElements()) {
     TreeEdge edge = (TreeEdge) edges.nextElement();
     if (!edge.visible) {
       continue;
     }
     Shape edgeShape = edge.getSchemeShape(diagram);
     PathIterator path = edgeShape.getPathIterator(null);
     shape.append(path, false);
     TreeVertex vertex = edge.getSourceVertex();
     if (!vertex.isVirtual()) {
       shape.append(vertex.getShape(diagram).getPathIterator(null), false);
     }
     vertex = edge.getDestVertex();
     if (!vertex.isVirtual()) {
       shape.append(vertex.getShape(diagram).getPathIterator(null), false);
     }
   }
   BasicStroke stroke = new BasicStroke(20, BasicStroke.CAP_ROUND, BasicStroke.JOIN_MITER);
   shapeTable.put(diagram, stroke.createStrokedShape(shape));
   return (Shape) shapeTable.get(diagram);
 }
Exemplo n.º 28
0
 // public void drawOld(Graphics2D g2d, double x, double y) {
 // for (CubicCurve2D.Double bez : beziers) {
 // bez = new CubicCurve2D.Double(x + bez.x1, y + bez.y1, x + bez.ctrlx1, y +
 // bez.ctrly1, x + bez.ctrlx2, y
 // + bez.ctrly2, x + bez.x2, y + bez.y2);
 // g2d.draw(bez);
 // }
 // }
 //
 public void draw(Graphics2D g2d, double x, double y) {
   final GeneralPath p = new GeneralPath();
   for (CubicCurve2D.Double bez : beziers) {
     bez =
         new CubicCurve2D.Double(
             x + bez.x1,
             y + bez.y1,
             x + bez.ctrlx1,
             y + bez.ctrly1,
             x + bez.ctrlx2,
             y + bez.ctrly2,
             x + bez.x2,
             y + bez.y2);
     p.append(bez, true);
   }
   g2d.draw(p);
 }
Exemplo n.º 29
0
  public Shape getShape(Rectangle2D bounds) {
    /*
     *  Start  Width = 8 * w, Height = 8 * h
     *  x      __
     *       _|  |_
     *     _|      |_
     *   _|  _    _  |_
     *  |   |_|  |_|   |
     *  |___   __   ___|
     *     _|_|__|_|_
     *   _|_|_|__|_|_|_
     *  |_| |_|  |_| |_|
     *
     */
    int x = (int) bounds.getX();
    int y = (int) bounds.getY();
    int w = (int) (bounds.getWidth() / 8);
    int h = (int) (bounds.getHeight() / 8);
    GeneralPath path = new GeneralPath();
    path.moveTo(x, y + 3 * h);
    path.lineTo(x + w, y + 3 * h);
    path.lineTo(x + w, y + 2 * h);
    path.lineTo(x + 2 * w, y + 2 * h);
    path.lineTo(x + 2 * w, y + h);
    path.lineTo(x + 3 * w, y + h);
    path.lineTo(x + 3 * w, y);
    path.lineTo(x + 5 * w, y);
    path.lineTo(x + 5 * w, y + h);
    path.lineTo(x + 6 * w, y + h);
    path.lineTo(x + 6 * w, y + 2 * h);
    path.lineTo(x + 7 * w, y + 2 * h);
    path.lineTo(x + 7 * w, y + 3 * h);
    path.lineTo(x + 8 * w, y + 3 * h);
    path.lineTo(x + 8 * w, y + 5 * h);
    path.lineTo(x, y + 5 * h);
    path.lineTo(x, y + 2 * h);

    path.append(new Rectangle2D.Double(x + 2 * w, y + 5 * h, w, h), false);
    path.append(new Rectangle2D.Double(x + 5 * w, y + 5 * h, w, h), false);
    path.append(new Rectangle2D.Double(x + w, y + 6 * h, w, h), false);
    path.append(new Rectangle2D.Double(x + 3 * w, y + 6 * h, 2 * w, h), false);
    path.append(new Rectangle2D.Double(x + 6 * w, y + 6 * h, w, h), false);
    path.append(new Rectangle2D.Double(x, y + 7 * h, w, h), false);
    path.append(new Rectangle2D.Double(x + 2 * w, y + 7 * h, w, h), false);
    path.append(new Rectangle2D.Double(x + 5 * w, y + 7 * h, w, h), false);
    path.append(new Rectangle2D.Double(x + 7 * w, y + 7 * h, w, h), false);
    return path;
  }
Exemplo n.º 30
0
  /**
   * converts this glyph into Shape. It could be called for root's preview mode or by include
   * invoke. Pushing either this GlyphFile or DIncludeInvoke should be handled before this.
   */
  public Shape toShape(AffineTransform a_trans) {

    int ppem = k_defaultPixelSize;

    GeneralPath retval = new GeneralPath();
    Iterator i = createIterator();
    while (i.hasNext()) {
      GlyphObject object = (GlyphObject) i.next();

      if (object instanceof EContourPoint || object instanceof EHint) {
        continue;
      } // if

      retval.append(object.toShape(a_trans, ppem), false);
    } // if

    return retval;
  }