tonyiris
tonyiris
采纳率0%
2020-04-13 17:18 阅读 207

哪位大神弄过 通过JAVA用aspose.diagram导出viso

10

哪位大神用过aspose.diagram for java的,自己做的一个小例子,用代码画了3个Shape,从上到下连接,现在的效果是,3个Shape是出来了,但是Shape之间的连接线不知道怎么画。。话不多说,贴代码上图

import com.aspose.diagram.Connect;
import com.aspose.diagram.Diagram;
import com.aspose.diagram.FromPartValue;
import com.aspose.diagram.SaveFileFormat;

public class Test {

    public static String BASE_PATH  =  "D:/";

    public static void main(String[] args)  throws Exception{
        // 存放路径
        String dataDir = BASE_PATH + "viso/";
        // 画图表
        Diagram diagram = new Diagram();

        //master名称
        String masterName = "Internet";
        String masterName2 = "Firewall";
        String masterName3 = "Device";
        // Add master with stencil file path and master name
        diagram.addMaster(dataDir + "test.vss", masterName);
        diagram.addMaster(dataDir + "test.vss", masterName2);
        diagram.addMaster(dataDir + "test.vss", masterName3);

        //坐标信息
        int PageIndex = 0;
        double width = 2, height = 2, pinX = 4, pinY = 10;
        double width2 = 2, height2 = 2, pinX2 = 4, pinY2 = 6;
        double width3 = 2, height3 = 2, pinX3 = 4, pinY3 = 2;

        // 增加图形
        Long internetId = diagram.addShape(pinX, pinY, width, height, masterName, PageIndex);
        Long firewallId = diagram.addShape(pinX2, pinY2, width2, height2, masterName2, PageIndex);
        Long deviceId = diagram.addShape(pinX3, pinY3, width3, height3, masterName3, PageIndex);

        //定义连接线。。是这样定义的吗,没有效果。。
        Connect connect = new Connect();
        connect.setFromSheet(internetId.intValue());
        connect.setToSheet(firewallId.intValue());
        connect.setFromPart(FromPartValue.BOTTOM_EDGE);
        connect.setToPart(FromPartValue.TOP_EDGE);

        //输出
        diagram.save(dataDir + "test.vsdx", SaveFileFormat.VSDX);

        System.out.println("Shape has been added.");

    }

}

图片说明
望指点!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