use of name.abuchen.portfolio.ui.util.swt.ColoredLabel in project portfolio by buchen.
the class LimitExceededWidget method createItemControl.
@Override
protected Composite createItemControl(Composite parent, LimitItem item) {
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FormLayout());
Label logo = new Label(composite, SWT.NONE);
logo.setImage(LogoManager.instance().getDefaultColumnImage(item.getSecurity(), getClient().getSettings()));
Label name = new Label(composite, SWT.NONE);
name.setText(item.getSecurity().getName());
ColoredLabel price = new ColoredLabel(composite, SWT.RIGHT);
// determine colors
LimitPriceSettings settings = new LimitPriceSettings(item.attributeType.getProperties());
price.setBackdropColor(item.limit.getRelationalOperator().isGreater() ? settings.getLimitExceededPositivelyColor(Colors.theme().greenBackground()) : settings.getLimitExceededNegativelyColor(Colors.theme().redBackground()));
price.setText(Values.Quote.format(item.getSecurity().getCurrencyCode(), item.price.getValue()));
Label limit = new Label(composite, SWT.NONE);
limit.setText(settings.getFullLabel(item.limit, item.price));
composite.addMouseListener(mouseUpAdapter);
name.addMouseListener(mouseUpAdapter);
limit.addMouseListener(mouseUpAdapter);
price.addMouseListener(mouseUpAdapter);
FormDataFactory.startingWith(logo).thenRight(name).right(new FormAttachment(100)).thenBelow(price).thenRight(limit);
return composite;
}
use of name.abuchen.portfolio.ui.util.swt.ColoredLabel in project portfolio by buchen.
the class AbstractHeatmapWidget method fillTable.
private void fillTable(HeatmapModel<N> model, Composite table, DashboardResources resources) {
addHeaderRow(table, model);
DoubleFunction<Color> coloring = optionallyGet(ColorSchemaConfig.class).map(s -> s.getValue().buildColorFunction(resources.getResourceManager())).orElse(null);
Values<N> formatter = model.getFormatter();
model.getRows().forEach(row -> {
Label label = new Label(table, SWT.CENTER);
label.setBackground(table.getBackground());
label.setText(row.getLabel());
if (row.getToolTip() != null)
InfoToolTip.attach(label, row.getToolTip());
row.getData().forEach(data -> {
Control lbl = null;
if (data != null) {
ColoredLabel dataLabel = new ColoredLabel(table, SWT.CENTER);
dataLabel.setData(UIConstants.CSS.CLASS_NAME, UIConstants.CSS.DATAPOINT);
dataLabel.setText(formatter.format(data));
if (coloring != null)
dataLabel.setBackdropColor(coloring.apply((double) data));
lbl = dataLabel;
} else {
lbl = new Label(table, SWT.LEFT);
}
if (model.getCellToolTip() != null)
InfoToolTip.attach(lbl, model.getCellToolTip().apply(data));
});
});
SimpleGridLayout layout = new SimpleGridLayout();
layout.setNumColumns(model.getHeaderSize() + 1);
layout.setNumRows((int) model.getRows().count() + 1);
layout.setRowHeight(SWTHelper.lineHeight(table) + 6);
table.setLayout(layout);
table.layout(true);
}
use of name.abuchen.portfolio.ui.util.swt.ColoredLabel in project portfolio by buchen.
the class AbstractIndicatorWidget method createControl.
@Override
public Composite createControl(Composite parent, DashboardResources resources) {
Composite container = new Composite(parent, SWT.NONE);
container.setBackground(parent.getBackground());
GridLayoutFactory.fillDefaults().numColumns(1).margins(5, 5).applyTo(container);
title = new Label(container, SWT.NONE);
title.setText(TextUtil.tooltip(getWidget().getLabel()));
title.setBackground(Colors.theme().defaultBackground());
GridDataFactory.fillDefaults().grab(true, false).applyTo(title);
indicator = new ColoredLabel(container, SWT.NONE);
indicator.setData(UIConstants.CSS.CLASS_NAME, UIConstants.CSS.KPI);
indicator.setBackground(Colors.theme().defaultBackground());
// $NON-NLS-1$
indicator.setText("");
GridDataFactory.fillDefaults().grab(true, false).applyTo(indicator);
return container;
}
use of name.abuchen.portfolio.ui.util.swt.ColoredLabel in project portfolio by buchen.
the class TimelineChartToolTip method createComposite.
@Override
protected void createComposite(Composite parent) {
final Composite container = new Composite(parent, SWT.NONE);
RowLayout layout = new RowLayout(SWT.VERTICAL);
layout.center = true;
container.setLayout(layout);
Composite data = new Composite(container, SWT.NONE);
GridLayoutFactory.swtDefaults().numColumns(2).applyTo(data);
Label left = new Label(data, SWT.NONE);
left.setText(categoryEnabled ? getChart().getAxisSet().getXAxis(0).getTitle().getText() : Messages.ColumnDate);
Label right = new Label(data, SWT.NONE);
right.setText(formatXAxisData(getFocusedObject()));
List<Pair<ISeries, Double>> values = computeValues(getChart().getSeriesSet().getSeries());
if (reverseLabels)
Collections.reverse(values);
if (isAltPressed())
Collections.sort(values, (l, r) -> r.getValue().compareTo(l.getValue()));
for (Pair<ISeries, Double> value : values) {
ISeries series = value.getKey();
Color color = series instanceof ILineSeries ? ((ILineSeries) series).getLineColor() : ((IBarSeries) series).getBarColor();
ColoredLabel cl = new ColoredLabel(data, SWT.NONE);
cl.setBackdropColor(color);
cl.setText(series.getId());
GridDataFactory.fillDefaults().grab(true, false).applyTo(cl);
right = new Label(data, SWT.RIGHT);
DecimalFormat valueFormat = overrideValueFormat.getOrDefault(series.getId(), defaultValueFormat);
right.setText(valueFormat.format(value.getRight()));
GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(right);
}
Object focus = getFocusedObject();
extraInfoProvider.forEach(provider -> provider.accept(container, focus));
Label hint = new Label(data, SWT.NONE);
hint.setText(Messages.TooltipHintPressAlt);
hint.setFont(this.resourceManager.createFont(FontDescriptor.createFrom(data.getFont()).increaseHeight(-3).withStyle(SWT.ITALIC)));
GridDataFactory.fillDefaults().span(2, 1).applyTo(hint);
}
use of name.abuchen.portfolio.ui.util.swt.ColoredLabel in project portfolio by buchen.
the class ScatterChartToolTip method createComposite.
@Override
protected void createComposite(Composite parent) {
final Composite container = new Composite(parent, SWT.NONE);
container.setBackgroundMode(SWT.INHERIT_FORCE);
GridLayoutFactory.swtDefaults().numColumns(3).applyTo(container);
IAxis xAxis = getChart().getAxisSet().getXAxis(0);
IAxis yAxis = getChart().getAxisSet().getYAxis(0);
ILineSeries closest = (ILineSeries) getFocusedObject();
// header
Label left = new Label(container, SWT.NONE);
// $NON-NLS-1$
left.setText("");
Label middle = new Label(container, SWT.NONE);
middle.setText(xAxis.getTitle().getText());
Label right = new Label(container, SWT.NONE);
right.setText(yAxis.getTitle().getText());
// values
ColoredLabel cl = new ColoredLabel(container, SWT.NONE);
cl.setBackdropColor(closest.getSymbolColor());
cl.setText(closest.getId());
middle = new Label(container, SWT.RIGHT);
middle.setText(xAxis.getTick().getFormat().format(closest.getXSeries()[0]));
GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(middle);
right = new Label(container, SWT.RIGHT);
right.setText(yAxis.getTick().getFormat().format(closest.getYSeries()[0]));
GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(right);
}
Aggregations