private void setHoverLocation( org.eclipse.swt.widgets.Shell shell, org.eclipse.swt.graphics.Point position) { org.eclipse.swt.graphics.Rectangle displayBounds = shell.getDisplay().getBounds(); org.eclipse.swt.graphics.Rectangle shellBounds = shell.getBounds(); shellBounds.x = Math.max(Math.min(position.x, displayBounds.width - shellBounds.width), 0); shellBounds.y = Math.max(Math.min(position.y + 16, displayBounds.height - shellBounds.height), 0); shell.setBounds(shellBounds); }
int XPointerMotion(int w, int client_data, int call_data, int continue_to_dispatch) { int result = super.XPointerMotion(w, client_data, call_data, continue_to_dispatch); if (result != 0) return result; XMotionEvent xEvent = new XMotionEvent(); OS.memmove(xEvent, call_data, XMotionEvent.sizeof); if (!dragging || (xEvent.state & OS.Button1Mask) == 0) return result; short[] x_root = new short[1], y_root = new short[1]; OS.XtTranslateCoords(handle, (short) 0, (short) 0, x_root, y_root); int eventX = xEvent.x_root - x_root[0], eventY = xEvent.y_root - y_root[0]; int[] argList1 = { OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0 }; OS.XtGetValues(handle, argList1, argList1.length / 2); int border = argList1[9], x = ((short) argList1[1]) - border, y = ((short) argList1[3]) - border; int width = argList1[5] + (border * 2), height = argList1[7] + (border * 2); int[] argList2 = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0}; OS.XtGetValues(parent.handle, argList2, argList2.length / 2); int parentBorder = argList2[5]; int parentWidth = argList2[1] + (parentBorder * 2); int parentHeight = argList2[3] + (parentBorder * 2); int newX = lastX, newY = lastY; if ((style & SWT.VERTICAL) != 0) { newX = Math.min(Math.max(0, eventX + x - startX - parentBorder), parentWidth - width); } else { newY = Math.min(Math.max(0, eventY + y - startY - parentBorder), parentHeight - height); } if (newX == lastX && newY == lastY) return result; drawBand(lastX, lastY, width, height); Event event = new Event(); event.time = xEvent.time; event.x = newX; event.y = newY; event.width = width; event.height = height; if ((style & SWT.SMOOTH) == 0) { event.detail = SWT.DRAG; } sendEvent(SWT.Selection, event); if (isDisposed()) return result; if (event.doit) { lastX = event.x; lastY = event.y; } parent.update(true); drawBand(lastX, lastY, width, height); if ((style & SWT.SMOOTH) != 0) { setBounds(lastX, lastY, width, height); // widget could be disposed at this point } return result; }
private String rgbToHex(int value) { value = Math.max(0, value); value = Math.min(value, 255); String hex = Integer.toHexString(value).toUpperCase(); if (hex.length() == 1) hex = '0' + hex; return hex; }
/** * Sets the size of the receiver's thumb relative to the difference between its maximum and * minimum values. This new value will be ignored if it is less than one, and will be clamped if * it exceeds the receiver's current range. * * @param value the new thumb value, which must be at least one and not larger than the size of * the current range * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> */ public void setThumb(int value) { checkWidget(); if (value < 1) return; value = Math.min(value, maximum - minimum); this.thumb = value; updateBar(getSelection(), minimum, maximum, value); }
void updateBar(int selection, int minimum, int maximum, int thumb) { NSScroller widget = (NSScroller) view; selection = Math.max(minimum, Math.min(maximum - thumb, selection)); float fraction = minimum == maximum ? 1 : (float) (selection - minimum) / (maximum - thumb - minimum); float knob = minimum == maximum ? 1 : (float) (thumb - minimum) / (maximum - minimum); widget.setFloatValue(fraction, knob); }
/** * Sets the minimum value. If this value is negative or greater than or equal to the maximum, the * value is ignored. If necessary, first the thumb and then the selection are adjusted to fit * within the new range. * * @param value the new minimum * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> */ public void setMinimum(int value) { checkWidget(); if (value < 0) return; if (value >= maximum) return; if (maximum - value < thumb) { thumb = maximum - value; } int selection = Math.min(maximum - thumb, Math.max(getSelection(), value)); this.minimum = value; updateBar(selection, value, maximum, thumb); }
/** * Sets the maximum. If this value is negative or less than or equal to the minimum, the value is * ignored. If necessary, first the thumb and then the selection are adjusted to fit within the * new range. * * @param value the new maximum, which must be greater than the current minimum * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> */ public void setMaximum(int value) { checkWidget(); if (value < 0) return; if (value <= minimum) return; if (value - minimum < thumb) { thumb = value - minimum; } int selection = Math.max(minimum, Math.min(getSelection(), value - thumb)); this.maximum = value; updateBar(selection, minimum, value, thumb); }
/** * Sets the receiver's selection, minimum value, maximum value, thumb, increment and page * increment all at once. * * <p>Note: This is similar to setting the values individually using the appropriate methods, but * may be implemented in a more efficient fashion on some platforms. * * @param selection the new selection value * @param minimum the new minimum value * @param maximum the new maximum value * @param thumb the new thumb value * @param increment the new increment value * @param pageIncrement the new pageIncrement value * @exception SWTException * <ul> * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver * </ul> */ public void setValues( int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) { checkWidget(); if (minimum < 0) return; if (maximum < 0) return; if (thumb < 1) return; if (increment < 1) return; if (pageIncrement < 1) return; thumb = Math.min(thumb, maximum - minimum); this.increment = increment; this.pageIncrement = pageIncrement; updateBar(selection, minimum, maximum, thumb); }
/** * 通过将检索结果结合中的记录分页加载的方法,实现控制检索结果记录的分页显示与快速加载 * * @param facttable 显示检索结果的GUI表格对象 * @param pagenum 显示在表格对象中的检索结果页码,从1开始计算 */ private void openCurrentTable(final int pagenum) { table.clearAll(); // 清空表格所有项目中的数据 // 数据记录在检索结果结合中的下标开始值 final int recordstart = (pagenum - 1) * pageSize; // 当前表格能显示的最后一条记录在检索结果集合中的索引号 int end = recordstart + pageSize; // 若表格可显示的记录大于检索结果记录的总数,就只显示到最后一条检索结果记录 final int recordend = Math.min(end, stationData.getRowCount()); // 显示的最后一条记录在检索结果集合中的索引号 // 当前页面显示的检索结果记录数 final int currentdispnum = recordend - recordstart; // 根据当前的页码,从检索结果集合中加载相应的数据到表的item域中 tableViewer.setInput(stationData.getRow(recordstart, recordstart + currentdispnum)); // 自动输入数据 tableViewer.refresh(); // 刷新表格false }
Point computeSize(GC gc) { int width = 0, height = 0; if ((style & SWT.SEPARATOR) != 0) { if ((parent.style & SWT.HORIZONTAL) != 0) { width = getWidth(); height = DEFAULT_HEIGHT; } else { width = DEFAULT_WIDTH; height = getWidth(); } if (control != null) { height = Math.max(height, control.getMinimumHeight()); } return new Point(width, height); } int[] argList = { OS.XmNmarginHeight, 0, OS.XmNmarginWidth, 0, OS.XmNshadowThickness, 0, }; OS.XtGetValues(handle, argList, argList.length / 2); int marginHeight = argList[1], marginWidth = argList[3]; int shadowThickness = argList[5]; if ((parent.style & SWT.FLAT) != 0) { shadowThickness = Math.min(2, display.buttonShadowThickness); } if (text.length() != 0 || image != null) { int textWidth = 0, textHeight = 0; if (text.length() != 0) { int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC; Point textExtent = gc.textExtent(text, flags); textWidth = textExtent.x; textHeight = textExtent.y; } int imageWidth = 0, imageHeight = 0; if (image != null) { Rectangle rect = image.getBounds(); imageWidth = rect.width; imageHeight = rect.height; } if ((parent.style & SWT.RIGHT) != 0) { width = imageWidth + textWidth; height = Math.max(imageHeight, textHeight); if (imageWidth != 0 && textWidth != 0) width += 2; } else { height = imageHeight + textHeight; if (imageHeight != 0 && textHeight != 0) height += 2; width = Math.max(imageWidth, textWidth); } } else { width = DEFAULT_WIDTH; height = DEFAULT_HEIGHT; } if ((style & SWT.DROP_DOWN) != 0) { width += 12; } if (width != 0) { width += (marginWidth + shadowThickness) * 2 + 2; } else { width = DEFAULT_WIDTH; } if (height != 0) { height += (marginHeight + shadowThickness) * 2 + 2; } else { height = DEFAULT_HEIGHT; } return new Point(width, height); }
int XmNexposureCallback(int w, int client_data, int call_data) { if ((style & SWT.SEPARATOR) != 0) return 0; int xDisplay = OS.XtDisplay(handle); if (xDisplay == 0) return 0; int xWindow = OS.XtWindow(handle); if (xWindow == 0) return 0; int[] argList = { OS.XmNcolormap, 0, OS.XmNwidth, 0, OS.XmNheight, 0, }; OS.XtGetValues(handle, argList, argList.length / 2); int width = argList[3], height = argList[5]; Image currentImage = image; boolean enabled = getEnabled(); if ((parent.style & SWT.FLAT) != 0) { boolean hasCursor = hasCursor(); /* Set the shadow thickness */ int thickness = 0; if (set || (hasCursor && enabled)) { thickness = Math.min(2, display.buttonShadowThickness); } argList = new int[] {OS.XmNshadowThickness, thickness}; OS.XtSetValues(handle, argList, argList.length / 2); /* Determine if hot image should be used */ if (enabled && hasCursor && hotImage != null) { currentImage = hotImage; } } GCData data = new GCData(); data.device = display; data.display = xDisplay; data.drawable = xWindow; data.font = parent.font; data.colormap = argList[1]; int xGC = OS.XCreateGC(xDisplay, xWindow, 0, null); if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES); GC gc = GC.motif_new(xGC, data); XmAnyCallbackStruct cb = new XmAnyCallbackStruct(); OS.memmove(cb, call_data, XmAnyCallbackStruct.sizeof); if (cb.event != 0) { XExposeEvent xEvent = new XExposeEvent(); OS.memmove(xEvent, cb.event, XExposeEvent.sizeof); Rectangle rect = new Rectangle(xEvent.x, xEvent.y, xEvent.width, xEvent.height); gc.setClipping(rect); } if (!enabled) { currentImage = disabledImage; if (currentImage == null && image != null) { currentImage = new Image(display, image, SWT.IMAGE_DISABLE); } Color disabledColor = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW); gc.setForeground(disabledColor); } else { gc.setForeground(parent.getForeground()); } gc.setBackground(parent.getBackground()); int textX = 0, textY = 0, textWidth = 0, textHeight = 0; if (text.length() != 0) { int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC; Point textExtent = gc.textExtent(text, flags); textWidth = textExtent.x; textHeight = textExtent.y; } int imageX = 0, imageY = 0, imageWidth = 0, imageHeight = 0; if (currentImage != null) { Rectangle imageBounds = currentImage.getBounds(); imageWidth = imageBounds.width; imageHeight = imageBounds.height; } int spacing = 0; if (textWidth != 0 && imageWidth != 0) spacing = 2; if ((parent.style & SWT.RIGHT) != 0) { imageX = (width - imageWidth - textWidth - spacing) / 2; imageY = (height - imageHeight) / 2; textX = spacing + imageX + imageWidth; textY = (height - textHeight) / 2; } else { imageX = (width - imageWidth) / 2; imageY = (height - imageHeight - textHeight - spacing) / 2; textX = (width - textWidth) / 2; textY = spacing + imageY + imageHeight; } if ((style & SWT.DROP_DOWN) != 0) { textX -= 6; imageX -= 6; } if (textWidth > 0) { int flags = SWT.DRAW_DELIMITER | SWT.DRAW_TAB | SWT.DRAW_MNEMONIC | SWT.DRAW_TRANSPARENT; gc.drawText(text, textX, textY, flags); } if (imageWidth > 0) gc.drawImage(currentImage, imageX, imageY); if ((style & SWT.DROP_DOWN) != 0) { int startX = width - 12, startY = (height - 2) / 2; int[] arrow = {startX, startY, startX + 3, startY + 3, startX + 6, startY}; gc.setBackground(parent.getForeground()); gc.fillPolygon(arrow); gc.drawPolygon(arrow); } gc.dispose(); OS.XFreeGC(xDisplay, xGC); if (!enabled && disabledImage == null) { if (currentImage != null) currentImage.dispose(); } return 0; }
int XKeyPress(int w, int client_data, int call_data, int continue_to_dispatch) { int result = super.XKeyPress(w, client_data, call_data, continue_to_dispatch); if (result != 0) return result; XKeyEvent xEvent = new XKeyEvent(); OS.memmove(xEvent, call_data, XKeyEvent.sizeof); byte[] buffer = new byte[1]; int[] keysym = new int[1]; OS.XLookupString(xEvent, buffer, buffer.length, keysym, null); switch (keysym[0]) { case OS.XK_Left: case OS.XK_Right: case OS.XK_Up: case OS.XK_Down: int xChange = 0, yChange = 0; int stepSize = PAGE_INCREMENT; if ((xEvent.state & OS.ControlMask) != 0) stepSize = INCREMENT; if ((style & SWT.VERTICAL) != 0) { if (keysym[0] == OS.XK_Up || keysym[0] == OS.XK_Down) break; xChange = keysym[0] == OS.XK_Left ? -stepSize : stepSize; } else { if (keysym[0] == OS.XK_Left || keysym[0] == OS.XK_Right) break; yChange = keysym[0] == OS.XK_Up ? -stepSize : stepSize; } int[] argList1 = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0}; OS.XtGetValues(handle, argList1, argList1.length / 2); int border = argList1[5]; int width = argList1[1] + (border * 2), height = argList1[3] + (border * 2); int[] argList2 = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0}; OS.XtGetValues(parent.handle, argList2, argList2.length / 2); int parentBorder = argList2[5]; int parentWidth = argList2[1] + (parentBorder * 2); int parentHeight = argList2[3] + (parentBorder * 2); int newX = lastX, newY = lastY; if ((style & SWT.VERTICAL) != 0) { newX = Math.min(Math.max(0, lastX + xChange - parentBorder - startX), parentWidth - width); } else { newY = Math.min(Math.max(0, lastY + yChange - parentBorder - startY), parentHeight - height); } if (newX == lastX && newY == lastY) return result; /* Ensure that the pointer image does not change */ int xDisplay = display.xDisplay; int xWindow = OS.XtWindow(parent.handle); int ptrGrabResult = OS.XGrabPointer( xDisplay, xWindow, 1, OS.None, OS.GrabModeAsync, OS.GrabModeAsync, OS.None, cursor, OS.CurrentTime); Event event = new Event(); event.time = xEvent.time; event.x = newX; event.y = newY; event.width = width; event.height = height; sendEvent(SWT.Selection, event); if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer(xDisplay, OS.CurrentTime); if (isDisposed()) break; if (event.doit) { lastX = event.x; lastY = event.y; if ((style & SWT.SMOOTH) != 0) { setBounds(event.x, event.y, width, height); if (isDisposed()) break; } int cursorX = event.x, cursorY = event.y; if ((style & SWT.VERTICAL) != 0) { cursorY += height / 2; } else { cursorX += width / 2; } OS.XWarpPointer(xDisplay, OS.None, xWindow, 0, 0, 0, 0, cursorX, cursorY); } break; } return result; }
void keyDown(Event event) { if (row == null) return; switch (event.character) { case SWT.CR: notifyListeners(SWT.DefaultSelection, new Event()); return; } int rowIndex = table.indexOf(row); int columnIndex = column == null ? 0 : table.indexOf(column); switch (event.keyCode) { case SWT.ARROW_UP: setRowColumn(Math.max(0, rowIndex - 1), columnIndex, true); break; case SWT.ARROW_DOWN: setRowColumn(Math.min(rowIndex + 1, table.getItemCount() - 1), columnIndex, true); break; case SWT.ARROW_LEFT: case SWT.ARROW_RIGHT: { int columnCount = table.getColumnCount(); if (columnCount == 0) break; int[] order = table.getColumnOrder(); int index = 0; while (index < order.length) { if (order[index] == columnIndex) break; index++; } if (index == order.length) index = 0; int leadKey = (getStyle() & SWT.RIGHT_TO_LEFT) != 0 ? SWT.ARROW_RIGHT : SWT.ARROW_LEFT; if (event.keyCode == leadKey) { setRowColumn(rowIndex, order[Math.max(0, index - 1)], true); } else { setRowColumn(rowIndex, order[Math.min(columnCount - 1, index + 1)], true); } break; } case SWT.HOME: setRowColumn(0, columnIndex, true); break; case SWT.END: { int i = table.getItemCount() - 1; setRowColumn(i, columnIndex, true); break; } case SWT.PAGE_UP: { int index = table.getTopIndex(); if (index == rowIndex) { Rectangle rect = table.getClientArea(); TableItem item = table.getItem(index); Rectangle itemRect = item.getBounds(0); rect.height -= itemRect.y; int height = table.getItemHeight(); int page = Math.max(1, rect.height / height); index = Math.max(0, index - page + 1); } setRowColumn(index, columnIndex, true); break; } case SWT.PAGE_DOWN: { int index = table.getTopIndex(); Rectangle rect = table.getClientArea(); TableItem item = table.getItem(index); Rectangle itemRect = item.getBounds(0); rect.height -= itemRect.y; int height = table.getItemHeight(); int page = Math.max(1, rect.height / height); int end = table.getItemCount() - 1; index = Math.min(end, index + page - 1); if (index == rowIndex) { index = Math.min(end, index + page - 1); } setRowColumn(index, columnIndex, true); break; } } }
public Shell open(Display display) { clipboard = new Clipboard(display); shell = new Shell(display); shell.setText("SWT Clipboard"); shell.setLayout(new FillLayout()); ScrolledComposite sc = new ScrolledComposite(shell, SWT.H_SCROLL | SWT.V_SCROLL); Composite parent = new Composite(sc, SWT.NONE); sc.setContent(parent); parent.setLayout(new GridLayout(2, true)); Group copyGroup = new Group(parent, SWT.NONE); copyGroup.setText("Copy From:"); GridData data = new GridData(GridData.FILL_BOTH); copyGroup.setLayoutData(data); copyGroup.setLayout(new GridLayout(3, false)); Group pasteGroup = new Group(parent, SWT.NONE); pasteGroup.setText("Paste To:"); data = new GridData(GridData.FILL_BOTH); pasteGroup.setLayoutData(data); pasteGroup.setLayout(new GridLayout(3, false)); Group controlGroup = new Group(parent, SWT.NONE); controlGroup.setText("Control API:"); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; controlGroup.setLayoutData(data); controlGroup.setLayout(new GridLayout(5, false)); Group typesGroup = new Group(parent, SWT.NONE); typesGroup.setText("Available Types"); data = new GridData(GridData.FILL_BOTH); data.horizontalSpan = 2; typesGroup.setLayoutData(data); typesGroup.setLayout(new GridLayout(2, false)); status = new Label(parent, SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); data.horizontalSpan = 2; data.heightHint = 60; status.setLayoutData(data); createTextTransfer(copyGroup, pasteGroup); createRTFTransfer(copyGroup, pasteGroup); createHTMLTransfer(copyGroup, pasteGroup); createFileTransfer(copyGroup, pasteGroup); createMyTransfer(copyGroup, pasteGroup); createControlTransfer(controlGroup); createAvailableTypes(typesGroup); sc.setMinSize(parent.computeSize(SWT.DEFAULT, SWT.DEFAULT)); sc.setExpandHorizontal(true); sc.setExpandVertical(true); Point size = shell.computeSize(SWT.DEFAULT, SWT.DEFAULT); Rectangle monitorArea = shell.getMonitor().getClientArea(); shell.setSize( Math.min(size.x, monitorArea.width - 20), Math.min(size.y, monitorArea.height - 20)); shell.open(); return shell; }
void drawInteriorWithFrame_inView( long /*int*/ id, long /*int*/ sel, NSRect cellRect, long /*int*/ view) { /* * Feature in Cocoa. When the last column in a tree does not reach the * rightmost edge of the tree view, the cell that draws the rightmost- * column's header is also invoked to draw the header space between its * right edge and the tree's right edge. If this case is detected then * nothing should be drawn. */ int columnIndex = parent.indexOf(nsColumn); NSRect headerRect = parent.headerView.headerRectOfColumn(columnIndex); if (headerRect.x != cellRect.x || headerRect.width != cellRect.width) return; NSGraphicsContext context = NSGraphicsContext.currentContext(); context.saveGraphicsState(); int contentWidth = 0; NSSize stringSize = null, imageSize = null; NSAttributedString attrString = null; NSTableHeaderCell headerCell = nsColumn.headerCell(); if (displayText != null) { Font font = Font.cocoa_new(display, headerCell.font()); attrString = parent.createString( displayText, font, null, SWT.LEFT, false, (parent.state & DISABLED) == 0, false); stringSize = attrString.size(); contentWidth += Math.ceil(stringSize.width); if (image != null) contentWidth += MARGIN; /* space between image and text */ } if (image != null) { imageSize = image.handle.size(); contentWidth += Math.ceil(imageSize.width); } if (parent.sortColumn == this && parent.sortDirection != SWT.NONE) { boolean ascending = parent.sortDirection == SWT.UP; headerCell.drawSortIndicatorWithFrame(cellRect, new NSView(view), ascending, 0); /* remove the arrow's space from the available drawing width */ NSRect sortRect = headerCell.sortIndicatorRectForBounds(cellRect); cellRect.width = Math.max(0, sortRect.x - cellRect.x); } int drawX = 0; if ((style & SWT.CENTER) != 0) { drawX = (int) (cellRect.x + Math.max(MARGIN, ((cellRect.width - contentWidth) / 2))); } else if ((style & SWT.RIGHT) != 0) { drawX = (int) (cellRect.x + Math.max(MARGIN, cellRect.width - contentWidth - MARGIN)); } else { drawX = (int) cellRect.x + MARGIN; } if (image != null) { NSRect destRect = new NSRect(); destRect.x = drawX; destRect.y = cellRect.y; destRect.width = Math.min(imageSize.width, cellRect.width - 2 * MARGIN); destRect.height = Math.min(imageSize.height, cellRect.height); boolean isFlipped = new NSView(view).isFlipped(); if (isFlipped) { context.saveGraphicsState(); NSAffineTransform transform = NSAffineTransform.transform(); transform.scaleXBy(1, -1); transform.translateXBy(0, -(destRect.height + 2 * destRect.y)); transform.concat(); } NSRect sourceRect = new NSRect(); sourceRect.width = destRect.width; sourceRect.height = destRect.height; image.handle.drawInRect(destRect, sourceRect, OS.NSCompositeSourceOver, 1f); if (isFlipped) context.restoreGraphicsState(); drawX += destRect.width; } if (displayText != null && displayText.length() > 0) { if (image != null) drawX += MARGIN; /* space between image and text */ NSRect destRect = new NSRect(); destRect.x = drawX; destRect.y = cellRect.y; destRect.width = Math.min(stringSize.width, cellRect.x + cellRect.width - MARGIN - drawX); destRect.height = Math.min(stringSize.height, cellRect.height); attrString.drawInRect(destRect); } if (attrString != null) attrString.release(); context.restoreGraphicsState(); }