示例#1
0
 private void visitDefs(DocumentVisitor db) {
   // Visit all definition of the svg-document
   NodeList nl = svgRoot.getElementsByTagName("defs");
   for (int i = 0; i < nl.getLength(); i++) {
     if (nl.item(i) instanceof SVGDefsElement) {
       SVGDefsElement svgDefs = (SVGDefsElement) nl.item(i);
       NodeList dnl = svgDefs.getChildNodes();
       for (int j = 0; j < dnl.getLength(); j++) {
         if (dnl.item(j) instanceof SVGPatternElement) {
           db.visitSVGPatternElement((SVGPatternElement) dnl.item(j));
         } else if (dnl.item(j) instanceof SVGFilterElement) {
           db.visitSVGFilterElement((SVGFilterElement) dnl.item(j));
         }
       }
     }
   }
 }
示例#2
0
  private void visitGroup(DocumentVisitor db, SVGGElement group) {

    db.visitSVGGElement(group);
    NodeList nl = group == null ? svgRoot.getChildNodes() : group.getChildNodes();

    for (int i = 0; i < nl.getLength(); i++) {
      if (nl.item(i) instanceof SVGGElement) {
        visitGroup(db, (SVGGElement) nl.item(i));
        visitStyleAttributes(db, ((SVGGElement) nl.item(i)).getAttributeNode("style"));
      } else if (nl.item(i) instanceof SVGPathElement) {
        visitPathSeg(db, (SVGPathElement) nl.item(i));
        visitStyleAttributes(db, ((SVGPathElement) nl.item(i)).getAttributeNode("style"));
      } else if (nl.item(i) instanceof SVGCircleElement) {
        db.visitSVGCircleElement((SVGCircleElement) nl.item(i));
        visitStyleAttributes(db, ((SVGCircleElement) nl.item(i)).getAttributeNode("style"));
      } else if (nl.item(i) instanceof SVGEllipseElement) {
        db.visitSVGEllipseElement((SVGEllipseElement) nl.item(i));
        visitStyleAttributes(db, ((SVGEllipseElement) nl.item(i)).getAttributeNode("style"));
      } else if (nl.item(i) instanceof SVGRectElement) {
        db.visitSVGRectElement((SVGRectElement) nl.item(i));
        visitStyleAttributes(db, ((SVGRectElement) nl.item(i)).getAttributeNode("style"));
      } else if (nl.item(i) instanceof SVGLineElement) {
        db.visitSVGLineElement((SVGLineElement) nl.item(i));
        visitStyleAttributes(db, ((SVGLineElement) nl.item(i)).getAttributeNode("style"));
      } else if (nl.item(i) instanceof SVGPolylineElement) {
        db.visitSVGPolylineElement((SVGPolylineElement) nl.item(i));
        visitStyleAttributes(db, ((SVGPolylineElement) nl.item(i)).getAttributeNode("style"));
      }
    }

    db.visitSVGGElementClose(group);
  }
示例#3
0
  private void visitPathSeg(DocumentVisitor db, SVGPathElement svgPath) {
    db.visitSVGPathElement(svgPath);

    SVGPathSegList psl = svgPath.getPathSegList();
    SVGPathSeg ps;

    for (int i = 0; i < psl.getNumberOfItems(); i++) {
      ps = psl.getItem(i);

      switch (ps.getPathSegType()) {
        case SVGPathSeg.PATHSEG_MOVETO_ABS:
          db.visitSVGPathSegMovetoAbs((SVGPathSegMovetoAbs) ps);
          break;
        case SVGPathSeg.PATHSEG_MOVETO_REL:
          db.visitSVGPathSegMovetoRel((SVGPathSegMovetoRel) ps);
          break;
        case SVGPathSeg.PATHSEG_LINETO_ABS:
          db.visitSVGPathSegLinetoAbs((SVGPathSegLinetoAbs) ps);
          break;
        case SVGPathSeg.PATHSEG_LINETO_REL:
          db.visitSVGPathSegLinetoRel((SVGPathSegLinetoRel) ps);
          break;
        case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_ABS:
          db.visitSVGPathSegLinetoHorizontalAbs((SVGPathSegLinetoHorizontalAbs) ps);
          break;
        case SVGPathSeg.PATHSEG_LINETO_HORIZONTAL_REL:
          db.visitSVGPathSegLinetoHorizontalRel((SVGPathSegLinetoHorizontalRel) ps);
          break;
        case SVGPathSeg.PATHSEG_LINETO_VERTICAL_ABS:
          db.visitSVGPathSegLinetoVerticalAbs((SVGPathSegLinetoVerticalAbs) ps);
          break;
        case SVGPathSeg.PATHSEG_LINETO_VERTICAL_REL:
          db.visitSVGPathSegLinetoVerticalRel((SVGPathSegLinetoVerticalRel) ps);
          break;
        case SVGPathSeg.PATHSEG_CURVETO_CUBIC_ABS:
          db.visitSVGPathSegCurvetoCubicAbs((SVGPathSegCurvetoCubicAbs) ps);
          break;
        case SVGPathSeg.PATHSEG_CURVETO_CUBIC_REL:
          db.visitSVGPathSegCurvetoCubicRel((SVGPathSegCurvetoCubicRel) ps);
          break;
        case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_ABS:
          db.visitSVGPathSegCurvetoCubicSmoothAbs((SVGPathSegCurvetoCubicSmoothAbs) ps);
          break;
        case SVGPathSeg.PATHSEG_CURVETO_CUBIC_SMOOTH_REL:
          db.visitSVGPathSegCurvetoCubicSmoothRel((SVGPathSegCurvetoCubicSmoothRel) ps);
          break;
        case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_ABS:
          db.visitSVGPathSegCurvetoQuadraticAbs((SVGPathSegCurvetoQuadraticAbs) ps);
          break;
        case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_REL:
          db.visitSVGPathSegCurvetoQuadraticRel((SVGPathSegCurvetoQuadraticRel) ps);
          break;
        case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_ABS:
          db.visitSVGPathSegCurvetoQuadraticSmoothAbs((SVGPathSegCurvetoQuadraticSmoothAbs) ps);
          break;
        case SVGPathSeg.PATHSEG_CURVETO_QUADRATIC_SMOOTH_REL:
          db.visitSVGPathSegCurvetoQuadraticSmoothRel((SVGPathSegCurvetoQuadraticSmoothRel) ps);
          break;
        case SVGPathSeg.PATHSEG_ARC_ABS:
          db.visitSVGPathSegArcAbs((SVGPathSegArcAbs) ps);
          break;
        case SVGPathSeg.PATHSEG_ARC_REL:
          db.visitSVGPathSegArcRel((SVGPathSegArcRel) ps);
          break;
        case SVGPathSeg.PATHSEG_CLOSEPATH:
          db.visitSVGPathSegClosePath((SVGPathSegClosePath) ps);
          break;
        default:
          throw new java.lang.IllegalStateException(
              "Unknown type of SVGPathSegm in SVGPathElement!");
      }
    }
  }