pdf.java

来自「RESIN 3.2 最新源码」· Java 代码 · 共 1,058 行 · 第 1/2 页

JAVA
1,058
字号
  /**   * Ends the path   */  public boolean endpath()  {    _stream.endpath();    return true;  }  /**   * Draws a bezier curve   */  public boolean curveto(double x1, double y1,                         double x2, double y2,                         double x3, double y3)  {    _stream.curveTo(x1, y1, x2, y2, x3, y3);    return true;  }  /**   * Draws a bezier curve   */  public boolean curveto_b(double x1, double y1,                           double x2, double y2)  {    _stream.curveTo(x1, y1, x1, y1, x2, y2);    return true;  }  /**   * Draws a bezier curve   */  public boolean curveto_e(double x1, double y1,                           double x2, double y2)  {    _stream.curveTo(x1, y1, x2, y2, x2, y2);    return true;  }  /**   * Creates a counterclockwise arg   */  public boolean arc(double x1, double y1, double r, double a, double b)  {    a = a % 360;    if (a < 0)      a += 360;    b = b % 360;    if (b < 0)      b += 360;    if (b < a)      b += 360;    int aQuarter = (int) (a / 90);    int bQuarter = (int) (b / 90);    if (aQuarter == bQuarter) {      clockwiseArc(x1, y1, r, a, b);    }    else {      clockwiseArc(x1, y1, r, a, (aQuarter + 1) * 90);      for (int q = aQuarter + 1; q < bQuarter; q++)        clockwiseArc(x1, y1, r, q * 90, (q + 1) * 90);      clockwiseArc(x1, y1, r, bQuarter * 90, b);    }    return true;  }  /**   * Creates a clockwise arc   */  public boolean arcn(double x1, double y1, double r, double a, double b)  {    a = a % 360;    if (a < 0)      a += 360;    b = b % 360;    if (b < 0)      b += 360;    if (a < b)      a += 360;    int aQuarter = (int) (a / 90);    int bQuarter = (int) (b / 90);    if (aQuarter == bQuarter) {      counterClockwiseArc(x1, y1, r, a, b);    }    else {      counterClockwiseArc(x1, y1, r, a, aQuarter * 90);      for (int q = aQuarter - 1; bQuarter < q; q--)        counterClockwiseArc(x1, y1, r, (q + 1) * 90, q * 90);      counterClockwiseArc(x1, y1, r, (bQuarter + 1) * 90, b);    }    return true;  }  /**   * Creates an arc from 0 to pi/2   */  private boolean clockwiseArc(double x, double y, double r,                               double aDeg, double bDeg)  {    double a = aDeg * Math.PI / 180.0;    double b = bDeg * Math.PI / 180.0;    double cos_a = Math.cos(a);    double sin_a = Math.sin(a);    double x1 = x + r * cos_a;    double y1 = y + r * sin_a;    double cos_b = Math.cos(b);    double sin_b = Math.sin(b);    double x2 = x + r * cos_b;    double y2 = y + r * sin_b;    double l = KAPPA * r * 2 * (b - a) / Math.PI;    lineto(x1, y1);    curveto(x1 - l * sin_a, y1 + l * cos_a,            x2 + l * sin_b, y2 - l * cos_b,            x2, y2);    return true;  }  /**   * Creates an arc from 0 to pi/2   */  private boolean counterClockwiseArc(double x, double y, double r,                                      double aDeg, double bDeg)  {    double a = aDeg * Math.PI / 180.0;    double b = bDeg * Math.PI / 180.0;    double cos_a = Math.cos(a);    double sin_a = Math.sin(a);    double x1 = x + r * cos_a;    double y1 = y + r * sin_a;    double cos_b = Math.cos(b);    double sin_b = Math.sin(b);    double x2 = x + r * cos_b;    double y2 = y + r * sin_b;    double l = KAPPA * r * 2 * (a - b) / Math.PI;    lineto(x1, y1);    curveto(x1 + l * sin_a, y1 - l * cos_a,            x2 - l * sin_b, y2 + l * cos_b,            x2, y2);    return true;  }  /**   * Creates a circle   */  public boolean circle(double x1, double y1, double r)  {    double l = r * KAPPA;    moveto(x1, y1 + r);    curveto(x1 - l, y1 + r, x1 - r, y1 + l, x1 - r, y1);    curveto(x1 - r, y1 - l, x1 - l, y1 - r, x1, y1 - r);    curveto(x1 + l, y1 - r, x1 + r, y1 - l, x1 + r, y1);    curveto(x1 + r, y1 + l, x1 + l, y1 + r, x1, y1 + r);    return true;  }  /**   * Sets the graphics position.   */  public boolean lineto(double x, double y)  {    _stream.lineTo(x, y);    return true;  }  /**   * Sets the graphics position.   */  public boolean moveto(double x, double y)  {    _stream.moveTo(x, y);    return true;  }  /**   * Creates a rectangle   */  public boolean rect(double x, double y, double width, double height)  {    _stream.rect(x, y, width, height);    return true;  }  /**   * Sets the color to a grayscale   */  public boolean setgray_stroke(double g)  {    return _stream.setcolor("stroke", "gray", g, 0, 0, 0);  }  /**   * Sets the color to a grayscale   */  public boolean setgray_fill(double g)  {    return _stream.setcolor("fill", "gray", g, 0, 0, 0);  }  /**   * Sets the color to a grayscale   */  public boolean setgray(double g)  {    return _stream.setcolor("both", "gray", g, 0, 0, 0);  }  /**   * Sets the color to a rgb   */  public boolean setrgbcolor_stroke(double r, double g, double b)  {    return _stream.setcolor("stroke", "rgb", r, g, b, 0);  }  /**   * Sets the fill color to a rgb   */  public boolean setrgbcolor_fill(double r, double g, double b)  {    return _stream.setcolor("fill", "rgb", r, g, b, 0);  }  /**   * Sets the color to a rgb   */  public boolean setrgbcolor(double r, double g, double b)  {    return _stream.setcolor("both", "rgb", r, g, b, 0);  }  /**   * Sets the color   */  public boolean setcolor(String fstype, String colorspace,                          double c1,                          @Optional double c2,                          @Optional double c3,                          @Optional double c4)  {    return _stream.setcolor(fstype, colorspace, c1, c2, c3, c4);  }  /**   * Sets the line width   */  public boolean setlinewidth(double w)  {    return _stream.setlinewidth(w);  }  /**   * Concatenates the matrix   */  public boolean concat(double a, double b, double c,                        double d, double e, double f)  {    return _stream.concat(a, b, c, d, e, f);  }  /**   * open image   */  public PDFImage open_image_file(String type, Path file,                                  @Optional String stringParam,                                  @Optional int intParam)    throws IOException  {    PDFImage img = new PDFImage(file);    img.setId(_out.allocateId(1));    _out.addPendingObject(img);    return img;  }  /**   * open image   */  public PDFImage load_image(String type,                             Path file,                             @Optional String optlist)    throws IOException  {    PDFImage img = new PDFImage(file);    img.setId(_out.allocateId(1));    _out.addPendingObject(img);    return img;  }  public boolean fit_image(PDFImage img, double x, double y,                           @Optional String opt)  {    _page.addResource(img.getResource());    _stream.save();    concat(img.get_width(), 0, 0, img.get_height(), x, y);    _stream.fit_image(img);    _stream.restore();    return true;  }  /**   * Skews the coordinates   *   * @param a degrees to skew the x axis   * @param b degrees to skew the y axis   */  public boolean skew(double aDeg, double bDeg)  {    double a = aDeg * Math.PI / 180;    double b = bDeg * Math.PI / 180;    return _stream.concat(1, Math.tan(a), Math.tan(b), 1, 0, 0);  }  /**   * scales the coordinates   *   * @param sx amount to scale the x axis   * @param sy amount to scale the y axis   */  public boolean scale(double sx, double sy)  {    return _stream.concat(sx, 0, 0, sy, 0, 0);  }  /**   * translates the coordinates   *   * @param tx amount to translate the x axis   * @param ty amount to translate the y axis   */  public boolean translate(double tx, double ty)  {    return _stream.concat(1, 0, 0, 1, tx, ty);  }  /**   * rotates the coordinates   *   * @param p amount to rotate   */  public boolean rotate(double pDeg)  {    double p = pDeg * Math.PI / 180;    return _stream.concat(Math.cos(p), Math.sin(p),                          -Math.sin(p), Math.cos(p),                          0, 0);  }  /**   * Saves the graphics state.   */  public boolean save()  {    return _stream.save();  }  /**   * Restores the graphics state.   */  public boolean restore()  {    return _stream.restore();  }  /**   * Displays text   */  public boolean show(String text)  {    _stream.show(text);    return true;  }  /**   * Displays text   */  public boolean show_boxed(String text, double x, double y,                            double width, double height,                            String mode, @Optional String feature)  {    set_text_pos(x, y);    _stream.show(text);    return true;  }  /**   * Displays text   */  public boolean show_xy(String text, double x, double y)  {    set_text_pos(x, y);    _stream.show(text);    return true;  }  /**   * Draws the graph   */  public boolean stroke()  {    _stream.stroke();    return true;  }  /**   * Displays text   */  public boolean continue_text(String text)  {    _stream.continue_text(text);    return true;  }  public boolean end_page()  {    _stream.flush();    PDFProcSet procSet = _stream.getProcSet();    _page.addResource(procSet.getResource());    _page = null;    _stream = null;    return true;  }  public boolean end_page_ext(String optlist)  {    return end_page();  }  public boolean end_document(@Optional String optList)    throws IOException  {    if (_pageGroup.size() > 0) {      _out.writePageGroup(_pageParentId, _pageGroup);      _pageGroup.clear();      if (_pagesGroupList.size() > 0)        _pagesGroupList.add(_pageParentId);    }    _out.writeCatalog(_catalogId, _pageParentId, _pagesGroupList, _pageCount);    _out.endDocument();    _os.close();    _out = null;    return true;  }  public boolean close()    throws IOException  {    return end_document("");  }  public boolean delete()    throws IOException  {    return true;  }  public String toString()  {    return "PDF[]";  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?