Class ScreenDesigner

  • All Implemented Interfaces:
    IScreenDesigner, java.util.EventListener, org.eclipse.swt.events.FocusListener, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener, org.eclipse.swt.internal.SWTEventListener

    public class ScreenDesigner
    extends java.lang.Object
    implements IScreenDesigner, org.eclipse.swt.events.FocusListener, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.MouseMoveListener
    Screen designer interfaces to the TerminalWindow to perform drawing of rectangles and to interface with the mouse and keyboard. Note that the display cannot be drawn correctly if the font size is smaller that 4 pixels vertically or horizontally.
    Author:
    Christopher Mindus
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.awt.Container imageObserver
      The image observer.
      java.lang.Runnable repainter
      The repainter.
    • Constructor Summary

      Constructors 
      Constructor Description
      ScreenDesigner​(ITermEditor editor)
      Constructs the instance of the screen designer.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void assignProperty​(PropCnr propCnr)
      Assigns the verification property and starts listening to it.
      static org.eclipse.swt.widgets.Composite createHostFieldToolTip​(HostField hostField, org.eclipse.swt.widgets.Composite parent)
      Creates a tooltip composite for a host field.
      void dispose()
      Disposes of the designer.
      void drawHandle​(ScreenRectangleInfo rectInfo, int handle, java.awt.Graphics2D g, java.awt.Color c, int x, int y, boolean draw)
      Draws a handle at position.
      static int drawLine​(java.awt.Graphics2D g, int x1, int y1, int x2, int y2, int type, int phase)
      Draws a "Business Graphics" line between two points with the current color and the same behavior as for "Java lines".
      void focusGained​(org.eclipse.swt.events.FocusEvent e)
      Focus gained.
      void focusLost​(org.eclipse.swt.events.FocusEvent e)
      Focus is lost.
      org.eclipse.swt.graphics.Rectangle getMarkingConstraints()
      Gets the rectangle marking constraints.
      int getMouseHandle​(int x, int y, IScreenRectangle[] returnValue)
      Gets the mouse handle: -1 when not found, 0 for move, otherwise a size handle.
      java.util.LinkedHashSet<IScreenRectangle> getSelectedRectProps()
      Gets the currently selected properties for rectangles.
      boolean hasMark()
      Checks if terminal has a mark.
      boolean hasSingleMark()
      Checks if terminal has a single mark.
      boolean isCursorPresent()
      Cursor present (and blinking)?
      boolean isHotSpotEnabled()
      Check for hotspot enabled.
      boolean isWrapped​(IScreenRectangle r)
      Checks if a rectangle is wrapped.
      void keyPressed​(org.eclipse.swt.events.KeyEvent e)
      Key pressed.
      void keyReleased​(org.eclipse.swt.events.KeyEvent e)
      Key released.
      void mouseDoubleClick​(org.eclipse.swt.events.MouseEvent e)
      Mouse double-click.
      void mouseDown​(org.eclipse.swt.events.MouseEvent e)
      Mouse pressed.
      void mouseMove​(org.eclipse.swt.events.MouseEvent e)
      Mouse move.
      void mouseUp​(org.eclipse.swt.events.MouseEvent e)
      Mouse released.
      void onDoubleClick​(int x, int y)
      Marks the host field.
      void paint​(java.awt.Graphics2D g, int leftMargin, int topMargin, int cxFont, int cyFont, int cxFontReal, int cyFontReal, int cxScreen, int cyScreen, org.eclipse.swt.graphics.Rectangle clipRect)
      Paints the Graphics once the screen is drawn, before the cursor.
      void paintFieldRect​(java.awt.Graphics2D g, IScreenRectangle r, boolean isSelected, org.eclipse.swt.graphics.Rectangle clipRect, boolean isHostField, int xOffset, int yOffset)
      Paints a screen rectangle property.
      void setTerminalWindow​(TerminalWindow window)
      Sets the TerminalWindow at creation of it.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • imageObserver

        public static final java.awt.Container imageObserver
        The image observer.
      • repainter

        public final java.lang.Runnable repainter
        The repainter.
    • Constructor Detail

      • ScreenDesigner

        public ScreenDesigner​(ITermEditor editor)
        Constructs the instance of the screen designer.
        Parameters:
        editor - Editor in question.
    • Method Detail

      • assignProperty

        public void assignProperty​(PropCnr propCnr)
        Assigns the verification property and starts listening to it.
        Parameters:
        propCnr - The property container.
      • dispose

        public void dispose()
        Disposes of the designer.
      • focusGained

        public void focusGained​(org.eclipse.swt.events.FocusEvent e)
        Focus gained.
        Specified by:
        focusGained in interface org.eclipse.swt.events.FocusListener
      • focusLost

        public void focusLost​(org.eclipse.swt.events.FocusEvent e)
        Focus is lost.
        Specified by:
        focusLost in interface org.eclipse.swt.events.FocusListener
      • keyPressed

        public void keyPressed​(org.eclipse.swt.events.KeyEvent e)
        Key pressed.
        Specified by:
        keyPressed in interface org.eclipse.swt.events.KeyListener
      • keyReleased

        public void keyReleased​(org.eclipse.swt.events.KeyEvent e)
        Key released.
        Specified by:
        keyReleased in interface org.eclipse.swt.events.KeyListener
      • mouseDown

        public void mouseDown​(org.eclipse.swt.events.MouseEvent e)
        Mouse pressed.
        Specified by:
        mouseDown in interface org.eclipse.swt.events.MouseListener
      • mouseDoubleClick

        public void mouseDoubleClick​(org.eclipse.swt.events.MouseEvent e)
        Mouse double-click.
        Specified by:
        mouseDoubleClick in interface org.eclipse.swt.events.MouseListener
      • mouseUp

        public void mouseUp​(org.eclipse.swt.events.MouseEvent e)
        Mouse released.
        Specified by:
        mouseUp in interface org.eclipse.swt.events.MouseListener
      • mouseMove

        public void mouseMove​(org.eclipse.swt.events.MouseEvent e)
        Mouse move.
        Specified by:
        mouseMove in interface org.eclipse.swt.events.MouseMoveListener
      • getMarkingConstraints

        public org.eclipse.swt.graphics.Rectangle getMarkingConstraints()
        Gets the rectangle marking constraints. This is used for pop-up windows.
        Specified by:
        getMarkingConstraints in interface IScreenDesigner
        Returns:
        null If no constrains are present.
      • drawLine

        public static int drawLine​(java.awt.Graphics2D g,
                                   int x1,
                                   int y1,
                                   int x2,
                                   int y2,
                                   int type,
                                   int phase)
        Draws a "Business Graphics" line between two points with the current color and the same behavior as for "Java lines".

        When not using Java 2, the line will be dotted if horizontal or vertical if the line type is not solid (=). The width will be 1.

        If the line is invisible, it won't be drawn!

        Valid line types are:

         SOLID           =       0
         ALTERNATE       =       1
         DOT             =       2
         SHORTDASH       =       3
         DASHDOT         =       4
         DOUBLEDOT       =       5
         LONGDASH        =       6
         DASHDOUBLEDOT   =       7
         INVISIBLE       =       8
         
        Returns:
        the phase of the line style.
      • paint

        public void paint​(java.awt.Graphics2D g,
                          int leftMargin,
                          int topMargin,
                          int cxFont,
                          int cyFont,
                          int cxFontReal,
                          int cyFontReal,
                          int cxScreen,
                          int cyScreen,
                          org.eclipse.swt.graphics.Rectangle clipRect)
        Paints the Graphics once the screen is drawn, before the cursor.
        Specified by:
        paint in interface IScreenDesigner
      • getSelectedRectProps

        public java.util.LinkedHashSet<IScreenRectangle> getSelectedRectProps()
        Gets the currently selected properties for rectangles.
        Returns:
        Do not change the returned set (!) as it may be reused or cached for performance reasons.
      • getMouseHandle

        public int getMouseHandle​(int x,
                                  int y,
                                  IScreenRectangle[] returnValue)
        Gets the mouse handle: -1 when not found, 0 for move, otherwise a size handle. All painted rectangles are checked.
        Parameters:
        x - X position, pixel.
        y - Y position, pixel.
        returnValue - Returned screen rectangle in [0].
        Returns:
        -1 for none, otherwise the handle.
      • paintFieldRect

        public void paintFieldRect​(java.awt.Graphics2D g,
                                   IScreenRectangle r,
                                   boolean isSelected,
                                   org.eclipse.swt.graphics.Rectangle clipRect,
                                   boolean isHostField,
                                   int xOffset,
                                   int yOffset)
        Paints a screen rectangle property.
      • isWrapped

        public boolean isWrapped​(IScreenRectangle r)
        Checks if a rectangle is wrapped.
        Parameters:
        r - The rectangle to verify.
        Returns:
        true if wrapping screen.
      • drawHandle

        public void drawHandle​(ScreenRectangleInfo rectInfo,
                               int handle,
                               java.awt.Graphics2D g,
                               java.awt.Color c,
                               int x,
                               int y,
                               boolean draw)
        Draws a handle at position.
      • hasMark

        public boolean hasMark()
        Checks if terminal has a mark.
        Returns:
        Mark flag.
      • hasSingleMark

        public boolean hasSingleMark()
        Checks if terminal has a single mark.
        Returns:
        true if one mark is present.
      • onDoubleClick

        public void onDoubleClick​(int x,
                                  int y)
        Marks the host field.
        Specified by:
        onDoubleClick in interface IScreenDesigner
      • createHostFieldToolTip

        public static org.eclipse.swt.widgets.Composite createHostFieldToolTip​(HostField hostField,
                                                                               org.eclipse.swt.widgets.Composite parent)
        Creates a tooltip composite for a host field.