Module: Asposeslidesjava::ConnectShapes
- Defined in:
- lib/asposeslidesjava/Shapes/connectshapes.rb
Instance Method Summary collapse
Instance Method Details
#connect_shapes ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/asposeslidesjava/Shapes/connectshapes.rb', line 11 def connect_shapes() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Shapes/' # Create an instance of Presentation class pres = Rjb::import('com.aspose.slides.Presentation').new # Accessing shapes collection for selected slide shapes = pres.getSlides().get_Item(0).getShapes() shape_type = Rjb::import('com.aspose.slides.ShapeType') # Add autoshape Ellipse ellipse = shapes.addAutoShape(shape_type.Ellipse, 0, 100, 100, 100) # Add autoshape Rectangle rectangle = shapes.addAutoShape(shape_type.Rectangle, 100, 300, 100, 100) # Adding connector shape to slide shape collection connector = shapes.addConnector(shape_type.BentConnector2, 0, 0, 10, 10) # Joining Shapes to connectors connector.setStartShapeConnectedTo(ellipse) connector.setEndShapeConnectedTo(rectangle) connector.reroute() # Write the presentation as a PPTX file save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "ConnectShapes.pptx", save_format.Pptx) puts "Connected shapes, please check the output file." end |
#connect_shapes_with_connector ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/asposeslidesjava/Shapes/connectshapes.rb', line 43 def connect_shapes_with_connector() data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/Shapes/' # Create an instance of Presentation class pres = Rjb::import('com.aspose.slides.Presentation').new # Accessing shapes collection for selected slide shapes = pres.getSlides().get_Item(0).getShapes() shape_type = Rjb::import('com.aspose.slides.ShapeType') # Add autoshape Ellipse ellipse = shapes.addAutoShape(shape_type.Ellipse, 0, 100, 100, 100) # Add autoshape Rectangle rectangle = shapes.addAutoShape(shape_type.Rectangle, 100, 300, 100, 100) # Adding connector shape to slide shape collection connector = shapes.addConnector(shape_type.BentConnector2, 0, 0, 10, 10) # Joining Shapes to connectors connector.setStartShapeConnectedTo(ellipse) connector.setEndShapeConnectedTo(rectangle) # Setting the desired connection site index of Ellipse shape for connector to get connected wantedIndex = 6 # Checking if desired index is less than maximum site index count if ellipse.getConnectionSiteCount() > wantedIndex # Setting the desired connection site for connector on Ellipse connector.setStartShapeConnectionSiteIndex(wantedIndex) end # Write the presentation as a PPTX file save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "ConnectShapesWithConnector.pptx", save_format.Pptx) puts "Connected shapes with connector, please check the output file." end |
#initialize ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/asposeslidesjava/Shapes/connectshapes.rb', line 3 def initialize() # Connecting shapes using connectors connect_shapes() # Connecting Shape with connector on desired connection site connect_shapes_with_connector() end |