From a3415792b13018c5483cbfb3331593a184a748c7 Mon Sep 17 00:00:00 2001 From: Milton Mamani Torres Date: Tue, 27 Sep 2022 14:30:34 +0200 Subject: [PATCH] added inverted method to attach points --- src/Roassal3-Chart/RSAbstractPlot.class.st | 4 ++-- .../RSAttachPointTest.class.st | 20 +++++++++++++++++++ src/Roassal3-Shapes/RSAttachPoint.class.st | 15 ++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/Roassal3-Chart/RSAbstractPlot.class.st b/src/Roassal3-Chart/RSAbstractPlot.class.st index c39f5fc2b..b5babf8e0 100644 --- a/src/Roassal3-Chart/RSAbstractPlot.class.st +++ b/src/Roassal3-Chart/RSAbstractPlot.class.st @@ -159,8 +159,8 @@ c addDecoration: RSYMarkerDecoration new. c ``` " - self assert: [ aCollection notNil ] description: 'Cannot be nil'. - self assert: [ aCollection2 notNil ] description: 'Cannot be nil'. + self assert: [ aCollection isCollection ] description: 'Should be a collection'. + self assert: [ aCollection2 isCollection ] description: 'Should be a collection'. self assert: [ aCollection size = aCollection2 size ] description: 'The two collections must have the same size'. xValues := aCollection. diff --git a/src/Roassal3-Global-Tests/RSAttachPointTest.class.st b/src/Roassal3-Global-Tests/RSAttachPointTest.class.st index 9c728e86a..18abc1107 100644 --- a/src/Roassal3-Global-Tests/RSAttachPointTest.class.st +++ b/src/Roassal3-Global-Tests/RSAttachPointTest.class.st @@ -67,6 +67,26 @@ RSAttachPointTest >> testHorizontalAttachPoint [ self assert: (l attachPoint endingPointOf: l) equals: 50 @ 50 ] +{ #category : #tests } +RSAttachPointTest >> testInverted [ + | ap e1 e2 line | + ap := RSCenteredAttachPoint new. + ap straight. + self deny: ap isInverted. + e1 := RSEllipse new. + e2 := RSEllipse new. + e1 translateTo: 20 asPoint. + line := RSLine new. + line attachPoint: ap. + line from: e1. + line to: e2. + line update. + self assert: e1 position equals: line startPoint. + ap inverted. + line update. + self assert: e1 position equals: line endPoint. +] + { #category : #tests } RSAttachPointTest >> testVerticalAttachPoint [ | b1 b2 l c | diff --git a/src/Roassal3-Shapes/RSAttachPoint.class.st b/src/Roassal3-Shapes/RSAttachPoint.class.st index c0856c44c..90e726322 100644 --- a/src/Roassal3-Shapes/RSAttachPoint.class.st +++ b/src/Roassal3-Shapes/RSAttachPoint.class.st @@ -86,6 +86,16 @@ RSAttachPoint >> initialize [ inverted := false. ] +{ #category : #public } +RSAttachPoint >> inverted [ + inverted := true +] + +{ #category : #testing } +RSAttachPoint >> isInverted [ + ^ inverted +] + { #category : #private } RSAttachPoint >> matrixFor: commonParents [ | matrix | @@ -143,3 +153,8 @@ RSAttachPoint >> startingPointOf: aLine [ ifFalse: [ self basicStartingPointOf: aLine ] ] + +{ #category : #public } +RSAttachPoint >> straight [ + inverted := false +]