net.sf.sdedit.ui
Class PanelPaintDevice

java.lang.Object
  extended by net.sf.sdedit.diagram.PaintDevice
      extended by net.sf.sdedit.ui.PanelPaintDevice
All Implemented Interfaces:
MouseListener, MouseMotionListener, Iterable<Drawable>, EventListener, MouseInputListener, Constants

public class PanelPaintDevice
extends PaintDevice
implements MouseInputListener, Constants

A PanelPaintDevice is a PaintDevice implementation that uses a JPanel (see getPanel()) for displaying diagrams. Its main benefit is that - in contrast to other PaintDevice implementations - it does not allocate extra memory.

Author:
Markus Strauch

Field Summary
 
Fields inherited from interface net.sf.sdedit.Constants
ACTIVE_LIFELINE_COLOR, ANTI_ALIAS, dashed, DEFAULT_CODE_FONT, DEFAULT_CURSOR, DEFAULT_ENCODING_SCHEME, dotted, emptyStroke, GLOBAL_CONF_FILE, HAND_CURSOR, MOVE_CURSOR, SAVE_AS_FILE_PROPERTY, SAVE_AS_TYPE_PROPERTY, solid, TEST_FREEHEP_CLASSNAME, thick, thick_dashed, THREAD_COLORS
 
Constructor Summary
PanelPaintDevice(boolean interactive)
          Creates a new PanelPaintDevice.
 
Method Summary
 void addListener(PanelPaintDeviceListener ppdl)
          Adds a PanelPaintDeviceListener that will be notified when the mouse enters, exits or clicks drawable objects
 void close()
          This method is called once when no Drawable object will be added anymore.
 Zoomable<JPanel> getPanel()
          Returns the panel for displaying the diagram.
 int getTextHeight(boolean bold)
           
 int getTextWidth(String text, boolean bold)
           
 boolean isBlank()
           
 void mouseClicked(MouseEvent e)
          Notifies all PanelPaintDeviceListeners when the mouse has clicked a drawable object.
 void mouseDragged(MouseEvent e)
           
 void mouseEntered(MouseEvent e)
           
 void mouseExited(MouseEvent e)
           
 void mouseMoved(MouseEvent e)
          This method is called when the mouse moved over the panel.
 void mousePressed(MouseEvent e)
           
 void mouseReleased(MouseEvent e)
           
 void setAntialiasing(boolean on)
           
 void setDiagram(Diagram diagram)
           
 
Methods inherited from class net.sf.sdedit.diagram.PaintDevice
addOtherDrawable, addSequenceElement, announce, clear, computeAxes, computeBounds, getColor, getDiagram, getFont, getHeight, getRightBound, getTextHeight, getTextWidth, getWidth, isEmpty, iterator, reinitialize, writeToStream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PanelPaintDevice

public PanelPaintDevice(boolean interactive)
Creates a new PanelPaintDevice.

Parameters:
interactive - flag denoting if the PanelPaintDevice is interactive, meaning that it reacts to mouse movement and clicks
Method Detail

setDiagram

public void setDiagram(Diagram diagram)
Overrides:
setDiagram in class PaintDevice

mouseMoved

public void mouseMoved(MouseEvent e)
This method is called when the mouse moved over the panel. If it has exited or entered a drawable object, PanelPaintDeviceListeners are notified.

Specified by:
mouseMoved in interface MouseMotionListener
Parameters:
e -

addListener

public void addListener(PanelPaintDeviceListener ppdl)
Adds a PanelPaintDeviceListener that will be notified when the mouse enters, exits or clicks drawable objects

Parameters:
ppdl - a a PanelPaintDeviceListener

close

public void close()
Description copied from class: PaintDevice
This method is called once when no Drawable object will be added anymore. Its default implementation is empty.

Overrides:
close in class PaintDevice
See Also:
PaintDevice.close()

getTextHeight

public int getTextHeight(boolean bold)
Specified by:
getTextHeight in class PaintDevice
See Also:
PaintDevice.getTextHeight(boolean)

getTextWidth

public int getTextWidth(String text,
                        boolean bold)
Specified by:
getTextWidth in class PaintDevice
See Also:
PaintDevice.getTextWidth(java.lang.String, boolean)

getPanel

public Zoomable<JPanel> getPanel()
Returns the panel for displaying the diagram.

Returns:
the panel for displaying the diagram

setAntialiasing

public void setAntialiasing(boolean on)

isBlank

public boolean isBlank()

mouseClicked

public void mouseClicked(MouseEvent e)
Notifies all PanelPaintDeviceListeners when the mouse has clicked a drawable object.

Specified by:
mouseClicked in interface MouseListener
Parameters:
e -

mouseDragged

public void mouseDragged(MouseEvent e)
Specified by:
mouseDragged in interface MouseMotionListener
See Also:
MouseMotionListener.mouseDragged(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(MouseEvent e)
Specified by:
mouseEntered in interface MouseListener
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(MouseEvent e)
Specified by:
mouseExited in interface MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

mousePressed

public void mousePressed(MouseEvent e)
Specified by:
mousePressed in interface MouseListener
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(MouseEvent e)
Specified by:
mouseReleased in interface MouseListener
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)


Copyright © 2011. All Rights Reserved.