public void drawLine( int x, int y, int x2, int y2 ) { gc.drawLine( x, y, x2, y2 ); }
public void drawLine( int x, int y, int x2, int y2 ) { gc.drawLine( x, y, x2, y2 ); }
private void repaint( GC gc, int width, int height ) { ImageData imd = image.getImageData(); double sizeOnPaperX = imd.width * factorx; double sizeOnPaperY = imd.height * factory; double actualSizeX = sizeOnPaperX * scale / 100; double actualSizeY = sizeOnPaperY * scale / 100; // What % of the screen is filled? // The canvas is nrcols * nrrows nr of pages large. double percentScreenX = actualSizeX / ( page.x * nrcols ); double percentScreenY = actualSizeY / ( page.y * nrrows ); gc.drawImage( image, 0, 0, imd.width, imd.height, 0, 0, (int) ( width * percentScreenX ), (int) ( height * percentScreenY ) ); StringBuilder text = new StringBuilder(); text.append( nrcols ).append( "x" ).append( nrrows ).append( " @ " ).append( scale ).append( "%" ); gc.drawText( text.toString(), 0, 0 ); for ( int c = 1; c < nrcols; c++ ) { gc.drawLine( c * ( width / nrcols ), 0, c * ( width / nrcols ), height ); } for ( int r = 1; r < nrrows; r++ ) { gc.drawLine( 0, r * ( height / nrrows ), width, r * ( height / nrrows ) ); } }
private void drawMarker( GC gc, int x, int maxy ) { int[] triangle = new int[] { LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 }; gc.fillPolygon( triangle ); gc.drawPolygon( triangle ); gc .drawLine( LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy ); }
private void drawMarker( GC gc, int x, int maxy ) { int[] triangle = new int[] { LEFT + MARGIN + x * fontwidth + offset.x, TOP - 4, LEFT + MARGIN + x * fontwidth + offset.x + 3, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x - 3, TOP + 1 }; gc.fillPolygon( triangle ); gc.drawPolygon( triangle ); gc .drawLine( LEFT + MARGIN + x * fontwidth + offset.x, TOP + 1, LEFT + MARGIN + x * fontwidth + offset.x, maxy ); }
gc.drawLine( x1, y1, x2, y2 );
/** * Get the image for when all other fallbacks have failed. This is an image * drawn on the canvas, a square with a red X. * * @param display the device to render the image to * @return the missing image */ public static SwtUniversalImage getMissingImage( Display display ) { Image img = new Image( display, ConstUI.ICON_SIZE, ConstUI.ICON_SIZE ); GC gc = new GC( img ); gc.setForeground( new Color( display, 0, 0, 0 ) ); gc.drawRectangle( 4, 4, ConstUI.ICON_SIZE - 8, ConstUI.ICON_SIZE - 8 ); gc.setForeground( new Color( display, 255, 0, 0 ) ); gc.drawLine( 4, 4, ConstUI.ICON_SIZE - 4, ConstUI.ICON_SIZE - 4 ); gc.drawLine( ConstUI.ICON_SIZE - 4, 4, 4, ConstUI.ICON_SIZE - 4 ); gc.dispose(); return new SwtUniversalImageBitmap( img ); }
gc.setBackground( bg ); gc.drawLine( LEFT + MARGIN, linepos, area.x, linepos ); gc.drawLine( LEFT + MARGIN + i * fontwidth + offset.x, linepos, LEFT + MARGIN + i * fontwidth + offset.x, linepos - 5 ); } else { gc.drawLine( LEFT + MARGIN + i * fontwidth + offset.x, linepos, LEFT + MARGIN + i * fontwidth + offset.x, linepos - 3 ); gc.fillRectangle( 0, TOP, LEFT, area.y ); gc.drawLine( LEFT, TOP, LEFT, area.y ); int numsize = number.length() * fontwidth; gc.drawText( number, LEFT - 5 - numsize, TOP + i * ( fontheight + 2 ) + offset.y, true ); gc.drawLine( LEFT, TOP + ( i + 1 ) * ( fontheight + 2 ) + offset.y, LEFT - 5, TOP + ( i + 1 ) * ( fontheight + 2 ) + offset.y );
gc.setBackground( bg ); gc.drawLine( LEFT + MARGIN, linepos, area.x, linepos ); gc.drawLine( LEFT + MARGIN + i * fontwidth + offset.x, linepos, LEFT + MARGIN + i * fontwidth + offset.x, linepos - 5 ); } else { gc.drawLine( LEFT + MARGIN + i * fontwidth + offset.x, linepos, LEFT + MARGIN + i * fontwidth + offset.x, linepos - 3 ); gc.fillRectangle( 0, TOP, LEFT, area.y ); gc.drawLine( LEFT, TOP, LEFT, area.y ); int numsize = number.length() * fontwidth; gc.drawText( number, LEFT - 5 - numsize, TOP + i * ( fontheight + 2 ) + offset.y, true ); gc.drawLine( LEFT, TOP + ( i + 1 ) * ( fontheight + 2 ) + offset.y, LEFT - 5, TOP + ( i + 1 ) * ( fontheight + 2 ) + offset.y );
@Override public void drawLine ( final int x1, final int y1, final int x2, final int y2 ) { this.gc.drawLine ( x1, y1, x2, y2 ); }
private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) { gc.setForeground(topleft); gc.drawLine(x, y, x+w-1, y); gc.drawLine(x, y, x, y+h-1); gc.setForeground(bottomright); gc.drawLine(x+w, y, x+w, y+h); gc.drawLine(x, y+h, x+w, y+h); } void paint(PaintEvent event) {
/** * Draw a rectangle in the given colors. */ private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) { gc.setForeground(bottomright); gc.drawLine(x+w, y, x+w, y+h); gc.drawLine(x, y+h, x+w, y+h); gc.setForeground(topleft); gc.drawLine(x, y, x+w-1, y); gc.drawLine(x, y, x, y+h-1); } /*
/** * Draw a rectangle in the given colors. */ private void drawBevelRect(GC gc, int x, int y, int w, int h, Color topleft, Color bottomright) { gc.setForeground(bottomright); gc.drawLine(x+w, y, x+w, y+h); gc.drawLine(x, y+h, x+w, y+h); gc.setForeground(topleft); gc.drawLine(x, y, x+w-1, y); gc.drawLine(x, y, x, y+h-1); } /*
void drawVerticals(GC gc, int w, int h) { for (int i = 0; i < w; i += VERTICAL_DIST) { gc.setForeground(gridColor); gc.drawLine(i, 0, i, h); } }
@Override protected void paintText(GC gc, Rectangle bounds) { super.paintText(gc, bounds); if (strikeThrough) { Point totalSize = computeTextSize(SWT.DEFAULT, SWT.DEFAULT); int textWidth = Math.min(bounds.width, totalSize.x); int textHeight = totalSize.y; // int descent = gc.getFontMetrics().getDescent(); int lineY = bounds.y + (textHeight / 2); // - descent + 1; gc.drawLine(bounds.x, lineY, bounds.x + textWidth, lineY); } }
private void drawRangeIndication(GC gc, Canvas canvas, Rectangle r) { final int MARGIN= 3; /* cap the height - at least on GTK, large numbers are converted to * negatives at some point */ int height= Math.min(r.y + r.height - MARGIN, canvas.getSize().y); gc.setForeground(canvas.getDisplay().getSystemColor(COLOR)); gc.setLineWidth(0); // NOTE: 0 means width is 1 but with optimized performance gc.drawLine(r.x + 4, r.y + 12, r.x + 4, height); gc.drawLine(r.x + 4, height, r.x + r.width - MARGIN, height); }
@Override public void paintControl(PaintEvent e) { timelineBar.update(timeline.getWidth()); e.gc.drawImage(timelineBar.contents, origin.x, 0); e.gc.setForeground(e.display.getSystemColor(SWT.COLOR_RED)); e.gc.drawLine(origin.x + (int) (currentTime / timeline.timePerPixel), 10, origin.x + (int) (currentTime / timeline.timePerPixel), barCanvas.getClientArea().height); } });