Java Code Examples for org.eclipse.swt.graphics.Font

The following are top voted examples for showing how to use org.eclipse.swt.graphics.Font. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: bdf2   File: TableFigure.java   View source code 6 votes vote down vote up
public TableFigure() {
	ToolbarLayout layout = new ToolbarLayout();
	setLayoutManager(layout);
	LineBorder lineBorder = new LineBorder(ColorConstants.lightGray, 2);
	setBorder(lineBorder);
	setOpaque(true);
	setBackgroundColor(ColorConstants.white);

	Font font = new Font(null, "宋体", 11, SWT.NORMAL);
	label.setFont(font);
	label.setBorder(new LineBorder(ColorConstants.lightGray));
	label.setIcon(Activator.getImage(Activator.IMAGE_TABLE_16));
	label.setOpaque(true);
	label.setBackgroundColor(ColorConstants.lightBlue);
	label.setForegroundColor(ColorConstants.black);
	add(label);
	add(columnFigure);
}
 
Example 2
Project: ide-plugins   File: PluginsSWT.java   View source code 6 votes vote down vote up
public PluginsSWT(Shell shell, List<String> lines) {
    super(shell);
    this.pluginsBean = new PluginsBean(lines);
    
    target = pluginsBean.getPlugins();
    source = Stream.of(Plugin.values())
            .filter(p -> ! target.contains(p))
            .collect(Collectors.toList());
    targetOriginal = target.stream().collect(Collectors.toList());
    
    rowColorTitle = new Color(display, 70, 130, 180);
    int color = myOS == OS.Mac ? 249 : 239;
    rowColorBack = new Color(display, color, color, color);
    rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE);
  
    fontAwesome = loadCustomFont(getFontAwesomeSize());
    fontGap = new Font(display, fontName, 4, SWT.NORMAL);
    rowTitleFont = new Font(display, fontName, getTopFontSize(), SWT.BOLD);
    rowTextFont = new Font(display, fontName, getTopFontSize() - 2, SWT.NORMAL);
    styleTitle = new TextStyle(rowTitleFont, rowColorTitle, null);
    styleGap = new TextStyle(fontGap, display.getSystemColor(SWT.COLOR_BLACK), null);
    styleRow = new TextStyle(rowTextFont, display.getSystemColor(SWT.COLOR_BLACK), null);
    styleTitleSelected = new TextStyle(rowTitleFont, rowColorSelection, null);
    styleRowSelected = new TextStyle(rowTextFont, rowColorSelection, null);
}
 
Example 3
Project: ide-plugins   File: PluginDialog.java   View source code 6 votes vote down vote up
protected void createTopContent(String title, InputStream imageName) {
    Composite top = new Composite(composite, SWT.NONE);

    top.setLayout(new GridLayout(2, false));
    top.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    top.setBackground(display.getSystemColor(SWT.COLOR_WHITE));
    
    final Image image = new Image(top.getDisplay(), imageName);
    Image resized = resizeImage(image, 48, 48);
    Label labelImage = new Label(top, SWT.CENTER);
    labelImage.setImage(resized);
    
    Label label = new Label(top, SWT.NONE);
    label.setText(title);
    final Font newFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL);
    label.setFont(newFont);
    label.setBackground(rowColorSelection);
    
    createLineContent();
    
    top.addDisposeListener(e -> {
        newFont.dispose();
        resized.dispose();
    });
}
 
