当前位置: 首页>>代码示例>>Java>>正文


Java SWT.BOLD属性代码示例

本文整理汇总了Java中org.eclipse.swt.SWT.BOLD属性的典型用法代码示例。如果您正苦于以下问题:Java SWT.BOLD属性的具体用法?Java SWT.BOLD怎么用?Java SWT.BOLD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.eclipse.swt.SWT的用法示例。


在下文中一共展示了SWT.BOLD属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: PluginsSWT

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);
}
 
开发者ID:gluonhq,项目名称:ide-plugins,代码行数:25,代码来源:PluginsSWT.java

示例2: addStats

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);
			}
		}
	}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:26,代码来源:StatisticsDialog.java

示例3: initFormText

public static void initFormText(FormText formText) {

        formText.setWhitespaceNormalized(false);

        Font formTextFont = formText.getFont();
        FontData formTextFontData = formTextFont.getFontData()[0];

        FontData h1FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 5, SWT.BOLD);
        final Font h1Font = new Font(formTextFont.getDevice(), h1FontData);
        formText.setFont(FONT_H1_KEY, h1Font);

        FontData h3FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 3, SWT.BOLD);
        final Font h3Font = new Font(formTextFont.getDevice(), h3FontData);
        formText.setFont(FONT_H3_KEY, h3Font);

        Font codeFont = JFaceResources.getTextFont();
        formText.setFont(FONT_CODE_KEY, codeFont);

        formText.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                h1Font.dispose();
                h3Font.dispose();
            }
        });

        // Set fontKeySet = JFaceResources.getFontRegistry().getKeySet();
        // if (fontKeySet != null) {
        // for (Object fontKey : fontKeySet) {
        // System.out.println(fontKey);
        // }
        // }

    }
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:35,代码来源:JmxDocFormText.java

示例4: getTextAttribute

