| /*=============================================================================# |
| # Copyright (c) 2012, 2021 Original NatTable authors and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 |
| # |
| # Contributors: |
| # Original NatTable authors and others - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.ecommons.waltable.config; |
| |
| import org.eclipse.swt.graphics.Color; |
| import org.eclipse.swt.graphics.Font; |
| |
| import org.eclipse.statet.ecommons.waltable.data.convert.DefaultDisplayConverter; |
| import org.eclipse.statet.ecommons.waltable.painter.cell.ICellPainter; |
| import org.eclipse.statet.ecommons.waltable.painter.cell.TextPainter; |
| import org.eclipse.statet.ecommons.waltable.painter.cell.decorator.LineBorderDecorator; |
| import org.eclipse.statet.ecommons.waltable.style.BorderStyle; |
| import org.eclipse.statet.ecommons.waltable.style.CellStyleAttributes; |
| import org.eclipse.statet.ecommons.waltable.style.HorizontalAlignment; |
| import org.eclipse.statet.ecommons.waltable.style.Style; |
| import org.eclipse.statet.ecommons.waltable.style.VerticalAlignment; |
| import org.eclipse.statet.ecommons.waltable.util.GUIHelper; |
| |
| |
| public class DefaultNatTableStyleConfiguration extends AbstractRegistryConfiguration { |
| |
| public Color bgColor= GUIHelper.COLOR_WHITE; |
| public Color fgColor= GUIHelper.COLOR_BLACK; |
| public Color gradientBgColor= GUIHelper.COLOR_WHITE; |
| public Color gradientFgColor= GUIHelper.getColor(136, 212, 215); |
| public Font font= GUIHelper.DEFAULT_FONT; |
| public HorizontalAlignment hAlign= HorizontalAlignment.CENTER; |
| public VerticalAlignment vAlign= VerticalAlignment.MIDDLE; |
| public BorderStyle borderStyle= null; |
| |
| public ICellPainter cellPainter= new LineBorderDecorator(new TextPainter()); |
| |
| @Override |
| public void configureRegistry(final IConfigRegistry configRegistry) { |
| configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, this.cellPainter); |
| |
| final Style cellStyle= new Style(); |
| cellStyle.setAttributeValue(CellStyleAttributes.BACKGROUND_COLOR, this.bgColor); |
| cellStyle.setAttributeValue(CellStyleAttributes.FOREGROUND_COLOR, this.fgColor); |
| cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_BACKGROUND_COLOR, this.gradientBgColor); |
| cellStyle.setAttributeValue(CellStyleAttributes.GRADIENT_FOREGROUND_COLOR, this.gradientFgColor); |
| cellStyle.setAttributeValue(CellStyleAttributes.FONT, this.font); |
| cellStyle.setAttributeValue(CellStyleAttributes.HORIZONTAL_ALIGNMENT, this.hAlign); |
| cellStyle.setAttributeValue(CellStyleAttributes.VERTICAL_ALIGNMENT, this.vAlign); |
| cellStyle.setAttributeValue(CellStyleAttributes.BORDER_STYLE, this.borderStyle); |
| |
| configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, cellStyle); |
| |
| configRegistry.registerConfigAttribute(CellConfigAttributes.DISPLAY_CONVERTER, new DefaultDisplayConverter()); |
| } |
| } |