2
A builder for to build:
3
- the coordinates of a point
4
- the equation of a circle
5
- the equation of a line
8
#name : #DrGCoordinatesBuilder,
9
#superclass : #DrGMathItemBuilder,
16
#category : #'DrGeoII-Core-Builder'
19
{ #category : #documentation }
20
DrGCoordinatesBuilder class >> description [
21
^ 'Vector or point coordinates, circle or line equation.' translated
24
{ #category : #documentation }
25
DrGCoordinatesBuilder class >> title [
26
^ 'Coordinates, equation' translated
29
{ #category : #private }
30
DrGCoordinatesBuilder >> addItem: aMathItemCollection at: aPoint [
33
item := aMathItemCollection first.
34
item isPointItem ifTrue: [^ pointA := item].
35
item isCircleItem ifTrue: [^ circle := item].
36
item isLineItem ifTrue: [^ line := item].
37
item isVectorItem ifTrue: [^ vector := item]
40
{ #category : #accessing }
41
DrGCoordinatesBuilder >> arguments [
42
^ Array with: ({pointA. vector . line . circle } detect: [:i | i isNil not] ifNone: [nil]) with: point
45
{ #category : #testing }
46
DrGCoordinatesBuilder >> isWanted: aMathItemCollection [
47
^ aMathItemCollection notEmpty
48
and: [aMathItemCollection first isPointItem
49
or: [aMathItemCollection first isLineItem
50
or: [aMathItemCollection first isCircleItem
51
or: [aMathItemCollection first isVectorItem]]]]
54
{ #category : #'as yet unclassified' }
55
DrGCoordinatesBuilder >> itemInstanceFrom: node [
56
"build an item from a XML description"
57
"this builder can create multiple item at once (coordinates X and Y), so we need
58
to select the one we want"
60
(self parentsById: node) do: [:each | self addItem: {each} at: 0@0].
61
nodeType := (node attributeAt: #type) asSymbol.
62
^ self getItem detect: [:item | item nodeType = nodeType]
66
{ #category : #constant }
67
DrGCoordinatesBuilder >> mathItemClass [
68
pointA ifNotNil: [^{DrGValuePtabscissaItem . DrGValuePtordinateItem}].
69
vector ifNotNil: [^{DrGValueVectorabscissaItem . DrGValueVectorordinateItem}].
70
circle ifNotNil: [^ DrGEquationCircleItem].
71
line ifNotNil: [^ DrGEquationLineItem]
75
DrGCoordinatesBuilder >> postProcess: item from: node [
76
super postProcess: item from: node.
77
self parseValuePosition: node of: item.
80
{ #category : #testing }
81
DrGCoordinatesBuilder >> readyToBuild [
82
^ {pointA. vector . line . circle } anySatisfy: [:i | i isNil not]
86
{ #category : #updating }
87
DrGCoordinatesBuilder >> reset [
89
pointA := vector := circle := line := nil