private TextAttribute getTextAttribute(IPreferenceStore prefs, SQLEditorStatementTypes type) {
    SQLEditorSyntaxModel sm = new SQLEditorSyntaxModel(type, prefs).load();
    int style = 0 | (sm.isBold() ? SWT.BOLD : 0)
            | (sm.isItalic() ? SWT.ITALIC: 0)
            | (sm.isUnderline() ? SWT.UNDERLINE_SINGLE: 0)
            | (sm.isUnderline() ? TextAttribute.UNDERLINE: 0)
            | (sm.isStrikethrough() ? TextAttribute.STRIKETHROUGH: 0);
    return new TextAttribute(fSharedColors.getColor(sm.getColor()), null, style);
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:9,代码来源:SQLEditorSourceViewerConfiguration.java

示例5: createTableColumns

private void createTableColumns(Table table, String[] fields, int width) {
	for (String field : fields) {
		TableColumn tableColumn = new TableColumn(table, SWT.LEFT|SWT.BOLD);
		tableColumn.setText(field);
		tableColumn.setWidth(width);
	}
	table.setHeaderVisible(true);
	table.setLinesVisible(true);

}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:10,代码来源:DebugDataWizard.java

示例6: createConsoleBufferWidget

/**
 * Create console buffer widget
 * @param bufferSize
 */
private void createConsoleBufferWidget(String bufferSize){
	HydroGroup hydroGroup = new HydroGroup(this, SWT.NONE);
	
	hydroGroup.setHydroGroupText(Messages.HYDROGRAPH_CONSOLE_PREFERANCE_PAGE_GROUP_NAME);
	hydroGroup.setLayout(new GridLayout(1, false));
	hydroGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
	hydroGroup.getHydroGroupClientArea().setLayout(new GridLayout(2, false));
	
	Label label = new Label(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
	
	label.setText(Messages.PREFERANCE_CONSOLE_BUFFER_SIZE);
	
	textWidget = new Text(hydroGroup.getHydroGroupClientArea(), SWT.BORDER);
	textWidget.setText(bufferSize);
	textWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
	textWidget.setTextLimit(6);
	
	attachConsoleBufferValidator();
	
	Composite purgeComposite = new Composite(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
	purgeComposite.setLayout(new GridLayout(2, false));
	purgeComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
	
	Label lblNote = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
	lblNote.setText(Messages.PREFERANCE_PAGE_NOTE);
	FontData fontData = lblNote.getFont().getFontData()[0];
	Font font = new Font(purgeComposite.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
	lblNote.setFont(font);
	Label lblmsg = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
	lblmsg.setText(Messages.UI_PERFORMANCE_NOTE_IN_CASE_OF_CHANGE_IN_BUFFER_SIZE);
	
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:36,代码来源:JobRunPreferenceComposite.java

示例7: addStyleRange

private void addStyleRange(StyleType styleType, int length) {
	int fontStyle = styleType == StyleType.BOLD ? SWT.BOLD : SWT.NONE;
	StyleRange range = new StyleRange(offset, length, null, null, fontStyle);
	if (styleType == StyleType.FIXED_WIDTH) {
		range.font = JFaceResources.getFont(JFaceResources.TEXT_FONT);
	}
	presentation.addStyleRange(range);
}
 
开发者ID:sebez,项目名称:vertigo-chroma-kspplugin,代码行数:8,代码来源:KspInformationPresenter.java

示例8: createPartControl

@Override
public void createPartControl(Composite parent) {

	FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
	fillLayout.marginHeight = 5;
	fillLayout.marginWidth = 5;
	parent.setLayout(fillLayout);

	// main container
	container = new Composite(parent, SWT.BORDER);
	container.setLayout(new FillLayout());

	// create container for stack trace data
	Composite stacktraceDataContainer = new Composite(parent, SWT.BORDER);

	FormLayout formLayout = new FormLayout();
	formLayout.marginHeight = 5;
	formLayout.marginWidth = 5;
	formLayout.spacing = 5;
	stacktraceDataContainer.setLayout(formLayout);

	Composite stackLabelContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
	stackLabelContainer.setLayout(new GridLayout());

	FormData stackLabelFormData = new FormData();
	stackLabelFormData.top = new FormAttachment(0);
	stackLabelFormData.left = new FormAttachment(0);
	stackLabelFormData.right = new FormAttachment(100);
	stackLabelFormData.bottom = new FormAttachment(20);
	stackLabelContainer.setLayoutData(stackLabelFormData);

	Composite stackTraceContainer = new Composite(stacktraceDataContainer, SWT.NO_SCROLL | SWT.SHADOW_NONE);
	stackTraceContainer.setLayout(new FillLayout());

	FormData stackTraceFormData = new FormData();
	stackTraceFormData.top = new FormAttachment(stackLabelContainer);
	stackTraceFormData.left = new FormAttachment(0);
	stackTraceFormData.right = new FormAttachment(100);
	stackTraceFormData.bottom = new FormAttachment(100);
	stackTraceContainer.setLayoutData(stackTraceFormData);

	// Create viewer for test tree in main container
	testTreeViewer = new TreeViewer(container);
	testTreeViewer.setContentProvider(new XpectContentProvider());
	testTreeViewer.setLabelProvider(new XpectLabelProvider(this.testsExecutionStatus));
	testTreeViewer.setInput(null);

	// create stack trace label
	stacktraceLabel = new Label(stackLabelContainer, SWT.SHADOW_OUT);
	FontData fontData = stacktraceLabel.getFont().getFontData()[0];
	Display display = Display.getCurrent();
	// may be null if outside the UI thread
	if (display == null)
		display = Display.getDefault();
	Font font = new Font(display, new FontData(fontData.getName(), fontData
			.getHeight(), SWT.BOLD));
	// Make stack trace label bold
	stacktraceLabel.setFont(font);

	stacktraceLabel.setText(NO_TRACE_MSG);

	// create stack trace console
	MessageConsole messageConsole = new MessageConsole("trace", null);
	stacktraceConsole = new TraceConsole(messageConsole);
	stacktraceConsoleViewer = new TextConsoleViewer(stackTraceContainer, messageConsole);

	// context menu
	getSite().setSelectionProvider(testTreeViewer);
	MenuManager contextMenu = new MenuManager();
	contextMenu.setRemoveAllWhenShown(true);
	getSite().registerContextMenu(contextMenu, testTreeViewer);
	Control control = testTreeViewer.getControl();
	Menu menu = contextMenu.createContextMenu(control);
	control.setMenu(menu);
	activateContext();

	createSelectionActions();

}
 
开发者ID:eclipse,项目名称:n4js,代码行数:79,代码来源:N4IDEXpectView.java

示例9: addToComposite

private void addToComposite(Group choosenGroup, final String name, final String description, final boolean isMultiValued) {
	boolean isNotChecked = true;
	
	if (allVariables != null) {
		isNotChecked = !isChecked(allVariables, name);
	}
	
	if (isNotChecked) {
		final Button checkBtn = new Button(choosenGroup, SWT.CHECK);	
		checkBtn.addListener(SWT.Selection, new Listener() {
			
			@Override
			public void handleEvent(Event event) {
				if (checkBtn.getSelection()) {
					selectedVariable.add(new CouchVariable(name, description, isMultiValued));
				} else {
					selectedVariable.remove(getIndex(name, selectedVariable));
				}
			}
		});
		
		Label labelName = new Label(choosenGroup, SWT.NONE);
		FontData fontData = labelName.getFont().getFontData()[0];
		Font font = new Font(this.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
		labelName.setFont(font);
		
		String label = name;
		if (label.startsWith("p_") || label.startsWith("q_")) {
			label = name.substring(2);
		}
		if (isMultiValued) {
			label += " [ ]";
		}			
		
		labelName.setText(label);
		
		C8oBrowser browserDescription = new C8oBrowser(choosenGroup, SWT.MULTI | SWT.WRAP);
		browserDescription.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false));
		browserDescription.setText("<html>" +
				"<head>" +
				"<script type=\"text/javascript\">"+
			        "document.oncontextmenu = new Function(\"return false\");"+
			    "</script>"+
						"<style type=\"text/css\">"+
							  "body {"+
							    "font-family: Tahoma new, sans-serif;" +
							    "font-size: 0.7em;"+
							    "margin-top: 5px;" +
							    "overflow-y: auto;" +
							    "background-color: #ECEBEB }"+
						"</style></head><p>" + description + "</p></html>");

		parametersCouch.add(name);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:55,代码来源:CouchVariablesComposite.java

示例10: run

public void run() {
	if (printer.startJob(getDisk(0).getFilename())) {
		clientArea = printer.getClientArea();
		dpiY = printer.getDPI().y;
		dpiX = printer.getDPI().x;
		// Setup 1" margin:
		Rectangle trim = printer.computeTrim(0, 0, 0, 0);
		clientArea.x = dpiX + trim.x; 				
		clientArea.y = dpiY + trim.y;
		clientArea.width -= (clientArea.x + trim.width);
		clientArea.height -= (clientArea.y + trim.height);
		// Set default values: 
		y = clientArea.y;
		x = clientArea.x;
		gc = new GC(printer);
		int fontSize = 12;
		if (getCurrentFormat() == FormattedDisk.FILE_DISPLAY_NATIVE) {
			fontSize = 10;
		} else if (getCurrentFormat() == FormattedDisk.FILE_DISPLAY_DETAIL) {
			fontSize = 8;
		}
		normalFont = new Font(printer, new String(), fontSize, SWT.NORMAL);
		headerFont = new Font(printer, new String(), fontSize, SWT.BOLD);
		for (int i=0; i<getDisks().length; i++) {
			FormattedDisk disk = getDisk(i);
			filename = disk.getFilename();
			fileHeaders =  disk.getFileColumnHeaders(getCurrentFormat());
			gc.setFont(headerFont);
			computeHeaderWidths();
			printFileHeaders();
			gc.setFont(normalFont);
			println(disk.getDiskName());
			printFiles(disk, 1);
		}
		if (y != clientArea.y) {	// partial page
			printFooter();
			printer.endPage();
		}
		printer.endJob();
	}
}
 
开发者ID:AppleCommander,项目名称:AppleCommander,代码行数:41,代码来源:DiskExplorerTab.java

示例11: logToStyledText

/**
 * Append the logging control with a new entry.
 */
protected void logToStyledText() {
	// Do nothing if the logging control is disposed. This might happen if the Window is currently beeing closed but this method is still invoked.
	if (this.loggingStyledText.isDisposed()) {
		return;
	}

	// Get the entries.
	String entries = this.loggingStyledText.getText();

	// Does an old entry have to be dropped?
	boolean dropentry = false;
	if (this.entriesLogged >= Options.getInst().maximumStepByStepLoggingEntries) dropentry = true;
	if (dropentry) {
		// Find the last \n position.
		int position = entries.lastIndexOf("\n");
		if (position == -1) {
			entries = "";
		} else {
			// Drop the last line with this information.
			entries = entries.substring(0, position);
		}
	}

	// Get the new entry.
	String newEntry = this.newLoggingEntryTimestamp.get(0) + "\t" + this.newLoggingEntryPriority.get(0).toString() + "\t\t";
	// Generate a style range.
	StyleRange styleRange = new StyleRange();
	styleRange.start = newEntry.length();
	styleRange.length = this.newLoggingEntryMessage.get(0).length();
	styleRange.fontStyle = SWT.BOLD;
	styleRange.foreground = this.display.getSystemColor(SWT.COLOR_BLACK);
	newEntry += this.newLoggingEntryMessage.get(0);

	// Append the logger.
	if (entries.equals("")) {
		// There are no entries, yet. Just add the new entry.
		this.loggingStyledText.setText(newEntry);
		this.loggingStyledText.setStyleRange(styleRange);
	} else {
		// Process the existing style ranges. Since the new entry has an own style range, these ranges have to be "shifted" so the text will keep the correct formatting.
		int totalLength = newEntry.length() + 1; // Add one for the \n at the lines' end.
		StyleRange[] styleRanges = this.loggingStyledText.getStyleRanges();
		if (dropentry) {
			// Drop the oldest one and shift the other old entries.
			for (int a = styleRanges.length - 1; a > 0; a--) {
				styleRanges[a - 1].start += totalLength;
				styleRanges[a] = styleRanges[a - 1];
			}
			styleRanges[0] = styleRange;
		} else {
			// Expand the number of StyleRanges and shift the old entries.
			StyleRange[] styleRanges2 = new StyleRange[styleRanges.length + 1];
			for (int a = 0; a < styleRanges.length; a++) {
				styleRanges[a].start += totalLength;
				styleRanges2[a + 1] = styleRanges[a];
			}
			styleRanges2[0] = styleRange;
			styleRanges = styleRanges2;
		}

		// Append
		this.loggingStyledText.setText(newEntry + "\n" + entries);
		try {
			this.loggingStyledText.setStyleRanges(styleRanges);
		} catch (Exception e) {
			// Something failed. Ignore it.
		}
	}
	this.entriesLogged++;

	// Remove the entry from the list to process.
	this.newLoggingEntryTimestamp.remove(0);
	this.newLoggingEntryPriority.remove(0);
	this.newLoggingEntryMessage.remove(0);
}
 
开发者ID:wwu-pi,项目名称:tap17-muggl-javaee,代码行数:78,代码来源:StepByStepExecutionComposite.java

示例12: createAdvancedControls

protected void createAdvancedControls(Composite parent) {
	LOGGER.debug("Creating Import Engine XML layout");
	Composite fileSelectionArea = new Composite(parent, SWT.NONE);
	fileSelectionArea.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));

	GridLayout fileSelectionLayout = new GridLayout();
	fileSelectionLayout.makeColumnsEqualWidth = false;
	fileSelectionLayout.marginWidth = 0;
	fileSelectionLayout.marginHeight = 0;
	fileSelectionArea.setLayout(fileSelectionLayout);

	editor = new FileFieldEditor("fileSelect", Messages.SELECT_FILE_LABEL_TEXT, fileSelectionArea);
	editor.getTextControl(fileSelectionArea).addModifyListener(new ModifyListener() {
		public void modifyText(ModifyEvent e) {
			IPath path = new Path(ImportEngineXmlWizardPage.this.editor.getStringValue());
			if (path.segment(0) != null) {
				targetxmlFilePath = editor.getStringValue();
				setFileName(path.lastSegment());
			} else {
				targetxmlFilePath = null;
				displayError();
			}
		}
	});
	String[] extensions = new String[] { ALLOWED_EXTENSIONS }; // NON-NLS-1
	editor.setFileExtensions(extensions);
	fileSelectionArea.moveAbove(null);

	Composite fileSelectionArea2 = new Composite(parent, SWT.NONE);
	fileSelectionArea2.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL));
	GridLayout fileSelectionLayout2 = new GridLayout();
	fileSelectionLayout2.numColumns = 2;

	fileSelectionLayout2.makeColumnsEqualWidth = false;
	fileSelectionLayout2.marginWidth = 0;
	fileSelectionLayout2.marginHeight = 0;
	fileSelectionArea2.setLayout(fileSelectionLayout2);
	Font fontNote = new Font(fileSelectionArea2.getDisplay(), TIMES_NEW_ROMAN_BALTIC_FONT, 9, SWT.BOLD);
	Label lblNoteHeader = new Label(fileSelectionArea2, SWT.NONE);
	lblNoteHeader.setText(Messages.NOTE_LABEL_HEADER_TEXT);
	lblNoteHeader.setFont(fontNote);
	Label lblNote = new Label(fileSelectionArea2, SWT.NONE);

	GridData gd_lblNote = new GridData(SWT.BOTTOM, SWT.CENTER, false, false, 1, 1);
	gd_lblNote.widthHint = 391;
	lblNote.setLayoutData(gd_lblNote);
	lblNote.setText(Messages.NOTE_MESSAGE_TEXT);

}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:49,代码来源:ImportEngineXmlWizardPage.java

示例13: SourceViewer

public SourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler,
		boolean showAnnotationsOverview, int styles, IAnnotationAccess annotationAccess, ISharedTextColors sharedColors,
		IDocument document) 
{
	super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, SWT.BOLD);
	int id = currentId++;
	filename = VIEWER_CLASS_NAME + id++ + ".java";
	this.sharedColors=sharedColors;
	this.annotationAccess=annotationAccess;
	this.fOverviewRuler=overviewRuler;
	oldAnnotations= new HashMap<ProjectionAnnotation, Position>();

	IJavaProject javaProject = JavaCore.create(BuildExpressionEditorDataSturcture.INSTANCE.getCurrentProject());
	try 
	{
		IPackageFragmentRoot[] ipackageFragmentRootList=javaProject.getPackageFragmentRoots();
		IPackageFragmentRoot ipackageFragmentRoot=null;
		for(IPackageFragmentRoot tempIpackageFragmentRoot:ipackageFragmentRootList)
		{
			if(tempIpackageFragmentRoot.getKind()==IPackageFragmentRoot.K_SOURCE 
					&& StringUtils.equals(PathConstant.TEMP_BUILD_PATH_SETTINGS_FOLDER,tempIpackageFragmentRoot.getPath().removeFirstSegments(1).toString()))
			{
				ipackageFragmentRoot=tempIpackageFragmentRoot;
				break;
			}   
		} 

		IPackageFragment compilationUnitPackage=   ipackageFragmentRoot.createPackageFragment(HYDROGRAPH_COMPILATIONUNIT_PACKAGE, true, new NullProgressMonitor());
		compilatioUnit=   compilationUnitPackage.createCompilationUnit(filename,document.get(),true, new NullProgressMonitor());
	} 
	catch (Exception exception) {
		LOGGER.warn("Exception occurred while initializing source viewer", exception);
	} finally {
		if (javaProject != null) {
			try {
				javaProject.close();
			} catch (JavaModelException javaModelException) {
				LOGGER.warn("Exception occurred while closing java-project", javaModelException);
			}
		}
	}
	initializeViewer(document);
	updateContents();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:44,代码来源:SourceViewer.java

示例14: ComponentFigure

/**
 * Instantiates a new component figure.
 * 
 * @param portDetails
 *            the port details
 * @param cIconPath
 *            the canvas icon path
 * @param label
 * 			  Label to be displayed on component
 * @param acronym
 * 			  Acronym to be displayed on component
 * @param linkedHashMap
 * 			  the properties of components
 */

	public ComponentFigure(Component component, String cIconPath, String label, String acronym,
			LinkedHashMap<String, Object> properties) {
	this.canvasIconPath = XMLConfigUtil.CONFIG_FILES_PATH + cIconPath;
	this.acronym = acronym;
	this.componentProperties = properties;
	layout = new XYLayout();
	setLayoutManager(layout);

	labelFont = new Font(Display.getDefault(), ELTFigureConstants.labelFont, 9, SWT.NORMAL);
	int labelLength = TextUtilities.INSTANCE.getStringExtents(label, labelFont).width;

	if (labelLength >= ELTFigureConstants.compLabelOneLineLengthLimitForText) {
		this.componentLabelMargin = ELTFigureConstants.componentTwoLineLabelMargin;
		this.incrementedHeight = true;
	} else if (labelLength < ELTFigureConstants.compLabelOneLineLengthLimitForText) {
		this.componentLabelMargin = ELTFigureConstants.componentOneLineLabelMargin;
		this.incrementedHeight = false;
	}

	canvasIcon = new Image(null, canvasIconPath);
	this.component=component;
	connectionAnchors = new HashMap<String, FixedConnectionAnchor>();
	inputConnectionAnchors = new ArrayList<FixedConnectionAnchor>();
	outputConnectionAnchors = new ArrayList<FixedConnectionAnchor>();

	setInitialColor();
	setComponentColorAndBorder();

	for (PortDetails pDetail : component.getPortDetails()) {
		setPortCount(pDetail);
		setHeight(totalPortsAtLeftSide, totalPortsAtRightSide);
		setWidth(totalPortsAtBottonSide);
	}

	acronymFont = new Font(Display.getDefault(), ELTFigureConstants.labelFont, 8, SWT.BOLD);
	setFont(acronymFont);
	setForegroundColor(org.eclipse.draw2d.ColorConstants.black);

	componentCanvas = getComponentCanvas();
	attachMouseListener();
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:56,代码来源:ComponentFigure.java

示例15: toAwtFont

/**
 * Create an awt font by converting as much information 
 * as possible from the provided swt <code>FontData</code>.
 * <p>Generally speaking, given a font size, an swt font will 
 * display differently on the screen than the corresponding awt 
 * one. Because the SWT toolkit use native graphical ressources whenever 
 * it is possible, this fact is plateform dependent. To address 
 * this issue, it is possible to enforce the method to return 
 * an awt font with the same height as the swt one.
 * 
 * @param device The swt device being drawn on (display or gc device).
 * @param fontData The swt font to convert.
 * @param ensureSameSize A boolean used to enforce the same size 
 * (in pixels) between the swt font and the newly created awt font.
 * @return An awt font converted from the provided swt font.
 */
public static java.awt.Font toAwtFont(Device device, FontData fontData, 
        boolean ensureSameSize) {
    int style;
    switch (fontData.getStyle()) {
        case SWT.NORMAL:
            style = java.awt.Font.PLAIN;
            break;
        case SWT.ITALIC:
            style = java.awt.Font.ITALIC;
            break;
        case SWT.BOLD:
            style = java.awt.Font.BOLD;
            break;
        default:
            style = java.awt.Font.PLAIN;
            break;
    }
    int height = (int) Math.round(fontData.getHeight() * device.getDPI().y 
            / 72.0);
    // hack to ensure the newly created awt fonts will be rendered with the
    // same height as the swt one
    if (ensureSameSize) {
        GC tmpGC = new GC(device);
        Font tmpFont = new Font(device, fontData);
        tmpGC.setFont(tmpFont);
        JPanel DUMMY_PANEL = new JPanel();
        java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(), 
                style, height);
        if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) 
                > tmpGC.textExtent(Az).x) {
            while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) 
                    > tmpGC.textExtent(Az).x) {
                height--;                
                tmpAwtFont = new java.awt.Font(fontData.getName(), style, 
                        height);
            }
        }
        else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) 
                < tmpGC.textExtent(Az).x) {
            while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) 
                    < tmpGC.textExtent(Az).x) {
                height++;
                tmpAwtFont = new java.awt.Font(fontData.getName(), style, 
                        height);
            }
        }
        tmpFont.dispose();
        tmpGC.dispose();
    }
    return new java.awt.Font(fontData.getName(), style, height);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:67,代码来源:SWTUtils.java


注:本文中的org.eclipse.swt.SWT.BOLD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。