Etoys: MorphicExtras-kfr.61.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Etoys: MorphicExtras-kfr.61.mcz

commits-2
Karl Ramberg uploaded a new version of MorphicExtras to project Etoys:
http://source.squeak.org/etoys/MorphicExtras-kfr.61.mcz

==================== Summary ====================

Name: MorphicExtras-kfr.61
Author: kfr
Time: 5 March 2012, 9:06:45 pm
UUID: 6966365e-b71c-3a44-b686-46937053f0bf
Ancestors: MorphicExtras-kfr.60

Change Set:             graphingFixes-sw
Date:                   4 March 2012
Author:                 Scott Wallace

Addresses various bug-reports and recommendations relating to recent number-line and graph-paper updates:
- Enforce reasonable ranges for the sliders governing the grid parameters, taking the grid-size, coarse-grid-size , and playfield dimensions into account.
- Provide a button to request 'graph paper' from the 'generic property sheet' when appropriate.
- Retain position of number line when its pixelsPerUnit changes.
- Disable the 'offset' when coarse-grid in effect.
- Protect sliders against zero-divide that can happen if minVal = maxVal.
- Protect InfiniteForms against incidental calls to #darker and #twiceDarker that can be sent to any object's fillStyle by some of the custom border code.
- Removes about a dozen superfluous methods that had mistakenly lingered in the earlier updates, and removes three inst vars of NumberLineMorph that were remnants from earlier code

=============== Diff against MorphicExtras-kfr.60 ===============

Item was removed:
- ----- Method: HorizontalNumberLineMorph>>placeLegendsAndMarks: (in category 'initialization') -----
- placeLegendsAndMarks: aBlock
- "Place the legends and tick-marks. The block provided has four arguments: :index :n :legendCenter :markCenter"
-
- | index offset current n legendCenter markCenter |
- index := 0.
- offset := self offset.
- current := self left + offset.
- [current < (self right - offset)]
- whileTrue: [n := minValue + index.
- index := index + 1.
- (index - 1 isDivisibleBy: increment)
- ifTrue: [legendCenter := current @ (self top + self marksHeight + (self legendsHeight / 2)) + (0 @ 2).
- markCenter := current @ (self top + (self marksHeight / 2)).
- aBlock valueWithArguments: {index. n. legendCenter. markCenter}].
- current := current + pixelsPerUnit].
- ^ index!

Item was changed:
  Morph subclass: #NumberLineMorph
+ instanceVariableNames: 'minValue actualColor axis showZero pixelsPerUnit unitsPerMark marksPerLegend'
- instanceVariableNames: 'minValue increment actualColor axis legends marks showZero pixelsPerUnit unitsPerMark marksPerLegend'
  classVariableNames: ''
  poolDictionaries: ''
  category: 'MorphicExtras-Charts'!
 
+ !NumberLineMorph commentStamp: 'sw 3/4/2012 00:20' prior: 0!
- !NumberLineMorph commentStamp: 'sw 2/15/2012 21:00' prior: 0!
  An abstract superclass for VerticalNumberLine and HorizontalNumberLine.
 
  minValue - Number - the value corresponding to the left edge of the line.
- increment - Number - the space along the line between individual legends/marks
  pixelsPerUnit - Integer - the number of pixels on the graph that correspond to a single unit in the metric space of the line.
+ actualColor - the color borne by the axis
- actualColor - th
  axis - a two-vertex PolygonMorph which is the actual line
- legends - a list of the legends showing values along the line.
- marks - a list of the tick-marks along the axis.
  showZero - Boolean - if false, then a 0 legend will *not* be show.!

Item was removed:
- ----- Method: NumberLineMorph class>>from:by:pixelsPerUnit: (in category 'instance creation') -----
- from: minValue by: increment pixelsPerUnit: pixelsPerUnit
- ^ (self basicNew
- setMinValue: minValue
- increment: increment
- pixelsPerUnit: pixelsPerUnit) initialize!

Item was removed:
- ----- Method: NumberLineMorph>>chooseTicksPerLegend (in category 'halo menu') -----
- chooseTicksPerLegend
- "Put up a dialog disclosing the current increment and inviting the user to specify a new one."
-
- | result |
- result := FillInTheBlank request: 'ticksPerLegend' translated initialAnswer: self ticksPerLegend printString.
- result isEmptyOrNil ifTrue: [^ self].
- self ticksPerLegend: result asNumber
- !

Item was removed:
- ----- Method: NumberLineMorph>>chooseUnitsPerTick (in category 'halo menu') -----
- chooseUnitsPerTick
- "Put up a dialog disclosing the current unitsPerTick and inviting the user to specify a new one."
-
- | result |
- result := FillInTheBlank request: 'units per tick' translated initialAnswer: self unitsPerTick printString.
- result isEmptyOrNil ifTrue: [^ self].
- self unitsPerTick: result asNumber
- !

Item was removed:
- ----- Method: NumberLineMorph>>increment (in category 'accessing') -----
- increment
- ^ increment!

Item was removed:
- ----- Method: NumberLineMorph>>increment: (in category 'accessing') -----
- increment: aNumber
- increment := aNumber max: 0.
- self update!

Item was changed:
  ----- Method: NumberLineMorph>>initialize (in category 'initialization') -----
  initialize
  "Basic initialization."
 
  super initialize.
  actualColor := Color black.
  axis := PolygonMorph arrowPrototype arrowSpec: 8 @ 4;
  lineBorderWidth: 1.
