52 lines
1.2 KiB
Java
52 lines
1.2 KiB
Java
package visualisation;
|
|
|
|
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
/**
|
|
* This class enables the user to add a legend area for describing the elements and symbols of an algorithm's visualization.
|
|
* Override method initialize(Graphics) for drawing your legend area's graphical output.
|
|
* @see JPanel
|
|
* @see HybridWindow
|
|
* @author Fabian Hamm
|
|
* DHBW Stuttgart Campus Horb
|
|
*/
|
|
public abstract class LegendArea extends JPanel {
|
|
|
|
/** The legend area's scroll pane. */
|
|
protected JScrollPane scrollPane;
|
|
|
|
/**
|
|
* Standard constructor
|
|
* Creates an empty legend area with scroll pane.
|
|
*/
|
|
public LegendArea() {
|
|
scrollPane=new JScrollPane(this);
|
|
}
|
|
|
|
/**
|
|
* Returns the legend area's scroll pane.
|
|
* @return the LegendArea's scroll pane
|
|
*/
|
|
public JScrollPane getScrollPane(){
|
|
return scrollPane;
|
|
}
|
|
|
|
/**
|
|
* Paints the legend area background and calls initialize(Graphics).
|
|
*/
|
|
public void paint(Graphics g) {
|
|
super.paint(g);
|
|
initialize(g);
|
|
}
|
|
|
|
/**
|
|
* Method that is responsible for drawing all elements and descriptions of the LegendArea.
|
|
* Implement this method to add and draw parameters to your legend area.
|
|
*
|
|
* @param g the Graphics object of the corresponding panel
|
|
*/
|
|
public abstract void initialize(Graphics g);
|
|
|
|
}
|