com.vwp.jLCD
Class LCD

java.lang.Object
  extended by com.vwp.jLCD.LCD

public class LCD
extends java.lang.Object

This class is the starting point for all connections to an lcdproc server. It has to be used to instantiate a connection to it and afterwards add a screen for displaying widgets on it. Following an example is given that demonstrates the usage of the jLCD package. It was originally developed in 2004 by Gavin & Georgina Sallery and is now incorporated into the Java X-Tools to ensure a further development of it

import com.vwp.jLCD.*;

public class TestCom 
{

  public static void main(String[] args) {
    int lcdPort = 13666;
    LCD myLCD;

    try
    {
       myLCD = new LCD(lcdPort, "90.0.0.30"); // replace this one by your servers IP!
    }
    catch (Exception e)
    {
        e.printStackTrace();
        return;
    }
    System.out.println("Found an LCD. Width = " + myLCD.getWidth() + ", height = " + myLCD.getHeight());
    // create a new screen and add it to the display
    Screen myScreen = new Screen();
    myScreen.setName("My first screen");
    myLCD.addScreen(myScreen);
    System.out.println("Screen Width = " + myScreen.getWidth() + ", height = " + myScreen.getHeight());

    // create a new graphical screen and add it to the display
    Screen myGraphScreen = new Screen();
    myGraphScreen.setName("My Graphical Screen");
    myLCD.addScreen(myGraphScreen);

    System.out.println("Added screens");

    // enable the heartbeat 
    myScreen.setHeartbeat(true);

    // let the backlight flesh 
    myLCD.flashBacklight(1000, 1000, 50000);

    // Add Widgets
    StringWidget stringWidget = new StringWidget(1, 1, "Hello World!");
    myScreen.addWidget(stringWidget);
    System.out.println(stringWidget.getX()+"  "+stringWidget.getX());

    ScrollerWidget scrollWidget = new ScrollerWidget(2, 3, 5, 4, "h", -5, "So you are a coward after all!, kneel" +
                                                                          " you fool, kneel before my whip and I shall..make...you...SCREAM!!!:-) Muuuhhhhaaa haaaaa!...Thwack");
    myScreen.addWidget(scrollWidget);

    TitleWidget titWidget = new TitleWidget("Title - Submission");
    myScreen.addWidget(titWidget);

    HBarWidget hbarWidget = new HBarWidget(20, 2, 7);
    HBarWidget hbarWidget1 = new HBarWidget(20, 3, 10);
    myScreen.addWidget(hbarWidget);
    myScreen.addWidget(hbarWidget1);

    VBarWidget verticalGraph = new VBarWidget(4, 3, 20);
    VBarWidget verticalGraph1 = new VBarWidget(6, 3, 15);
    VBarWidget verticalGraph2 = new VBarWidget(8, 3, 10);
    VBarWidget verticalGraph3 = new VBarWidget(10, 3, 18);
    myGraphScreen.addWidget(verticalGraph);
    myGraphScreen.addWidget(verticalGraph1);
    myGraphScreen.addWidget(verticalGraph2);
    myGraphScreen.addWidget(verticalGraph3);


    System.out.println("Added widget");
    while (true) {
      try {
        Thread.sleep(1000);
        //        stringWidget.setText("System time: " + System.currentTimeMillis());
      } catch (InterruptedException e) {
        e.printStackTrace();  //To change body of catch statement use Options | File Templates.
      }
    }
  } //end main
}


Constructor Summary
LCD(int port, java.lang.String hostname)
          The standard constructor for a new LCD object, it tries to establish a connection to the lcdproc server that itself controls the display
 
Method Summary
 void addScreen(Screen s)
          Add a screen to the current display.
 void finalize()
           
 void flashBacklight(int onPeriod, int offPeriod, int duration)
          Flash the backlight using the given pattern (only possible when backlight control is supported by the used display controller)
 boolean getBacklight()
          Gets the current state of the backlight (as far as supported by the display)
 int getCellHeight()
          Gives the height of one single cell of the display
 int getCellWidth()
          Gives the width of one single cell of the display
 int getHeight()
          Get the height of the display in unit cells
 int getWidth()
          Get the width of the display in unit cells
 void removeScreen(Screen s)
          Remove a screen from the display
 void setBacklight(boolean state)
          Switch the backlight of the display (as far as supported by it)
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LCD

public LCD(int port,
           java.lang.String hostname)
    throws java.io.IOException
The standard constructor for a new LCD object, it tries to establish a connection to the lcdproc server that itself controls the display

Parameters:
port - the port number the lcdproc server is listening at; default is 13666
hostname - the hostname or IP the lcdproc server is running at; please make sure that the server is able to access connections from outside in case jLCD and lcdproc are NOT running on the same machine!
Throws:
java.io.IOException
Method Detail

getWidth

public int getWidth()
Get the width of the display in unit cells

Returns:
the width of the display

getHeight

public int getHeight()
Get the height of the display in unit cells

Returns:
the height of the display

addScreen

public void addScreen(Screen s)
Add a screen to the current display. Screens are the base objects that have to be used for displaying

Parameters:
s - the screen to be added to the display

removeScreen

public void removeScreen(Screen s)
Remove a screen from the display

Parameters:
s - the screen that has t obe removed

setBacklight

public void setBacklight(boolean state)
Switch the backlight of the display (as far as supported by it)

Parameters:
state - true to turn on the backlight or false otherwise

getBacklight

public boolean getBacklight()
Gets the current state of the backlight (as far as supported by the display)

Returns:
true if backlight is turned on or false otherwise

flashBacklight

public void flashBacklight(int onPeriod,
                           int offPeriod,
                           int duration)
Flash the backlight using the given pattern (only possible when backlight control is supported by the used display controller)

Parameters:
onPeriod - period in milliseconds the backlight has to be turned on
offPeriod - period in milliseconds the backlight has t obe turned off
duration - time in milliseconds the backlight flashing has to be used

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object

getCellHeight

public int getCellHeight()
Gives the height of one single cell of the display

Returns:
the height in pixels

getCellWidth

public int getCellWidth()
Gives the width of one single cell of the display

Returns:
the width in pixels