Example 4
Project: neoscada   File: TitleRenderer.java   View source code 6 votes vote down vote up
private Font createFont ( final ResourceManager resourceManager )
{
    final Font defaultFont = resourceManager.getDevice ().getSystemFont ();

    if ( defaultFont == null )
    {
        return null;
    }

    final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
    if ( fd == null )
    {
        return null;
    }

    for ( final FontData f : fd )
    {
        if ( this.fontSize > 0 )
        {
            f.setHeight ( this.fontSize );
        }
    }
    return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
 
Example 5
Project: convertigo-eclipse   File: TextEditorComposite.java   View source code 6 votes vote down vote up
private void initialize() {
	GridLayout gridLayout = new GridLayout();
	gridLayout.numColumns = 1;
	GridData gridData = new org.eclipse.swt.layout.GridData();
	gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
	gridData.grabExcessVerticalSpace = true;
	gridData.grabExcessHorizontalSpace = true;
	gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
	
	//minimum size (when dialog open)
	gridData.minimumHeight = 200;
	gridData.minimumWidth = 300;
	
	this.setLayout(gridLayout);
	textArea = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
	textArea.setFont(new Font(null,"Tahoma",10,0));
	textArea.setLayoutData(gridData);
}
 
Example 6
Project: convertigo-eclipse   File: SqlQueryEditorComposite.java   View source code 6 votes vote down vote up
private void initialize() {
	labelSyntaxe = new Label(this, SWT.NONE);
	
	labelSyntaxe.setText("SQL query syntax examples :\n");
	labelSyntaxe.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false));
	labelSQLQuery = new Label(this, SWT.NONE);
	labelSQLQuery.setFont(new Font(null,"Tahoma",8,1));
	labelSQLQuery.setText("SELECT * FROM EMPLOYEES WHERE (NAME='{parameter_name}')\n"
							+ "{? = CALL STORED_FUNCTION({parameter_name})}\n"
							+ "{CALL STORED_PROCEDURE({parameter_name})}\n\n");
	labelSQLQuery.setLayoutData(new GridData(SWT.FILL,SWT.CENTER,true,false));
	textAreaSQLQuery = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
	textAreaSQLQuery.setFont(new Font(null,"Tahoma",10,0));
	textAreaSQLQuery.setLayoutData(new GridData(SWT.FILL,SWT.FILL,true,true));
	GridLayout gridLayout = new GridLayout();
	this.setLayout(gridLayout);
	setSize(new org.eclipse.swt.graphics.Point(402,289));
}
 
Example 7
Project: convertigo-eclipse   File: ViewLabelProvider.java   View source code 6 votes vote down vote up
public ViewLabelProvider() {
	Device device = Display.getCurrent();

	fontSystem = device.getSystemFont();

	FontData fontData = fontSystem.getFontData()[0];
	
	fontDetectedDatabaseObject = new Font(device, fontData);
	
	FontData fontDataModified = fontSystem.getFontData()[0];
	fontDataModified.setStyle(SWT.BOLD);
	fontModifiedDatabaseObject = new Font(device, fontDataModified);

	colorUnloadedProject = new Color(device, 12, 116, 176);
	colorDisabledDatabaseObject = new Color(device, 255, 0, 0);
	colorInheritedDatabaseObject = new Color(device, 150, 150, 150);
	colorUnreachableDatabaseObject = new Color(device, 255, 140, 0);
	colorDetectedDatabaseObject = new Color(device, 192, 219, 207);
}
 
Example 8
Project: convertigo-eclipse   File: StatisticsDialog.java   View source code 6 votes vote down vote up
private void addStats() {

		for (String key : statsProject.keySet()) {
			if (key != project.getName()) {
				CLabel title = new CLabel(descriptifRight, SWT.BOLD);
				title.setText(key);
				title.setImage(new Image(display, getClass()
						.getResourceAsStream(
								"images/stats_"
										+ key.replaceAll(" ", "_")
												.toLowerCase() + "_16x16.png")));
				title.setBackground(new Color(display, 255, 255, 255));
				title.setMargins(10, 10, 0, 0);

				FontData[] fd = title.getFont().getFontData();
				fd[0].setStyle(SWT.BOLD);
				title.setFont(new Font(title.getFont().getDevice(), fd));

				CLabel subText = new CLabel(descriptifRight, SWT.NONE);
				subText.setText(statsProject.get(key)
						.replaceAll("<br/>", "\r\n").replaceAll("&nbsp;", " "));
				subText.setBackground(new Color(display, 255, 255, 255));
				subText.setMargins(30, 0, 0, 0);
			}
		}
	}
 
