eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'SimpleFunctionGraphView':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: SimpleFunctionGraphView


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--View
               |
               +--SimpleFunctionGraphView

Package:
stx:libwidg3
Category:
Views-Graphs
Version:
rev: 1.9 date: 2023/07/06 14:35:56
user: cg
file: SimpleFunctionGraphView.st directory: libwidg3
module: stx stc-classLibrary: libwidg3

Description:


A very quick and dirty (and simple) hack to
display a graph of a function.

TODO: grid & scale drawing.

copyright

COPYRIGHT (c) 1997 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Instance protocol:

accessing
o  autoScaleHolder: aValueHolder
set the value of the instance variable 'minXHolder' (automatically generated)

o  displayModeHolder
return the value of the instance variable 'displayModeHolder' (automatically generated)

o  displayModeHolder: aValueHolder
set the value of the instance variable 'displayModeHolder' (automatically generated)

o  function: aBlock
(comment from inherited method)
set the drawing function if it has changed.
The argument is one of:
#copy,#copyInverted,#xor,#and,#andReverse
#andInverted,#or,#orReverse,#orInverted
#invert,#clear,#set,#noop,#equiv,#nand
Notice: not all graphicMedia support all functions

o  functionHolder
return the value of the instance variable 'functionHolder' (automatically generated)

o  functionHolder: aValueHolder
set the value of the instance variable 'functionHolder' (automatically generated)

o  graphColorHolder
return the value of the instance variable 'graphColorHolder' (automatically generated)

o  graphColorHolder: aValueHolder
set the value of the instance variable 'graphColorHolder' (automatically generated)

o  gridColorHolder
return the value of the instance variable 'gridColorHolder' (automatically generated)

o  gridColorHolder: aValueHolder
set the value of the instance variable 'gridColorHolder' (automatically generated)

o  invalidColorHolder
return the value of the instance variable 'invalidColorHolder' (automatically generated)

o  invalidColorHolder: aValueHolder
set the value of the instance variable 'invalidColorHolder' (automatically generated)

o  markInvalidHolder
return the value of the instance variable 'markInvalidHolder' (automatically generated)

o  markInvalidHolder: aValueHolder
set the value of the instance variable 'markInvalidHolder' (automatically generated)

o  maxXHolder
return the value of the instance variable 'maxXHolder' (automatically generated)

o  maxXHolder: aValueHolder
set the value of the instance variable 'maxXHolder' (automatically generated)

o  maxYHolder
return the value of the instance variable 'maxYHolder' (automatically generated)

o  maxYHolder: aValueHolder
set the value of the instance variable 'maxYHolder' (automatically generated)

o  minXHolder
return the value of the instance variable 'minXHolder' (automatically generated)

o  minXHolder: aValueHolder
set the value of the instance variable 'minXHolder' (automatically generated)

o  minYHolder
return the value of the instance variable 'minYHolder' (automatically generated)

o  minYHolder: aValueHolder
set the value of the instance variable 'minYHolder' (automatically generated)

o  showGridHolder
return the value of the instance variable 'showGridHolder' (automatically generated)

o  showGridHolder: aValueHolder
set the value of the instance variable 'showGridHolder' (automatically generated)

o  showUnitsXHolder
return the value of the instance variable 'showUnitsXHolder' (automatically generated)

o  showUnitsXHolder: aValueHolder
set the value of the instance variable 'showUnitsXHolder' (automatically generated)

o  showUnitsYHolder
return the value of the instance variable 'showUnitsYHolder' (automatically generated)

o  showUnitsYHolder: aValueHolder
set the value of the instance variable 'showUnitsYHolder' (automatically generated)

o  unitColorHolder
return the value of the instance variable 'unitColorHolder' (automatically generated)

o  unitColorHolder: aValueHolder
set the value of the instance variable 'unitColorHolder' (automatically generated)

change & update
o  sizeChanged: how from: oldExtentOrNil
my view has changed the size (not the contents)

o  update: something with: someArgument from: changedObject
something changed - for now, do a full redraw

drawing
o  chooseGrid
for every centimeter on the display ...

o  computeGraph
compute the graph

o  drawAxis
stepX := rangeX / nSteps.

o  redrawX: x y: y width: w height: h
redraw the graph

o  test: arg
redraw the graph

Usage example(s):

     self basicNew test:nil


Examples:


        |top graphView|

        top := StandardSystemView extent:300@300.
        graphView := SimpleFunctionGraphView origin:0.0@0.0 corner:1.0@1.0 in:top.

        graphView minXHolder:(-5 asValue).
        graphView maxXHolder:(5 asValue).
        graphView minYHolder:(-2 asValue).
        graphView maxYHolder:(2 asValue).

        graphView function:[:x | x sin].

        top open.
        |top graphView|

        top := StandardSystemView extent:300@300.
        graphView := SimpleFunctionGraphView origin:0.0@0.0 corner:1.0@1.0 in:top.

        graphView graphColorHolder:(Color white).
        graphView backgroundColor:Color black.
        graphView minXHolder:(-5 asValue).
        graphView maxXHolder:(5 asValue).
        graphView minYHolder:(-2 asValue).
        graphView maxYHolder:(2 asValue).

        graphView function:[:x | x sin].

        top open.
        |top graphView minX maxX|

        top := StandardSystemView extent:300@300.
        graphView := SimpleFunctionGraphView origin:0.0@0.0 corner:1.0@1.0 in:top.

        graphView graphColorHolder:(Color white).
        graphView backgroundColor:Color black.
        graphView minXHolder:(minX := -5 asValue).
        graphView maxXHolder:(maxX := 5 asValue).
        graphView minYHolder:(-2 asValue).
        graphView maxYHolder:(2 asValue).

        graphView function:[:x | x sin].

        top openAndWaitUntilVisible.

        [
            [top realized] whileTrue:[
                Delay waitForSeconds:0.05.
                minX value:(minX value + 0.1).
                maxX value:(maxX value + 0.1).
            ]
        ] fork
                
        |top graphView functionList|

        functionList := OrderedCollection new.
        functionList add:[:x | x].
        functionList add:[:x | x * x].
        functionList add:[:x | x sqrt].
        functionList add:[:x | x sin].
        functionList add:[:x | x cos].
        functionList add:[:x | x tan].
        functionList add:[:x | x log].
        functionList add:[:x | x exp].
        functionList add:[:x | 0].

        top := StandardSystemView extent:300@300.
        graphView := SimpleFunctionGraphView origin:0.0@0.0 corner:1.0@1.0 in:top.

        graphView graphColorHolder:(Color white).
        graphView backgroundColor:Color black.
        graphView minXHolder:(-5 asValue).
        graphView maxXHolder:(5 asValue).
        graphView minYHolder:(-2 asValue).
        graphView maxYHolder:(2 asValue).
        graphView displayModeHolder:(#lineMode asValue).

        graphView function:(functionList last).

        top openAndWaitUntilVisible.

        [
            [top realized] whileTrue:[
                functionList do:[:funcBlock |
                    Delay waitForSeconds:1.
                    graphView displayModeHolder value:#dotMode.
                    Delay waitForSeconds:1.
                    graphView displayModeHolder value:#lineMode.
                    Delay waitForSeconds:1.
                    graphView displayModeHolder value:#dotMode.

                    Delay waitForSeconds:1.
                    graphView displayModeHolder value:#lineMode.
                    graphView functionHolder value:funcBlock.
                ]
            ]
        ] fork



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Tue, 24 Dec 2024 20:45:36 GMT