コード例 #1
0
ファイル: SVGApplet.java プロジェクト: shahidminhas/abc
 public String getData() {
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   try {
     getDrawing().getOutputFormats().get(0).write(out, getDrawing());
     return out.toString("UTF8");
   } catch (IOException e) {
     SVGTextFigure tf = new SVGTextFigure();
     tf.setText(e.getMessage());
     tf.setBounds(new Point2D.Double(10, 10), new Point2D.Double(100, 100));
     getDrawing().add(tf);
     e.printStackTrace();
     return "";
   }
 }
コード例 #2
0
 private void writeTextElement(IXMLElement parent, SVGTextFigure f) throws IOException {
     IXMLElement elem = parent.createElement("AREA");
     Rectangle2D.Double rect = f.getBounds();
     double grow = getPerpendicularHitGrowth(f);
     rect.x -= grow;
     rect.y -= grow;
     rect.width += grow;
     rect.height += grow;
     if (writeRectAttributes(elem, f, rect)) {
         parent.addChild(elem);
     }
 }
コード例 #3
0
ファイル: SVGApplet.java プロジェクト: shahidminhas/abc
  public void setData(String text) {
    if (text != null && text.length() > 0) {
      InputStream in = null;
      try {
        Object result = null;
        Drawing drawing = createDrawing();
        // Try to read the data using all known input formats.
        for (InputFormat fmt : drawing.getInputFormats()) {
          try {
            fmt.read(in, drawing);
            in = new ByteArrayInputStream(text.getBytes("UTF8"));
            result = drawing;
            break;
          } catch (IOException e) {
            result = e;
          }
        }
        if (result instanceof IOException) {
          throw (IOException) result;
        }

        setDrawing(drawing);
      } catch (Throwable e) {
        getDrawing().removeAllChildren();
        SVGTextFigure tf = new SVGTextFigure();
        tf.setText(e.getMessage());
        tf.setBounds(new Point2D.Double(10, 10), new Point2D.Double(100, 100));
        getDrawing().add(tf);
        e.printStackTrace();
      } finally {
        if (in != null) {
          try {
            in.close();
          } catch (IOException ex) {
            ex.printStackTrace();
          }
        }
      }
    }
  }
コード例 #4
0
ファイル: SVGTextFigure.java プロジェクト: DevBoost/Reuseware
 public SVGTextFigure clone() {
   SVGTextFigure that = (SVGTextFigure) super.clone();
   that.coordinates = new Point2D.Double[this.coordinates.length];
   for (int i = 0; i < this.coordinates.length; i++) {
     that.coordinates[i] = (Point2D.Double) this.coordinates[i].clone();
   }
   that.rotates = (double[]) this.rotates.clone();
   that.cachedBounds = null;
   that.cachedDrawingArea = null;
   that.cachedTextShape = null;
   return that;
 }