Example 9
Project: avoCADo   File: MELabel.java   View source code 6 votes vote down vote up
@Override
void paintElement(PaintEvent e) {
	GC g = e.gc;
	g.setBackground(this.getBackground());
	int width  = this.getBounds().width;
	int height = this.getBounds().height;
	
	// clear entire canvas where button will be painted
	g.fillRectangle(0, 0, width, height);
	
	// draw text
	g.setForeground(this.meColorForeground);
	FontData fd = new FontData();
	fd.setHeight(8);
	if(textIsBold){
		fd.setStyle(SWT.BOLD);
	}else{
		fd.setStyle(SWT.NORMAL);
	}
	g.setFont(new Font(this.getDisplay(), fd));
	Point textPt = g.textExtent(this.meLabel);			
	g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
 
Example 10
Project: openaudible   File: FontShop.java   View source code 6 votes vote down vote up
public FontShop(Display display) {
    if (display == null) {
        Application.report("font display null");
    }

    regFonts = new Font[kNumFonts];
    boldFonts = new Font[kNumFonts];
    italicFonts = new Font[kNumFonts];
    for (int x = 0; x < kNumFonts; x++) {
        regFonts[x] = newDefaultFont(x);
        newStyledFont(x);
    }

    if (curFonts == null)
        curFonts = this;

}
 
Example 11
Project: eclipse-plugin-commander   File: KaviListColumns.java   View source code 6 votes vote down vote up
@SuppressWarnings("unchecked")
private RankedItem<T> applyCellDefaultStyles(final ColumnOptions<T> options, ViewerCell cell) {
	final RankedItem<T> rankedItem = (RankedItem<T>) cell.getElement();
	cell.setForeground(fromRegistry(options.getFontColor()));
	int rowState = rowStateResolver.apply(rankedItem);
	
    if ((rowState & RowState.SELECTED.value) != 0 && options.isEnableBackgroundSelection()) {
		cell.setBackground(fromRegistry(new RGB(225,226,206)));
	} else {
		cell.setBackground(fromRegistry(options.getBackgroundColor()));
	}
    if ((rowState & RowState.CURSOR.value) != 0 && options.isEnableBackgroundSelection()) {
		cell.setBackground(fromRegistry(ColorUtil.blend(cell.getBackground().getRGB(), new RGB(200,200,200))));
    }
	Font font = createColumnFont(options, cell);
	cell.setFont(font);
	return rankedItem;
}
 
Example 12
Project: SWET   File: ScrolledTextEx.java   View source code 6 votes vote down vote up
private StyledText createStyledText() {
	styledText = new StyledText(shell,
			SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL); // SWT.WRAP
	GridData gridData = new GridData();
	styledText.setFont(
			new Font(shell.getDisplay(), "Source Code Pro Light", 10, SWT.NORMAL));
	gridData.horizontalAlignment = GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	gridData.verticalAlignment = GridData.FILL;
	gridData.grabExcessVerticalSpace = true;
	styledText.setLayoutData(gridData);
	styledText.addLineStyleListener(lineStyler);
	styledText.setEditable(false);
	styledText
			.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_GRAY));
	return styledText;
}
 
Example 13
Project: Hydrograph   File: SourceViewer.java   View source code 6 votes vote down vote up
private void initializeViewer(IDocument document) {
	fAnnotationPreferences = EditorsPlugin.getDefault().getMarkerAnnotationPreferences();
	setDocument(document);
	installViewerConfiguration();
	setEditable(true);
	Font font = JFaceResources.getFontRegistry().get(JFaceResources.TEXT_FONT);
	getTextWidget().setFont(font);
	getTextWidget().setData("document",document);
	Control control = getControl();
	GridData data = new GridData(GridData.FILL_BOTH);
	control.setLayoutData(data);
	prependVerifyKeyListener(new VerifyKeyListener() {

		@Override
		public void verifyKey(VerifyEvent event) {
			handleVerifyKeyPressed(event);
		}
	});
	addDocumentListener(document);
}
 
Example 14
Project: Hydrograph   File: CommentBoxFigure.java   View source code 6 votes vote down vote up
/**
 * Creates a new CommentBoxFigure with a MarginBorder that is the given size and a FlowPage containing a TextFlow
 * with the style WORD_WRAP_SOFT.
 * 
 * @param borderSize
 *            the size of the MarginBorder
 */
