3.9.2 - Draw Panel - JdlDrawPanel

John W. Campbell

3.9.2.1 Introduction

This class provides a simple panel for drawing on, using an object supporting the JdlDrawPanelDrawer interface.

Class, constructor and methods:

Class Details
Accessible Fields
Constructor
Panel Drawer Methods
Panel Size Methods
Overriden Superclass Methods

3.9.2.2 Class Details

Package:
Jdl.JdlView;
Class name:
JdlDrawPanel
Class definition:
public class JdlDrawPanel
Extends:
JPanel
Implements:
Scrollable
Actions:
none

3.9.2.3 Accessible Fields

The following accessible fields have been defined:

static final long serialVersionUID

3.9.2.4 Constructor

3.9.2.4.1 Introduction

Two constructors are available.

Constructor:

Constructor 1
Default constructor

3.9.2.4.2 Constructor 1

Constructs a draw panel with a requested width and height.

Constructor Definition:
public JdlDrawPanel (int w, int h)
Parameters List:
w
The panel width required.
h
The panel height required.

3.9.2.4.3 Default constructor

Constructs draw with default resources (height = 25, width = 25).

Constructor Definition:
public JdlDrawPanel()
Parameters List:
none

3.9.2.5 Panel Drawer Methods

3.9.2.5.1 Introduction

This section contains methods for setting and getting the panel drawer resources.

Methods:

Set drawer - setDrawer
Get drawer - getDrawer
Get drawer ID - getDrawerId

3.9.2.5.2 Set drawer - setDrawer

This method sets the JdlDrawPanelDrawer object resource.

Method Definition:
public void setDrawer (JdlDrawPanelDrawer dr, int id)
Parameters List:
dr
A JdlDrawPanelDrawer interfaced object to carry out the drawing on the panel (default = null). Its jdl_draw_panel_drawer method is called from the paint routine after the border has been drawn.
id
Identifier to be passed to the drawing method when called.

3.9.2.5.3 Get drawer - getDrawer

This method returns the JdlDrawPanelDrawer object resource.

Method Definition:
public JdlDrawPanelDrawer getDrawer()
Parameters List:
none
Method Return:
Returns the currently installed JdlDrawPanelDrawer object or null if none has been set up.

3.9.2.5.4 Get drawer ID - getDrawerId

This method returns the JdlDrawPanelDrawer identifier resource.

Method Definition:
public int getDrawerId()
Parameters List:
none
Method Return:
Returns the identifier of the currently installed JdlDrawPanelDrawer object.

3.9.2.6 Panel Size Methods

3.9.2.6.1 Introduction

This section contains methods to set and get the panel height and width resources.

Methods:

Set panel height - setPanelHeight
Get panel height - getPanelHeight
Set panel width - setPanelWidth
Get panel width - getPanelWidth

3.9.2.6.2 Set panel height - setPanelHeight

This method sets the panel height resource.

Method Definition:
public void setPanelHeight (int height)
Parameters List:
height
The required panel height in pixels.

3.9.2.6.3 Get panel height - getPanelHeight

This method returns the panel height resource.

Method Definition:
public int getPanelHeight()
Parameters List:
none
Method Return:
Returns the requested panel height in pixels.

3.9.2.6.4 Set panel width - setPanelWidth

This method sets the panel width resource.

Method Definition:
public void setPanelWidth (int width)
Parameters List:
width
The required panel width in pixels.

3.9.2.6.5 Get panel width - getPanelWidth

This method returns the panel width resource.

Method Definition:
public int getPanelWidth()
Parameters List:
none
Method Return:
Returns the requested panel width in pixels.

3.9.2.7 Overriden Superclass Methods

3.9.2.7.1 Introduction

This section contains methods which override the corresponding superclass methods. These are basically standard for JdlView objects and comprise methods to set background and foreground colours and to get the minimum and preferred sizes for the object. (The paintComponent method is also over-ridden but is not normally called by the user).

Methods:

Set background - setBackground
Set foreground - setForeground
Get minimum size - getMinimumSize
Get preferred size - getPreferredSize

3.9.2.7.2 Set background - setBackground

This method sets the background colour resource.

Method Definition:
public void setBackground (Color c)
Parameters List:
c
The color to become this object's background color.

3.9.2.7.3 Set foreground - setForeground

This method sets the foreground colour resource.

Method Definition:
public void setForeground (Color c)
Parameters List:
c
The color to become this object's foreground color.

3.9.2.7.4 Get minimum size - getMinimumSize

This method returns the minimum size of the component.

Method Definition:
public Dimension getMinimumSize()
Parameters List:
none

3.9.2.7.5 Get preferred size - getPreferredSize

This method returns the preferred size of the component.

Method Definition:
public Dimension getPreferredSize()
Parameters List:
none

⇑ Up 3   ⇑ Up 2   ⇑ Up 1   ⇑ Top of this