public void buildTransformationImage() { Point max = transMeta.getMaximum(); Point thumb = getThumb( area, max ); offset = getOffset( thumb, area ); // First clear the image in the background color gc.setBackground( EColor.BACKGROUND ); gc.fillRectangle( 0, 0, area.x, area.y ); // If there is a shadow, we draw the transformation first with an alpha setting // if ( shadowSize > 0 ) { shadow = true; gc.setTransform( translationX, translationY, shadowSize, magnification ); gc.setAlpha( 20 ); drawTrans( thumb ); } // Draw the transformation onto the image // shadow = false; gc.setTransform( translationX, translationY, 0, magnification ); gc.setAlpha( 255 ); drawTrans( thumb ); gc.dispose(); }
gc.setFont( EFont.SMALL ); 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; gc.setForeground( EColor.DARKGRAY ); gc.setBackground( EColor.LIGHTGRAY ); gc.setLineWidth( 1 ); gc.fillRoundRectangle( popupX, popupY, popupWidth, popupHeight, 7, 7 ); gc.setBackground( EColor.LIGHTGRAY ); gc.drawRoundRectangle( popupX, popupY, popupWidth, popupHeight, 7, 7 ); gc.setBackground( EColor.BACKGROUND ); } else { gc.setBackground( EColor.LIGHTGRAY ); gc.fillRoundRectangle( popupX + 1, barY + 1, popupWidth - 2, rowHeight, 7, 7 ); barY += rowHeight; gc.setForeground( EColor.BLACK ); gc.setBackground( EColor.BACKGROUND ); gc.setBackground( EColor.BACKGROUND ); } else {
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 ); } }
protected void drawGrid() { Point bounds = gc.getDeviceBounds(); for ( int x = 0; x < bounds.x; x += gridSize ) { for ( int y = 0; y < bounds.y; y += gridSize ) { gc.drawPoint( x + ( offset.x % gridSize ), y + ( offset.y % gridSize ) ); } } }
private void drawTextRightAligned( String txt, int x, int y ) { int off = gc.textExtent( txt ).x; x -= off; gc.drawText( txt, x, y ); }
protected void drawRect( Rectangle rect ) { if ( rect == null ) { return; } gc.setLineStyle( ELineStyle.DASHDOT ); gc.setLineWidth( linewidth ); gc.setForeground( EColor.GRAY ); // PDI-2619: SWT on Windows doesn't cater for negative rect.width/height so handle here. Point s = real2screen( rect.x, rect.y ); if ( rect.width < 0 ) { s.x = s.x + rect.width; } if ( rect.height < 0 ) { s.y = s.y + rect.height; } gc.drawRectangle( s.x, s.y, Math.abs( rect.width ), Math.abs( rect.height ) ); gc.setLineStyle( ELineStyle.SOLID ); }
int alpha = gc.getAlpha(); gc.setLineWidth( 1 ); gc.setForeground( EColor.GRAY ); gc.setBackground( EColor.BACKGROUND ); 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.drawRectangle( point.x, point.y, textExtent.x, textExtent.y ); gc.drawText( nrInput, point.x + 1, point.y + 1 ); gc.drawLine( point.x + textExtent.x, point.y + textExtent.y / 2, x - iconsize / 2, point.y + textExtent.y / 2 ); drawArrow( EImage.ARROW_DISABLED, gc.setLineWidth( 1 ); gc.setForeground( EColor.GRAY ); gc.setBackground( EColor.BACKGROUND ); 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; gc.drawRectangle( point.x, point.y, textExtent.x, textExtent.y ); gc.drawText( nrOutput, point.x + 1, point.y + 1 );
int alpha = gc.getAlpha(); gc.setLineWidth( 3 ); } else { gc.setLineWidth( 1 ); gc.setBackground( EColor.BACKGROUND ); gc.fillRoundRectangle( x - 1, y - 1, iconsize + 1, iconsize + 1, 7, 7 ); gc.drawJobEntryIcon( x, y, jobEntryCopy, magnification ); gc.setForeground( EColor.RED ); } else if ( jobEntryCopy.isDeprecated() ) { gc.setForeground( EColor.DEPRECATED ); } else { gc.setForeground( EColor.CRYSTAL ); gc.drawRoundRectangle( x - 1, y - 1, iconsize + 1, iconsize + 1, 7, 7 ); gc.setForeground( EColor.CRYSTAL ); Point textsize = new Point( gc.textExtent( "" + name ).x, gc.textExtent( "" + name ).y ); gc.setBackground( EColor.BACKGROUND ); gc.setLineWidth( 1 ); gc.setForeground( EColor.BLACK ); gc.drawText( name, xpos, ypos, true ); gc.setForeground( EColor.BLUE ); int iconX = ( x + iconsize ) - ( MINI_ICON_SIZE / 2 ); int iconY = y - ( MINI_ICON_SIZE / 2 );
gc.setFont( EFont.NOTE ); gc.setFont( EFont.GRAPH ); Point to = endHopLocation; if ( endHopEntry == null ) { gc.setForeground( EColor.GRAY ); arrow = EImage.ARROW_DISABLED; } else { gc.setForeground( EColor.BLUE ); arrow = EImage.ARROW_DEFAULT; Point to = endHopEntry.getLocation(); if ( startHopEntry == null ) { gc.setForeground( EColor.GRAY ); arrow = EImage.ARROW_DISABLED; } else { gc.setForeground( EColor.BLUE ); arrow = EImage.ARROW_DEFAULT; gc.setLineWidth( 2 ); gc.setForeground( EColor.RED ); Point n = noInputEntry.getLocation(); gc.drawLine( offset.x + n.x - 5, offset.y + n.y - 5, offset.x + n.x + iconsize + 5, offset.y + n.y + iconsize + 5 ); gc.drawLine( offset.x + n.x - 5, offset.y + n.y + iconsize + 5, offset.x + n.x + iconsize + 5, offset.y + n.y - 5 ); gc.setLineStyle( ELineStyle.SOLID );
protected void drawNote( NotePadMeta notePadMeta ) { if ( notePadMeta.isSelected() ) { gc.setLineWidth( 2 ); } else { gc.setLineWidth( 1 ); gc.setFont( Const.NVL( notePadMeta.getFontName(), noteFontName ), notePadMeta.getFontSize() == -1 ? noteFontHeight : notePadMeta.getFontSize(), notePadMeta.isFontBold(), notePadMeta.isFontItalic() ); ext = gc.textExtent( notePadMeta.getNote() ); note.x + s, note.y + height + 2 * margin + s // bottom left }; gc.setBackground( EColor.LIGHTGRAY ); gc.fillPolygon( shadowa ); gc.setBackground( notePadMeta.getBackGroundColorRed(), notePadMeta.getBackGroundColorGreen(), notePadMeta .getBackGroundColorBlue() ); gc.setForeground( notePadMeta.getBorderColorRed(), notePadMeta.getBorderColorGreen(), notePadMeta .getBorderColorBlue() ); gc.fillPolygon( noteshape ); gc.drawPolygon( noteshape ); gc.setForeground( notePadMeta.getFontColorRed(), notePadMeta.getFontColorGreen(), notePadMeta .getFontColorBlue() ); gc.drawText( notePadMeta.getNote(), note.x + margin, note.y + margin, true ); gc.setLineWidth( 1 ); } else {
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.drawLine( x1, y1, x2, y2 ); gc.drawImage( arrow, mx + 1, my, magnification, angle ); } else if ( q2 || q4 ) { gc.drawImage( arrow, mx, my, magnification, angle ); Point bounds = gc.getImageBounds( hopsIcon ); gc.drawImage( hopsIcon, mx, my, magnification ); if ( !shadow ) { areaOwners gc.drawImage( hopsIcon, mx, my, magnification ); if ( !shadow ) { areaOwners.add( new AreaOwner(
public Image getTransformationImage( Device device, int x, int y, float magnificationFactor ) { GCInterface gc = new SWTGC( device, new Point( x, y ), iconsize ); int gridSize = PropsUI.getInstance().isShowCanvasGridEnabled() ? PropsUI.getInstance().getCanvasGridSize() : 1; TransPainter transPainter = new TransPainter( gc, transMeta, new Point( x, y ), new SwtScrollBar( hori ), new SwtScrollBar( vert ), candidate, drop_candidate, selectionRegion, areaOwners, mouseOverSteps, PropsUI.getInstance().getIconSize(), PropsUI.getInstance().getLineWidth(), gridSize, PropsUI.getInstance().getShadowSize(), PropsUI.getInstance() .isAntiAliasingEnabled(), PropsUI.getInstance().getNoteFont().getName(), PropsUI.getInstance() .getNoteFont().getHeight(), trans, PropsUI.getInstance().isIndicateSlowTransStepsEnabled() ); transPainter.setMagnification( magnificationFactor ); transPainter.setStepLogMap( stepLogMap ); transPainter.setStartHopStep( startHopStep ); transPainter.setEndHopLocation( endHopLocation ); transPainter.setNoInputStep( noInputStep ); transPainter.setEndHopStep( endHopStep ); transPainter.setCandidateHopType( candidateHopType ); transPainter.setStartErrorHopStep( startErrorHopStep ); transPainter.setShowTargetStreamsStep( showTargetStreamsStep ); transPainter.buildTransformationImage(); Image img = (Image) gc.getImage(); gc.dispose(); return img; }
painter.setMagnification( 0.25f ); painter.drawJob(); BufferedImage bufferedImage = (BufferedImage) gc.getImage(); int newWidth = bufferedImage.getWidth() - min.x; int newHeigth = bufferedImage.getHeight() - min.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 ); }
private void drawStepStatusIndicator( StepMeta stepMeta ) { if ( stepMeta == null ) { return; } // draw status indicator if ( trans != null ) { Point pt = stepMeta.getLocation(); if ( pt == null ) { pt = new Point( 50, 50 ); } Point screen = real2screen( pt.x, pt.y ); int x = screen.x; int y = screen.y; List<StepInterface> steps = trans.findBaseSteps( stepMeta.getName() ); for ( StepInterface step : steps ) { if ( step.getStatus().equals( StepExecutionStatus.STATUS_FINISHED ) ) { gc.drawImage( EImage.TRUE, ( x + iconsize ) - ( MINI_ICON_SIZE / 2 ) + 4, y - ( MINI_ICON_SIZE / 2 ) - 1, magnification ); } } } }
gc.setFont( EFont.NOTE ); gc.setFont( EFont.GRAPH ); gc.setBackground( EColor.BACKGROUND ); Point to = endHopLocation; if ( endHopStep == null ) { gc.setForeground( EColor.GRAY ); arrow = EImage.ARROW_DISABLED; } else { gc.setForeground( EColor.BLUE ); arrow = EImage.ARROW_DEFAULT; Point to = endHopStep.getLocation(); if ( startHopStep == null ) { gc.setForeground( EColor.GRAY ); arrow = EImage.ARROW_DISABLED; } else { gc.setForeground( EColor.BLUE ); arrow = EImage.ARROW_DEFAULT; gc.setLineWidth( 2 ); gc.setForeground( EColor.RED ); Point n = noInputStep.getLocation(); gc.drawLine( n.x - 5, n.y - 5, n.x + iconsize + 10, n.y + iconsize + 10 ); gc.drawLine( n.x - 5, n.y + iconsize + 5, n.x + iconsize + 5, n.y - 5 ); gc.setLineStyle( ELineStyle.SOLID ); gc.setForeground( EColor.BLACK );
gc.setLineWidth( linewidth + 1 ); if ( System.currentTimeMillis() % 2000 > 1000 ) { gc.setForeground( EColor.BACKGROUND ); gc.setLineStyle( ELineStyle.SOLID ); gc.drawRectangle( x + 1, y + 1, iconsize - 2, iconsize - 2 ); gc.setForeground( EColor.DARKGRAY ); gc.setLineStyle( ELineStyle.DOT ); gc.drawRectangle( x + 1, y + 1, iconsize - 2, iconsize - 2 ); } else { gc.setForeground( EColor.DARKGRAY ); gc.setLineStyle( ELineStyle.SOLID ); gc.drawRectangle( x + 1, y + 1, iconsize - 2, iconsize - 2 ); gc.setForeground( EColor.BACKGROUND ); gc.setLineStyle( ELineStyle.DOT ); gc.drawRectangle( x + 1, y + 1, iconsize - 2, iconsize - 2 ); gc.setLineStyle( ELineStyle.SOLID );
gc.drawLine( x1, y1, x2, y2 ); gc.drawImage( arrow, mx + 1, my, magnification, angle ); } else if ( q2 || q4 ) { gc.drawImage( arrow, mx, my, magnification, angle ); if ( targetStream != null ) { EImage hopsIcon = BasePainter.getStreamIconImage( targetStream.getStreamIcon() ); Point bounds = gc.getImageBounds( hopsIcon ); gc.drawImage( hopsIcon, mx, my, magnification ); if ( !shadow ) { areaOwners.add( new AreaOwner( Point bounds = gc.getImageBounds( eImage ); gc.drawImage( eImage, mx, my, magnification ); Point bounds = gc.getImageBounds( EImage.COPY_ROWS ); gc.drawImage( EImage.COPY_ROWS, mx, my, magnification ); Point bounds = gc.getImageBounds( EImage.COPY_ROWS ); gc.drawImage( EImage.FALSE, mx, my, magnification ); if ( !shadow ) { areaOwners.add( new AreaOwner( AreaType.HOP_ERROR_ICON, mx, my, bounds.x, bounds.y, offset, fs, ts ) ); Point bounds = gc.getImageBounds( EImage.INFO ); gc.drawImage( EImage.INFO, mx, my, magnification ); if ( !shadow ) { areaOwners.add( new AreaOwner( AreaType.HOP_INFO_ICON, mx, my, bounds.x, bounds.y, offset, fs, ts ) );
painter.setTranslationY( min.y ); painter.buildTransformationImage(); BufferedImage bufferedImage = (BufferedImage) gc.getImage(); int newWidth = bufferedImage.getWidth() - min.x; int newHeigth = bufferedImage.getHeight() - min.y;