package visualisation; import java.awt.Graphics; import javax.swing.JPanel; import javax.swing.JScrollPane; /** * 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 javax.swing.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); }