VennDrawing
Class DrawPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by VennDrawing.DrawPane
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

 class DrawPane
extends javax.swing.JPanel
implements java.awt.event.MouseListener

A panel object where the Venn Diagram to be drawn with interaction with user.

The Panel where the graphical work is done to draw the venn diagram. Also implements
a MouseListener to keep interaction with user.

Copyright: Copyright (c) 2008

Company: Bangladesh University of engineering and technology


Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private)  int boxHeight
          The width of the box which represents a setLabel.
(package private)  int boxWidth
          The width of the box which represents a setLabel.
(package private)  int colorStep
          Used to randomize the boxes with colors.
(package private)  int[][] Grid
          The grid array.
(package private)  int[][] Grid2
          A copy of Grid array just not having the values which have null values.
(package private)  int highlightSet
          marker for which set to highlight
static int INITCOLOR
          MACRO INITCOLOR as the initial color value in RGB Initialized as 255 (all white).
static int MAX
          MACRO MAX as the maximum box size.
(package private)  int maxX
          The maximum value of x in the GUI frame
(package private)  int maxY
          The maximum value of y in the GUI frame
(package private)  boolean nullValueVisible
          Check flag to show the venn diagram with or without null values.
(package private)  int order
          The order of the venn diagram.
(package private)  RSet[] setArray
          Native setArray.
(package private)  int testValue
          Checks the flag for the venn diagram showing sets
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
DrawPane(int maxX, int maxY, int[][] Grid, int order, RSet[] setArray)
          Constructor for the object.
 
Method Summary
private  java.lang.String getLabel(int val)
          Converts label value in integer to String.
private  java.lang.String getLabelWithValue(int val)
          Converts label value in integer to String.
private  void initBoxSize()
          Initializes the field boxWidth , boxHeight using MAX , maxX and maxY.
private  boolean isNull(int label)
          Checks a label having null set data.
 void mouseClicked(java.awt.event.MouseEvent e)
          The method is invoked when mouse is clicked.
 void mouseEntered(java.awt.event.MouseEvent e)
          The method is invoked when mouse is entered.
 void mouseExited(java.awt.event.MouseEvent e)
          The method is invoked when mouse exited the screen.
 void mousePressed(java.awt.event.MouseEvent e)
          The method is invoked when mouse key is pressed.
 void mouseReleased(java.awt.event.MouseEvent e)
          The method is invoked when mouse key is released.
 void paintComponent(java.awt.Graphics g)
          Paints the DrawPanel panel with Graphics2D.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX

public static final int MAX
MACRO MAX as the maximum box size. Initialized as 400

See Also:
Constant Field Values

INITCOLOR

public static final int INITCOLOR
MACRO INITCOLOR as the initial color value in RGB Initialized as 255 (all white).

See Also:
Constant Field Values

maxX

int maxX
The maximum value of x in the GUI frame


maxY

int maxY
The maximum value of y in the GUI frame


order

int order
The order of the venn diagram. Initialized from the consturctor.


Grid

int[][] Grid
The grid array. Initially Null. But initialized from constructor to depict to GUI.


boxWidth

int boxWidth
The width of the box which represents a setLabel.


boxHeight

int boxHeight
The width of the box which represents a setLabel.


colorStep

int colorStep
Used to randomize the boxes with colors.


setArray

RSet[] setArray
Native setArray. Array of sets. Intialized at the constructor.


Grid2

int[][] Grid2
A copy of Grid array just not having the values which have null values.


nullValueVisible

boolean nullValueVisible
Check flag to show the venn diagram with or without null values.


testValue

int testValue
Checks the flag for the venn diagram showing sets


highlightSet

int highlightSet
marker for which set to highlight

Constructor Detail

DrawPane

public DrawPane(int maxX,
                int maxY,
                int[][] Grid,
                int order,
                RSet[] setArray)
Constructor for the object.

Parameters:
maxX - Maximum value of X of the GUI Draw Panel.
maxY - Maximum value of Y of the GUI Draw Panel.
Grid - the 2D array already initialized in VennDiagram object.
order - order of the venn diagram.
setArray - Array of possible all sets as RSet objects
Method Detail

initBoxSize

private void initBoxSize()
Initializes the field boxWidth , boxHeight using MAX , maxX and maxY.


getLabel

private java.lang.String getLabel(int val)
Converts label value in integer to String. For Example. In order 3. If label is 5 or 101 in binary then the String
would be AC. Which represents a set Region AC having members of A and C only,
where possible sets A, B and C.

Parameters:
val - The label value in integer
Returns:
Returns a String corresponding to the label value "val".

isNull

private boolean isNull(int label)
Checks a label having null set data.

Parameters:
label - the label which is to be checked.

getLabelWithValue

private java.lang.String getLabelWithValue(int val)
Converts label value in integer to String. With addition addes values. For Example. In order 3. If label is 5 or 101 in binary then the String
would be AC. Which represents a set Region AC having members of A and C only,
where possible sets A, B and C.

Parameters:
val - The label value in integer
Returns:
Returns a String corresponding to the label value "val".

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
The method is invoked when mouse is clicked.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent object.

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
The method is invoked when mouse is entered.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent object.

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
The method is invoked when mouse key is pressed.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent object.

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
The method is invoked when mouse exited the screen.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent object.

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
The method is invoked when mouse key is released.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Parameters:
e - a MouseEvent object.

paintComponent

public void paintComponent(java.awt.Graphics g)
Paints the DrawPanel panel with Graphics2D.

Overrides:
paintComponent in class javax.swing.JComponent
Parameters:
g - A Graphics object.