Example usage for com.google.gwt.event.dom.client StockPrice getChange

List of usage examples for com.google.gwt.event.dom.client StockPrice getChange

Introduction

In this page you can find the example usage for com.google.gwt.event.dom.client StockPrice getChange.

Prototype

public double getChange() 

Source Link

Usage

From source file:com.google.gwt.example.stockwatcher.client.StockWatcher.java

/**
 * Update a single row in the stock table.
 *
 * @param price Stock data for a single row.
 *//*ww w.j  a va 2 s  .  c o  m*/

private void updateTable(StockPrice price) {
    // Make sure the stock is still in the stock table.
    if (!stocks.contains(price.getSymbol())) {
        return;
    }

    int row = stocks.indexOf(price.getSymbol()) + 1;

    // Format the data in the Price and Change fields.
    String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(price.getChange());
    String changePercentText = changeFormat.format(price.getChangePercent());

    // Populate the Price and Change fields with new data.
    stocksFlexTable.setText(row, 1, priceText);
    Label changeWidget = (Label) stocksFlexTable.getWidget(row, 2);
    changeWidget.setText(changeText + " (" + changePercentText + "%)");

    // Change the color of text in the change field based on its value.
    String changeStyleName = "noChange";
    if (price.getChangePercent() < -0.1f) {
        changeStyleName = "negativeChange";
    } else if (price.getChangePercent() > 0.1f) {
        changeStyleName = "positiveChange";
    }

    changeWidget.setStyleName(changeStyleName);
}

From source file:com.google.gwt.sample.stockwatch.client.StockWatcher.java

private void updateTable(StockPrice price) {
    //Make sure the stock is still in the stock table.
    if (!stocks.contains(price.getSymbol())) {
        return;/*from  w w w .  ja  va2  s  . com*/
    }

    int row = stocks.indexOf(price.getSymbol()) + 1;

    //Format the data in the Price and Change fields
    String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(price.getChange());
    String changePercentText = changeFormat.format(price.getChangePercent());

    //Populate the Price and the Change fields with new data.
    stocksFlexTable.setText(row, 1, priceText);

    Label changeWidget = (Label) stocksFlexTable.getWidget(row, 2);
    changeWidget.setText(changeText + "(" + changePercentText + "%)");

    // Change the color of text in the Change field based on its value
    String changeStyleName = "noChange";
    if (price.getChangePercent() < -0.1f) {
        changeStyleName = "negativeChange";
    } else if (price.getChangePercent() > 0.1f) {
        changeStyleName = "positiveChange";
    }

    changeWidget.setStyleName(changeStyleName);
}

From source file:com.google.gwt.sample.stockwatcher.client.CopyOfStockWatcher.java

private void updateTable(StockPrice price) {
    // Make sure the stock is still in the stock table.
    if (!stocks.contains(price.getSymbol())) {
        return;/*from  w  w w  .j a  v a2  s. co m*/
    }

    int row = stocks.indexOf(price.getSymbol()) + 1;

    // Format the data in the Price and Change fields.
    String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(price.getChange());
    String changePercentText = changeFormat.format(price.getChangePercent());

    // Populate the Price and Change fields with new data.
    // Populate the Price and Change fields with new data.
    stocksFlexTable.setText(row, 1, priceText);
    Label changeWidget = (Label) stocksFlexTable.getWidget(row, 2);
    changeWidget.setText(changeText + " (" + changePercentText + "%)");

    // Change the color of text in the Change field based on its value.
    String changeStyleName = "noChange";
    if (price.getChangePercent() < -0.1f) {
        changeStyleName = "negativeChange";
    } else if (price.getChangePercent() > 0.1f) {
        changeStyleName = "positiveChange";
    }

    changeWidget.setStyleName(changeStyleName);

}

From source file:com.google.gwt.sample.stockwatcher.client.Gwt_Project_StockWatcher.java

private void updateTable(StockPrice price) {
    //Make sure the stock is still in the stock table.
    if (!stocks.contains(price.getSymbol())) {
        return;/*from  www .  j av a2s  .  com*/
    }

    int row = stocks.indexOf(price.getSymbol()) + 1;

    // Format the data in the Price and Change fields.
    String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(price.getChange());
    String changePercentText = changeFormat.format(price.getChangePercent());

    // Populate the Price and Change fields with new data.
    stocksFlexTable.setText(row, 1, priceText);
    Label changeWidget = (Label) stocksFlexTable.getWidget(row, 2);
    changeWidget.setText(changeText + " (" + changePercentText + "%)");

    // Change the color of text in the Change field based on its value.
    String changeStyleName = "noChange";
    if (price.getChangePercent() < -0.1f) {
        changeStyleName = "negativeChange";
    } else if (price.getChangePercent() > 0.1f) {
        changeStyleName = "positiveChange";
    }

    changeWidget.setStyleName(changeStyleName);

}

From source file:com.google.gwt.sample.stockwatcher.client.StockWatch.java

/**
 * Update a single row in the stock table.
 *
 * @param price//  w  w w  .j  a  va  2  s  .  c  om
 *            Stock data for a single row.
 */
