<< Chapter < Page
  Digital signal processing - dsp     Page 16 / 24
Chapter >> Page >

Listing 12 also signals the end of the constructor for the class named ImgMod29 .

Six different inner classes

We have finally gotten to the fun part of the program. This is the part where we write the code that determines how the surface elevations and the calibrationscale values are displayed. This part of the program consists of six different inner classes.

The fact that the classes are inner classes makes it possible for methods in the class to access instance variables and methods of the containing object oftype ImgMod29 . This makes the programming somewhat easier than would be the case if they were all top-level classes.

Subclasses of the canvas class

Each of the six inner classes is a subclass of the class named Canvas and each of the classes overrides the paint method. The code in the overridden paint methods for the classes that display the 3D surfaces

  • access the surface elevation data,
  • convert that data into colors and,
  • display those colors in the correct locations on the screen.

The names and behaviors of three of those three classes are:

  • CanvasType0surface - Displays a Grayscale plot
  • CanvasType1surface - Displays a Color Shift plot
  • CanvasType2surface - Displays a Color Contour plot

Associated directly with the three above classes are three other inner classes that are used to display the calibration scale immediately below theplot of the 3D surface. The names and behaviors of those three classes are:

  • CanvasType0scale - Displays a Grayscale calibration scale
  • CanvasType1scale - Displays a Color Shift calibration scale
  • CanvasType2scale - Displays a Color Contour calibration scale

The getCenter method

Before getting into the details of these inner classes, however, I will present and briefly discuss a method named getCenter , which is called by the constructor for each of the surface plotting classes.

The getCenter method is used to find the horizontal and vertical center of the surface. These values are used to position the optionalred axes that may be drawn on the surface. This method is shown in its entirety in Listing 13 .

Listing 13. The method named getCenter.
int horizCenter; int vertCenter;void getCenter(){ if(dataWidth%2 == 0){//evenhorizCenter = dataWidth * blockSize/2 + blockSize/2;}else{//odd horizCenter = dataWidth * blockSize/2;}//end elseif(dataHeight%2 == 0){//even vertCenter =dataHeight * blockSize/2 + blockSize/2; }else{//oddvertCenter = dataHeight * blockSize/2; }//end else}//end getCenter

Even or odd is very important

Note that the returned values depend on whether the dimensions of the surface are even or odd.

(For example, the center of a string of five blocks of pixels is the third block whereas the center of a string of six blocks of pixels is halfway between the third and fourth blocks.)

Now that you know about the difference between even and odd surface dimensions, the code in Listing 13 should be straightforward and should not require further discussion.

Grayscale plot format

Listing 14 shows the beginning of the class named CanvasType0surface and also shows the entire constructor for that class.

Questions & Answers

what is phylogeny
Odigie Reply
evolutionary history and relationship of an organism or group of organisms
AI-Robot
ok
Deng
what is biology
Hajah Reply
the study of living organisms and their interactions with one another and their environments
AI-Robot
what is biology
Victoria Reply
HOW CAN MAN ORGAN FUNCTION
Alfred Reply
the diagram of the digestive system
Assiatu Reply
allimentary cannel
Ogenrwot
How does twins formed
William Reply
They formed in two ways first when one sperm and one egg are splited by mitosis or two sperm and two eggs join together
Oluwatobi
what is genetics
Josephine Reply
Genetics is the study of heredity
Misack
how does twins formed?
Misack
What is manual
Hassan Reply
discuss biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles
Joseph Reply
what is biology
Yousuf Reply
the study of living organisms and their interactions with one another and their environment.
Wine
discuss the biological phenomenon and provide pieces of evidence to show that it was responsible for the formation of eukaryotic organelles in an essay form
Joseph Reply
what is the blood cells
Shaker Reply
list any five characteristics of the blood cells
Shaker
lack electricity and its more savely than electronic microscope because its naturally by using of light
Abdullahi Reply
advantage of electronic microscope is easily and clearly while disadvantage is dangerous because its electronic. advantage of light microscope is savely and naturally by sun while disadvantage is not easily,means its not sharp and not clear
Abdullahi
cell theory state that every organisms composed of one or more cell,cell is the basic unit of life
Abdullahi
is like gone fail us
DENG
cells is the basic structure and functions of all living things
Ramadan
What is classification
ISCONT Reply
is organisms that are similar into groups called tara
Yamosa
in what situation (s) would be the use of a scanning electron microscope be ideal and why?
Kenna Reply
A scanning electron microscope (SEM) is ideal for situations requiring high-resolution imaging of surfaces. It is commonly used in materials science, biology, and geology to examine the topography and composition of samples at a nanoscale level. SEM is particularly useful for studying fine details,
Hilary
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing - dsp. OpenStax CNX. Jan 06, 2016 Download for free at https://legacy.cnx.org/content/col11642/1.38
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing - dsp' conversation and receive update notifications?

Ask