Java Code Examples for org.eclipse.swt.graphics.GC#drawString()
The following examples show how to use
org.eclipse.swt.graphics.GC#drawString() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TitleControl.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void onPaint(PaintEvent e) { GC gc = e.gc; Point s = getSize(); int w = s.x; int h = s.y; gc.setForeground(gradient1Color); gc.setBackground(gradient2Color); gc.fillGradientRectangle(0, 0, w, h - 1, true); Rectangle imgsize = new Rectangle(0, 0, 0, 0); if (image != null) { imgsize = image.getBounds(); gc.drawImage(image, 12, 0); } gc.setForeground(bottomLineColor); gc.drawLine(0, h - 1, w, h - 1); gc.setFont(font); gc.setForeground(writingColor); Point textSize = gc.stringExtent(text); int ty = (h - textSize.y) / 2; gc.drawString(text, 22 + imgsize.width, TOP_SPACE + ty, true); }
Example 2
Source File: MultilineListCellRenderer.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public void draw(GC gc, JaretTable jaretTable, ICellStyle cellStyle, Rectangle drawingArea, IRow row, IColumn column, boolean drawFocus, boolean selected, boolean printing) { drawBackground(gc, drawingArea, cellStyle, selected, printing); Rectangle drect = drawBorder(gc, cellStyle, drawingArea, printing); Rectangle rect = applyInsets(drect); DummyRow dr = (DummyRow) row; Image img = dr.getImg(); int x = rect.x + 4; int y = rect.y + (rect.height - img.getBounds().height) / 2; gc.drawImage(img, x, y); Font save = gc.getFont(); gc.setFont(boldFont); gc.drawString(dr.getT2(), rect.x + 70, y + 5); gc.setFont(normalFont); gc.drawString(dr.getT3(), rect.x + 70, y + 25); gc.setFont(save); if (drawFocus) { drawFocus(gc, drawingArea); } drawSelection(gc, drawingArea, cellStyle, selected, printing); }
Example 3
Source File: HeaderControl.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void onPaint(PaintEvent e) { GC gc = e.gc; gc.setFont(font); gc.setForeground(foreground); gc.drawString(text, 0, TOP_SPACE, true); Point size = getSize(); int w = size.x; int h = size.y; gc.drawLine(0, h - 1, w, h - 1); }
Example 4
Source File: JaretTablePrinter.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private void drawFooter(GC gc, String footer) { Point extent = gc.textExtent(footer); int y = _printer.getClientArea().height - _footerHeight - pixelForCmY(_borderBottom); // gc.drawLine(0,y,_pageWidth, y); // gc.drawLine(0,y+extent.y,_pageWidth, y+extent.y); gc.drawString(footer, pixelForCmX(_borderLeft), y); }
Example 5
Source File: PreviewLabel.java From birt with Eclipse Public License 1.0 | 5 votes |
protected void paintControl( PaintEvent e ) { GC gc = e.gc; if ( text == null ) { text = ""; //$NON-NLS-1$ } Point pt = gc.stringExtent( text ); gc.drawString( text, ( getSize( ).x - pt.x ) / 2, ( getSize( ).y - pt.y ) / 2, true ); if ( isUnderline ) { gc.drawLine( ( getSize( ).x - pt.x ) / 2, ( getSize( ).y - pt.y ) / 2 + pt.y, ( getSize( ).x - pt.x ) / 2 + pt.x, ( getSize( ).y - pt.y ) / 2 + pt.y ); } if ( isLinethrough ) { gc.drawLine( ( getSize( ).x - pt.x ) / 2, ( getSize( ).y - pt.y ) / 2 + pt.y / 2, ( getSize( ).x - pt.x ) / 2 + pt.x, ( getSize( ).y - pt.y ) / 2 + pt.y / 2 ); } if ( isOverline ) { gc.drawLine( ( getSize( ).x - pt.x ) / 2, ( getSize( ).y - pt.y ) / 2, ( getSize( ).x - pt.x ) / 2 + pt.x, ( getSize( ).y - pt.y ) / 2 ); } }
Example 6
Source File: CalendarComposite.java From nebula with Eclipse Public License 2.0 | 5 votes |
private void drawTitleDays(GC gc) { Calendar temp = Calendar.getInstance(mSettings.getLocale()); // fetch the first day of the week, and draw starting on that day int fdow = temp.getFirstDayOfWeek(); Rectangle bounds = super.getBounds(); int xStart = mSettings.getDatesLeftMargin() + 5; int yStart = bounds.y + mSettings.getHeaderTopMargin() + mSettings.getHeaderHeight() + 1; int spacer = 0; int letterHeight = 0; for (int i = 0; i < 7; i++) { Point strWidth = gc.stringExtent(mDayTitles[fdow]); int x = xStart + mSettings.getOneDateBoxSize() + spacer - strWidth.x; // don't add the string width, as our string width later when // drawing days will differ mDayXs[i] = xStart + mSettings.getOneDateBoxSize() + spacer; gc.drawString(mDayTitles[fdow], x, yStart, true); letterHeight = strWidth.y; spacer += mSettings.getOneDateBoxSize() + mSettings.getBoxSpacer(); fdow++; if (fdow > 7) { fdow = 1; } } int lineStart = yStart + 1 + letterHeight; gc.setForeground(mColorManager.getLineColor()); gc.drawLine(mSettings.getDatesLeftMargin() + 1, lineStart, bounds.width - mSettings.getDatesRightMargin() - 3, lineStart); mDatesTopY = lineStart + 3; }
Example 7
Source File: MainSplash.java From arx with Apache License 2.0 | 5 votes |
/** * Paint. * * @param gc */ private void paint(GC gc) { Point size = shell.getSize(); Point offsets = gc.textExtent(version); gc.setAdvanced(true); gc.setAntialias(SWT.ON); gc.setInterpolation(SWT.ON); gc.drawImage(splash, 0, 0, splash.getBounds().width, splash.getBounds().height, 0, 0, size.x, size.y); gc.setForeground(GUIHelper.COLOR_BLACK); gc.drawString(version, size.x - (int)offsets.x - 10, size.y - (int)offsets.y - 10, true); }
Example 8
Source File: TestProgressBar.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Paint. */ protected void onPaint(GC gc) { final Rectangle b = getBounds(); final TestStatus status = counter != null ? counter.getAggregatedStatus() : null; if (status != null) { final int total = Math.max(expectedTotal, counter.getTotal()); // this is our 100% value final int value = counter.getTotal(); // current value final int totalPx = b.width; final int valuePx = Math.round(totalPx * (((float) value) / ((float) total))); gc.setBackground(getColorForStatus(status)); gc.fillRectangle(0, 0, valuePx, b.height); gc.setBackground(getBackground()); gc.fillRectangle(0 + valuePx, 0, b.width - valuePx, b.height); } else { // clear gc.setBackground(getBackground()); gc.fillRectangle(b); } if (counter != null) { final FontMetrics fm = gc.getFontMetrics(); gc.setForeground(getForeground()); final int pending = expectedTotal > 0 ? expectedTotal - counter.getTotal() : -1; gc.drawString(counter.toString(true, pending, SWT.RIGHT), 4, b.height / 2 - fm.getHeight() / 2 - fm.getDescent(), true); } }
Example 9
Source File: GridToolTip.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * Paints the tooltip. * * @param gc */ private void onPaint(GC gc) { gc.drawRectangle(0, 0, shell.getSize().x - 1, shell.getSize().y - 1); gc.drawString(text, xmargin, ymargin, true); }
Example 10
Source File: AbstractPaintManager.java From nebula with Eclipse Public License 2.0 | 5 votes |
public void drawDaysOnChart(final GanttComposite ganttComposite, final ISettings settings, final IColorManager colorManager, final GanttEvent event, final GC gc, final boolean threeDee, final int x, final int y, final int eventWidth, final int daysNumber, final Rectangle bounds) { if (event.isImage()) { return; } final int top = y - 2; final int xE = x + eventWidth; final int middle = x + ((xE - x) / 2); int yMiddle = event.getY() + (event.getHeight() / 2); final StringBuffer buf = new StringBuffer(); buf.append(daysNumber); final String dayString = buf.toString(); final Point extent = gc.stringExtent(dayString); final Point unmodified = new Point(extent.x, extent.y); extent.x = extent.x + (2 * 2) + 2; // 2 pixel spacing on 2 sides, for clarity's sake Color gradient = event.getGradientStatusColor(); if (gradient == null) { gradient = settings.getDefaultGradientEventColor(); } if ((middle - extent.x) > x) { gc.setBackground(gradient); gc.fillRectangle(middle - extent.x / 2, top, extent.x, settings.getEventHeight() + 4); gc.setForeground(colorManager.getTextColor()); gc.drawRectangle(middle - extent.x / 2, top, extent.x, settings.getEventHeight() + 4); yMiddle -= unmodified.y / 2; gc.drawString(dayString, middle - unmodified.x + (unmodified.x / 2) + 1, yMiddle, true); } }
Example 11
Source File: WhitespaceCharacterPainter.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Draw string at widget offset. * * @param gc * @param offset * the widget offset * @param s * the string to be drawn * @param fg * the foreground color */ private void draw(GC gc, int offset, String s, Color fg) { // Compute baseline delta (see // https://bugs.eclipse.org/bugs/show_bug.cgi?id=165640) int baseline = fTextWidget.getBaseline(offset); FontMetrics fontMetrics = gc.getFontMetrics(); int fontBaseline = fontMetrics.getAscent() + fontMetrics.getLeading(); int baslineDelta = baseline - fontBaseline; Point pos = fTextWidget.getLocationAtOffset(offset); gc.setForeground(fg); gc.drawString(s, pos.x, pos.y + baslineDelta, true); }
Example 12
Source File: NButton.java From ldparteditor with MIT License | 4 votes |
private void paint(PaintEvent event) { final GC gc = event.gc; final Image img = this.img; final boolean focused = this.isFocusControl(); final boolean enabled = this.isEnabled(); final boolean hasImage = img != null; final int img_width = hasImage ? img.getImageData().width : 0; final int img_height = hasImage ? img.getImageData().height : 0; final int this_width = getBounds().width - 1; gc.setFont(Font.SYSTEM); // setFont before using textExtent, so that the size of the text // can be calculated correctly final Point textExtent = getText().isEmpty() ? new Point(0,0) : gc.textExtent(getText()); // TODO 1. Calculate sizes // TODO 2. Draw Content if (selected && (canToggle || isRadio)) { gc.setBackground(SWTResourceManager.getColor(160, 160, 200)); gc.fillRoundRectangle(0, 0, Math.max(img_width + 9 + textExtent.x, this_width), Math.max(textExtent.y, img_height) + 9, 5, 5); gc.setBackground(getBackground()); } gc.setForeground(SWTResourceManager.getColor(255, 255, 255)); if (hovered || focused) { gc.setForeground(SWTResourceManager.getColor(0, 0, 0)); } if (pressed) { gc.setForeground(SWTResourceManager.getColor(220, 220, 220)); } if (!canCheck && !hasBorder) { if (!enabled) { gc.setForeground(SWTResourceManager.getColor(200, 200, 200)); } gc.drawRoundRectangle(0, 0, Math.max(img_width + 9 + textExtent.x, this_width), Math.max(textExtent.y, img_height) + 9, 5, 5); gc.setForeground(SWTResourceManager.getColor(60, 60, 60)); if (hovered || focused) { gc.setBackground(SWTResourceManager.getColor(160, 160, 200)); gc.fillRoundRectangle(1, 1, Math.max(img_width + 9 + textExtent.x, this_width) - 1, Math.max(textExtent.y, img_height) + 9 - 1, 5, 5); if (selected && (canToggle || isRadio)) { gc.setBackground(SWTResourceManager.getColor(160, 160, 200)); } else { gc.setBackground(getBackground()); } gc.fillRoundRectangle(2, 2, Math.max(img_width + 9 + textExtent.x, this_width) - 3, Math.max(textExtent.y, img_height) + 9 - 3, 5, 5); } if (pressed) { gc.setForeground(SWTResourceManager.getColor(30, 30, 30)); } if (!enabled) { gc.setForeground(SWTResourceManager.getColor(200, 200, 200)); } gc.drawRoundRectangle(1, 1, Math.max(img_width + 9 + textExtent.x, this_width) - 1, Math.max(textExtent.y, img_height) + 9 - 1, 5, 5); } if (hasImage) { gc.drawImage(img, 5, 5); } gc.setForeground(getForeground()); gc.drawString(getText(), img_width + 5, 5, true); // 3. Paint custom forms for (PaintListener pl : painters) { pl.paintControl(event); } }
Example 13
Source File: AbstractButtonPainter.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void paintText(GC gc, IColorManager colorManager, ISettings settings, Rectangle bounds, Rectangle imageBounds, boolean hover, boolean selected, String text) { if (text == null || text.length() == 0) return; int imgWidth = 0; if (imageBounds != null) imgWidth = imageBounds.width; Point se = gc.stringExtent(text); int textTop = (CustomButton.BUTTON_HEIGHT - se.y) / 2; //int textWidth = se.x; Font oldFont = gc.getFont(); Font newFont = settings.getButtonTextFont(oldFont); gc.setFont(newFont); // skip image if image is null (TODO: feature to let users align imageless button text with image button text? //int spaceNeeded = (imgWidth > 0 ? mLeftSpacer + imgWidth : 0) + mRightSpacer + textWidth; String textToUse = text; // out of bounds? /* if (spaceNeeded > bounds.width) { //TODO: truncate text char[] total = mText.toCharArray(); StringBuffer fin = new StringBuffer(); int loop = 0; while (gc.stringExtent(fin.toString()).x < (bounds.width - gc.stringExtent("...").x)) { fin.append(total[loop]); loop++; } fin.append("..."); textToUse = fin.toString(); } */ gc.setForeground(settings.getButtonTextColor()); gc.drawString(textToUse, (imgWidth > 0 ? settings.getLeftButtonTextSpacing() + imgWidth : 0) + settings.getButtonTextImageSpacing(), textTop-1, true); // reset fonts newFont.dispose(); gc.setFont(oldFont); }
Example 14
Source File: JavaViewer.java From birt with Eclipse Public License 1.0 | 4 votes |
private final void showException( GC g2d, Exception ex ) { String sWrappedException = ex.getClass( ).getName( ); Throwable th = ex; while ( ex.getCause( ) != null ) { ex = (Exception) ex.getCause( ); } String sException = ex.getClass( ).getName( ); if ( sWrappedException.equals( sException ) ) { sWrappedException = null; } String sMessage = null; if ( th instanceof BirtException ) { sMessage = ( (BirtException) th ).getLocalizedMessage( ); } else { sMessage = ex.getMessage( ); } if ( sMessage == null ) { sMessage = "<null>";//$NON-NLS-1$ } StackTraceElement[] stea = ex.getStackTrace( ); Point d = this.getSize( ); Device dv = Display.getCurrent( ); Font fo = new Font( dv, "Courier", SWT.BOLD, 16 );//$NON-NLS-1$ g2d.setFont( fo ); FontMetrics fm = g2d.getFontMetrics( ); g2d.setBackground( dv.getSystemColor( SWT.COLOR_WHITE ) ); g2d.fillRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setClipping( 20, 20, d.x - 40, d.y - 40 ); int x = 25, y = 20 + fm.getHeight( ); g2d.drawString( "Exception:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Exception:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sException, x, y ); x = 25; y += fm.getHeight( ); if ( sWrappedException != null ) { g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawString( "Wrapped In:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Wrapped In:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sWrappedException, x, y ); x = 25; y += fm.getHeight( ); } g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Message:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Message:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLUE ) ); g2d.drawString( sMessage, x, y ); x = 25; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Trace:", x, y );//$NON-NLS-1$ x = 40; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_DARK_GREEN ) ); for ( int i = 0; i < stea.length; i++ ) { g2d.drawString( stea[i].getClassName( ) + ":"//$NON-NLS-1$ + stea[i].getMethodName( ) + "(...):"//$NON-NLS-1$ + stea[i].getLineNumber( ), x, y ); x = 40; y += fm.getHeight( ); } fo.dispose( ); }
Example 15
Source File: LauncherLabel.java From nebula with Eclipse Public License 2.0 | 4 votes |
/** * Draw the content of the LLabel * * @param event paintevent */ private void onPaint(final PaintEvent event) { final Rectangle rect = getClientArea(); if (rect.width == 0 || rect.height == 0) { return; } final Image bufferImage = new Image(getDisplay(), Math.max(1, rect.width), Math.max(1, rect.height)); final GC gc = new GC(bufferImage); gc.setForeground(getForeground()); gc.setBackground(getBackground()); gc.fillRectangle(rect); final Point extent = getTotalSize(image.getBounds().width, image.getBounds().height); final int xImage = (rect.width - image.getBounds().width) / 2; final int yImage = (rect.height - extent.y) / 2; gc.drawImage(image, xImage, yImage); gc.setFont(font); final int xText = (rect.width - textSize.x) / 2; final int yText = yImage + image.getBounds().height + GAP - textSize.y / 2; gc.drawString(text, xText, yText); if (animationStep != 0) { final float zoom = 1f + animationStep * (Math.max(extent.x, extent.y) - Math.max(image.getBounds().width, image.getBounds().height)) / MAX_NUMBER_OF_STEPS / 100f; final int newSizeX = (int) (image.getBounds().width * zoom); final int newSizeY = (int) (image.getBounds().height * zoom); gc.setAntialias(SWT.ON); gc.setInterpolation(SWT.HIGH); gc.setAlpha(255 - 255 / MAX_NUMBER_OF_STEPS * animationStep); final Point extentZoomedImage = getTotalSize(newSizeX, newSizeY); final int xZoomedImage = (rect.width - newSizeX) / 2; final int yZoomedImage = (rect.height - extentZoomedImage.y) / 2; gc.drawImage(image, 0, 0, image.getBounds().width, image.getBounds().height, xZoomedImage, yZoomedImage, (int) (image.getBounds().width * zoom), (int) (image.getBounds().height * zoom)); } gc.dispose(); event.gc.drawImage(bufferImage, 0, 0); bufferImage.dispose(); }
Example 16
Source File: TextPiece.java From nebula with Eclipse Public License 2.0 | 4 votes |
public void paint(final GC gc, final int x, final int y) { Font oldFont = gc.getFont(); Color oldForeground = gc.getForeground(); Color oldBackground = gc.getBackground(); final int width = getSize().x; final int align = style.getAlignment(); try { boolean transparent = initGC(gc); FontMetrics fm = gc.getFontMetrics(); int lineHeight = fm.getHeight(); boolean strikeout = style.getStrikeout(); boolean underline = style.getUnderline(); int lineThickness = Math.max(1, fm.getDescent() / 3); int strikeoutOffset = fm.getLeading() + fm.getAscent() / 2; int underlineOffset = ascent + lineThickness; for (int i = 0; i < lines.length; i++) { String line = lines[i]; int lineWidth = gc.stringExtent(line).x; int offset = getHorzAlignmentOffset(align, lineWidth, width); gc.drawString(lines[i], x + offset, y + lineHeight * i, transparent); if (strikeout || underline) { Color saveBackground = gc.getBackground(); gc.setBackground(gc.getForeground()); if (strikeout) gc.fillRectangle(x + offset, y + lineHeight * i + strikeoutOffset, lineWidth, lineThickness); if (underline) gc.fillRectangle(x + offset, y + lineHeight * i + underlineOffset, lineWidth, lineThickness); gc.setBackground(saveBackground); } } } finally { restoreGC(gc, oldFont, oldForeground, oldBackground); } }
Example 17
Source File: GlobalActions.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
protected void printPatient(final Patient patient){ PrinterData pd = getPrinterData("Etiketten"); //$NON-NLS-1$ if (pd != null) { // 25.01.2010 patch tschaller: page orientation of printer // driver is not handled correctly (we always get porttrait // even when the printer settings have landscape stored) Integer iOrientation = -1; String sOrientation = CoreHub.localCfg.get("Drucker/Etiketten/Ausrichtung", null); //$NON-NLS-1$ try { iOrientation = Integer.parseInt(sOrientation); } catch (NumberFormatException ex) {} if (iOrientation != -1) pd.orientation = iOrientation; Printer prn = new Printer(pd); if (prn.startJob(Messages.GlobalActions_PrintLabelJobName) == true) { //$NON-NLS-1$ GC gc = new GC(prn); int y = 0; prn.startPage(); gc.drawString(Messages.GlobalActions_PatientIDLabelText + patient.getPatCode(), 0, 0); //$NON-NLS-1$ FontMetrics fmt = gc.getFontMetrics(); y += fmt.getHeight(); String pers = patient.getPersonalia(); gc.drawString(pers, 0, y); y += fmt.getHeight(); gc.drawString(patient.getAnschrift().getEtikette(false, false), 0, y); y += fmt.getHeight(); StringBuilder tel = new StringBuilder(); tel.append(Messages.GlobalActions_PhoneHomeLabelText) .append(patient.get("Telefon1")) //$NON-NLS-1$ //$NON-NLS-2$ .append(Messages.GlobalActions_PhoneWorkLabelText) .append(patient.get("Telefon2")) //$NON-NLS-1$ //$NON-NLS-2$ .append(Messages.GlobalActions_PhoneMobileLabelText) .append(patient.get("Natel")); //$NON-NLS-1$ //$NON-NLS-2$ gc.drawString(tel.toString(), 0, y); gc.dispose(); prn.endPage(); prn.endJob(); prn.dispose(); } else { MessageDialog.openError(mainWindow.getShell(), Messages.GlobalActions_PrinterErrorTitle, Messages.GlobalActions_PrinterErrorMessage); //$NON-NLS-1$ //$NON-NLS-2$ } } }
Example 18
Source File: JavaScriptViewer.java From birt with Eclipse Public License 1.0 | 4 votes |
private final void showException( GC g2d, Exception ex ) { String sWrappedException = ex.getClass( ).getName( ); Throwable th = ex; while ( ex.getCause( ) != null ) { ex = (Exception) ex.getCause( ); } String sException = ex.getClass( ).getName( ); if ( sWrappedException.equals( sException ) ) { sWrappedException = null; } String sMessage = null; if ( th instanceof BirtException ) { sMessage = ( (BirtException) th ).getLocalizedMessage( ); } else { sMessage = ex.getMessage( ); } if ( sMessage == null ) { sMessage = "<null>";//$NON-NLS-1$ } StackTraceElement[] stea = ex.getStackTrace( ); Point d = this.getSize( ); Device dv = Display.getCurrent( ); Font fo = new Font( dv, "Courier", SWT.BOLD, 16 );//$NON-NLS-1$ g2d.setFont( fo ); FontMetrics fm = g2d.getFontMetrics( ); g2d.setBackground( dv.getSystemColor( SWT.COLOR_WHITE ) ); g2d.fillRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawRectangle( 20, 20, d.x - 40, d.y - 40 ); g2d.setClipping( 20, 20, d.x - 40, d.y - 40 ); int x = 25, y = 20 + fm.getHeight( ); g2d.drawString( "Exception:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Exception:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sException, x, y ); x = 25; y += fm.getHeight( ); if ( sWrappedException != null ) { g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); g2d.drawString( "Wrapped In:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Wrapped In:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_RED ) ); g2d.drawString( sWrappedException, x, y ); x = 25; y += fm.getHeight( ); } g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Message:", x, y );//$NON-NLS-1$ x += g2d.textExtent( "Message:" ).x + 5;//$NON-NLS-1$ g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLUE ) ); g2d.drawString( sMessage, x, y ); x = 25; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_BLACK ) ); y += 10; g2d.drawString( "Trace:", x, y );//$NON-NLS-1$ x = 40; y += fm.getHeight( ); g2d.setForeground( dv.getSystemColor( SWT.COLOR_DARK_GREEN ) ); for ( int i = 0; i < stea.length; i++ ) { g2d.drawString( stea[i].getClassName( ) + ":"//$NON-NLS-1$ + stea[i].getMethodName( ) + "(...):"//$NON-NLS-1$ + stea[i].getLineNumber( ), x, y ); x = 40; y += fm.getHeight( ); } fo.dispose( ); }
Example 19
Source File: GlobalActions.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
protected void printAdr(final Kontakt k){ // 25.01.2010 patch tschaller: there was always the printer selection // dialog. With printEtikette it wasn't so I copied the hardcoded string // from there // PrinterData pd = // getPrinterData(Messages.getString("GlobalActions.printersticker")); // //$NON-NLS-1$ PrinterData pd = getPrinterData("Etiketten"); //$NON-NLS-1$ if (pd != null) { // 25.01.2010 patch tschaller: page orientation of printer driver is // not handled correctly (we always get porttrait even when the // printer settings have landscape stored) Integer iOrientation = -1; String sOrientation = CoreHub.localCfg.get("Drucker/Etiketten/Ausrichtung", null); //$NON-NLS-1$ try { iOrientation = Integer.parseInt(sOrientation); } catch (NumberFormatException ex) {} if (iOrientation != -1) pd.orientation = iOrientation; Printer prn = new Printer(pd); if (prn.startJob("Etikette drucken") == true) { //$NON-NLS-1$ GC gc = new GC(prn); int y = 0; prn.startPage(); FontMetrics fmt = gc.getFontMetrics(); String pers = k.getPostAnschrift(true); String[] lines = pers.split("\n"); //$NON-NLS-1$ for (String line : lines) { gc.drawString(line, 0, y); y += fmt.getHeight(); } gc.dispose(); prn.endPage(); prn.endJob(); prn.dispose(); } else { MessageDialog.openError(mainWindow.getShell(), Messages.GlobalActions_PrinterErrorTitle, Messages.GlobalActions_PrinterErrorMessage); //$NON-NLS-1$ //$NON-NLS-2$ } } }
Example 20
Source File: TextCellRenderer.java From tmxeditor8 with GNU General Public License v2.0 | 2 votes |
/** * Draw single line String. * * @param gc gc * @param rect drawing area * @param s String to draw */ private void drawCellStringSingle(GC gc, Rectangle rect, String s) { gc.drawString(s, rect.x, rect.y + 10, true); }