Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE DO IN JAVA Pixel Class In digital imaging, a pixel, or picture element is a physical point in a raster image, or the smallest

PLEASE DO IN JAVA

Pixel Class

In digital imaging, a pixel, or picture element is a physical point in a raster image, or the smallest addressable element in an all points addressable display device. It is the smallest controllable element of a picture represented on the screen.In a computer monitor a Pixel can be represented using x, y coordinates and the RGB colors. For this exercise, let's ignore the RGB attribute. Define a class Pixel. A Pixel has x, y coordinates, which are both integer values. A Pixel also has the following behaviours:

  • It can return the value of its x and y coordinates. Use the follwoing method signatures to implement these behaviours. public int getX( ) public int getY( )
  • It can change the value of its x and y coordinates. Use the following method signatures to implement these behaviours. public void setX(int xCoord ) public void setY(int yCoord )
  • It can also return the x, y coordinates in a format exactly like (x,y). Use the method signature: public String toString( )
  • The Pixel also has a construcor that initilizes the values of x, y coordinates to their default values.
  • It also has a second constructor that initializes the coordinates to given values. Use the signature: public Pixel (int x, int y)

Cell Class

A Cell abstracts a 10x10 pixel region of the screen, which is a smaller part of a larger region of the screen. Since we know the size of a Cell, then knowing where the bottom left corner of the cell is located tells us everything we need to know about the position of the rest of the Cell. The x coordinate of a pixel increments towards the right and decrements towards the left. With the same token, the y of a pixel increments and decremments in up and down the pixel, respectively. Define a class named Cell which has the following behaviors:

  • It can return the pixel that represents the Cell, which is the bottom left corner of the cell. Use the method signature: public Pixel getBottomLeft( )
  • It can change the pixel that represents the Cell. Use the method signature: public void setBottomLeft( Pixel pi)
  • It can return the center (pixel) of the Cell. Use the method signature: public Pixel getCenter( )
  • It can return the corners (pixel) of the Cell. Use the method signatures: public Pixel getTopLeft( ) public Pixel getTopRight( ) public Pixel getBottomRight( )

The Cell has the following two construcors that initilizes the value of pixel of its bottom-left corner.

  • Default Constructor that initializes the x,ycoordintes of the pixel to zero.

    public Cell( )

  • A Constructor that accepted the pixel value and initializes the left-bottom corner pixel. public Cell(Pixel pix )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions