org.eclipse.swt.graphics.Rectangle Java Examples
The following examples show how to use
org.eclipse.swt.graphics.Rectangle.
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: BackgroundImagePainter.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
@Override public void paintCell(LayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) { // Save GC settings Color originalBackground = gc.getBackground(); Color originalForeground = gc.getForeground(); gc.setBackgroundPattern(new Pattern(Display.getCurrent(), bgImage)); gc.fillRectangle(rectangle); gc.setBackgroundPattern(null); if (isNotNull(separatorColor)) { gc.setForeground(separatorColor); gc.drawLine(rectangle.x - 1, rectangle.y, rectangle.x - 1, rectangle.y + rectangle.height); gc.drawLine(rectangle.x - 1 + rectangle.width, rectangle.y, rectangle.x - 1 + rectangle.width, rectangle.y + rectangle.height); } // Restore original GC settings gc.setBackground(originalBackground); gc.setForeground(originalForeground); // Draw interior Rectangle interiorBounds = new Rectangle(rectangle.x + 2, rectangle.y + 2, rectangle.width - 4, rectangle.height - 4); super.paintCell(cell, gc, interiorBounds, configRegistry); }
Example #2
Source File: DatePickerCombo.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private void popupEvent(Event event){ switch (event.type) { case SWT.Paint: // draw black rectangle around dp Rectangle listRect = dp.getBounds(); Color black = getDisplay().getSystemColor(SWT.COLOR_BLACK); event.gc.setForeground(black); event.gc.drawRectangle(0, 0, listRect.width + 1, listRect.height + 1); break; case SWT.Close: event.doit = false; dropDown(false); break; case SWT.Deactivate: dropDown(false); break; } }
Example #3
Source File: PingGraphic.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
@Override public void initialize(Canvas canvas) { super.initialize(canvas); drawCanvas.addPaintListener(new PaintListener() { @Override public void paintControl(PaintEvent e) { if (bufferImage != null && !bufferImage.isDisposed()) { Rectangle bounds = bufferImage.getBounds(); if (bounds.width >= ( e.width + e.x ) && bounds.height >= ( e.height + e.y )) { e.gc.drawImage(bufferImage, e.x, e.y, e.width, e.height, e.x, e.y, e.width, e.height); } } } }); drawCanvas.addListener(SWT.Resize, new Listener() { @Override public void handleEvent(Event event) { drawChart(true); } }); }
Example #4
Source File: vboWithRGBA.java From ldparteditor with MIT License | 6 votes |
@Override public void drawScene(float mouseX, float mouseY) { final GLCanvas canvas = cp.getCanvas(); if (!canvas.isCurrent()) { canvas.setCurrent(); GL.setCapabilities(cp.getCapabilities()); } GL11.glColorMask(true, true, true, true); GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT | GL11.GL_STENCIL_BUFFER_BIT); Rectangle bounds = cp.getBounds(); GL11.glViewport(0, 0, bounds.width, bounds.height); shaderProgram.use(); GL30.glBindVertexArray(VAO); GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 3); GL30.glBindVertexArray(0); canvas.swapBuffers(); }
Example #5
Source File: Star.java From nebula with Eclipse Public License 2.0 | 6 votes |
void draw(final GC gc, final int x, final int y) { Image image; if (!parent.isEnabled()) { image = defaultImage; } else { if (marked) { if (hover) { image = selectedHoverImage; } else { image = selectedImage; } } else { if (hover) { image = hoverImage; } else { image = defaultImage; } } } gc.drawImage(image, x, y); bounds = new Rectangle(x, y, image.getBounds().width, image.getBounds().height); }
Example #6
Source File: SWTBotSash.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Drag the sash from its middle point to the destination point * * @param dst * the destination point relative to the parent */ public void drag(final Point dst) { Rectangle bounds = getBounds(); int x = bounds.width / 2; int y = bounds.height / 2; notify(SWT.MouseEnter); notify(SWT.Activate); notify(SWT.Selection, createSelectionEvent(bounds.x + x, bounds.y + y, SWT.NONE)); notify(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.NONE, 1)); notify(SWT.DragDetect, createMouseEvent(x, y, 0, SWT.NONE, 0)); notify(SWT.Move); notify(SWT.Selection, createSelectionEvent(dst.x, dst.y, SWT.NONE)); notify(SWT.MouseMove, createMouseEvent(x, y, 0, SWT.BUTTON1, 0)); notify(SWT.Selection, createSelectionEvent(dst.x, dst.y, SWT.BUTTON1)); notify(SWT.MouseUp, createMouseEvent(x, y, 1, SWT.NONE, 1)); notify(SWT.MouseExit); }
Example #7
Source File: CompositeMinSize.java From BiglyBT with GNU General Public License v2.0 | 6 votes |
protected Point betterComputeSize(Composite c, Point size, int wHint, int hHint, boolean changed) { if (c.getChildren().length == 0 && (size.x == 64 || size.y == 64)) { Object ld = c.getLayoutData(); if (ld instanceof FormData) { FormData fd = (FormData) ld; if (fd.width != 0 && fd.height != 0) { Rectangle trim = c.computeTrim (0, 0, fd.width, fd.height); return new Point(trim.width, trim.height); } } return new Point(1, 1); } if (size.x == 0 || size.y == 0) { return size; } if (minWidth > 0 && size.x < minWidth) { size.x = minWidth; } if (minHeight > 0 && size.y < minHeight) { size.y = minHeight; } return size; }
Example #8
Source File: XAxisDynamicRenderer.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override public Rectangle resize ( final ResourceManager resourceManager, final Rectangle clientRectangle ) { final int height = this.height >= 0 ? this.height : calcHeight ( resourceManager ); if ( this.bottom ) { this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y + clientRectangle.height - height, clientRectangle.width, height ); return new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, clientRectangle.height - height ); } else { this.rect = new Rectangle ( clientRectangle.x, clientRectangle.y, clientRectangle.width, height ); return new Rectangle ( clientRectangle.x, clientRectangle.y + height, clientRectangle.width, clientRectangle.height - height ); } }
Example #9
Source File: AdditionalInfoController.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
protected void computeInformation() { if (fProposal instanceof ICompletionProposalExtension3) { setCustomInformationControlCreator(((ICompletionProposalExtension3) fProposal) .getInformationControlCreator()); } else { setCustomInformationControlCreator(null); } // compute subject area Point size = fProposalTable.getShell().getSize(); // set information & subject area setInformation(fInformation, new Rectangle(0, 0, size.x, size.y)); }
Example #10
Source File: GridColumn.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Returns the bounds of this column's header. * * @return bounds of the column header */ Rectangle getBounds() { Rectangle bounds = new Rectangle(0, 0, 0, 0); if (!isVisible()) { return bounds; } Point loc = parent.getOrigin(this, null); bounds.x = loc.x; bounds.y = loc.y; bounds.width = getWidth(); bounds.height = parent.getHeaderHeight(); if (getColumnGroup() != null) { bounds.height -= parent.getGroupHeaderHeight(); } return bounds; }
Example #11
Source File: LineClipperTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * clip an X to a smaller X */ @Test public void clipXTest() { Rectangle bounds = new Rectangle(0, 0, 1000, 1000); int x0 = -100; int y0 = -100; int x1 = 1100; int y1 = 1100; Rectangle rect = LineClipper.clip(bounds, x0, y0, x1, y1); assertEquals(new Rectangle(0, 0, 1000, 1000), rect); x0 = 1100; y0 = -100; x1 = -100; y1 = 1100; rect = LineClipper.clip(bounds, x0, y0, x1, y1); assertEquals(new Rectangle(1000, 0, -1000, 1000), rect); }
Example #12
Source File: SelectionModel.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public int[] getSelectedColumns() { TreeSet<Integer> selectedColumns = new TreeSet<Integer>(); selectionsLock.readLock().lock(); try { for (Rectangle r : selections) { int startColumn = r.x; int numColumns = r.width; // Change from row < startRow to row < startRow+numRows for (int column = startColumn; column < startColumn + numColumns; column++) { selectedColumns.add(Integer.valueOf(column)); } } } finally { selectionsLock.readLock().unlock(); } // Convert to array return ObjectUtils.asIntArray(selectedColumns); }
Example #13
Source File: TableHierarchyRenderer.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public boolean isInActiveArea(IRow row, Rectangle drawingArea, int xx, int yy) { int offx = scaleX(_levelWidth); ITableNode node = (ITableNode) row; int level = node.getLevel(); boolean leaf = node.getChildren().size() == 0; // leaves can not be toggled if (leaf) { return false; } int x = drawingArea.x + offx * level + SIZE / 2; int y = drawingArea.y + (drawingArea.height - SIZE) / 2; return x <= xx && xx <= x + SIZE && y <= yy && yy <= y + SIZE; }
Example #14
Source File: CompositeLayer.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public void setChildLayer(String regionName, ILayer childLayer, final int layoutX, final int layoutY) { if (childLayer == null) { throw new IllegalArgumentException("Cannot set null child layer"); } childLayerToRegionNameMap.put(childLayer, regionName); childLayer.addLayerListener(this); childLayerToLayoutCoordinateMap.put(childLayer, new LayoutCoordinate(layoutX, layoutY)); childLayerLayout[layoutX][layoutY] = childLayer; childLayer.setClientAreaProvider(new IClientAreaProvider() { public Rectangle getClientArea() { return getChildClientArea(layoutX, layoutY); } }); }
Example #15
Source File: AbstractCombo.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Calculates and returns the location of popup.<br> * Called just before than the popup is dropped. */ protected void setPopupLocation() { Display display = Display.getCurrent(); Rectangle r = getBounds(); Point p = display.map(this, null, 0, r.height); Rectangle sb = display.getBounds(); if (p.y + popup.getSize().y > sb.height) { p.y -= r.height + popup.getSize().y + getBorderWidth(); } int popx = popup.getSize().x; if (p.x + popx > sb.width) { p.x -= popx - r.width + getBorderWidth(); } else if (popx < r.width) { p.x += r.width - popx; } popup.setLocation(p.x, p.y); }
Example #16
Source File: RowSelectionModel.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public List<Rectangle> getSelections() { List<Rectangle> selectionRectangles = new ArrayList<Rectangle>(); selectionsLock.readLock().lock(); try { int width = selectionLayer.getColumnCount(); for (Serializable rowId : selectedRows.keySet()) { int rowPosition = getRowPositionById(rowId); selectionRectangles.add(new Rectangle(0, rowPosition, width, 1)); } } finally { selectionsLock.readLock().unlock(); } return selectionRectangles; }
Example #17
Source File: ChartPrintJob.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * @param printer * @param safetyBorder * @return the rectangle in pixels to print on (and which is also supported * by the printer hardware) */ private Rectangle getPrintableArea(Printer printer, double safetyBorder) { int safetyBorderWidth = (int) (safetyBorder * printer.getDPI().x); int safetyBorderHeight = (int) (safetyBorder * printer.getDPI().y); Rectangle trim = printer.computeTrim(0, 0, 0, 0); int trimLeft = -trim.x; int trimTop = -trim.y; int trimRight = trim.x + trim.width; int trimBottom = trim.y + trim.height; int marginLeft = Math.max(trimLeft, safetyBorderWidth); int marginRight = Math.max(trimRight, safetyBorderWidth); int marginTop = Math.max(trimTop, safetyBorderHeight); int marginBottom = Math.max(trimBottom, safetyBorderHeight); int availWidth = printer.getClientArea().width - marginLeft - marginRight; int availHeight = printer.getClientArea().height - marginTop - marginBottom; return new Rectangle(marginLeft, marginTop, availWidth, availHeight); }
Example #18
Source File: Win7ColumnHeaderUtil.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Based on the provided state (hover/selected) generate the appropriate column * header rendering. * * @param graphics * @param bounds * @param palette * @param hover * indicates whether the mouse is hovering over the column header * @param selected * indicates whether the column is selected (mousedown) * @param mousedown */ public static void drawColumn(GC graphics, Rectangle bounds, Win7PaletteProvider palette, boolean hover, boolean selected, boolean mousedown) { if (mousedown) { drawColumnHeader(graphics, bounds, palette.getPalette((Display) graphics.getDevice(), Win7PaletteProvider.MOUSEDOWN_GRID_COLUMN_HEADER)); drawColumnSelectedTopShadow(graphics, bounds, palette.getPalette((Display) graphics.getDevice(), Win7PaletteProvider.SHADOW_GRID_COLUMN_HEADER)); } else if (hover) { drawColumnHeader(graphics, bounds, palette.getPalette((Display) graphics.getDevice(), Win7PaletteProvider.HOVER_GRID_COLUMN_HEADER)); } else if (selected) { drawColumnHeader(graphics, bounds, palette.getPalette((Display) graphics.getDevice(), Win7PaletteProvider.SELECTED_GRID_COLUMN_HEADER)); } else { drawColumnHeader(graphics, bounds, palette.getPalette((Display) graphics.getDevice(), Win7PaletteProvider.NORMAL_GRID_COLUMN_HEADER)); } }
Example #19
Source File: ColumnStructuralChangeEvent.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
@Override public Collection<Rectangle> getChangedPositionRectangles() { Collection<Rectangle> changedPositionRectangles = new ArrayList<Rectangle>(); Collection<Range> columnPositionRanges = getColumnPositionRanges(); if (columnPositionRanges != null && columnPositionRanges.size() > 0) { int leftmostColumnPosition = Integer.MAX_VALUE; for (Range range : columnPositionRanges) { if (range.start < leftmostColumnPosition) { leftmostColumnPosition = range.start; } } int columnCount = getLayer().getColumnCount(); int rowCount = getLayer().getRowCount(); changedPositionRectangles.add(new Rectangle(leftmostColumnPosition, 0, columnCount - leftmostColumnPosition, rowCount)); } return changedPositionRectangles; }
Example #20
Source File: CalendarComposite.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void drawChartOntoGC(GC gc) { Rectangle bounds = super.getBounds(); gc.setBackground(mColorManager.getCalendarBackgroundColor()); gc.fillRectangle(bounds); Font used = null; if (CalendarCombo.OS_CARBON) { used = mSettings.getCarbonDrawFont(); if (used != null) gc.setFont(used); } // header drawHeader(gc); // day titles drawTitleDays(gc); // days drawDays(gc); // 1 pixel border drawBorder(gc); gc.dispose(); if (used != null) used.dispose(); }
Example #21
Source File: ContentAssistant.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * getAboveLocation * * @param shell * @param offset * @return Point */ protected Point getAboveLocation(Shell shell, int offset) { Point location = fContentAssistSubjectControlAdapter.getLocationAtOffset(offset); location = fContentAssistSubjectControlAdapter.getControl().toDisplay(location); Rectangle shellBounds = shell.getBounds(); Rectangle displayBounds = shell.getDisplay().getClientArea(); location.y = location.y - (shellBounds.height + fContentAssistSubjectControlAdapter.getLineHeight()); shiftHorizontalLocation(location, shellBounds, displayBounds); shiftVerticalLocation(location, shellBounds, displayBounds, true); return location; }
Example #22
Source File: GridLineCellLayerPainter.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
protected void drawGridLines(ILayer natLayer, GC gc, Rectangle rectangle) { gc.setForeground(GUIHelper.COLOR_GRAY); drawHorizontalLines(natLayer, gc, rectangle); drawVerticalLines(natLayer, gc, rectangle); // paint far bottom left corner pixel gc.drawPoint(natLayer.getWidth() - 1, natLayer.getHeight() - 1); }
Example #23
Source File: SWTBotTimeGraphEntry.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public Rectangle absoluteLocation() { return UIThreadRunnable.syncExec(() -> { Rectangle bounds = widget.getItemBounds(fEntry); if (bounds == null) { return null; } Point location = widget.toDisplay(bounds.x, bounds.y); bounds.x = location.x; bounds.y = location.y; return bounds; }); }
Example #24
Source File: LineBackgroundPainter.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Draws the current line highlight (over top using theme colors and alpha). If the line highlight is fully opaque, * then this method will not do anything and we'll fall back to using the mechanism eclipse does in * CursorLinePainter with a little modification. */ public void paintControl(PaintEvent e) { // if highlight current line is disabled, don't draw! if (!fEnabled) { return; } // If there's no alpha value for the line highlight, then we need to force the bg color of the whole line // to the rgb value! RGBa lineHighlight = getCurrentTheme().getLineHighlight(); if (lineHighlight.isFullyOpaque()) { return; } Rectangle rect = new Rectangle(e.x, e.y, e.width, e.height); Rectangle lineRect = getLineRectangle(getCurrentLinePosition()); if (lineRect == null || !lineRect.intersects(rect)) { return; } int previousAlpha = e.gc.getAlpha(); Color previousBG = e.gc.getBackground(); e.gc.setAlpha(lineHighlight.getAlpha()); e.gc.setBackground(getColorManager().getColor(lineHighlight.toRGB())); // Only paint the part of lineRect that is contained in rect! e.gc.fillRectangle(lineRect.intersection(rect)); // BUGFIX: need to set alpha and background color back to what they were before or it breaks // the painting of pair matching! e.gc.setAlpha(previousAlpha); e.gc.setBackground(previousBG); }
Example #25
Source File: ColumnSubResultNew.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
@Override public void cellPaint(GC gc, TableCellSWT cell) { SubscriptionResultFilterable entry = (SubscriptionResultFilterable) cell.getDataSource(); Rectangle cellBounds = cell.getBounds(); Image img = entry== null || entry.getRead() ? imgOld: imgNew; if (img != null && !img.isDisposed()) { Rectangle imgBounds = img.getBounds(); gc.drawImage(img, cellBounds.x + ((cellBounds.width - imgBounds.width) / 2), cellBounds.y + ((cellBounds.height - imgBounds.height) / 2)); } }
Example #26
Source File: ChartCheckbox.java From birt with Eclipse Public License 1.0 | 5 votes |
public void paintControl( PaintEvent e ) { // Do some drawing if ( button.isFocusControl( ) ) { Rectangle rect = ( (Canvas) e.widget ).getBounds( ); e.gc.drawFocus( 0, 0, rect.width, rect.height ); } }
Example #27
Source File: CompositeLayer.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private Rectangle getChildClientArea(final int layoutX, final int layoutY) { final ChildLayerInfo childLayerInfo = getChildLayerInfoByLayout(layoutX, layoutY); final Rectangle compositeClientArea = getClientAreaProvider().getClientArea(); final Rectangle childClientArea = new Rectangle( compositeClientArea.x + childLayerInfo.getWidthOffset(), compositeClientArea.y + childLayerInfo.getHeightOffset(), childLayerInfo.getLayer().getPreferredWidth(), childLayerInfo.getLayer().getPreferredHeight()); final Rectangle intersection = compositeClientArea.intersection(childClientArea); return intersection; }
Example #28
Source File: TSWizardDialog.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
/** * Returns the client area for the given composite according to this * layout. * * @param c * the composite * @return the client area rectangle */ public Rectangle getClientArea(Composite c) { Rectangle rect = c.getClientArea(); rect.x = rect.x + marginWidth; rect.y = rect.y + marginHeight; rect.width = rect.width - 2 * marginWidth; rect.height = rect.height - 2 * marginHeight; return rect; }
Example #29
Source File: ViewUtils.java From BiglyBT with GNU General Public License v2.0 | 5 votes |
private static void setViewRequires( Composite genComposite, boolean one_or_more ){ if (genComposite == null || genComposite.isDisposed()) { return; } Utils.disposeComposite(genComposite, false); Label lab = new Label(genComposite, SWT.NULL); if ( genComposite.getLayout() instanceof GridLayout ){ GridData gridData = new GridData(SWT.CENTER, SWT.CENTER, true, true); gridData.verticalIndent = 10; lab.setLayoutData(gridData); }else{ lab.setLayoutData( Utils.getFilledFormData()); } Messages.setLanguageText(lab, one_or_more?"view.one.or.more.download":"view.one.download.only"); genComposite.layout(true); Composite parent = genComposite.getParent(); if (parent instanceof ScrolledComposite) { ScrolledComposite scrolled_comp = (ScrolledComposite) parent; Rectangle r = scrolled_comp.getClientArea(); scrolled_comp.setMinSize(genComposite.computeSize(r.width, SWT.DEFAULT )); } }
Example #30
Source File: TimeGraphFindDialog.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
/** * Returns the dialog's boundaries. * * @return the dialog's boundaries */ private Rectangle getDialogBoundaries() { if (okToUse(getShell())) { return getShell().getBounds(); } return fDialogPositionInit; }