Blog Archive

Friday, July 29, 2016

Java Programming

JAVA – LESSON No. 01
The Java Programming Language
  • The Java programming language is a high-level language that can be characterized by all of the following buzzwords:
    • Simple
    • Architecture neutral
    • Object oriented
    • Portable
    • Distributed
    • High performance
    • Multi threaded
    • Robust
    • Dynamic
    • Secure
The Java Platform
  • A platform is the hardware or software environment in which a program runs.
  • Some of the most popular platforms are Microsoft Windows, Linux, Solaris OS, and Mac OS.
  • Most platforms can be described as a combination of the operating system and underlying hardware.
  • The Java platform differs from most other platforms is that it's a software-only platform that runs on top of other hardware-based platforms.
  • The Java platform has two components:
    • The Java Virtual Machine
    • The Java Application Programming Interface (API)

The Java Virtual Machine
  • In the Java programming language, all source code is first written in plain text files ending with the .java extension.
  • Those source files are then compiled into .class files by the javac compiler.
  • A .class file does not contain code that is native to your processor; it instead contains byte codes— the machine language of the Java Virtual Machine (Java VM).
  • The java launcher tool then runs your application with an instance of the Java Virtual Machine.

The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related classes and interfaces; these libraries are known as packages.

What Can Java Technology Do?
  • The general-purpose, high-level Java programming language is a powerful software platform. Every full implementation of the Java platform gives you the following features:
    • Development Tools: The development tools provide everything you'll need for compiling, running, monitoring, debugging, and documenting your applications. As a new developer, the main tools you'll be using are the java compiler, the java launcher, and the Javadoc documentation tool.
    • Application Programming Interface (API): The API provides the core functionality of the Java programming language. It offers a wide array of useful classes ready for use in your own applications. It spans everything from basic objects, to networking and security, to XML generation and database access, and more. The core API is very large.
    • Deployment Technologies: The JDK software provides standard mechanisms such as the Java Web Start software and Java Plug-In software for deploying your applications to end users.
    • User Interface Toolkits: The Swing and Java 2D toolkits make it possible to create sophisticated Graphical User Interfaces (GUIs).
    • Integration Libraries: Integration libraries such as the Java IDL API, JDBC™ API, Java Naming and Directory Interface™ (JNDI) API, Java RMI, and Java Remote Method Invocation over Internet Inter-ORB Protocol Technology (Java RMI-IIOP Technology) enable database access and manipulation of remote objects.
