Skip to content

Commit

Permalink
[BACKLOG-3903] PDI Canvas Grid Option
Browse files Browse the repository at this point in the history
  • Loading branch information
e-cuellar committed Jul 8, 2015
1 parent d54c77e commit 9167695
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 7 deletions.
1 change: 1 addition & 0 deletions core/src/org/pentaho/di/core/Props.java
Expand Up @@ -123,6 +123,7 @@ public class Props implements Cloneable {
public static final String STRING_ONLY_ACTIVE_STEPS = "OnlyActiveSteps";
public static final String STRING_START_SHOW_REPOSITORIES = "ShowRepositoriesAtStartup";
public static final String STRING_ANTI_ALIASING = "EnableAntiAliasing54";
public static final String STRING_SHOW_CANVAS_GRID = "ShowCanvasGrid";
public static final String STRING_SHOW_EXIT_WARNING = "ShowExitWarning";
public static final String STRING_SHOW_OS_LOOK = "ShowOSLook54";
public static final String STRING_LAST_ARGUMENT = "LastArgument";
Expand Down
11 changes: 10 additions & 1 deletion ui/src/org/pentaho/di/ui/core/PropsUI.java
Expand Up @@ -816,6 +816,15 @@ public boolean isAntiAliasingEnabled() {
public void setAntiAliasingEnabled( boolean anti ) {
properties.setProperty( STRING_ANTI_ALIASING, anti ? YES : NO );
}

public boolean isShowCanvasGridEnabled() {
String showCanvas = properties.getProperty( STRING_SHOW_CANVAS_GRID, NO );
return YES.equalsIgnoreCase( showCanvas ); // Default: don't show canvas grid
}

public void setShowCanvasGridEnabled( boolean anti ) {
properties.setProperty( STRING_SHOW_CANVAS_GRID, anti ? YES : NO );
}

public boolean showExitWarning() {
String show = properties.getProperty( STRING_SHOW_EXIT_WARNING, YES );
Expand Down Expand Up @@ -1067,7 +1076,7 @@ public void setOpenTabFiles( List<LastUsedFile> openTabFiles ) {
}

public int getCanvasGridSize() {
return Const.toInt( properties.getProperty( CANVAS_GRID_SIZE, "1" ), 1 );
return Const.toInt( properties.getProperty( CANVAS_GRID_SIZE, "16" ), 16 );
}

public void setCanvasGridSize( int gridSize ) {
Expand Down
Expand Up @@ -339,3 +339,6 @@ tooltip_refresh=Refresh Tree

DatabaseExplorerDialog.TableLayout.ShellText=Table layout
DatabaseExplorerDialog.TableLayout.OriginText=Table

EnterOptionsDialog.ShowCanvasGrid.Label=Show Canvas Grid
EnterOptionsDialog.ShowCanvasGrid.ToolTip=If enabled, the canvas grid will be visible
28 changes: 25 additions & 3 deletions ui/src/org/pentaho/di/ui/core/dialog/EnterOptionsDialog.java
Expand Up @@ -144,6 +144,8 @@ public class EnterOptionsDialog extends Dialog {
private Text wMiddlePct;

private Text wGridSize;

private Button wShowCanvasGrid;

private Button wAntiAlias;

Expand Down Expand Up @@ -832,22 +834,41 @@ public void widgetSelected( SelectionEvent arg0 ) {
fdGridSize.right = new FormAttachment( 100, -margin );
fdGridSize.top = new FormAttachment( wMiddlePct, margin );
wGridSize.setLayoutData( fdGridSize );


// Show Canvas Grid
Label wlShowCanvasGrid = new Label( wLookComp, SWT.RIGHT );
wlShowCanvasGrid.setText( BaseMessages.getString( PKG, "EnterOptionsDialog.ShowCanvasGrid.Label" ) );
wlShowCanvasGrid.setToolTipText( BaseMessages.getString( PKG, "EnterOptionsDialog.ShowCanvasGrid.ToolTip" ) );
props.setLook( wlShowCanvasGrid );
FormData fdlShowCanvasGrid = new FormData();
fdlShowCanvasGrid.left = new FormAttachment( 0, 0 );
fdlShowCanvasGrid.right = new FormAttachment( middle, -margin );
fdlShowCanvasGrid.top = new FormAttachment( wGridSize, margin );
wlShowCanvasGrid.setLayoutData( fdlShowCanvasGrid );
wShowCanvasGrid = new Button( wLookComp, SWT.CHECK );
props.setLook( wShowCanvasGrid );
wShowCanvasGrid.setSelection( props.isShowCanvasGridEnabled() );
FormData fdShowCanvasGrid = new FormData();
fdShowCanvasGrid.left = new FormAttachment( middle, 0 );
fdShowCanvasGrid.right = new FormAttachment( 100, -margin );
fdShowCanvasGrid.top = new FormAttachment( wGridSize, margin );
wShowCanvasGrid.setLayoutData( fdShowCanvasGrid );

// Enable anti-aliasing
Label wlAntiAlias = new Label( wLookComp, SWT.RIGHT );
wlAntiAlias.setText( BaseMessages.getString( PKG, "EnterOptionsDialog.CanvasAntiAliasing.Label" ) );
props.setLook( wlAntiAlias );
FormData fdlAntiAlias = new FormData();
fdlAntiAlias.left = new FormAttachment( 0, 0 );
fdlAntiAlias.top = new FormAttachment( wGridSize, margin );
fdlAntiAlias.top = new FormAttachment( wShowCanvasGrid, margin );
fdlAntiAlias.right = new FormAttachment( middle, -margin );
wlAntiAlias.setLayoutData( fdlAntiAlias );
wAntiAlias = new Button( wLookComp, SWT.CHECK );
props.setLook( wAntiAlias );
wAntiAlias.setSelection( props.isAntiAliasingEnabled() );
FormData fdAntiAlias = new FormData();
fdAntiAlias.left = new FormAttachment( middle, 0 );
fdAntiAlias.top = new FormAttachment( wGridSize, margin );
fdAntiAlias.top = new FormAttachment( wShowCanvasGrid, margin );
fdAntiAlias.right = new FormAttachment( 100, 0 );
wAntiAlias.setLayoutData( fdAntiAlias );

Expand Down Expand Up @@ -1615,6 +1636,7 @@ private void ok() {
props.setShowCopyOrDistributeWarning( wCopyDistrib.getSelection() );
props.setRepositoriesDialogAtStartupShown( wShowRep.getSelection() );
props.setAntiAliasingEnabled( wAntiAlias.getSelection() );
props.setShowCanvasGridEnabled( wShowCanvasGrid.getSelection() );
props.setExitWarningShown( wExitWarning.getSelection() );
props.setOSLookShown( wOriginalLook.getSelection() );
props.setBrandingActive( wBranding.getSelection() );
Expand Down
5 changes: 4 additions & 1 deletion ui/src/org/pentaho/di/ui/spoon/job/JobGraph.java
Expand Up @@ -2761,11 +2761,14 @@ public void paintControl( PaintEvent e ) {
public Image getJobImage( 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;

JobPainter jobPainter =
new JobPainter(
gc, jobMeta, new Point( x, y ), new SwtScrollBar( hori ), new SwtScrollBar( vert ), hop_candidate,
drop_candidate, selectionRegion, areaOwners, mouseOverEntries, PropsUI.getInstance().getIconSize(),
PropsUI.getInstance().getLineWidth(), PropsUI.getInstance().getCanvasGridSize(), PropsUI
PropsUI.getInstance().getLineWidth(), gridSize, PropsUI
.getInstance().getShadowSize(), PropsUI.getInstance().isAntiAliasingEnabled(), PropsUI
.getInstance().getNoteFont().getName(), PropsUI.getInstance().getNoteFont().getHeight() );

Expand Down
6 changes: 4 additions & 2 deletions ui/src/org/pentaho/di/ui/spoon/trans/TransGraph.java
Expand Up @@ -3026,11 +3026,13 @@ public Image getTransformationImage( Device device, int x, int y, float magnific

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(), PropsUI.getInstance()
.getCanvasGridSize(), PropsUI.getInstance().getShadowSize(), PropsUI.getInstance()
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() );

Expand Down

0 comments on commit 9167695

Please sign in to comment.