VennDrawing
Class VennDiagram

java.lang.Object
  extended by VennDrawing.VennDiagram

 class VennDiagram
extends java.lang.Object

An object representing the Venn Diagram.

The main obejct which draws the venn diagram in a GUI.

Copyright: Copyright (c) 2008

Company: Bangladesh University of engineering and technology


Field Summary
static int ABSENT
          MACRO defining any label is absent as value -1
(package private)  int[][] Grid
          The grid where values to be set
(package private)  int Gs
          Grid Size
(package private)  int[] label
          label Array
(package private)  java.util.PriorityQueue labelQueue
          A priority queue where we can get the max label from it.
(package private)  int maxX
          Maximum X in the grid of the GUI.
(package private)  int maxY
          Maximum Y in the grid of the GUI.
(package private)  int order
          Order of the venn diagram.
(package private)  RSet[] setArray
          Array of All available Set Objects
 
Constructor Summary
VennDiagram(int order, RSet[] setArray)
          Constructor of the object.
 
Method Summary
private  void construct()
          The method which executes the algorithm for constructing the venn diagram.
 int countBits(int x)
          Returns how many 1's in the number Like in '3' it contains 2 "1"s in the binary value.
 SetLabel getMax()
          Removes the SetLabel which is marked as Max in the priority queue labelQueue
private  boolean isValid(int row, int col, int label)
          Checks any grid position in Grid array, whether it is valid or not.
static int power2(int x)
          Implements the function f(x)=2^x.
 void printGrid()
          Prints the grid values in the console in System.out.println();
(package private)  void printQueue()
          Prints the labelQueue
private  void removeLabel(int labelValue)
          Removes a labels from the labelQueue linked list.
 void showGrid()
          Prints the grid values in the javax.swing.JOptionPane.showMessageDialog();
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ABSENT

public static final int ABSENT
MACRO defining any label is absent as value -1

See Also:
Constant Field Values

label

int[] label
label Array


Gs

int Gs
Grid Size


Grid

int[][] Grid
The grid where values to be set


labelQueue

java.util.PriorityQueue labelQueue

A priority queue where we can get the max label from it.

The queue keeps a list of SetLabel Objects. And dequeues a SetLabel object having the highest number of 1's in its binary representation.


order

int order
Order of the venn diagram. Constraints as could be up to 15.


maxX

int maxX
Maximum X in the grid of the GUI.


maxY

int maxY
Maximum Y in the grid of the GUI.


setArray

RSet[] setArray
Array of All available Set Objects

Constructor Detail

VennDiagram

public VennDiagram(int order,
                   RSet[] setArray)
Constructor of the object. Initializes all fields and creates a GUIBuilder

Parameters:
order - order of the venn diagram . Should be less than 15.
setArray - Array of possible all sets as RSet objects
Method Detail

printQueue

void printQueue()
Prints the labelQueue


removeLabel

private void removeLabel(int labelValue)
Removes a labels from the labelQueue linked list.

Parameters:
lableValue - the label which will be removed from the label queue.

power2

public static int power2(int x)
Implements the function f(x)=2^x.

Parameters:
x - the input
Returns:
Returns 2^x .

construct

private void construct()
The method which executes the algorithm for constructing the venn diagram.


isValid

private boolean isValid(int row,
                        int col,
                        int label)
Checks any grid position in Grid array, whether it is valid or not. A grid position (i,j) is valid for label 'l' if
(Grid[i-1][j] | Grid[i+1][j] | Grid[i][j-1] | Grid[i][j+1] ) & l = Grid[i][j]

Parameters:
row - row position of the grid in the Grid array.
col - column position of the grid in the Grid array.
label - label value for which the grid position to be checked.
Returns:
true if the the grid position (row,col) is valid for 'label' false not valid.

showGrid

public void showGrid()
Prints the grid values in the javax.swing.JOptionPane.showMessageDialog();


printGrid

public void printGrid()
Prints the grid values in the console in System.out.println();


countBits

public int countBits(int x)
Returns how many 1's in the number Like in '3' it contains 2 "1"s in the binary value.

Parameters:
x - the value which's number of 1s in binary representation to be checked.
Returns:
number of bits in integer "x"

getMax

public SetLabel getMax()
Removes the SetLabel which is marked as Max in the priority queue labelQueue

Returns:
Returns the SetLabel object which is marked as Max.