Example usage for java.lang Comparable toString

List of usage examples for java.lang Comparable toString

Introduction

In this page you can find the example usage for java.lang Comparable toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:com.esofthead.mycollab.community.ui.chart.PieChartWrapper.java

@Override
protected final ComponentContainer createLegendBox() {
    final CustomLayout boxWrapper = CustomLayoutExt.createLayout("legendBox");
    final CssLayout mainLayout = new CssLayout();

    mainLayout.setSizeUndefined();//from w  w  w .  jav  a  2  s .  com
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        final HorizontalLayout layout = new HorizontalLayout();
        layout.setMargin(new MarginInfo(false, false, false, true));
        layout.addStyleName("inline-block");
        final Comparable key = (Comparable) keys.get(i);
        final String color = "<div style = \" width:8px;height:8px;border-radius:5px;background: #"
                + GenericChartWrapper.CHART_COLOR_STR[i % GenericChartWrapper.CHART_COLOR_STR.length] + "\" />";
        final Label lblCircle = new Label(color);
        lblCircle.setContentMode(ContentMode.HTML);

        String btnCaption;
        if (enumKeyCls == null) {
            btnCaption = String.format("%s(%d)", key, pieDataSet.getValue(key).intValue());
        } else {
            btnCaption = String.format("%s(%d)", AppContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        final Button btnLink = new Button(btnCaption, new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                PieChartWrapper.this.onClickedDescription(key.toString());
            }
        });
        btnLink.addStyleName("link");
        layout.addComponent(lblCircle);
        layout.setComponentAlignment(lblCircle, Alignment.MIDDLE_CENTER);
        layout.addComponent(btnLink);
        layout.setComponentAlignment(btnLink, Alignment.MIDDLE_CENTER);
        layout.setSizeUndefined();
        mainLayout.addComponent(layout);
    }
    boxWrapper.setWidth("100%");
    boxWrapper.addComponent(mainLayout, "legendBoxContent");
    return boxWrapper;
}

From source file:com.igalia.java.zk.components.JFreeChartEngine.java

private void decodeLegendInfo(Area area, LegendItemEntity info, Chart chart) {
    if (info == null)
        return;//ww w  .j a  v a 2  s .  c  o m

    final ChartModel model = chart.getModel();
    final int seq = ((Integer) chart.getAttribute("LEGEND_SEQ")).intValue();

    if (model instanceof CategoryModel) {
        Comparable series = ((CategoryModel) model).getSeries(seq);
        area.setAttribute("series", series);
        if (chart.isShowTooltiptext() && info.getToolTipText() == null) {
            area.setTooltiptext(series.toString());
        }
    } else if (model instanceof XYModel) {
        Comparable series = ((XYModel) model).getSeries(seq);
        area.setAttribute("series", series);
        if (chart.isShowTooltiptext() && info.getToolTipText() == null) {
            area.setTooltiptext(series.toString());
        }
    }
}

From source file:com.igalia.java.zk.components.JFreeChartEngine.java

/**
 * decode TickLabelEntity into key-value pair of Area's componentScope.
 *//* w w w .j av a  2  s  .c  om*/
private void decodeTickLabelInfo(Area area, TickLabelEntity info, Chart chart) {
    if (info == null) {
        return;
    }
    final ChartModel model = chart.getModel();
    final int seq = ((Integer) chart.getAttribute("TICK_SEQ")).intValue();

    if (model instanceof CategoryModel) {
        Comparable category = ((CategoryModel) model).getCategory(seq);
        area.setAttribute("category", category);
        if (chart.isShowTooltiptext() && info.getToolTipText() == null) {
            area.setTooltiptext(category.toString());
        }
    }
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the number of sub-intervals for a given item.
 *
 * @param rowKey  the row key./*from   w  w  w  .  jav  a  2 s.  c o m*/
 * @param columnKey  the column key.
 *
 * @return The sub-interval count.
 */
@Override
public int getSubIntervalCount(Comparable rowKey, Comparable columnKey) {
    int result = 0;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        result = task.getSubtaskCount();
    }
    return result;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the percent complete for a given item.
 *
 * @param rowKey  the row key.//from   w  w  w .ja  v  a  2  s .  com
 * @param columnKey  the column key.
 *
 * @return The percent complete.
 */
@Override
public Number getPercentComplete(Comparable rowKey, Comparable columnKey) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        result = task.getPercentComplete();
    }
    return result;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the start value for a task.  This is a date/time value, measured
 * in milliseconds since 1-Jan-1970./*from w w  w . j ava2 s.  c  o  m*/
 *
 * @param rowKey  the series.
 * @param columnKey  the category.
 *
 * @return The start value (possibly <code>null</code>).
 */
@Override
public Number getStartValue(Comparable rowKey, Comparable columnKey) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        TimePeriod duration = task.getDuration();
        if (duration != null) {
            result = new Long(duration.getStart().getTime());
        }
    }
    return result;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the end value for a task.  This is a date/time value, measured
 * in milliseconds since 1-Jan-1970./*  w ww. j a va  2  s .co m*/
 *
 * @param rowKey  the series.
 * @param columnKey  the category.
 *
 * @return The end value (possibly <code>null</code>).
 */
@Override
public Number getEndValue(Comparable rowKey, Comparable columnKey) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        TimePeriod duration = task.getDuration();
        if (duration != null) {
            result = new Long(duration.getEnd().getTime());
        }
    }
    return result;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the percentage complete value of a sub-interval for a given item.
 *
 * @param rowKey  the row key./*from   ww w  .j ava 2s . c o m*/
 * @param columnKey  the column key.
 * @param subinterval  the sub-interval.
 *
 * @return The percent complete value (possibly <code>null</code>).
 */
@Override
public Number getPercentComplete(Comparable rowKey, Comparable columnKey, int subinterval) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        Task sub = task.getSubtask(subinterval);
        if (sub != null) {
            result = sub.getPercentComplete();
        }
    }
    return result;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the start value of a sub-interval for a given item.
 *
 * @param rowKey  the row key.//  w  w w . ja v a  2s .c o m
 * @param columnKey  the column key.
 * @param subinterval  the subinterval.
 *
 * @return The start value (possibly <code>null</code>).
 */
@Override
public Number getStartValue(Comparable rowKey, Comparable columnKey, int subinterval) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        Task sub = task.getSubtask(subinterval);
        if (sub != null) {
            TimePeriod duration = sub.getDuration();
            result = new Long(duration.getStart().getTime());
        }
    }
    return result;
}

From source file:org.jfree.data.gantt.TaskSeriesCollection.java

/**
 * Returns the end value of a sub-interval for a given item.
 *
 * @param rowKey  the row key.// www .  j  a v a  2 s . c  o  m
 * @param columnKey  the column key.
 * @param subinterval  the subinterval.
 *
 * @return The end value (possibly <code>null</code>).
 */
@Override
public Number getEndValue(Comparable rowKey, Comparable columnKey, int subinterval) {
    Number result = null;
    int row = getRowIndex(rowKey);
    TaskSeries series = (TaskSeries) this.data.get(row);
    Task task = series.get(columnKey.toString());
    if (task != null) {
        Task sub = task.getSubtask(subinterval);
        if (sub != null) {
            TimePeriod duration = sub.getDuration();
            result = new Long(duration.getEnd().getTime());
        }
    }
    return result;
}