Package totalcross.ui

Class Whiteboard


  • public class Whiteboard
    extends Control
    This is a whiteboard that can be used to draw something. It uses a special event flag in order to improve the accuracy.
    • Field Detail

      • borderColor

        public int borderColor
        Set this to some color so a frame can be drawn around the image
      • useAA

        @Deprecated
        public boolean useAA
        Deprecated.
        This field is useless in OpenGL platforms
        Set to true to enable antialiase on the line drawing. It must be set right after the constructor.
      • thick

        public boolean thick
        Set to true to draw a thick line.
        Since:
        TotalCross 1.14
    • Constructor Detail

      • Whiteboard

        public Whiteboard()
        Constructs a new whiteboard, setting the back color to white.
    • Method Detail

      • onBoundsChanged

        public void onBoundsChanged​(boolean screenChanged)
        Now that we know our bounds, we can create the image that will hold the drawing
        Overrides:
        onBoundsChanged in class Control
        Parameters:
        screenChanged - If the bounds were changed due to a screen change (rotation, collapse)
      • getImage

        public Image getImage()
        Returns the image where the drawing is taking place.
      • getPreferredWidth

        public int getPreferredWidth()
        Returns the preferred width: FILL
        Overrides:
        getPreferredWidth in class Control
      • getPreferredHeight

        public int getPreferredHeight()
        Returns the preferred height: FILL
        Overrides:
        getPreferredHeight in class Control
      • setImage

        public void setImage​(Image image)
                      throws ImageException
        Sets the image for this WhiteBoard. Pass null to create an empty image.
        Throws:
        ImageException
      • clear

        public void clear()
        Clears the WhiteBoard to the current background color.
        Overrides:
        clear in class Control
      • setPenColor

        public void setPenColor​(int c)
        Sets the drawing pen color
      • getPenColor

        public int getPenColor()
        Returns the drawing pen color.
      • onPaint

        public void onPaint​(Graphics g)
        Description copied from class: Control
        Called to draw the control. When this method is called, the graphics object passed has been translated into the coordinate system of the control and the area behind the control has already been painted.
        Overrides:
        onPaint in class Control
        Parameters:
        g - the graphics object for drawing
        See Also:
        Graphics
      • onEvent

        public void onEvent​(Event event)
        Description copied from class: Control
        Called to process key, pen, control and other posted events.
        Overrides:
        onEvent in class Control
        Parameters:
        event - the event to process
        See Also:
        Event, KeyEvent, PenEvent