Skip to content

Commit 22bc423

Browse files
committed
Aspose.Slides Java for Jython Examples - Initial Commit
1 parent 17d770f commit 22bc423

File tree

100 files changed

+3580
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+3580
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Metadata-Version: 1.1
2+
Name: aspose-slides-java-for-jython
3+
Version: 1.0.0
4+
Summary: Aspose.slides Java for Jython is a project that demonstrates / provides the Aspose.Slides for Java API usage examples in Jython.
5+
Home-page: https://github.com/asposeslides/Aspose_Slides_Java/tree/master/Plugins/Aspose-Slides-Java-for-Jython
6+
Author: Fahad Adeel
7+
Author-email: [email protected]
8+
License: UNKNOWN
9+
Description: UNKNOWN
10+
Platform: UNKNOWN
11+
Classifier: Programming Language :: Python
12+
Classifier: Programming Language :: Python :: 2
13+
Classifier: License :: OSI Approved :: MIT License
14+
Classifier: Operating System :: OS Independent
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
setup.py
2+
aspose_slides_java_for_jython.egg-info/PKG-INFO
3+
aspose_slides_java_for_jython.egg-info/SOURCES.txt
4+
aspose_slides_java_for_jython.egg-info/dependency_links.txt
5+
aspose_slides_java_for_jython.egg-info/top_level.txt
6+
asposeslides/__init__.py
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
asposeslides
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ShapeType
4+
from com.aspose.slides import FillType
5+
from com.aspose.slides import SaveFormat
6+
from java.awt import Color
7+
8+
class HelloWorld:
9+
10+
def __init__(self):
11+
12+
dataDir = Settings.dataDir + 'IntroductionToPresentation/HelloWorld'
13+
14+
# Instantiate Presentation
15+
pres = Presentation()
16+
17+
# Get the first slide
18+
slide = pres.getSlides().get_Item(0)
19+
20+
# Add an AutoShape of Rectangle type
21+
shape_type = ShapeType
22+
ashp = slide.getShapes().addAutoShape(shape_type.Rectangle, 150, 75, 150, 50)
23+
24+
# Add ITextFrame to the Rectangle
25+
ashp.addTextFrame("Hello World")
26+
27+
# Change the text color to Black (which is White by default)
28+
fill_type = FillType
29+
color = Color
30+
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat().setFillType(fill_type.Solid)
31+
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat().getSolidFillColor().setColor(color.BLACK)
32+
33+
# Change the line color of the rectangle to White
34+
ashp.getShapeStyle().getLineColor().setColor(color.WHITE)
35+
36+
# Remove any fill formatting in the shape
37+
ashp.getFillFormat().setFillType (fill_type.NoFill)
38+
39+
# Save the presentation to disk
40+
save_format = SaveFormat
41+
pres.save(dataDir + "HelloWorld.pptx", save_format.Pptx)
42+
43+
print "Document has been saved, please check the output file."
44+
45+
if __name__ == '__main__':
46+
HelloWorld()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ControlType
4+
from com.aspose.slides import SaveFormat
5+
6+
class AddActiveX:
7+
8+
def __init__(self):
9+
10+
dataDir = Settings.dataDir + 'WorkingWithActiveXControls/'
11+
# Create an instance of Presentation class
12+
pres = Presentation()
13+
14+
# Adding the Media Player ActiveX control
15+
controlType = ControlType
16+
pres.getSlides().get_Item(0).getControls().addControl(controlType.WindowsMediaPlayer, 100, 100, 400, 400)
17+
18+
# Access the Media Player ActiveX control and set the video path
19+
pres.getSlides().get_Item(0).getControls().get_Item(0).getProperties().set_Item("URL" , dataDir + "Wildlife.mp4")
20+
21+
# Write the presentation as a PPTX file
22+
saveFormat = SaveFormat
23+
pres.save(dataDir + "AddActiveX.pptx", saveFormat.Pptx)
24+
25+
print "Added ActiveX control, please check the output file."
26+
27+
if __name__ == '__main__':
28+
AddActiveX()
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ShapeType
4+
from com.aspose.slides import FillType
5+
from com.aspose.slides import SaveFormat
6+
from java.awt import Color
7+
8+
class ChartLegend:
9+
10+
def __init__(self):
11+
12+
dataDir = Settings.dataDir + 'WorkingWithCharts/'
13+
14+
# Instantiate Presentation
15+
pres = Presentation()
16+
17+
# Get the first slide
18+
slide = pres.getSlides().get_Item(0)
19+
20+
# Add an AutoShape of Rectangle type
21+
shape_type = ShapeType
22+
ashp = slide.getShapes().addAutoShape(shape_type.Rectangle, 150, 75, 150, 50)
23+
24+
# Add ITextFrame to the Rectangle
25+
ashp.addTextFrame("Hello World")
26+
27+
# Change the text color to Black (which is White by default)
28+
fill_type = FillType
29+
color = Color
30+
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat().setFillType(fill_type.Solid)
31+
ashp.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0).getPortionFormat().getFillFormat().getSolidFillColor().setColor(color.BLACK)
32+
33+
# Change the line color of the rectangle to White
34+
ashp.getShapeStyle().getLineColor().setColor(color.WHITE)
35+
36+
# Remove any fill formatting in the shape
37+
ashp.getFillFormat().setFillType (fill_type.NoFill)
38+
39+
# Save the presentation to disk
40+
save_format = SaveFormat
41+
pres.save(dataDir + "HelloWorld.pptx", save_format.Pptx)
42+
43+
print "Document has been saved, please check the output file."
44+
45+
if __name__ == '__main__':
46+
ChartLegend()
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ChartType
4+
from com.aspose.slides import SaveFormat
5+
6+
class ChartProperties:
7+
8+
def __init__(self):
9+
10+
# Setting the RotationX, RotationY and DepthPercents properties of 3D Chart.
11+
self.set_rotation_and_depth()
12+
13+
# Setting the GapWidth property of Chart Series
14+
self.set_gapwidth()
15+
16+
def set_rotation_and_depth(dataDir):
17+
18+
dataDir = Settings.dataDir + 'WorkingWithCharts/ChartProperties'
19+
20+
pres = Presentation()
21+
22+
# Access first slide
23+
sld = pres.getSlides().get_Item(0)
24+
25+
# Add chart with default data
26+
charType=ChartType
27+
chart = sld.getShapes().addChart(charType.StackedColumn3D, 0, 0, 500, 500)
28+
29+
# Getting the chart data worksheet
30+
fact = chart.getChartData().getChartDataWorkbook()
31+
32+
# Delete default generated series and categories
33+
chart.getChartData().getSeries().clear()
34+
chart.getChartData().getCategories().clear()
35+
36+
# Adding series
37+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType())
38+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType())
39+
40+
# Adding categories
41+
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1"))
42+
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2"))
43+
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3"))
44+
45+
# Set Rotation3D properties
46+
chart.getRotation3D().setRightAngleAxes(True)
47+
chart.getRotation3D().setRotationX(40)
48+
chart.getRotation3D().setRotationY(270)
49+
chart.getRotation3D().setDepthPercents(150)
50+
51+
# Take first chart series
52+
series = chart.getChartData().getSeries().get_Item(0)
53+
54+
# Populating series data
55+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20))
56+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50))
57+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30))
58+
59+
# Take second chart series
60+
series = chart.getChartData().getSeries().get_Item(1)
61+
62+
# Populating series data
63+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30))
64+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10))
65+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60))
66+
67+
# Saving the presentation
68+
save_format = SaveFormat
69+
pres.save(dataDir + "3Drotation.pptx", save_format.Pptx)
70+
71+
print "Done with rotation, please check the output file."
72+
73+
def set_gapwidth(dataDir):
74+
75+
dataDir = Settings.dataDir + 'WorkingWithCharts/ChartProperties'
76+
77+
pres = Presentation()
78+
79+
# Access first slide
80+
sld = pres.getSlides().get_Item(0)
81+
82+
# Add chart with default data
83+
charType=ChartType
84+
chart = sld.getShapes().addChart(charType.StackedColumn3D, 0, 0, 500, 500)
85+
86+
# Getting the chart data worksheet
87+
fact = chart.getChartData().getChartDataWorkbook()
88+
89+
# Delete default generated series and categories
90+
chart.getChartData().getSeries().clear()
91+
chart.getChartData().getCategories().clear()
92+
93+
# Adding series
94+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType())
95+
chart.getChartData().getSeries().add(fact.getCell(0, 0, 2, "Series 2"), chart.getType())
96+
97+
# Adding categories
98+
chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "Caetegoty 1"))
99+
chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "Caetegoty 2"))
100+
chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "Caetegoty 3"))
101+
102+
# Take first chart series
103+
series = chart.getChartData().getSeries().get_Item(0)
104+
105+
# Populating series data
106+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 1, 20))
107+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 1, 50))
108+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 1, 30))
109+
110+
# Take second chart series
111+
series = chart.getChartData().getSeries().get_Item(1)
112+
113+
# Populating series data
114+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 1, 2, 30))
115+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 2, 2, 10))
116+
series.getDataPoints().addDataPointForBarSeries(fact.getCell(0, 3, 2, 60))
117+
118+
# Set GapWidth value
119+
series.getParentSeriesGroup().setGapWidth(75)
120+
121+
# Saving the presentation
122+
save_format = SaveFormat
123+
pres.save(dataDir + "SetGapWidth.pptx", save_format.Pptx)
124+
125+
print "Set Gapwidth property of chart series, please check the output file."
126+
127+
if __name__ == '__main__':
128+
ChartProperties()
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ChartType
4+
from com.aspose.slides import SaveFormat
5+
6+
class ChartSeries:
7+
8+
def __init__(self):
9+
10+
# Adding Chart Series Overlap for Charts
11+
self.add_overlap_for_chart()
12+
13+
def add_overlap_for_chart(dataDir):
14+
15+
dataDir = Settings.dataDir + 'WorkingWithCharts/ChartSeries'
16+
17+
# Instantiate Presentation class that represents the presentation file
18+
pres = Presentation()
19+
20+
# Adding chart
21+
chartType = ChartType
22+
23+
chart = pres.getSlides().get_Item(0).getShapes().addChart(chartType.ClusteredColumn, 50, 50, 600, 400, True)
24+
25+
series = chart.getChartData().getSeries()
26+
if (series.get_Item(0).getOverlap() == 0):
27+
# Setting series overlap
28+
series . get_Item(0) . getParentSeriesGroup().setOverlap(-30)
29+
30+
# Saving the presentation
31+
save_format = SaveFormat
32+
pres.save(dataDir + "Overlap.pptx", save_format.Pptx)
33+
34+
print "Added chart series overlap for charts, please check the output file."
35+
36+
if __name__ == '__main__':
37+
ChartSeries()
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from asposeslides import Settings
2+
from com.aspose.slides import Presentation
3+
from com.aspose.slides import ChartType
4+
from com.aspose.slides import SaveFormat
5+
from com.aspose.slides import TrendlineType
6+
from com.aspose.slides import FillType
7+
from java.awt import Color
8+
9+
class ChartTrendLines:
10+
11+
def __init__(self):
12+
13+
dataDir = Settings.dataDir + 'WorkingWithCharts/ChartTrendLines'
14+
15+
# Creating empty presentation
16+
pres =Presentation()
17+
18+
# Creating a clustered column chart
19+
chartType=ChartType
20+
chart = pres.getSlides().get_Item(0).getShapes().addChart(chartType.ClusteredColumn, 20, 20, 500, 400)
21+
22+
# Adding ponential trend line for chart series 1
23+
trendlineType=TrendlineType
24+
tredLinep = chart.getChartData().getSeries().get_Item(0).getTrendLines().add(trendlineType.Exponential)
25+
tredLinep.setDisplayEquation(False)
26+
tredLinep.setDisplayRSquaredValue(False)
27+
28+
# Adding Linear trend line for chart series 1
29+
fillType=FillType
30+
color=Color
31+
32+
tredLineLin = chart.getChartData().getSeries().get_Item(0).getTrendLines().add(trendlineType.Linear)
33+
tredLineLin.setTrendlineType(trendlineType.Linear)
34+
tredLineLin.getFormat().getLine().getFillFormat().setFillType(fillType.Solid)
35+
tredLineLin.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(color.RED)
36+
37+
38+
# Adding Logarithmic trend line for chart series 2
39+
tredLineLog = chart.getChartData().getSeries().get_Item(1).getTrendLines().add(trendlineType.Logarithmic)
40+
tredLineLog.setTrendlineType(trendlineType.Logarithmic)
41+
tredLineLog.addTextFrameForOverriding("New log trend line")
42+
43+
# Adding MovingAverage trend line for chart series 2
44+
tredLineMovAvg = chart.getChartData().getSeries().get_Item(1).getTrendLines().add(trendlineType.MovingAverage)
45+
tredLineMovAvg.setTrendlineType(trendlineType.MovingAverage)
46+
tredLineMovAvg.setPeriod(3)
47+
tredLineMovAvg.setTrendlineName("New TrendLine Name")
48+
49+
# Adding Polynomial trend line for chart series 3
50+
tredLinePol = chart.getChartData().getSeries().get_Item(2).getTrendLines().add(trendlineType.Polynomial)
51+
tredLinePol.setTrendlineType(trendlineType.Polynomial)
52+
tredLinePol.setForward(1)
53+
tredLinePol.setOrder(3)
54+
55+
# Adding Power trend line for chart series 3
56+
tredLinePower = chart.getChartData().getSeries().get_Item(1).getTrendLines().add(trendlineType.Power)
57+
tredLinePower.setTrendlineType(trendlineType.Power)
58+
tredLinePower.setBackward(1)
59+
60+
# Saving the presentation
61+
save_format = SaveFormat
62+
pres.save(dataDir + "ChartTrendLines.pptx", save_format.Pptx)
63+
64+
print "Done with chart trend lines, please check the output file."
65+
66+
if __name__ == '__main__':
67+
ChartTrendLines()

0 commit comments

Comments
 (0)