/** * Get an array of all the selected note locations. * * @return The selected note locations. */ public Point[] getSelectedNoteLocations() { List<Point> points = new ArrayList<>(); for ( NotePadMeta ni : getSelectedNotes() ) { Point p = ni.getLocation(); points.add( new Point( p.x, p.y ) ); // explicit copy of location } return points.toArray( new Point[points.size()] ); }
/** * Get all the selected note locations * * @return The selected step and notes locations. */ public Point[] getSelectedNoteLocations() { List<Point> points = new ArrayList<Point>(); for ( NotePadMeta ni : getSelectedNotes() ) { Point p = ni.getLocation(); points.add( new Point( p.x, p.y ) ); // explicit copy of location } return points.toArray( new Point[points.size()] ); }
/** * Find the note that is located on a certain point on the canvas. * * @param x the x-coordinate of the point queried * @param y the y-coordinate of the point queried * @return The note information if a note is located at the point. Otherwise, if nothing was found: null. */ public NotePadMeta getNote( int x, int y ) { int i, s; s = notes.size(); for ( i = s - 1; i >= 0; i-- ) { // Back to front because drawing goes from start to end NotePadMeta ni = notes.get( i ); Point loc = ni.getLocation(); Point p = new Point( loc.x, loc.y ); if ( x >= p.x && x <= p.x + ni.width + 2 * Const.NOTE_MARGIN && y >= p.y && y <= p.y + ni.height + 2 * Const.NOTE_MARGIN ) { return ni; } } return null; }
/** * Gets the maximum. * * @return the maximum */ public Point getMaximum() { int maxx = 0, maxy = 0; for ( int i = 0; i < nrJobEntries(); i++ ) { JobEntryCopy entry = getJobEntry( i ); Point loc = entry.getLocation(); if ( loc.x > maxx ) { maxx = loc.x; } if ( loc.y > maxy ) { maxy = loc.y; } } for ( int i = 0; i < nrNotes(); i++ ) { NotePadMeta ni = getNote( i ); Point loc = ni.getLocation(); if ( loc.x + ni.width > maxx ) { maxx = loc.x + ni.width; } if ( loc.y + ni.height > maxy ) { maxy = loc.y + ni.height; } } return new Point( maxx + 100, maxy + 100 ); }
/** * Gets the maximum size of the canvas by calculating the maximum location of a step. * * @return Maximum coordinate of a step in the transformation + (100,100) for safety. */ public Point getMaximum() { int maxx = 0, maxy = 0; for ( int i = 0; i < nrSteps(); i++ ) { StepMeta stepMeta = getStep( i ); Point loc = stepMeta.getLocation(); if ( loc.x > maxx ) { maxx = loc.x; } if ( loc.y > maxy ) { maxy = loc.y; } } for ( int i = 0; i < nrNotes(); i++ ) { NotePadMeta notePadMeta = getNote( i ); Point loc = notePadMeta.getLocation(); if ( loc.x + notePadMeta.width > maxx ) { maxx = loc.x + notePadMeta.width; } if ( loc.y + notePadMeta.height > maxy ) { maxy = loc.y + notePadMeta.height; } } return new Point( maxx + 100, maxy + 100 ); }
Point loc = notePadMeta.getLocation(); if ( loc.x < minx ) { minx = loc.x;
Point loc = notePadMeta.getLocation(); if ( loc.x < minx ) { minx = loc.x;
selectedNotes = new ArrayList<>(); selectedNotes.add( selectedNote ); previous_note_locations = new Point[] { selectedNote.getLocation() }; redraw(); } else if ( selectionRegion != null && startHopEntry == null ) { for ( int i = 0; i < selectedNotes.size(); i++ ) { NotePadMeta ni = selectedNotes.get( i ); PropsUI.setLocation( ni, ni.getLocation().x + dx, ni.getLocation().y + dy ); int dx = note.x - selectedNote.getLocation().x; int dy = note.y - selectedNote.getLocation().y; for ( int i = 0; i < selectedNotes.size(); i++ ) { NotePadMeta ni = selectedNotes.get( i ); PropsUI.setLocation( ni, ni.getLocation().x + dx, ni.getLocation().y + dy );
public void selectInRect( JobMeta jobMeta, org.pentaho.di.core.gui.Rectangle rect ) { int i; for ( i = 0; i < jobMeta.nrJobEntries(); i++ ) { JobEntryCopy je = jobMeta.getJobEntry( i ); Point p = je.getLocation(); if ( ( ( p.x >= rect.x && p.x <= rect.x + rect.width ) || ( p.x >= rect.x + rect.width && p.x <= rect.x ) ) && ( ( p.y >= rect.y && p.y <= rect.y + rect.height ) || ( p.y >= rect.y + rect.height && p.y <= rect.y ) ) ) { je.setSelected( true ); } } for ( i = 0; i < jobMeta.nrNotes(); i++ ) { NotePadMeta ni = jobMeta.getNote( i ); Point a = ni.getLocation(); Point b = new Point( a.x + ni.width, a.y + ni.height ); if ( rect.contains( a.x, a.y ) && rect.contains( b.x, b.y ) ) { ni.setSelected( true ); } } }
selectedNotes = new ArrayList<>(); selectedNotes.add( selectedNote ); previous_note_locations = new Point[] { selectedNote.getLocation() }; redraw(); } else if ( selectionRegion != null && startHopStep == null ) { for ( int i = 0; i < selectedNotes.size(); i++ ) { NotePadMeta ni = selectedNotes.get( i ); PropsUI.setLocation( ni, ni.getLocation().x + dx, ni.getLocation().y + dy ); int dx = note.x - selectedNote.getLocation().x; int dy = note.y - selectedNote.getLocation().y; for ( int i = 0; i < selectedNotes.size(); i++ ) { NotePadMeta ni = selectedNotes.get( i ); PropsUI.setLocation( ni, ni.getLocation().x + dx, ni.getLocation().y + dy );
@Test public void shouldUseCoordinatesOfItsStepsAndNotesWhenCalculatingMinimumPoint() { Point jobEntryPoint = new Point( 500, 500 ); Point notePadMetaPoint = new Point( 400, 400 ); JobEntryCopy jobEntryCopy = mock( JobEntryCopy.class ); when( jobEntryCopy.getLocation() ).thenReturn( jobEntryPoint ); NotePadMeta notePadMeta = mock( NotePadMeta.class ); when( notePadMeta.getLocation() ).thenReturn( notePadMetaPoint ); // empty Job return 0 coordinate point Point point = jobMeta.getMinimum(); assertEquals( 0, point.x ); assertEquals( 0, point.y ); // when Job contains a single step or note, then jobMeta should return coordinates of it, subtracting borders jobMeta.addJobEntry( 0, jobEntryCopy ); Point actualStepPoint = jobMeta.getMinimum(); assertEquals( jobEntryPoint.x - JobMeta.BORDER_INDENT, actualStepPoint.x ); assertEquals( jobEntryPoint.y - JobMeta.BORDER_INDENT, actualStepPoint.y ); // when Job contains step or notes, then jobMeta should return minimal coordinates of them, subtracting borders jobMeta.addNote( notePadMeta ); Point stepPoint = jobMeta.getMinimum(); assertEquals( notePadMetaPoint.x - JobMeta.BORDER_INDENT, stepPoint.x ); assertEquals( notePadMetaPoint.y - JobMeta.BORDER_INDENT, stepPoint.y ); }
Point a = ni.getLocation(); Point b = new Point( a.x + ni.width, a.y + ni.height ); if ( rect.contains( a.x, a.y ) && rect.contains( b.x, b.y ) ) {
/** * * @param rep * @param id_transformation * @throws KettleException */ public void saveNotePadMeta( NotePadMeta note, ObjectId id_transformation ) throws KettleException { try { Point location = note.getLocation(); int x = location == null ? -1 : location.x; int y = location == null ? -1 : location.y; // Insert new Note in repository note.setObjectId( insertNote( note.getNote(), x, y, note.getWidth(), note.getHeight(), note.getFontName(), note.getFontSize(), note .isFontBold(), note.isFontItalic(), note.getFontColorRed(), note.getFontColorGreen(), note .getFontColorBlue(), note.getBackGroundColorRed(), note.getBackGroundColorGreen(), note .getBackGroundColorBlue(), note.getBorderColorRed(), note.getBorderColorGreen(), note .getBorderColorBlue(), note.isDrawShadow() ) ); } catch ( KettleDatabaseException dbe ) { throw new KettleException( "Unable to save notepad in repository (id_transformation=" + id_transformation + ")", dbe ); } }
assertTrue( meta.hasChanged() ); NotePadMeta note2 = mock( NotePadMeta.class ); when( note2.getLocation() ).thenReturn( new Point( 0, 0 ) ); when( note2.isSelected() ).thenReturn( true ); meta.addNote( 1, note2 );
Node noteNode = XMLHandler.getSubNodeByNr( notesNode, "notepad", i ); notes[i] = new NotePadMeta( noteNode ); Point p = notes[i].getLocation(); notes[i].setLocation( p.x + offset.x, p.y + offset.y ); transMeta.addNote( notes[i] );
Point loc = notePadMeta.getLocation(); Point note = real2screen( loc.x, loc.y ); int margin = Const.NOTE_MARGIN;
selectedNotes = jobMeta.getSelectedNotes(); selectedNote = ni; Point loc = ni.getLocation();
selectedNotes = transMeta.getSelectedNotes(); selectedNote = ni; Point loc = ni.getLocation();
public NotePadMeta getNote( int x, int y ) { int i, s; s = notes.size(); // Back to front because drawing goes from start to end for ( i = s - 1; i >= 0; i-- ) { NotePadMeta ni = (NotePadMeta) notes.get( i ); Point loc = ni.getLocation(); Point p = new Point( loc.x, loc.y ); if ( x >= p.x && x <= p.x + ni.width + 2 * Const.NOTE_MARGIN && y >= p.y && y <= p.y + ni.height + 2 * Const.NOTE_MARGIN ) { return ni; } } return null; }
/** * Stores a notepad in the CWM model in a CwmSchema. * * @param cwm * @param cwmSchema * @param notePadMeta */ public void storeNotePadMeta( CWM cwm, CwmSchema cwmSchema, NotePadMeta notePadMeta ) { if ( !hasAccess( CwmSchemaFactoryInterface.ACCESS_TYPE_SCHEMA_ADMIN, null ) ) { throw new CwmSchemaFactoryException( Messages .getString( "CwmSchemaFactory.ERROR_0001_SCHEMA_ADMIN_ACCESS_DENIED" ) ); //$NON-NLS-1$ } CwmDescription cwmDescription = cwm.createDescription( notePadMeta.getNote() ); cwmDescription.setType( CWM.DESCRIPTION_TYPE_NOTEPAD ); cwm.setPosition( cwmDescription, notePadMeta.getLocation().x, notePadMeta.getLocation().y ); cwm.setWidth( cwmDescription, notePadMeta.getWidth() ); cwm.setHeight( cwmDescription, notePadMeta.getHeight() ); cwm.setDescription( cwmSchema, cwmDescription ); }