Previous: Using VisAD Displays in the IDV Next:  Miscellaneous Table of contents Frames User guide
Unidata IDV Workshop for version 6.2u2 > Java Developer Topics > Display Controls

5.6.2 Creating a Weather Text Display Control
Let's create a custom DisplayControl for our weather text that will use the category "wxtext" that we created in the Data Source.
  1. Change to the example directory.
    cd /home/idv/idv/ucar/unidata/apps/example
  2. Open WxTextDisplayControl.java in an editor and let's look what's there.
  3. Copy controls.xml up from the resources subdirectory and take a look at that.
  4. Compile the display control.
  5. Start the IDV.
  6. Select a product from the Weather Text chooser and click the Add Source button.
  7. Display the data in the Weather Text display.

Now let's add in a widget that will highlight some text.

  1. Exit the IDV.
  2. Open WxTextDisplayControl.java in an editor.
  3. Uncomment:
  4. Start the IDV and load in some weather text.
  5. Type in some text to hightlight and hit enter. Does it get highlighted?
  6. Notice that we have a new item in the Edit menu which allows us to change the highlight color. Change it. Does anything happen? Hit return in the TextField. Does it change then?
  7. Exit the IDV.
  8. Open WxTextDisplayControl.java in an editor.
  9. Uncomment the applyColor method. This is called when the color changes.
  10. Compile and restart the IDV and load in some weather text.
  11. Type in some text to highlight and hit enter. Change the color. Does it change now?
  12. Save this as your default bundle and then reload it. Notice that the text is not hightlighted this time. We need to add some bean property methods to save the selected text. Add the following methods:
        /**
         * Get the highlighted text
         *
         * @return the highlighted text
         */
        public String getHighlightedText() {
            return highlightedText;
        }
    
        /**
         * Set the text to hightlight
         *
         * @param text the text to hightlight
         */
        public void setHighlightedText(String text) {
            highlightedText = text;
        }
    
  13. Since we use the FLAG_COLOR attribute any color changes we make get saved automatically.
Now, let's add in a point that shows where the station is. Remember, we passed along the station as a property to the data source. We can add those properties to the DataChoice by passing them along when we create the DirectDataChoice.
  1. Edit the WxTextDataSource and where we create the DirectDataChoice, change:
                                 DataChoice.NULL_PROPERTIES);  //no properties
    
    to:
                                 getProperties());
    
  2. Now, let's uncomment the section of code in the WxTextDisplayControl.init that adds in a displayable to the default ViewManager.
  3. Compile the files.
  4. Start the ExampleIdv and remove the default bundle:
    idve -cleardefault
  5. Load in some weather text.
  6. Change the color. What happens to the selector point?

 


Previous: Using VisAD Displays in the IDV Next:  Miscellaneous Table of contents Frames User guide
Unidata IDV Workshop for version 6.2u2 > Java Developer Topics > Display Controls