Class Thermometer

  • All Implemented Interfaces:
    java.awt.image.ImageObserver, java.awt.MenuContainer,, javax.accessibility.Accessible, javax.swing.RootPaneContainer, javax.swing.WindowConstants

    public class Thermometer
    extends javax.swing.JFrame

    Thermometer is a Java program to run on a Pi with a small touch screen attached (ie UCTRONICS 3.5 inch touch screen) to display the temperature collected from up to six remote Pis running one of the TemperatureSender?? programs.

    Thermometer has two display panels, the TempPanel and the SelectPanel. The TempPanel displays the temperature and location/description from a selected channel and the SelectPanel allows selecting the channel to be displayed. Touching the TempPanel display will switch the display to the SelectPanel. Touching one of the channel select buttons on the SelectPanel will switch the display to the TempPane with the selected channel now displayed.

    A forty pixel arc is drawn on the upper left corner of the TempPanel. Touching inside of this arc will shut cause the shutdown of the Thermometer program.

    The data to be displayed is transmitted from another Pi running one of the TemperatureSender?? applications. The TemperatureSender?? application reads the temperature from a temperature sensor and transmits its channel number, location/description and temperature via multicast packets.

    The default temperature display is in degrees fahrenheit. To change the display to Celsius, use the celsius command line option. To display the program in a regular window with a border and controls, use the notouch command line option.

    Command Line Options
    celsiusdisplay the temperature in degrees celsius, default is fahrenheit
    notouchused if running on a computer without a touch screen, adds a frame to the program window and unhides the mouse cursor
    helpdisplay usage and command line option descriptions
    Program Revisions
    0.1003 Jan 2019incept
    0.1104 Jan 2019documentation update for TemperatureSender variants
    0.11 - 4 January 2019
    Knute Johnson
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  Thermometer.Channel
      Class to hold data for a specified channel including the location, temperature and the last time data was received for this channel.
      private class  Thermometer.Receiver
      Receiver listens for multicast packets from the TemperatureSender?? program and stores that information in the appropriate channel.
      private class  Thermometer.SelectPanel
      The SelectPanel is used to select the channel to display.
      private class  Thermometer.TempPanel
      The TempPanel displays the temperature and the location for the selected channel.
      • Nested classes/interfaces inherited from class javax.swing.JFrame

      • Nested classes/interfaces inherited from class java.awt.Frame

      • Nested classes/interfaces inherited from class java.awt.Window

        java.awt.Window.AccessibleAWTWindow, java.awt.Window.Type
      • Nested classes/interfaces inherited from class java.awt.Container

      • Nested classes/interfaces inherited from class java.awt.Component

        java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
    • Field Summary

      Modifier and Type Field Description
      private static boolean celsius
      Celsius flag
      private int channel
      Current channel to display
      private Thermometer.Channel[] channels
      Channel data objects
      private static int CHANNELS
      Number of channels
      private static java.lang.String DATE
      Program Date
      private static int H
      Height of your touch screen
      private java.awt.Cursor invisibleCursor
      Invisible cursor
      private static java.lang.String IPADDR
      Mulitcast socket address
      private static int PORT
      Multicast port
      private Thermometer.Receiver rcvr
      Receiver reference
      private Thermometer.SelectPanel selectPanel
      SelectPanel reference
      private static long serialVersionUID
      Serial version UID
      private Thermometer.TempPanel tempPanel
      TempPanel reference
      private static boolean touch
      Touch screen flag
      private static java.lang.String VERSION
      Program version
      private static int W
      Width of your touch screen
      • Fields inherited from class javax.swing.JFrame

        accessibleContext, rootPane, rootPaneCheckingEnabled
      • Fields inherited from class java.awt.Frame

      • Fields inherited from class java.awt.Component

      • Fields inherited from interface java.awt.image.ImageObserver

      • Fields inherited from interface javax.swing.WindowConstants

    • Constructor Summary

      Constructor Description
      Creates a new Thermometer object, initializes the display panels and multicast packet receiver, sizes the frame and displays it.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void main​(java.lang.String... args)
      Program entry point, parses the command line options and creates a new Thermometer object and starts it running.
      private void start()
      Starts the receiver
      private void stop()
      Disposes the Thermometer frame and stops the receiver
      • Methods inherited from class javax.swing.JFrame

        addImpl, createRootPane, frameInit, getAccessibleContext, getContentPane, getDefaultCloseOperation, getGlassPane, getGraphics, getJMenuBar, getLayeredPane, getRootPane, getTransferHandler, isDefaultLookAndFeelDecorated, isRootPaneCheckingEnabled, paramString, processWindowEvent, remove, repaint, setContentPane, setDefaultCloseOperation, setDefaultLookAndFeelDecorated, setGlassPane, setIconImage, setJMenuBar, setLayeredPane, setLayout, setRootPane, setRootPaneCheckingEnabled, setTransferHandler, update
      • Methods inherited from class java.awt.Frame

        addNotify, getCursorType, getExtendedState, getFrames, getIconImage, getMaximizedBounds, getMenuBar, getState, getTitle, isResizable, isUndecorated, remove, removeNotify, setBackground, setCursor, setExtendedState, setMaximizedBounds, setMenuBar, setOpacity, setResizable, setShape, setState, setTitle, setUndecorated
      • Methods inherited from class java.awt.Window

        addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getOwnerlessWindows, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindows, getWindowStateListeners, hide, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowFocusEvent, processWindowStateEvent, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, setVisible, show, toBack, toFront
      • Methods inherited from class java.awt.Container

        add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusDownCycle, validate, validateTree
      • Methods inherited from class java.awt.Component

        action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setMixingCutoutShape, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.awt.MenuContainer

        getFont, postEvent
    • Field Detail

      • serialVersionUID

        private static final long serialVersionUID
        Serial version UID
        See Also:
        Constant Field Values
      • IPADDR

        private static final java.lang.String IPADDR
        Mulitcast socket address
        See Also:
        Constant Field Values
      • invisibleCursor

        private final java.awt.Cursor invisibleCursor
        Invisible cursor
      • celsius

        private static boolean celsius
        Celsius flag
      • touch

        private static boolean touch
        Touch screen flag
      • channel

        private volatile int channel
        Current channel to display
    • Constructor Detail

      • Thermometer

        public Thermometer()
        Creates a new Thermometer object, initializes the display panels and multicast packet receiver, sizes the frame and displays it.
    • Method Detail

      • start

        private void start()
        Starts the receiver
      • stop

        private void stop()
        Disposes the Thermometer frame and stops the receiver
      • main

        public static void main​(java.lang.String... args)
        Program entry point, parses the command line options and creates a new Thermometer object and starts it running.
        args - command line arguments