The NetBeans Software



  • We're going to be create a Java Application, so select Javaunder Categories, and then Java Application under Projects. Click the Next button at the bottom to go to step two;


  • In the Project Name area at the top, type a Name for your Project. Notice how the text at the bottom changes to match your project name (in the text box to the right of Create Main Class):
    • Main
  • If we leave it like that, the Class will have the name Main. Change it to FirstProject:


  • Now, the Class created will be called FirstProject, with a capital "F", capital "P".
  • The package is also called firstproject, but with a lowercase "f" and lowercase "j".
  • The default location to save your projects appears in the Project Location text box.
  • You can change this, if you prefer. NetBeans will also create a folder with your project name, in the same location.
  • Click the Finish button and NetBeans will go to work creating all the necessary files for you.
  • When NetBeans returns you to the IDE, have a look at the Projects area in the top left of the screen (if you can't see this, click Window > Projectsfrom the menu bar at the top of the software):


Click the plus symbol to expand your project, and you'll see the following:




Now expand Source Packages to see your project name again. Expand this and you'll see the Java file that is your source code.




This same source code should be displayed to the right, in the large text area. It will be called FirstProject.java. If you can't see a code window, simply double click FirstProject.java in your Projects window above. The code will appear, ready for you to start work.




The coding window that appears should look like this (we've changed the author's name):

Java Comments
  • When you create a New Project in NetBeans, you'll notice that some text is grayed out, with lots of slashes and asterisks.
  • The grayed-out areas are comments.
  • When the program runs, comments are ignored. So you can type whatever you want inside of your comments.
  • But it's usual to have comments that explain what is you're trying to do.
  • You can have a single line comment by typing two slashes, followed by your comment:
    • //This is a single line comment
  • If you want to have more than one line, you can either do this:
    • //This is a comment spreading
      //
      over two lines or more
  • Or you can do this:
    • /*
      This is a comment spreading
      over two lines or more
      */

  • There's also something called a Javadoc comment.
  • You can see two of these in the coding image on the previous page.
  • A Javadoc comment starts with a single forward slash and two asterisks ( /** ) and ends with an asterisk and one slash ( */ ).
  • Each line of the comment starts with one asterisk.

  • /**
    *
    This is a Javadoc comment 
    */

  • Javadoc comments are used to document code. The documented code can then be turned into an HTML page that will be helpful to others. You can see what these look like by clicking Run from the menu at the top of NetBeans. From the Run menu, select Generate Javadoc.
  • Hello World Application
  • When you created this project, you left the Create Main Class checkbox selected in the New Project wizard.
  • The IDE has therefore created a skeleton class for you.
  • You can add the "Hello World!" message to the skeleton code by replacing the line:
    • // TODO code application logic here
  • with the line:
    • out.println("Hello World!"); // Display the string.

Warning : Type all code, commands, and file names exactly as shown. Both the compiler (javac) and launcher (java) are case-sensitive, so you must capitalize consistently.

Compile the Source File into a .class File
  • To compile your source file, choose Build | Build Main Project from the IDE's main menu.
  • The Output window opens and displays output similar to what you see in the following figure:

  • If the build output concludes with the statement BUILD SUCCESSFUL, congratulations! You have successfully compiled your program!
  • If the build output concludes with the statement BUILD FAILED, you probably have a syntax error in your code.
  • Errors are reported in the Output window as hyper-linked text.
  • You double-click such a hyper-link to navigate to the source of an error.
  • You can then fix the error and once again choose Build | Build Main Project.
  • When you build the project, the byte code file FirstProject.class is generated.
  • Now that you have built the project, you can run your program.

The main Method
  • In the Java programming language, every application must contain a main method whose signature is:
    • public static void main(String[] args)
  • The modifiers public and static can be written in either order (public static or static public), but the convention is to use public static as shown above.
  • You can name the argument anything you want, but most programmers choose "args" or "argv".
  • The main method is similar to the main function in C and C++; it's the entry point for your application and will subsequently invoke all the other methods required by your program.
  • The main method accepts a single argument: an array of elements of type String.
    • public static void main(String[] args)
  • This array is the mechanism through which the runtime system passes information to your application.
    • For example:java My App arg1 arg2
  • Each string in the array is called a command-line argument.
  • Command-line arguments let users affect the operation of the application without recompiling it.
  • For example, a sorting program might allow the user to specify that the data be sorted in descending order with this command-line argument:
    • descending

THANK YOU!

Sunday, July 17, 2016

Adobe Photoshop CS6 - Lesson 04

Image Editing (Lesson-04)
 Now that you know how to find your way around in the Adobe Photoshop CS6 interface and are familiar with the most common commands, palettes, and tools, you can start doing some basic image editing. In the next few chapters of this tutorial you will learn how to crop, resize, correct, and sharpen/blur your images.

Cropping
Cropping is one of the most basic editing techniques that can improve your images. Cropping helps to bring out the most important features in your image and focus the viewers’ attention on these features. Cropping also allows you to make your image a standard photo size.
There are several ways to crop images in Adobe Photoshop: 

1. Cropping with the Crop Tool  
2. Cropping to a specific size  
3. Cropping with the Marquee Tool 

Cropping with the Crop Tool

  The Crop Tool allows you to make a precise selection of an image you wish to edit. To crop with the Crop Tool, follow these steps:  
1. Open the image you wish to crop (see Getting Started for detailed instructions).  
2. Select the Crop Tool from the Toolbox (see Selection Tools for location and description).  3. It will automatically select your entire image. Drag the edges to fit the dimensions you desire.  
4. Resize the border by dragging the squares at the sides and corners until you are satisfied with the    way your image looks. 5. Once you are completely satisfied with your cropped image, press Enter.
Note: You can also rotate your cropping border. Move the cursor outside the border, you will see how it turns into a double-headed arrow. Drag the arrows in the directions you wish to rotate your selection.  


Cropping to a specific size
If you wish to print your digital photos or other images on standard size photo paper, you will have to crop your images to a specific size, such as 8x10. To crop an image to a specific size, do the following:
 1. Open the image you wish to crop. 

 2. Select the Crop Tool from the Toolbox.  
3. In the Options bar, specify the values for Width and Height.  
4. Click in your image and drag the cropping border. Notice that the border is constrained. You cannot    make it wider or longer than the specified values. For example, if you entered 8 for Width    and 10 for Height, whatever size you make the border, the area within it will fit on an 8x10 photo.    
 5. Once you are completely satisfied with your cropped image, press Enter. 

Cropping with the Marquee Tool
If you are in a hurry and need just a simple crop, you can use the Marquee Tool and a menu command. To crop with the Marquee Tool, follow the steps below:
 1. Open the image you wish to crop.  

 2. Select the Rectangular Marquee Tool from the Toolbox (see Selection Tools).  
 3. Click and drag the mouse to draw a marquee around the area you wish to crop.  
4. In the main menu, go to Image > Crop. The image will be immediately cropped.
 

Resizing 
Resizing in Photoshop can help you print your images in standard photo sizes, resize and preserve the high quality of digital photos, and enlarge small images to a poster size.
Resizing to a specific size To resize your image to a preset size, follow the steps below:
 1. In the main menu, go to File > New.  

 2. In the New dialog box, click on the Preset drop down menu. You will see several preset sizes, such as     2x3, 4x6 and 5x7. Remember that 72 ppi is fine for online images, but a ppi of 150-300 is better     for printed images.

3. Choose the size that you wish and click OK.
Note: All the preset sizes are in portrait orientation. If you wish to resize an image with the landscape orientation, you need to create your own preset. To create your own size, do the following:
 1. Type in the values for Width and Height, for example 7x5.  

 2. Type in your desired resolution (150 ppi for high quality prints, and 72 ppi is good for web images). 
 3. Click the Save Preset button  

Resizing digital photos
Digital photos usually have large dimensions but low resolution, 72 ppi, which affects their quality when their size is decreased or increased. When printed, the photos with the changed size will look pixilated. To resize the digital photos without loosing the quality, follow these steps:
 1. Open the digital photo you wish to resize.  

 2. In the main menu, go to View > Rulers. You will see the dimension of your photo
 3. In the main menu, go to Image > Image Size.  
 4. In the Image Size dialog box, check the Re-sample Image box off. Type in your desired resolution (anything between 150 and 300 ppi). The photo is now 3.208 x 3.083 inches.

Enlarging 
If you want to make your digital photo into a poster size image, you can do it in the Image Size dialog box. However, just increasing the dimensions will make the image appear blurry and pixilated.  To enlarge the image without losing the quality, follow these steps:
 1. Open the digital image you wish to enlarge.  

 2. In the main menu, go to Image > Image Size.  
 3. In the Image Size dialog box, make sure the Re-sample Image box is checked off and choose Bi-cubic       Smoother from the drop down box.  
4. Change the Document Size measurements to Percent. Type in 110. This will increase the size of the       image by 10 percent.  
5. Continue enlarging by 10 percent until you are satisfied with the size.

Correcting
Digital cameras tend to cause various problems, such as “red eye” or “hot spots”, if you use flash, or underexposure, if you don’t. In Photoshop, you can correct these problems, as well as adjust the overall color of your digital photo. Red Eye Removal The digital camera flash is located right above the lens, which causes the “red-eye”; however, you can fix your photos easily in Photoshop. To remove the “red eye”, follow the steps below:
 1. Open a photo you wish to correct.  

 2. Select the Zoom Tool from the Toolbox. Click and drag a rectangle around the eye.
4. Click and hold on the little black triangle of the Healing Brush Tool button and select the Red Eye        Tool.
5. Click on the red part of the eye and paint, holding down the mouse button. You will see how the red       will disappear.

Hot Spot Removal
Using a flash can also cause shiny areas on peoples’ faces or the flash to reflect on shiny surfaces. To correct this problem, follow the steps below:
 1. Open the photo you wish to correct.  2. Select the Clone Stamp Tool from the Toolbox.  3. In the Options bar, change the Blend Mode from Normal to Darken.

 3.  Make sure your default Foreground and Background colors are black and white.
 4. Set the Opacity to 50 percent.  
 5. Choose a soft-edged brush, set the diameter to 40 or 50. 6. Hold down the Shift key and click in the clean area (without “hot spots”) to get a sample of color.
7. Paint over the “hot spot”, the light area will gradually darken.

Adding Flash
If you took pictures indoors without a flash, they will turn out underexposed and dark. To fix underexposed photos, follow these steps:
 1. Open a digital photo you wish to correct.

 2. In the main menu, go to Layers > Duplicate. In the next window, name the layer Layer 1.
 3. Make sure Layer 1 is selected in the Layers palette. Select Image from the menu, select Adjustments       and select Exposure. Select the amount of exposure. The whole image will lighten. 
4. Keep duplicating Layer 1 until you are satisfied with the your image.

Color Adjustment
Color adjustment options in Photoshop CS6 can help you to make your digital photos look more natural. To color correct your images, follow these steps: 
 1. Open the image you wish to correct.  

 2. In the main menu, go to Image > Adjustments > Levels. You will see a dialog box displaying a diagram       of the colors in your image. The black triangle is for shadows, the gray is for midtones, the      white is for highlights. In the Channels drop down menu, you can choose between RGB. These indicate      whether your changes effect all the colors, or just one (red, green, or blue). 

Saving
Remember to save your work often. Saving frequently lessens the risk of losing the work you have been doing. To save your Photoshop document, do the following:
 1. Click File > Save As.   

 2. Navigate to the place you would like your document to be saved by using the drop down menu and       the navigation window.  
 3. Enter the name of your document in the Save As text field.  
 4. Choose a format to save your project in from the Format drop-down menu.
 5. Click the Save button in the bottom right corner of the dialogue box.  
 6. Check to make sure that your document is saved in the place you intended. 


THANK YOU......!

Saturday, July 16, 2016

Adobe Photoshop CS6 - Lesson 03

4. Toolbox (Lesson 03)
If you used other Adobe products, such as Illustrator or In Design, you should be familiar with the toolbox in  Adobe Photoshop CS6 as it shares some of the tools from these applications. If you are a new user of Adobe products, you should keep in mind that you might not need to use all of the tools. In this tutorial, only the basic tools will be discussed in-depth.
Some tools in the toolbar have additional “hidden” tools. These tools have small black triangles in the right-hand corner. To view the “hidden” tools, click and hold down on any tool that has a gray triangle in the corner (Figure 10). 



Move Tool
Used to select and move objects on the page. Click the tool button, then click on any object on the page you wish to move.

Marquee Tool
Selects an object by drawing a rectangle or an ellipse around it. Click the tool button, choose a rectangular or an elliptical marquee. Drag the marquee over the area of the image you wish to select.

Lasso Tool
Selects an object by drawing a freehand border around it. Click the tool button, drag to draw a freehand border around the are of the image you wish to select.

Magic Wand Tool
Selects all objects in a document with the same or similar fill color, stroke weight, stroke color, opacity or blending mode. By specifying the color range or tolerance, you can control what the Magic Wand tool selects

Crop Tool
Click the tool button, then click and drag the tool over the part of the image that you want to keep. Resize the selected area dragging the squares at the sides and corners. Click the Return/Enter key when your crop box is sized correctly.

Eye Dropper Tool
Takes color samples from colors on the page and displays them in the Color Boxes. Select the tool, click on the color in the image you wish to sample. The Color Box will display this color.

 Healing Brush Tool
 Corrects small blemishes in scanned photos. Select the tool, hold down the ALT key and left-click on the base color you need to heal. Then left-click over the blemish.

Brush Tool
 Draws brush strokes of different thicknesses and colors. Select the tool. Then click on the selected area, drag to draw lines. Use the Options bar to change the brush, mode, opacity and flow.

Clone Stamp Tool
 Takes a sample of an image and applies over another image, or a part of the             same image. Select the tool. Hold down the ALT key and left-click on a certain point of the document where you want to start your copy point. Then, put your mouse over whatever part of the new document you want the picture to go to. Hold down the left mouse button and drag the mouse across the page to copy the picture.

Art History Brush Tool
 Paints over an image using the source data from a specified history state or snapshot. Select the tool, specify the brush, blending mode, opacity, style, area and tolerance.

Eraser Tool
 Removes part of an existing path or stroke. You can use the Erase tool on paths. Text can only be erased when rasterized. Select the tool, click on the part of the image you wish to erase. Drag to erase pixels.

Paint Bucket Tool
 Applies a color fill to a selected part of the image or to an entire layer. Select a layer you wish to apply the paint bucket to, click the tool button, click on the starting point, and click the area you wish to fill.

Blur Tool
Blurs the sharp edges of an image. Select an area where you wish to apply the tool. Click the tool button and choose the brush, mode, and strength. Drag the brush along the edges.

Path Selection
Selects paths and path segments. Select the tool, click anywhere on the path.




Type
Types text on a page. Every time you click the Type Tool on a new portion of the page, a new layer will be created. Select the type tool, click on the page and begin to type. You can specify the font and size in the Options bar. You can also resize and transform the text box by dragging the squares at the sides and corners. Use the Move Tool to move the text on the page.


Pen
Draws smooth-edged paths. Select the tool, click on the page and drag to draw a path. Click and drag the anchor points to modify the path.

Line Shape
Draws a straight line. Other shapes that are hidden in this tool are: Rounded Rectangle Tool, Ellipse Tool, Polygon Tool, Line Tool, and Custom Shape Tool.
Select the tool, click and drag on the page to draw a line.

Hand
Allows you to move around within the image. Select the tool, click on the spot on the page, hold the mouse button down, drag to move in the area.

Magnify
Magnifies or reduces the display of any area in your image window. Select the tool, choose Zoom In or Zoom Out in the Options bar, click on the area of the image you wish to magnify or reduce.

Color Boxes
The foreground color appears in the upper color selection box and represents a color that is currently active. The background color appears in the lower box and represents an inactive color.
1. To change the foreground color, click the upper color selection box in the Toolbox.
2. To change the background color, click the lower color selection box in the Toolbox.
3. To reverse the foreground and background colors, click the Switch Colors icon  (the arrow) in the toolbox.
4. To restore the default foreground and background colors, click the Default Colors icon (the little black and white boxes) in the toolbox.
Note: If you are using the Gradient Tool, the currently selected foreground and background colors will be the default colors of the gradient.

See Lesson 04