public CommentBoxFigure(int borderSize) {
	setBorder(new MarginBorder(5));
	FlowPage flowPage = new FlowPage();

	textFlow = new TextFlow();

	textFlow.setLayoutManager(new ParagraphTextLayout(textFlow, ParagraphTextLayout.WORD_WRAP_SOFT));

	flowPage.add(textFlow);

	setLayoutManager(new StackLayout());
	add(flowPage);
	font = new Font(Display.getDefault(), "Arial", 9, SWT.NORMAL);
	setFont(font);
	setForegroundColor(ColorConstants.black);
	setOpaque(false);

}
 
Example 15
Project: Hydrograph   File: CommentBoxLabelEditManager.java   View source code 6 votes vote down vote up
/**
 * update scaledFonts
 * @param zoom
 * 				at zoom 
 */
private void updateScaledFont(double zoom) {
	if (cachedZoom == zoom)
		return;
	
	Text text = (Text)getCellEditor().getControl();
	Font font = getEditPart().getFigure().getFont();
	
	disposeScaledFont();
	cachedZoom = zoom;
	if (zoom == 1.0)
		text.setFont(font);
	else {
		FontData fd = font.getFontData()[0];
		fd.setHeight((int)(fd.getHeight() * zoom));
		text.setFont(scaledFont = new Font(null, fd));
	}
}
 
Example 16
Project: n4js   File: LaunchConfigurationMainTab.java   View source code 5 votes vote down vote up
@SuppressWarnings("javadoc")
public static Composite createComposite(Composite parent, Font font, int columns, int hspan, int fill) {
	Composite g = new Composite(parent, SWT.NONE);
	g.setLayout(new GridLayout(columns, false));
	g.setFont(font);
	GridData gd = new GridData(fill);
	gd.horizontalSpan = hspan;
	g.setLayoutData(gd);
	return g;
}
 
Example 17
Project: n4js   File: OpenTypeSelectionDialog.java   View source code 5 votes vote down vote up
@Override
public Font get() {
	final Font font = getDialogArea().getFont();
	final FontData[] data = font.getFontData();
	for (int i = 0; i < data.length; i++) {
		data[i].setStyle(BOLD);
	}
	return new Font(font.getDevice(), data);
}
 
Example 18
Project: n4js   File: OpenTypeSelectionDialog.java   View source code 5 votes vote down vote up
@Override
public void dispose() {
	super.dispose();
	if (null != boldFontSupplier) {
		final Font font = boldFontSupplier.get();
		if (null != font && !font.isDisposed()) {
			font.dispose();
		}
	}
}
 
Example 19
Project: BiglyBT   File: SubscriptionWizard.java   View source code 5 votes vote down vote up
private void createFonts() {

		FontData[] fDatas = shell.getFont().getFontData();

		for(int i = 0 ; i < fDatas.length ; i++) {
			fDatas[i].setStyle(SWT.BOLD);
		}
		boldFont = new Font(display,fDatas);


		for(int i = 0 ; i < fDatas.length ; i++) {
			if(com.biglybt.core.util.Constants.isOSX) {
				fDatas[i].setHeight(12);
			} else {
				fDatas[i].setHeight(10);
			}
		}
		subTitleFont = new Font(display,fDatas);

		for(int i = 0 ; i < fDatas.length ; i++) {
			if(com.biglybt.core.util.Constants.isOSX) {
				fDatas[i].setHeight(17);
			} else {
				fDatas[i].setHeight(14);
			}
		}
		titleFont = new Font(display,fDatas);

		// When GTK3 can show a textbox without a border, we can remove the logic
		textInputFont = FontUtils.getFontWithHeight(shell.getFont(), null, Utils.isGTK3 ? 12 : 14);


	}
 
