use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class AbstractMeta method getNote.
/**
* 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;
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class JobMeta method getSelectedNoteLocations.
/**
* 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();
// explicit copy of location
points.add(new Point(p.x, p.y));
}
return points.toArray(new Point[points.size()]);
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class JobPainter method drawArrow.
@Override
protected void drawArrow(EImage arrow, int x1, int y1, int x2, int y2, double theta, int size, double factor, JobHopMeta jobHop, Object startObject, Object endObject) {
int mx, my;
int a, b, dist;
double angle;
// gc.setLineWidth(1);
// WuLine(gc, black, x1, y1, x2, y2);
gc.drawLine(x1, y1, x2, y2);
// What's the distance between the 2 points?
a = Math.abs(x2 - x1);
b = Math.abs(y2 - y1);
dist = (int) Math.sqrt(a * a + b * b);
// 0-->100%)
if (factor < 0) {
if (dist >= 2 * iconsize) {
factor = 1.3;
} else {
factor = 1.2;
}
}
// in between 2 points
mx = (int) (x1 + factor * (x2 - x1) / 2);
my = (int) (y1 + factor * (y2 - y1) / 2);
// calculate points for arrowhead
angle = Math.atan2(y2 - y1, x2 - x1) + (Math.PI / 2);
boolean q1 = Math.toDegrees(angle) >= 0 && Math.toDegrees(angle) <= 90;
boolean q2 = Math.toDegrees(angle) > 90 && Math.toDegrees(angle) <= 180;
boolean q3 = Math.toDegrees(angle) > 180 && Math.toDegrees(angle) <= 270;
boolean q4 = Math.toDegrees(angle) > 270 || Math.toDegrees(angle) < 0;
if (q1 || q3) {
gc.drawImage(arrow, mx + 1, my, magnification, angle);
} else if (q2 || q4) {
gc.drawImage(arrow, mx, my, magnification, angle);
}
// Display an icon above the hop...
//
factor = 0.8;
// in between 2 points
mx = (int) (x1 + factor * (x2 - x1) / 2) - 8;
my = (int) (y1 + factor * (y2 - y1) / 2) - 8;
if (jobHop != null) {
EImage hopsIcon;
if (jobHop.isUnconditional()) {
hopsIcon = EImage.UNCONDITIONAL;
} else {
if (jobHop.getEvaluation()) {
hopsIcon = EImage.TRUE;
} else {
hopsIcon = EImage.FALSE;
}
}
Point bounds = gc.getImageBounds(hopsIcon);
gc.drawImage(hopsIcon, mx, my, magnification);
if (!shadow) {
areaOwners.add(new AreaOwner(AreaType.JOB_HOP_ICON, mx, my, bounds.x, bounds.y, offset, subject, jobHop));
}
if (jobHop.getFromEntry().isLaunchingInParallel()) {
factor = 1;
// in between 2 points
mx = (int) (x1 + factor * (x2 - x1) / 2) - 8;
my = (int) (y1 + factor * (y2 - y1) / 2) - 8;
hopsIcon = EImage.PARALLEL;
gc.drawImage(hopsIcon, mx, my, magnification);
if (!shadow) {
areaOwners.add(new AreaOwner(AreaType.JOB_HOP_PARALLEL_ICON, mx, my, bounds.x, bounds.y, offset, subject, jobHop));
}
}
JobPainterExtension extension = new JobPainterExtension(gc, shadow, areaOwners, jobMeta, jobHop, x1, y1, x2, y2, mx, my, offset);
try {
ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.JobPainterArrow.id, extension);
} catch (Exception e) {
LogChannel.GENERAL.logError("Error calling extension point(s) for the job painter arrow", e);
}
}
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransMetaTest method testGetCacheVersionWithIrrelevantParameters.
@Test
public void testGetCacheVersionWithIrrelevantParameters() throws Exception {
TransMeta transMeta = new TransMeta(getClass().getResource("one-step-trans.ktr").getPath());
int oldCacheVersion = transMeta.getCacheVersion();
int currCacheVersion;
transMeta.setSizeRowset(1000);
currCacheVersion = transMeta.getCacheVersion();
assertNotEquals(oldCacheVersion, currCacheVersion);
oldCacheVersion = currCacheVersion;
// scenarios that should not impact the cache version
// transformation description
transMeta.setDescription("transformation description");
// transformation status
transMeta.setTransstatus(100);
// transformation log table
transMeta.setTransLogTable(mock(TransLogTable.class));
// transformation created user
transMeta.setCreatedUser("user");
// transformation modified user
transMeta.setModifiedUser("user");
// transformation created date
transMeta.setCreatedDate(new Date());
// transformation modified date
transMeta.setModifiedDate(new Date());
// transformation is key private flag
transMeta.setPrivateKey(false);
// transformation attributes
Map<String, String> attributes = new HashMap<>();
attributes.put("key", "value");
transMeta.setAttributes("group", attributes);
// step description
StepMeta stepMeta = transMeta.getStep(0);
stepMeta.setDescription("stepDescription");
// step position
stepMeta.setLocation(10, 20);
stepMeta.setLocation(new Point(30, 40));
// step type id
stepMeta.setStepID("Dummy");
// step is distributed flag
stepMeta.setDistributes(false);
// step copies
stepMeta.setCopies(5);
// step partitioning meta
stepMeta.setStepPartitioningMeta(mock(StepPartitioningMeta.class));
// assert that nothing impacted the cache version
assertEquals(oldCacheVersion, transMeta.getCacheVersion());
}
use of org.pentaho.di.core.gui.Point in project pentaho-kettle by pentaho.
the class TransMetaTest method testGetMinimum.
@Test
public void testGetMinimum() {
final Point minimalCanvasPoint = new Point(0, 0);
// for test goal should content coordinate more than NotePadMetaPoint
final Point stepPoint = new Point(500, 500);
// empty Trans return 0 coordinate point
Point point = transMeta.getMinimum();
assertEquals(minimalCanvasPoint.x, point.x);
assertEquals(minimalCanvasPoint.y, point.y);
// when Trans content Step than trans should return minimal coordinate of step
StepMeta stepMeta = mock(StepMeta.class);
when(stepMeta.getLocation()).thenReturn(stepPoint);
transMeta.addStep(stepMeta);
Point actualStepPoint = transMeta.getMinimum();
assertEquals(stepPoint.x - TransMeta.BORDER_INDENT, actualStepPoint.x);
assertEquals(stepPoint.y - TransMeta.BORDER_INDENT, actualStepPoint.y);
}
Aggregations