- legends := OrderedCollection new.
- marks := OrderedCollection new.
  pixelsPerUnit := 40.
  unitsPerMark := 5.
  marksPerLegend := 1.
  showZero := true.
  minValue := 0.
  self addMorph: axis;
  color: actualColor.
  self update!

Item was changed:
  ----- Method: NumberLineMorph>>pixelsPerUnit: (in category 'accessing') -----
  pixelsPerUnit: aNumber
  "Set the number of pixels that will constitute one 'unit' along the receiver.  Retain existing min and max values."
 
  | newPixelsPerUnit existingMax |
  (newPixelsPerUnit := aNumber max: 1) = pixelsPerUnit
  ifTrue: [^ self].
 
+ self retainCenterAcross:
+ [existingMax := self maxValue.
+ pixelsPerUnit := newPixelsPerUnit.
+ self update.
+ self maxValue: existingMax]!
- existingMax := self maxValue.
- pixelsPerUnit := newPixelsPerUnit.
- self update.
- self maxValue: existingMax!

Item was removed:
- ----- Method: NumberLineMorph>>placeLegendsAndMarks (in category 'updating') -----
- placeLegendsAndMarks
- | usedLegends usedMarks unusedLegends unusedMarks legend mark |
- usedLegends := OrderedCollection new.
- usedMarks := OrderedCollection new.
- self
- placeLegendsAndMarks: [:index :n :legendCenter :markCenter |
- (n ~= 0
- or: [showZero])
- ifTrue: [legend := usedLegends
- add: (legends
- at: index
- ifAbsent: [legends add: StringMorph new]).
- self addMorph: legend.
- legend contents: n asString;
- center: legendCenter;
- color: self color].
- mark := usedMarks
- add: (marks
- at: index
- ifAbsent: [marks add: self newMark]).
- self addMorph: mark.
- mark center: markCenter;
- color: self color].
- unusedLegends := legends copyWithoutAll: usedLegends.
- unusedLegends
- do: [:each | each delete].
- legends removeAll: unusedLegends.
- unusedMarks := marks copyWithoutAll: usedMarks.
- unusedMarks
- do: [:each | each delete].
- marks removeAll: unusedMarks!

Item was removed:
- ----- Method: NumberLineMorph>>placeLegendsAndMarks: (in category 'abstract') -----
- placeLegendsAndMarks: aBlock
- ^ self subclassResponsibility!

Item was added:
+ ----- Method: NumberLineMorph>>retainCenterAcross: (in category 'coordinates') -----
+ retainCenterAcross: aBlock
+ "The scale of the receiver is being changed..."
+
+ | oldCenter |
+ oldCenter := self center.
+ aBlock value.
+ self center: oldCenter!

Item was removed:
- ----- Method: NumberLineMorph>>setMinValue:increment:pixelsPerUnit: (in category 'initialization') -----
- setMinValue: minValue1 increment: increment1 pixelsPerUnit: pixelsPerUnit1
- "Initialize the receiver to have the given minimum value, increment and pixelsPerUnit"
-
- minValue := minValue1.
- increment := increment1.
- pixelsPerUnit := pixelsPerUnit1!

Item was removed:
- ----- Method: NumberLineMorph>>ticksPerLegend: (in category 'halo menu') -----
- ticksPerLegend: aNumber
- marksPerLegend := aNumber rounded max: 1!

Item was removed:
- ----- Method: Player>>getIncrement (in category '*morphicExtras-Charts') -----
- getIncrement
- ^ self getValueFromCostume: #increment!

Item was removed:
- ----- Method: Player>>getTicksPerLegend (in category '*morphicExtras-Charts') -----
- getTicksPerLegend
- ^ self getValueFromCostume: #ticksPerLegend!

Item was removed:
- ----- Method: Player>>setTicksPerLegend: (in category '*morphicExtras-Charts') -----
- setTicksPerLegend: aNumber
- self setCostumeSlot: #ticksPerLegend toValue: aNumber!

Item was changed:
  ----- Method: SimpleSliderMorph>>adjustToValue: (in category 'private') -----
  adjustToValue: aNumber
  "Adjust the position of this slider to correspond to the given value in the range minVal..maxVal."
  "Details: Internal values are normalized to the range 0..1."
 
+ | toUse |
+ toUse := minVal = maxVal
+ ifTrue:
+ [minVal]
+ ifFalse:
+ [(aNumber - minVal) asFloat / (maxVal - minVal)].
+ self value: toUse
- self value:
- (aNumber - minVal) asFloat / (maxVal - minVal).
  !

Item was removed:
- ----- Method: VerticalNumberLineMorph>>placeLegendsAndMarks: (in category 'initialization') -----
- placeLegendsAndMarks: aBlock
- "Place the legends and tick-marks. The block provided has four arguments: :index :n :legendCenter :markCenter"
-
- | index offset current n legendCenter markCenter |
- index := 0.
- offset := self offset.
- current := self bottom - offset.
- [current > (self top + offset)]
- whileTrue: [n := minValue + index.
- index := index + 1.
- (index - 1 isDivisibleBy: increment)
- ifTrue: [legendCenter := self left + self legendsWidth - ((self widthOfString: n asString)
- / 2) @ current + (-2 @ 0).
- markCenter := self left + self legendsWidth + (self marksWidth / 2) @ current.
- aBlock valueWithArguments: {index. n. legendCenter. markCenter}].
- current := current - pixelsPerUnit].
- ^ index!

_______________________________________________
etoys-dev mailing list
[hidden email]
http://lists.squeakland.org/mailman/listinfo/etoys-dev