private void drawTextRightAligned( String txt, int x, int y ) { int off = gc.textExtent( txt ).x; x -= off; gc.drawText( txt, x, y ); }
public Point getNamePosition( String string, Point screen, int iconsize ) { Point textsize = gc.textExtent( string ); int xpos = screen.x + ( iconsize / 2 ) - ( textsize.x / 2 ); int ypos = screen.y + iconsize + 5; return new Point( xpos, ypos ); }
void drawTimeScaleLine( int height, double pixelsPerMs, long periodInMs ) { int log10 = (int) Math.log10( periodInMs ) + 1; int timeLineDistance = (int) Math.pow( 10, log10 - 1 ) / 2; int incrementUnit = Math.max( timeLineDistance, 1 ); for ( int time = timeLineDistance; time <= periodInMs; time += incrementUnit ) { int x = (int) ( time * pixelsPerMs ); getGc().setForeground( EColor.LIGHTGRAY ); getGc().drawLine( x, 0, x, height ); String marker = Integer.toString( time ); Point point = getGc().textExtent( marker ); getGc().setForeground( EColor.DARKGRAY ); getGc().drawText( marker, x - ( point.x / 2 ), 0, true ); } }
@Test( timeout = 1000 ) public void testDrawTimeScaleLineInfinityLoop() { GCInterface gCInterfaceMock = mock( GCInterface.class ); when( metricsPainter.getGc() ).thenReturn( gCInterfaceMock ); doCallRealMethod().when( metricsPainter ).drawTimeScaleLine( heightStub, pixelsPerMsStub, periodInMsStub ); when( gCInterfaceMock.textExtent( anyString() ) ).thenReturn( mock( Point.class ) ); metricsPainter.drawTimeScaleLine( heightStub, pixelsPerMsStub, periodInMsStub ); }
private void drawDurations( List<MetricsDuration> durations, List<MetricsDrawArea> areas, double pixelsPerMs ) { // set top indent int y = 20; for ( MetricsDuration duration : durations ) { Long realDuration = duration.getEndDate().getTime() - duration.getDate().getTime(); // How many pixels does it take to drawn this duration? // int durationWidth = (int) ( realDuration * pixelsPerMs ); int x = 2 + (int) ( ( duration.getDate().getTime() - periodStart ) * pixelsPerMs ); getGc().setBackground( EColor.BACKGROUND ); getGc().setForeground( EColor.LIGHTBLUE ); getGc().fillGradientRectangle( x, y, durationWidth, barHeight, false ); getGc().setForeground( EColor.BLACK ); getGc().drawRectangle( x, y, durationWidth, barHeight ); areas.add( new MetricsDrawArea( new Rectangle( x, y, durationWidth, barHeight ), duration ) ); LoggingObjectInterface loggingObject = LoggingRegistry.getInstance().getLoggingObject( duration.getLogChannelId() ); String message = duration.getDescription() + " - " + loggingObject.getObjectName() + " : " + duration.getDuration() + "ms"; if ( duration.getCount() > 1 ) { message += " " + duration.getCount() + " calls, avg=" + ( duration.getDuration() / duration.getCount() ); } getGc().setFont( EFont.GRAPH ); getGc().textExtent( message ); getGc().drawText( message, x + 3, y + 4, true ); y += barHeight + 5; } }
gc.setFont( EFont.GRAPH ); String nrInput = Integer.toString( stepMeta.getRemoteInputSteps().size() ); Point textExtent = gc.textExtent( nrInput ); textExtent.x += 2; // add a tiny listartHopStepttle bit of a margin textExtent.y += 2; gc.setFont( EFont.GRAPH ); String nrOutput = Integer.toString( stepMeta.getRemoteOutputSteps().size() ); Point textExtent = gc.textExtent( nrOutput ); textExtent.x += 2; // add a tiny little bit of a margin textExtent.y += 2; Point textExtent = gc.textExtent( nrInput ); textExtent.x += 2; // add a tiny little bit of a margin textExtent.y += 2; gc.setAlpha( 192 ); gc.setBackground( 216, 230, 241 ); gc.fillRoundRectangle( namePosition.x - 8, namePosition.y - 2, gc.textExtent( name ).x + 15, 25, BasePainter.CORNER_RADIUS_5 + 15, BasePainter.CORNER_RADIUS_5 + 15 ); gc.setAlpha( tmpAlpha ); Point textExtent = gc.textExtent( clusterMessage ); gc.setBackground( EColor.BACKGROUND ); gc.setForeground( EColor.BLACK ); gc.setForeground( EColor.BLACK ); String copies = "x" + stepMeta.getCopiesString(); Point textExtent = gc.textExtent( copies );
Point p = gc.textExtent( "0000000000" ); int colWidth = p.x + MINI_ICON_MARGIN; int rowHeight = p.y + MINI_ICON_MARGIN; Point titleExtent = gc.textExtent( title ); titleWidth = Math.max( titleExtent.x + MINI_ICON_MARGIN, titleWidth ); popupHeight += titleExtent.y + MINI_ICON_MARGIN;
Point textsize = new Point( gc.textExtent( "" + name ).x, gc.textExtent( "" + name ).y ); String trimmedName = jobEntryCopy.getName().length() < 30 ? jobEntryCopy.getName() : jobEntryCopy.getName().substring( 0, 30 ); Point nameExtent = gc.textExtent( trimmedName ); nameExtent.y += 2 * MINI_ICON_MARGIN; nameExtent.x += 3 * MINI_ICON_MARGIN;
? noteFontHeight : notePadMeta.getFontSize(), notePadMeta.isFontBold(), notePadMeta.isFontItalic() ); ext = gc.textExtent( notePadMeta.getNote() );