Google’s GDrive


The GDrive service will provide anyone (who trusts Google with their data) a universally accessible network share that spans across computers, operating systems and even devices.  Users will no longer require third party applications to emulate this behaviour by abusing Gmail storage.

In a Windows environment, most users know how to use the typical C: in “My Computer”.  Network drives work exactly the same but are given a different letter and the files within are not stored on the computer.  If my suspicions are correct and GDrive is simply a network share, most applications could take advantage of this service without modification.

The question of course is how Google will monetize a service like this.  I cannot see how file storage using a network share could be used to serve up advertisements — so maybe they won’t.  In some screenshots of Gmail for domains, it appears there are different “account plans” that I assume provide additional email addresses.  Could a similar system work for online storage?  For example, 1GB free and pay $5 for each additional.

Another way to generate income from this service would be to provide users a DVD backup of their data for a small monthly fee.  Depending on how often a GDrive is used by someone, it could make sense to receive a backup on a regular schedule — while they are at it, why not include some “cool” extras on those DVD’s?

Online storage with GDrive could be an important part of Google’s future plans — universal access to your data will soon become reality. Watch out and wait.

Program to check rectangle overlapping.


Algorithm : 

  • Two rectangles can overlap if one rectangle has 0,1,2,4 corners inside the other rectangle. The check of above mentioned condition could result is many different combinations. Remember overlapping rectangle cannot have 3 corners inside.
  • Other way we can say that two rectangle overlap if the region of one rectangle lies inside the other.

various overlapping possibilites

  • The best way to find is to identify whether an overlapping area is present or not which can be known if the below mentioned all conditions are true.

If we check that

·        The left edge of B is to the left of right edge of R.

·         The top edge of B is above the R bottom edge.

·         The right edge of B is to the right of left edge of R.

·        The bottom edge of B is below the R upper edge.

Then we can say that rectangles are overlapping.

 

Consider an example: There are two rectangles as shown in diagram – Black Rectangle (B) and Red rectangle(R).

overlap21

 

If we check that

·        The left edge of B  is to the left of  right edge of  R. The selected area will be :

overlap1_11

 

 

·        The top edge of B is above the R bottom edge. So the selected area will be:

overlap2_1

·        The right edge of B is to the right of left edge of R. The selected area will be:

overlap3_11

 

 

 

 

·        The bottom edge of B is below the R upper edge. The selected area will be:

 

overlap4_1

 

Hence all conditions are true we can say that rectangles are overlapping.

Therefore we can see that all the conditions are valid and hence rectangle is overlapping.

 

Below is the source code attached. The logic is only present in checkOverlap() method, rest is used to display the GUI and check.

 

package com;

 

import java.awt.*;

import java.awt.event.*;

 

import javax.swing.*;

 

public class RectangleOverlap extends JPanel{

 

      int r1x1,r1x2,r2x1,r2x2 ;

      int r1y1,r1y2,r2y1,r2y2 ;

            int r1width,r2width ;

            int r1height,r2height ;

      static JButton btn = new JButton(“Check”);

      public RectangleOverlap(int r1x1,int r1y1,int r1x2,int r1y2,int r2x1,int r2y1,int r2x2,int r2y2){

            this.r1x1=r1x1;

            this.r1x2=r1x2;

            this.r1y1=r1y1;

            this.r1y2=r1y2;

            this.r2x1=r2x1;

            this.r2x2=r2x2;

            this.r2y1=r2y1;

            this.r2y2=r2y2;

            r1width = Math.abs(r1x1-r1x2);

            r2width = Math.abs(r2x1-r2x2);

            r1height = Math.abs(r1y1-r1y2);

            r2height = Math.abs(r2y1-r2y2);

            addActionListener();

      }

 

      private void addActionListener() {

            btn.addActionListener(new ActionListener(){

 

                  public void actionPerformed(ActionEvent e) {

                        checkOverlap();

            }

            });

           

      }

      private void checkOverlap() {

            // condition to check whether the rectangles are overlapping or not.s

            boolean isOVerlap= ((r1x2 >= r2x1) &&

                  (r1y2 >= r2y1) &&

                  (r1x1 <= r2x2) &&

                (r1y1 <= r2y2));

     

      if(isOVerlap ){

            JOptionPane.showMessageDialog(null, “OVerlap”);

      }else{

            JOptionPane.showMessageDialog(null, “No OVerlap”);

      }

      }

 

      @Override

      protected void paintComponent(Graphics g) {

            g.drawRect(r1x1,r1y1 , r1width, r1height);

            g.setColor(new Color(123,232,122));

            g.drawRect(r2x1, r2y1, r2width,r2height);

      }

 

      public static void main(String args[]){

            JFrame frame = new JFrame();

            frame.setSize(500,500);

// input to check overlap condition.

// the order followed as : enter coordinate for 1st rectangle as lower limit and upper limit to rectangles          

            frame.getContentPane().add(new RectangleOverlap(20,30,120,130,10,50,160,120),BorderLayout.CENTER);

            frame.getContentPane().add(btn,BorderLayout.SOUTH);

            frame.addWindowListener(new WindowAdapter(){

                  @Override

                  public void windowClosing(WindowEvent e) {

                        System.exit(0);

                  }

                 

            });

            frame.setVisible(true);

      }

}

 

 

How to create customized singly linked list


Linked list work on the concept of FIFO – First in First out. i.e the element inserted first will be the one retrieved first.

Create a class which will act as data structure and act as a single Node.

 public class MyList {

 

            public Object ob;

            public MyList next;

           

            public MyList(Object ob){

                        this.ob=ob;

            }

}

Now create a class to implement the basic functionality:

public class MyLinkedList {

 

            private MyList first=null;

            private MyList last=null;

           

            public MyLinkedList (){

                       

            }

            public void add(Object o){

                        if(first == null){

                                    first = last= new MyList(o);

                        }else{

                                    last.next = new MyList(o);

                                    last= last.next;

                        }

            }

            private void getData(){

                        MyList temp =first;

                        do{

                                    System.out.println(temp.ob + ” “);

                                    temp=temp.next;

                        }while(temp != null);

                       

            }

            private void delete(Object o){

                        MyList temp =first;

                        MyList prev =null;

                       

                        do{

                                    if(temp.ob.equals(o)){

                                                prev.next=temp.next;

                                                break;

                                    }

                                    prev = temp;

                                    temp=temp.next;

                        }while(temp != null);

                       

            }

 

public static void main(String args[]){

                         MyLinkedList lst = new MyLinkedList();

                         lst.add(6);

                         lst.add(62);

                         lst.add(16);

                         lst.add(65);

                         lst.add(26);

                         lst.add(25);

                         System.out.println(“After Insert”);

                         lst.getData();

                         lst.delete(16);

                         System.out.println(“After Delete”);

                         lst.getData();

                         

            }

}

The output will be :

After Insert

6 62 16 65 26 25

 

After Delete

6 62 65 26 25