Example 20
Project: n4js   File: ExportSelectionPage.java   View source code 5 votes vote down vote up
@Override
protected void createOptionsGroupButtons(Group optionsGroup) {
	Font font = optionsGroup.getFont();
	optionsGroup.setLayout(new GridLayout(2, true));

	Composite left = new Composite(optionsGroup, SWT.NONE);
	left.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false));
	left.setLayout(new GridLayout(1, true));

	// compress... checkbox
	compressContentsCheckbox = new Button(left, SWT.CHECK | SWT.LEFT);
	compressContentsCheckbox.setText(DataTransferMessages.ZipExport_compressContents);
	compressContentsCheckbox.setFont(font);

}
 
Example 21
Project: n4js   File: AbstractLaunchConfigurationMainTab.java   View source code 5 votes vote down vote up
/**
 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
 */
@Override
public void createControl(Composite parent) {
	Font font = parent.getFont();
	Composite comp = createComposite(parent, font, 1, 1, GridData.FILL_BOTH);
	createResourceGroup(comp);
	createImplementationIdGroup(comp);
	setControl(comp);
}
 
Example 22
Project: ide-plugins   File: PluginsSWT.java   View source code 5 votes vote down vote up
private Font loadCustomFont(int fontSize) {
    String fontPath = ProjectUtils.extractResourceToTmp("fontawesome-webfont.ttf");
    boolean isLoaded = display.loadFont(fontPath);
    if (isLoaded) {
        return Stream.of(Display.getDefault().getFontList(null, true))
                .filter(fd -> fd.getName().toLowerCase(Locale.ROOT).contains("fontawesome"))
                .findFirst()
                .map(fd -> {
                    fd.setHeight(fontSize);
                    return new Font(display, fd);
                })
                .orElse(null);
    }
    return null;   
}
 
Example 23
Project: ide-plugins   File: PluginDialog.java   View source code 5 votes vote down vote up
public PluginDialog(Shell shell) {
    super(shell);
    this.display = Display.getDefault();
    
    fontName = display.getSystemFont().getFontData()[0].getName();
    backColor = new Color(display, 244, 244, 244);
    rowColorSelection = display.getSystemColor(SWT.COLOR_WHITE);
    titleFont = new Font(display, fontName, getTitleFontSize(), SWT.NORMAL);
    topFont = new Font(display, fontName, getTopFontSize(), SWT.NORMAL);
}
 
Example 24
Project: gemoc-studio-modeldebugging   File: LaunchConfigurationMainTab.java   View source code 5 votes vote down vote up
/***
 * Create the Field where user enters the language used to execute
 * 
 * @param parent container composite
 * @param font used font
 * @return the created composite containing the fields
 */
public Composite createLanguageLayout(Composite parent, Font font) {
	// Language
	createTextLabelLayout(parent, "Melange languages");
	_languageCombo = new Combo(parent, SWT.NONE);
	_languageCombo.setLayoutData(createStandardLayout());

	List<String> languagesNames = MelangeHelper.getAllLanguages();
	String[] empty = {};
	_languageCombo.setItems(languagesNames.toArray(empty));
	_languageCombo.addSelectionListener(new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent e) {
			//String selection = _languageCombo.getText();
			//List<String> modelTypeNames = MelangeHelper.getModelTypes(selection);
			updateLaunchConfigurationDialog();
		}
	});
	createTextLabelLayout(parent, "");

	createTextLabelLayout(parent, "Melange resource adapter query");
	_melangeQueryText = new Text(parent, SWT.SINGLE | SWT.BORDER);
	_melangeQueryText.setLayoutData(createStandardLayout());
	_melangeQueryText.setFont(font);
	_melangeQueryText.setEditable(false);
	createTextLabelLayout(parent, "");
	
	return parent;
}
 
Example 25
Project: gemoc-studio-modeldebugging   File: DecoratingColumLabelProvider.java   View source code 5 votes vote down vote up
@Override
public Font getFont(Object element) {
	final Font res;

	if (fontProvider == null) {
		res = null;
	} else {
		res = fontProvider.getFont(element);
	}

	return res;
}
 
Example 26
Project: gemoc-studio-modeldebugging   File: DecoratingColumLabelProvider.java   View source code 5 votes vote down vote up
@Override
public Font getToolTipFont(Object element) {
	final Font res;

	if (cellLabelProvider == null) {
		res = null;
	} else {
		res = cellLabelProvider.getToolTipFont(element);
	}

	return res;
}
 
