Module: Asposeslidesjava::FormatLines
- Defined in:
- lib/asposeslidesjava/Shapes/formatlines.rb
Instance Method Summary collapse
Instance Method Details
#format_join_styles ⇒ 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/asposeslidesjava/Shapes/formatlines.rb', line 43 def format_join_styles() 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 # Get the first slide sld = pres.getSlides().get_Item(0) # Add three autoshapes of rectangle type shape_type = Rjb::import('com.aspose.slides.ShapeType') shp1 = sld.getShapes().addAutoShape(shape_type.Rectangle, 50, 100, 150, 75) shp2 = sld.getShapes().addAutoShape(shape_type.Rectangle, 300, 100, 150, 75) shp3 = sld.getShapes().addAutoShape(shape_type.Rectangle, 50, 250, 150, 75) # Set the fill color of the rectangle shape fill_type = Rjb::import('com.aspose.slides.FillType') color = Rjb::import('java.awt.Color') shp1.getFillFormat().setFillType(fill_type.Solid) shp1.getFillFormat().getSolidFillColor().setColor(color.BLACK) shp2.getFillFormat().setFillType(fill_type.Solid) shp2.getFillFormat().getSolidFillColor().setColor(color.BLACK) shp3.getFillFormat().setFillType(fill_type.Solid) shp3.getFillFormat().getSolidFillColor().setColor(color.BLACK) # Set the line width shp1.getLineFormat().setWidth(15) shp2.getLineFormat().setWidth(15) shp3.getLineFormat().setWidth (15) # Set the color of the line of rectangle shp1.getLineFormat().getFillFormat().setFillType(fill_type.Solid) shp1.getLineFormat().getFillFormat().getSolidFillColor().setColor(color.BLUE) shp2.getLineFormat().getFillFormat().setFillType(fill_type.Solid) shp2.getLineFormat().getFillFormat().getSolidFillColor().setColor(color.BLUE) shp3.getLineFormat().getFillFormat().setFillType(fill_type.Solid) shp3.getLineFormat().getFillFormat().getSolidFillColor().setColor(color.BLUE) # Set the Join Style line_join_style = Rjb::import('com.aspose.slides.LineJoinStyle') shp1.getLineFormat().setJoinStyle(line_join_style.Miter) shp2.getLineFormat().setJoinStyle(line_join_style.Bevel) shp3.getLineFormat().setJoinStyle(line_join_style.Round) # Add text to each rectangle shp1.getTextFrame().setText ("This is Miter Join Style") shp2.getTextFrame().setText( "This is Bevel Join Style") shp3.getTextFrame().setText ("This is Round Join Style") # Write the presentation as a PPTX file save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "RectShpLnJoin.pptx", save_format.Pptx) puts "Formatted join styles, please check the output file." end |
#format_lines ⇒ 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/formatlines.rb', line 11 def format_lines() 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 # Get the first slide sld = pres.getSlides().get_Item(0) # Add autoshape of rectangle type shp = sld.getShapes().addAutoShape(Rjb::import('com.aspose.slides.ShapeType').Rectangle, 50, 150, 75, 150) # Set the fill color of the rectangle shape shp.getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid) shp.getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').WHITE) # Apply some formatting on the line of the rectangle shp.getLineFormat().setStyle(Rjb::import('com.aspose.slides.LineStyle').ThickThin) shp.getLineFormat().setWidth(7) shp.getLineFormat().setDashStyle(Rjb::import('com.aspose.slides.LineDashStyle').Dash) # set the color of the line of rectangle shp.getLineFormat().getFillFormat().setFillType(Rjb::import('com.aspose.slides.FillType').Solid) shp.getLineFormat().getFillFormat().getSolidFillColor().setColor(Rjb::import('java.awt.Color').BLUE) # Write the presentation as a PPTX file save_format = Rjb::import('com.aspose.slides.SaveFormat') pres.save(data_dir + "RectShpLn.pptx", save_format.Pptx) puts "Formatted lines, please check the output file." end |
#initialize ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/asposeslidesjava/Shapes/formatlines.rb', line 3 def initialize() # Formatting the Lines of Shapes format_lines() # Formatting the Join Styles format_join_styles() end |