-
asImage [converting]
| aView anImage |
aView := self getView.
(aView isNil or: [aView isOpen not])
ifTrue: [anImage := super asImage]
ifFalse:
[self errorSignal handle: [:exception | anImage := super asImage]
do:
[| aWindow aPixmap |
aWindow := aView topComponent.
aWindow isCollapsed ifTrue: [aWindow expand].
aWindow raise.
aWindow display.
anImage := aWindow asImage.
aPixmap := Pixmap extent: aView bounds extent.
anImage displayOn: aPixmap graphicsContext
at: (aView localPointToGlobal: 0 @ 0) negated.
anImage := aPixmap asImage.
aPixmap close]].
^anImage
-
displaySuperimposeInView: aView [displaying]
| aGraphicsContext aBlock numberOfArbuments aCollection |
self exceptIndex ifTrue: [^nil].
aView isNil ifTrue: [^nil].
aView isOpen ifFalse: [^nil].
self moleculeObject isNil ifTrue: [^nil].
aGraphicsContext := aView graphicsContext.
aBlock := self indexExpressionBlock.
numberOfArbuments := aBlock numArgs.
aCollection := SortedCollection new: self numberOfAtoms.
self atomObjectsAndIndexesDo:
[:atomObject :index |
true = (aBlock
valueWithArguments: ((Array
with: index
with: atomObject atomicSymbol
with: atomObject atomicPoint) copyFrom: 1 to: numberOfArbuments))
ifTrue:
[| aText aPoint zValue |
(atomObject isHydrogen and: [self exceptHydrogen])
ifFalse:
[aText := index printString asText.
aPoint := self convertModelPointToView3dPoint: atomObject atomicPoint
in: aView bounds.
zValue := aPoint z.
aPoint := (aPoint x @ aPoint y) rounded.
aCollection add: zValue -> (Array with: aText with: aPoint)]]].
aCollection reverseDo:
[:anAssociation |
| aText aPoint |
aText := anAssociation value first.
aPoint := anAssociation value last.
aView
displayText: aText
on: aGraphicsContext
at: aPoint
textColor: (ColorValue brightness: 0.05)
vergeColor: (ColorValue brightness: 0.95)
styleSymbol: #small
alignmentSymbol: #center]
-
exceptHydrogen [accessing]
^false
-
exceptIndex [accessing]
^false
-
flushDisplayObject [flushing]
^self
-
indexExpression [accessing]
| index string |
index := self class allInstVarNames indexOf: 'indexExpression'.
index < 1 ifTrue: [^'[]' copy].
(self instVarAt: index) isNil
ifTrue:
[string := '[:index :atom | (atom = ''H'') not]' copy.
self setIndexExpression: string
setIndexExpressionBlock: (Compiler evaluate: string)].
^self instVarAt: index
-
indexExpression: aString [accessing]
| aBlock aBoolean |
self errorSignal handle: [:exception | aBlock := nil]
do:
[aBlock := Compiler
evaluate: aString
for: self
logged: false.
aBoolean := aBlock
valueWithArguments: ((Array
with: 999
with: 'H'
with: 0 , 0 , 0
with: nil) copyFrom: 1 to: aBlock numArgs).
(aBoolean isKindOf: Boolean) ifFalse: [self error: 'unexpected error']].
aBlock isNil ifTrue: [^nil].
self setIndexExpression: aString setIndexExpressionBlock: aBlock
-
indexExpressionBlock [accessing]
| index |
index := self class allInstVarNames indexOf: 'indexExpressionBlock'.
index < 1 ifTrue: [^[] yourself].
(self instVarAt: index) isNil ifTrue: [self indexExpression].
^self instVarAt: index
-
initialize [initialize-release]
super initialize.
self useMovementProcess: false
-
isOpen [testing]
self getView ifNil: [^false] ifNotNil: [:aView | ^aView isOpen]
-
moleculeObject [accessing]
^nil
-
requestNewImageFilename [menu messages]
"ChemoJunGeneralViewer new requestNewImageFilename."
| labels values menu message aFilename |
labels := Array
with: (Array with: (#jun_Image_files >> 'Image files') asString).
values := Array with: JunSystem defaultImageExtensionPatterns.
menu := Menu labelList: labels values: values.
message := #jun_Input_an_image_file_ >> 'Input an image file.'
expandMacrosWith: 'image'.
aFilename := ChemoJunFileRequesterDialog
requestNewFilename: message
initialFilename: self defaultBaseName , '.jpg'
fileTypeMenu: menu
initialFileType: values first.
aFilename isNil ifTrue: [^nil].
^aFilename
-
saveAsImage [menu messages]
| aBoolean anImage aFilename |
aBoolean := JunSensorUtility shiftDown or: [JunSensorUtility altDown].
anImage := self asImage.
anImage isNil ifTrue: [^nil].
aBoolean
ifTrue:
[anImage := anImage convertToPalette: JunImageProcessor grayPalette256
renderedBy: NearestPaint new].
aFilename := self requestNewImageFilename.
aFilename isNil ifTrue: [^nil].
self writeImage: anImage to: aFilename.
^anImage
-
setIndexExpression: aString setIndexExpressionBlock: aBlock [private]
^self
-
settingIndex [menu messages]
| aStream aString |
aStream := String new writeStream.
aStream nextPutAll: (#chemoJun_Expression_ >> 'Expression?') asString.
aStream cr.
aStream nextPutAll: (#jun_ex_ >> 'ex.') asString , ')'.
aStream cr.
aStream nextPutAll: '[:index | true]'.
aStream cr.
aStream nextPutAll: '[:index | index odd]'.
aStream cr.
aStream nextPutAll: '[:index | index even]'.
aStream cr.
aStream nextPutAll: '[:index | (index \\ 3) = 1]'.
aStream cr.
aStream nextPutAll: '[:index | #(1 10 50 100 150 999) includes: index]'.
aStream cr.
aStream nextPutAll: '[:index :atom | atom = ''C'']'.
aStream cr.
aStream nextPutAll: '[:index :atom | (atom = ''H'') not]'.
aStream cr.
aStream nextPutAll: '[:index :atom | (index odd) & (atom = ''C'')]'.
aStream cr.
aStream nextPutAll: '[:index :atom :point | false]'.
aString := aStream contents.
aStream close.
aString := JunDialog request: aString initialAnswer: self indexExpression.
aString isNil ifTrue: [^nil].
aString isEmpty ifTrue: [^nil].
self indexExpression: aString.
self flushDisplayObject.
self changed: #object
-
updateFileMenuIndication [menu accessing]
| menuItem aMenu displayObjectIsEmpty |
super updateFileMenuIndication.
menuItem := self menuItemLabeled: 'File' inMenu: self menuBar.
menuItem isNil ifTrue: [^self].
aMenu := menuItem submenu.
aMenu isNil ifTrue: [^nil].
displayObjectIsEmpty := self isEmpty.
menuItem := self menuItemLabeled: 'Save as' asString inMenu: aMenu.
menuItem notNil
ifTrue:
[displayObjectIsEmpty ifTrue: [menuItem disable] ifFalse: [menuItem enable]]