From 965250e002e7b7fd57b60244ddfd554fd57dd468 Mon Sep 17 00:00:00 2001 From: CyrilFerlicot Date: Wed, 19 Dec 2018 11:14:09 +0100 Subject: [PATCH 1/2] Add sugar + Fix stream error on clock Fixes #7 --- src/Artefact-Core/PDFDocument.class.st | 17 +++ src/Artefact-Core/PDFPage.class.st | 7 +- .../PDFClockElement.class.st | 100 ++++++++++++------ 3 files changed, 90 insertions(+), 34 deletions(-) diff --git a/src/Artefact-Core/PDFDocument.class.st b/src/Artefact-Core/PDFDocument.class.st index 25b44fb..22e1f31 100644 --- a/src/Artefact-Core/PDFDocument.class.st +++ b/src/Artefact-Core/PDFDocument.class.st @@ -318,6 +318,18 @@ PDFDocument class >> FrameworkManual [ ^ self comment ] +{ #category : #'instance creation' } +PDFDocument class >> element: anElement [ + ^ self elements: { anElement } +] + +{ #category : #'instance creation' } +PDFDocument class >> elements: aCollection [ + ^ self new + addAll: aCollection; + yourself +] + { #category : #action } PDFDocument >> add: aPage [ "add a new page in the PDF document" @@ -327,6 +339,11 @@ PDFDocument >> add: aPage [ +] + +{ #category : #action } +PDFDocument >> addAll: aCollection [ + aCollection do: [ :each | self add: each ] ] { #category : #configuration } diff --git a/src/Artefact-Core/PDFPage.class.st b/src/Artefact-Core/PDFPage.class.st index f7348f3..2a74739 100644 --- a/src/Artefact-Core/PDFPage.class.st +++ b/src/Artefact-Core/PDFPage.class.st @@ -33,7 +33,12 @@ Class { #category : #'Artefact-Core-Base' } -{ #category : #accessing } +{ #category : #'instance creation' } +PDFPage class >> element: anElement [ + ^ self elements: {anElement} +] + +{ #category : #'instance creation' } PDFPage class >> elements: aCollectionOfElements [ ^ self new elements: aCollectionOfElements; diff --git a/src/Artefact-Examples/PDFClockElement.class.st b/src/Artefact-Examples/PDFClockElement.class.st index b8a6ffa..03c728b 100644 --- a/src/Artefact-Examples/PDFClockElement.class.st +++ b/src/Artefact-Examples/PDFClockElement.class.st @@ -19,64 +19,98 @@ Class { { #category : #steps } PDFClockElement class >> clockTutorialStep1 [ - "PDFClockElement clockTutorialStep1" + "I will generate a PDF with the clock step example" - | doc | - doc := PDFDocument new. - doc add: (PDFPage new add: ((PDFClockElement from: 2 cm @ 2 cm to: 10 cm @ 10 cm) time: Time current)). - doc exportTo: 'clockTutorialStep1.pdf' asFileReference writeStream +