Example 27
Project: gemoc-studio-modeldebugging   File: EnginesStatusView.java   View source code 5 votes vote down vote up
/**
	 * This is a callback that will allow us
	 * to create the viewer and initialize it.
	 */
	public void createPartControl(Composite parent) {
		_viewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
		_contentProvider = new ViewContentProvider();
		_viewer.setContentProvider(_contentProvider);
		ColumnViewerToolTipSupport.enableFor(_viewer);
		_viewer.addSelectionChangedListener(
				new ISelectionChangedListener() {
					public void selectionChanged(SelectionChangedEvent event) {
						fireEngineSelectionChanged();
					}
				});
		
		createColumns();
//		_viewer.setColumnProperties( new String[] {"Status", "Identifier", "Step", "Status"} );
//		_viewer.getTree().setHeaderVisible(true);
		Font mono = JFaceResources.getFont(JFaceResources.TEXT_FONT);
		_viewer.getTree().setFont(mono);
		
		// Create the help context id for the viewer's control
		PlatformUI.getWorkbench().getHelpSystem().setHelp(_viewer.getControl(), "org.eclipse.gemoc.executionframework.ui.views.engine.EngineStatusView");
			
		// register for changes in the RunningEngineRegistry
		//org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry.addObserver(this);
		
		buildMenu();		

		org.eclipse.gemoc.executionframework.engine.Activator.getDefault().gemocRunningEngineRegistry.addEngineRegistrationListener(this);
	}
 
Example 28
Project: openaudible   File: FontShop.java   View source code 5 votes vote down vote up
private Font newStyledFont(int index, int style) {

        Font f = regFonts[index];
        if (isset(f)) {
            FontData[] fontData = f.getFontData();
            fontData[0].setStyle(style);
            fontData[0].setLocale(Translate.getLocale().toString());
            return new Font(Display.getDefault(), fontData);
        } else {
            Application.report("newBold failed. f=" + f);
        }
        return null;
    }
 
Example 29
Project: neoscada   File: TreeNodeLabelProvider.java   View source code 5 votes vote down vote up
public TreeNodeLabelProvider ( final TreeViewer viewer, final IObservableMap... attributeMaps )
{
    super ( attributeMaps );
    this.viewer = viewer;

    this.defaultFont = viewer.getControl ().getFont ();

    final FontData[] fds = this.viewer.getControl ().getFont ().getFontData ();
    for ( final FontData fd : fds )
    {
        fd.setStyle ( SWT.ITALIC );
    }
    this.font = new Font ( this.viewer.getControl ().getDisplay (), fds );
}
 
Example 30
Project: neoscada   File: TreeNodeLabelProvider.java   View source code 5 votes vote down vote up
@Override
public Font getFont ( final Object element )
{
    final TreeNode node = (TreeNode)element;
    if ( node.isProviderSet () )
    {
        return this.defaultFont;
    }
    else
    {
        return this.font;
    }
}
 
Example 31
Project: neoscada   File: StyleBlinker.java   View source code 5 votes vote down vote up
public CurrentStyle ( final Image image, final Color foreground, final Color background, final Font font )
{
    this.image = image;
    this.foreground = foreground;
    this.background = background;
    this.font = font;
}
 
Example 32
Project: neoscada   File: StyleHandler.java   View source code 5 votes vote down vote up
public Style ( final Image[] images, final Color[] foregroundColor, final Color[] backgroundColor, final Font[] font )
{
    this.images = images;
    this.foregroundColor = foregroundColor;
    this.backgroundColor = backgroundColor;
    this.font = font;
}
 
Example 33
Project: convertigo-eclipse   File: ViewLabelProvider.java   View source code 5 votes vote down vote up
public Font getFont(Object element) {
	if (element instanceof DatabaseObjectTreeObject) {
		DatabaseObjectTreeObject databaseObjectTreeObject = (DatabaseObjectTreeObject) element;
		DatabaseObject databaseObject = databaseObjectTreeObject.getObject();
		if (databaseObject.hasChanged) return fontModifiedDatabaseObject;
		if (databaseObjectTreeObject.isDetectedObject) return fontDetectedDatabaseObject;
	}
	return fontSystem;
}
 
