Non Primitive Şekildeki Veri

Basit olmayan Şeklin Verilerine Erişmek

Bazı durumlarda, yerleşik olmayan bir şekilden veriye erişmeniz gerekebilir. Yerleşik şekiller basit şekiller olarak adlandırılırken, diğerleri basit olmayan şekiller olarak adlandırılır. Örneğin, farklı eğri bağlantılı çizgiler kullanarak kendi şekillerinizi tanımlayabilirsiniz.

Basit Olmayan Bir Şekil

Aspose.Cells’de basit olmayan şekiller AutoShapeType.NOT_PRIMITIVE türüne atanır. Bunların türünü Shape.getAutoShapeType() yöntemi kullanarak kontrol edebilirsiniz.

Şekil verilerine Shape.getPaths() yöntemini kullanarak erişin. Bu, basit olmayan şekli oluşturan tüm bağlantılı yolları döndürür. Bu yollar, her bir segmentteki noktaları içeren bir liste tutan ShapePath türündedir.

Aşağıdaki kod örneği, basit olmayan şeklin yol bilgilerine erişmek için Shape.getPaths() yönteminin kullanımını göstermektedir.

Basit olmayan bir şeklin örneğini gösterir

todo:image_alt_text

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the resource directory
String dataDir = Utils.getSharedDataDir(NonPrimitiveShape.class) + "DrawingObjects/";
Workbook workbook = new Workbook(dataDir + "NonPrimitiveShape.xlsx");
Worksheet worksheet = workbook.getWorksheets().get(0);
// Accessing the user defined shape
Shape shape = worksheet.getShapes().get(0);
if (shape.getAutoShapeType() == AutoShapeType.NOT_PRIMITIVE) {
// Access Shape paths
ShapePathCollection shapePathCollection = shape.getPaths();
// Access information of individual shape path
ShapePath shapePath = shapePathCollection.get(0);
// Access shape segment path list
ShapeSegmentPathCollection shapeSegmentPathCollection = shapePath.getPathSegementList();
// Access individual segment path
ShapeSegmentPath shapeSegmentPath = shapeSegmentPathCollection.get(0);
ShapePathPointCollection segmentPoints = shapeSegmentPath.getPoints();
for (Object obj : segmentPoints) {
ShapePathPoint pathPoint = (ShapePathPoint) obj;
System.out.println("X: " + pathPoint.getX() + ", Y: " + pathPoint.getY());
}
}