private void updateTable(StockPrice price) {
    // Make sure the stock is still in the stock table.
    if (!stocks.contains(price.getSymbol())) {
        return;
    }

    int row = stocks.indexOf(price.getSymbol()) + 1;

    // Format the data in the Price and Change fields.
    String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(price.getChange());
    String changePercentText = changeFormat.format(price.getChangePercent());

    // Populate the Price and Change fields with new data.
    stockTable.setText(row, 1, priceText);
    Label changeWidget = (Label) stockTable.getWidget(row, 2);
    changeWidget.setText(changeText + " (" + changePercentText + "%)");

    // Change the color of text in the Change field based on its value.
    String changeStyleName = "noChange";
    if (price.getChangePercent() < -0.1f) {
        changeStyleName = "negativeChange";
    } else if (price.getChangePercent() > 0.1f) {
        changeStyleName = "positiveChange";
    }

    changeWidget.setStyleName(changeStyleName);
}

From source file:com.google.gwt.sample.stockwatcher.client.StockWatcher.java

/**
 * Update a single row in the stock table.
 *
 * @param price Stock data for a single row.
 *///from  w ww.  ja  va 2  s.c o  m
private void updateTable(StockPrice stockPrice) {
    // TODO Auto-generated method stub
    // Make sure the stock is still in the stock table.
    if (!stocks.contains(stockPrice.getSymbol())) {
        return;
    }

    int row = stocks.indexOf(stockPrice.getSymbol()) + 1;

    // Format the data in the Price and Change fields.
    String priceText = NumberFormat.getFormat("#,##0.00").format(stockPrice.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(stockPrice.getChange());
    String changePercentText = changeFormat.format(stockPrice.getChangePercent());

    // Populate the Price and Change fields with new data.
    stocksFlexTable.setText(row, 1, priceText);
    stocksFlexTable.setText(row, 2, changeText + " (" + changePercentText + "%)");
}

From source file:com.google.gwt.sample.stockwatcher.client.StockWatcher1.java

private void updateTable(StockPrice price) {
    // Make sure the stock is still in the stock table.
    if (!stocks.contains(price.getSymbol())) {
        return;/* w ww .ja v a 2  s .  co  m*/
    }

    int row = stocks.indexOf(price.getSymbol()) + 1;

    // Format the data in the Price and Change fields.
    String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(price.getChange());
    String changePercentText = changeFormat.format(price.getChangePercent());

    // Populate the Price and Change fields with new data.
    stocksFlexTable.setText(row, 1, priceText);
    stocksFlexTable.setText(row, 2, changeText + " (" + changePercentText + "%)");

}

From source file:com.google.gwt.sample.stockwatcher.client.StockWatcher2.java

private void updateTable(StockPrice price) {
    // Make sure the stock is still in the stock table.
    if (!stocks.contains(price.getSymbol())) {
        return;/*from   www  . j  a  va 2s  .c om*/
    }

    int row = stocks.indexOf(price.getSymbol()) + 1;

    // Format the data in the Price and Change fields.
    String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(price.getChange());
    String changePercentText = changeFormat.format(price.getChangePercent());

    // Populate the Price and Change fields with new data.
    stocksFlexTable.setText(row, 1, priceText);
    Label changeWidget = (Label) stocksFlexTable.getWidget(row, 2);
    changeWidget.setText(changeText + " (" + changePercentText + "%)");
    // Change the color of text in the Change field based on its value.
    String changeStyleName = "noChange";
    if (price.getChangePercent() < -0.1f) {
        changeStyleName = "negativeChange";
    } else if (price.getChangePercent() > 0.1f) {
        changeStyleName = "positiveChange";
    }

    changeWidget.setStyleName(changeStyleName);
}

From source file:com.google.gwt.sample.stockwatcher.client.StockWatcherActivity.java

private void updateTable(StockPrice stockPrice) {
    int row = stocks.indexOf(stockPrice.getSymbol()) + 1;
    String priceText = NumberFormat.getFormat("#,##0.00").format(stockPrice.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(stockPrice.getChange());
    String changePercentText = changeFormat.format(stockPrice.getChangePercent());

    display.setRowData(row, priceText, changeText + " (" + changePercentText + "%)");
}

From source file:com.google.gwt.sample.stockwatcher.client.StockWatcherT.java

/**
 * Update a single row in the stock table.
 *
 * @param price Stock data for a single row.
 *///  w  w  w. j  av  a  2  s.  c  om
private void updateTable(StockPrice price) {
    // Make sure the stock is still in the stock table.
    if (!stocks.contains(price.getSymbol())) {
        return;
    }

    int row = stocks.indexOf(price.getSymbol()) + 1;

    // Format the data in the Price and Change fields.
    String priceText = NumberFormat.getFormat("#,##0.00").format(price.getPrice());
    NumberFormat changeFormat = NumberFormat.getFormat("+#,##0.00;-#,##0.00");
    String changeText = changeFormat.format(price.getChange());
    String changePercentText = changeFormat.format(price.getChangePercent());

    // Populate the Price and Change fields with new data.
    stocksFlexTable.setText(row, 1, priceText);
    Label changeWidget = (Label) stocksFlexTable.getWidget(row, 2);
    changeWidget.setText(changeText + " (" + changePercentText + "%)");

    // Change the color of text in the Change field based on its value.
    String changeStyleName = "noChange";
    if (price.getChangePercent() < -0.1f) {
        changeStyleName = "negativeChange";
    } else if (price.getChangePercent() > 0.1f) {
        changeStyleName = "positiveChange";
    }

    changeWidget.setStyleName(changeStyleName);

}