Example 34
Project: convertigo-eclipse   File: CicsConnectorComposite.java   View source code 5 votes vote down vote up
protected void initialize() {
	GridData gridData = new org.eclipse.swt.layout.GridData();
	gridData.horizontalAlignment = org.eclipse.swt.layout.GridData.FILL;
	gridData.grabExcessHorizontalSpace = true;
	gridData.grabExcessVerticalSpace = true;
	gridData.verticalAlignment = org.eclipse.swt.layout.GridData.FILL;
	cicsData = new Text(this, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
	cicsData.setEditable(false);
	cicsData.setBackground(new Color(null,253,253,244));
	cicsData.setFont(new Font(null,"Courier New",10,1));
	cicsData.setLayoutData(gridData);
	cicsData.setText("");
	this.setLayout(new GridLayout());
	setSize(new Point(300, 200));
}
 
Example 35
Project: codelens-eclipse   File: DefaultViewZone.java   View source code 5 votes vote down vote up
@Override
public void draw(int paintX, int paintSpaceLeadingX, int paintY, GC gc) {
	StyledText styledText = super.getTextViewer().getTextWidget();
	Rectangle client = styledText.getClientArea();
	gc.setBackground(styledText.getDisplay().getSystemColor(SWT.COLOR_WHITE));
	styledText.drawBackground(gc, paintX, paintY, client.width, super.getHeightInPx());
	gc.setForeground(styledText.getDisplay().getSystemColor(SWT.COLOR_GRAY));

	Font font = new Font(styledText.getDisplay(), "Arial", 9, SWT.ITALIC);
	gc.setFont(font);
	gc.drawText(this.getText(), paintX, paintY + 4);
}
 
Example 36
Project: codelens-eclipse   File: StyledTextPatcher.java   View source code 5 votes vote down vote up
private static Method getSetFontMethod(Object styledTextRenderer) throws NoSuchMethodException {
	// if (SET_FONT_METHOD == null) {
	Method SET_FONT_METHOD = styledTextRenderer.getClass().getDeclaredMethod("setFont",
			new Class[] { Font.class, int.class });
	SET_FONT_METHOD.setAccessible(true);
	// }
	return SET_FONT_METHOD;
}
 
Example 37
Project: eclipse-plugin-commander   File: KaviListColumns.java   View source code 5 votes vote down vote up
private Font createColumnFont(final ColumnOptions<T> options, ViewerCell cell) {
	Font font = options.getFont();
	if (font == null) {
		FontDescriptor fontDescriptor = FontDescriptor.createFrom(cell.getFont()).setStyle(options.getFontStyle());
		font = fontDescriptor.createFont(cell.getControl().getDisplay());
		options.setFont(font);
	}
	return font;
}
 
Example 38
Project: pandionj   File: ValueLabel.java   View source code 5 votes vote down vote up
private void setAutoFont(int size, String text, FontStyle ... styles) {
	Font f = FontManager.getFont(size, styles);
	while(FigureUtilities.getTextWidth(text, f) > PandionJConstants.POSITION_WIDTH-4 && size > 8) {
		size--;
		f = FontManager.getFont(size, styles);
	}
	setFont(f);
}
 
Example 39
Project: eclipse-plugin-commander   File: KaviList.java   View source code 5 votes vote down vote up
private int averageCharacterWidth(Font font) {
	int width;
    GC gc = new GC(Display.getDefault());
    gc.setFont(font);
    FontMetrics fontMetrics = gc.getFontMetrics();
	width = fontMetrics.getAverageCharWidth();
	gc.dispose();
	return width;
}
 
Example 40
Project: openaudible   File: FontShop.java   View source code 5 votes vote down vote up
private Font swapFont(Font old, Font newFont) {
    if (old == newFont)
        logger.error("font swap error.");

    if (isset(old))
        old.dispose();
    return newFont;
}